Browse Source

切割机 可配置新增删除接口,机器名称字段

zhangxin 1 month ago
parent
commit
18b60d0aac

+ 2 - 0
prod-line-comm/src/main/java/com/huaxia/comm/domain/imes/SysMeConfig.java

@@ -46,4 +46,6 @@ public class SysMeConfig implements Serializable {
     private String createBy;//创建人
 
     private String updateBy;//修改人
+
+    private String machineName;//机器名称
 }

+ 11 - 0
prod-line-imes/src/main/java/com/huaxia/imes/controller/SysMeConfigController.java

@@ -62,4 +62,15 @@ public class SysMeConfigController extends BaseController {
         service.updateBoy(boy);
         return R.ok();
     }
+
+    /**
+     * 删除数据
+     * @param ids
+     * @return
+     */
+    @DeleteMapping("/remove")
+    public R<Void> remove(Long[] ids){
+        service.delete(ids);
+        return R.ok();
+    }
 }

+ 26 - 1
prod-line-imes/src/main/java/com/huaxia/imes/service/SysMeConfigService.java

@@ -13,6 +13,7 @@ import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.utils.StringUtils;
 import lombok.AllArgsConstructor;
+import org.aspectj.weaver.ast.Var;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
@@ -74,6 +75,11 @@ public class SysMeConfigService extends ServiceImpl<SysMeConfigMapper, SysMeConf
         String cutrecordNo = boy.getTblMachineNo();
         Long count = cutpieceMapper.selectCount(new LambdaQueryWrapper<Cutpiece>().eq(Cutpiece::getTblMachineNo, cutrecordNo));
         Assert.isTrue(count > 0, "500-机器编号不存在");
+        //通过编码去查询配置表防止出现重复机器编号
+        LambdaQueryWrapper<SysMeConfig> wr = new LambdaQueryWrapper<>();
+        wr.eq(SysMeConfig::getTblMachineNo, cutrecordNo);
+        Long aLong = sysMeConfigMapper.selectCount(wr);
+        Assert.isTrue(aLong == 0, "500-机器编号已存在");
         //新增数据
         boy.setCreateTime(new Date());
         sysMeConfigMapper.insert(boy);
@@ -81,6 +87,7 @@ public class SysMeConfigService extends ServiceImpl<SysMeConfigMapper, SysMeConf
 
     /**
      * 修改数据
+     *
      * @param boy
      */
     public void updateBoy(SysMeConfig boy) {
@@ -95,6 +102,23 @@ public class SysMeConfigService extends ServiceImpl<SysMeConfigMapper, SysMeConf
         sysMeConfigMapper.updateById(boy);
     }
 
+    /**
+     * 根据id删除数据
+     *
+     * @param ids
+     */
+    public void delete(Long[] ids) {
+        //遍历ids 判断数据是否存在
+        for (Long id : ids) {
+            SysMeConfig sysMeConfig = sysMeConfigMapper.selectById(id);
+            Assert.isTrue(sysMeConfig != null, "500-数据不存在");
+            //删除数据
+            sysMeConfigMapper.deleteById(id);
+        }
+
+    }
+
+
     /**
      * 新增数据时校验数据
      *
@@ -103,7 +127,8 @@ public class SysMeConfigService extends ServiceImpl<SysMeConfigMapper, SysMeConf
     private void check(SysMeConfig boy) {
         Assert.isTrue(StringUtils.isNotBlank(boy.getTblMachineNo()), "500-机器编号不能为空");
         Assert.isTrue(boy.getCapacity() != null && boy.getCapacity() > 0, "500-产能不能为空");
-        Assert.isTrue(boy.getConfiTime()!=null, "500-上班时间不能为空");
+        Assert.isTrue(boy.getConfiTime() != null, "500-上班时间不能为空");
+        Assert.isTrue(StringUtils.isNotBlank(boy.getMachineName()), "500-机器名称不能为空");
     }
 
 

+ 6 - 0
prod-line-imes/src/main/resources/mapper/SysMeConfigMapper.xml

@@ -59,6 +59,9 @@
                 <if test="params.boy.updateBy != null">
                     AND updateBy = #{params.boy.updateBy}
                 </if>
+                <if test="params.boy.machine_name !=null">
+                    AND machine_name = #{params.boy.machineName}
+                </if>
             </if>
         </where>
     </select>
@@ -90,6 +93,9 @@
                 <if test="params.boy.updateBy != null">
                     AND updateBy = #{params.boy.updateBy}
                 </if>
+                <if test="params.boy.machine_name !=null">
+                    AND machine_name = #{params.boy.machineName}
+                </if>
             </if>
         </where>
         ORDER BY id