Przeglądaj źródła

客户管理修改

yurk 3 lat temu
rodzic
commit
1454f15026

+ 22 - 9
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/CustomerInfoController.java

@@ -57,20 +57,33 @@ public class CustomerInfoController {
         List<String> codeList=new ArrayList<>();
         customerInfoMapperAll.forEach(cu->{
             nameList.add(cu.getCustomerName());
-            codeList.add(cu.getCustomerCode());
+            if(cu.getCustomerCode()!=null){
+                codeList.add(cu.getCustomerCode());
+            }
         });
-        if(nameList.contains(info.getCustomerName())){
-            msg.setError("客户名称已存在");
-            return msg;
-        }
-        if(codeList.contains(info.getCustomerCode())){
-            msg.setError("客户编号已存在");
-            return msg;
-        }
         if (info.getId() == null) {
+            if(nameList.contains(info.getCustomerName())){
+                msg.setError("客户名称已存在");
+                return msg;
+            }
+            if(codeList.contains(info.getCustomerCode())){
+                msg.setError("客户编号已存在");
+                return msg;
+            }
             info.setCompanyId(user.getCompanyId());
             customerInfoMapper.insert(info);
         } else {
+            CustomerInfo customerInfo = customerInfoMapper.selectById(info.getId());
+            nameList.remove(customerInfo.getCustomerName());
+            codeList.remove(customerInfo.getCustomerCode());
+            if(nameList.contains(info.getCustomerName())){
+                msg.setError("客户名称已存在");
+                return msg;
+            }
+            if(codeList.contains(info.getCustomerCode())){
+                msg.setError("客户编号已存在");
+                return msg;
+            }
             info.setCompanyId(user.getCompanyId());
             customerInfoMapper.updateById(info);
             //更新项目表中的客户名称

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/CustomerInfoMapper.xml

@@ -19,7 +19,7 @@
         id, customer_code, customer_name, contact_name, contact_phone, email, address, company_id
     </sql>
     <select id="getAll" resultMap="BaseResultMap">
-        select id, customer_name from customer_info where company_id = #{companyId}
+        select id, customer_name,customer_code from customer_info where company_id = #{companyId}
         ORDER BY id DESC
     </select>