Browse Source

修改bug

laoyao 3 years ago
parent
commit
4772954094

+ 5 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/BomProcedureVersionServiceImpl.java

@@ -315,12 +315,15 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
 
     private boolean checkSameName(List<Map<String,Object>> procedureList){
         if(CollectionUtil.isNotEmpty(procedureList)){
-            Map<String,String> map = procedureList.stream().collect(Collectors.toMap(t->t.get("no").toString(), t->t.get("no").toString()));
+            Map<String,String> map = procedureList.stream().collect(Collectors.toMap(t->t.get("no").toString(), t->t.get("no").toString(),(k1,k2)->k1));
             if(map.size()<procedureList.size()){
                 return true;
             }
 
-            Map<String,String> map1 = procedureList.stream().collect(Collectors.toMap(t->t.get("name").toString(), t->t.get("name").toString()));
+            Map<String,String> map1 = procedureList.stream().collect(Collectors.toMap(t->t.get("name").toString(), t->t.get("name").toString(),(k1,k2)->k1));
+            if(map1.size()<procedureList.size()){
+                return true;
+            }
         }
         return false;
     }

+ 16 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ZZoneServiceImpl.java

@@ -25,6 +25,8 @@ import com.github.zuihou.database.mybatis.auth.DataScope;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.tenant.dao.ProductionresourceviewMapper;
+import com.github.zuihou.tenant.dto.CodeRuleSaveDTO;
+import com.github.zuihou.tenant.entity.CodeRule;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.tenant.service.ProductionresourceService;
 import com.github.zuihou.utils.BeanPlusUtil;
@@ -98,6 +100,9 @@ public class ZZoneServiceImpl extends SuperServiceImpl<ZZoneMapper, ZZone> imple
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ZZone save(ZZoneSaveDTO data) {
+        isFalse(check(data.getName()), "该产线已存在,请重新输入");
+
+
         ZZone zZone = BeanPlusUtil.toBean(data, ZZone.class);
         //根据编码规则
         String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_ZZONE);
@@ -107,10 +112,21 @@ public class ZZoneServiceImpl extends SuperServiceImpl<ZZoneMapper, ZZone> imple
         return zZone;
     }
 
+
+
+    public boolean check(String name) {
+        return super.count(Wraps.<ZZone>lbQ().eq(ZZone::getName,name)) > 0;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ZZone update(ZZoneUpdateDTO data) {
         ZZone zZone = BeanPlusUtil.toBean(data, ZZone.class);
+        ZZone oriZone = baseMapper.selectById(zZone.getId());
+        if(!zZone.getName().equals(oriZone.getName())){//修改过名称
+            isFalse(check(data.getName()), "该产线已存在,请重新输入");
+        }
+
         updateById(zZone);
 
         return zZone;