ソースを参照

补充原接口重名校验,修改转义相关

zhouyy 4 ヶ月 前
コミット
4213299a1e

+ 13 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ProductController.java

@@ -118,6 +118,19 @@ public class ProductController {
             msg.setError("产品编码为["+product.getProductCode()+"]的产品已存在");
             return msg;
         }
+        if(product.getId()==null){
+            count = productService.count(new LambdaQueryWrapper<Product>().eq(Product::getCompanyId, companyId).eq(Product::getProductName, product.getProductName()));
+        }else {
+            count = productService.count(new LambdaQueryWrapper<Product>().eq(Product::getCompanyId, companyId).ne(Product::getId,product.getId()).eq(Product::getProductName, product.getProductName()));
+        }
+        if(count>0){
+            msg.setError("已存在同名产品");
+            return msg;
+        }
+
+
+
+
         Integer id = product.getId();
         if(!productService.saveOrUpdate(product)){
             msg.setError("验证失败");

+ 17 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ClueServiceImpl.java

@@ -713,10 +713,27 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
         clue.setIsDelete(0);
         if (null != clue.getId()) {
             //修改
+            Integer count = clueMapper.selectCount(new LambdaQueryWrapper<Clue>()
+                    .eq(Clue::getClueName, clue.getClueName())
+                    .eq(Clue::getCompanyId, user.getCompanyId())
+                    .ne(Clue::getId,clue.getId())
+            );
+            if(count > 0){
+                msg.setError("已存在同名线索");
+                return msg;
+            }
             clueMapper.updateById(clue);
             msg.setMsg("操作成功");
         } else {
             //新增
+            Integer count = clueMapper.selectCount(new LambdaQueryWrapper<Clue>()
+                    .eq(Clue::getClueName, clue.getClueName())
+                    .eq(Clue::getCompanyId, user.getCompanyId())
+            );
+            if(count > 0){
+                msg.setError("已存在同名线索");
+                return msg;
+            }
             clue.setCreateId(user.getId());
             clueMapper.insert(clue);
             msg.setMsg("操作成功");

+ 9 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java

@@ -130,6 +130,15 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
             httpRespMsg.setError("已存在该联系人,手机号重复!");
             return httpRespMsg;
         }
+        Integer count = contactsMapper.selectCount(new LambdaQueryWrapper<Contacts>()
+                .eq(Contacts::getName, contacts.getName())
+                .eq(Contacts::getPhone, contacts.getPhone())
+                .eq(Contacts::getCompanyId,companyId)
+        );
+        if(count > 0){
+            httpRespMsg.setError("已存在同名联系人");
+            return httpRespMsg;
+        }
         contacts.setCompanyId(companyId)
                 //todo:联系人的所有人是可选择的
 //                .setOwnerId(user.getId())//添加时默认

+ 16 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContractServiceImpl.java

@@ -353,6 +353,13 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
             httpRespMsg.setError(MessageUtils.message("name.nullNameError"));
             return httpRespMsg;
         }
+        Integer count = contract.selectCount(new LambdaQueryWrapper<Contract>().eq(Contract::getCompanyId, user.getCompanyId())
+                .eq(Contract::getName, contract.getName())
+        );
+        if(count > 0){
+            httpRespMsg.setError("已存在同名合同");
+            return httpRespMsg;
+        }
         //合同编号不可重复
         if (StringUtils.isNotBlank(contract.getNumber()) && user.getCompanyId() != 4215){
             for (Contract ContractNumber: contracts) {
@@ -449,6 +456,15 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
                 httpRespMsg.setError(MessageUtils.message("Contract.amountNegative"));
                 return httpRespMsg;
             }
+            Integer count = contractMapper.selectCount(new LambdaQueryWrapper<Contract>()
+                    .eq(Contract::getCompanyId, user.getCompanyId())
+                    .eq(Contract::getName, contract.getName())
+                    .ne(Contract::getId, contract.getId())
+            );
+            if(count>0){
+                httpRespMsg.setError("已存在同名合同");
+                return httpRespMsg;
+            }
             //合同编号不可重复
             if (StringUtils.isNotBlank(contract.getNumber()) && user.getCompanyId() != 4215){
                 Contract number = contractMapper.selectOne(new QueryWrapper<Contract>().eq("number", contract.getNumber()).eq("company_id", user.getCompanyId()));

+ 24 - 13
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/InformationServiceImpl.java

@@ -11,11 +11,14 @@ import com.management.platform.mapper.WxCorpInfoMapper;
 import com.management.platform.service.InformationService;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -50,22 +53,30 @@ public class InformationServiceImpl extends ServiceImpl<InformationMapper, Infor
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                 List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id",user.getCompanyId()));
+                Map<String, User> companyUserMap = users.stream().collect(Collectors.toMap(User::getId, t -> t));
                 for (Information info : information) {
-                    if (info.getMsg() == null){
-                        continue;
-                    } else if (info.getMsg().contains("更新任务进展为")){
-                        String name = info.getMsg().substring(0, info.getMsg().indexOf("更新任务进展为"));
-                        String userWxId = "";
-                        for (User item : users) {
-                            if (name.equals(item.getName())){
-                                userWxId = item.getCorpwxRealUserid();
-                                break;
-                            }
+                    if(StringUtils.isNotBlank(info.getMsg())){
+                        User tmpUser = companyUserMap.get(info.getUserId());
+                        if(null != tmpUser){
+                            String replace = info.getMsg().replace(tmpUser.getName(), "$username=" + tmpUser.getCorpwxUserid() + "$");
+                            info.setMsg(replace);
                         }
-                        String msg = info.getMsg();
-                        String newMsg = msg.replace(name, "$userName=" + userWxId + "$");
-                        info.setMsg(newMsg);
                     }
+//                    if (info.getMsg() == null){
+//                        continue;
+//                    } else if (info.getMsg().contains("更新任务进展为")){
+//                        String name = info.getMsg().substring(0, info.getMsg().indexOf("更新任务进展为"));
+//                        String userWxId = "";
+//                        for (User item : users) {
+//                            if (name.equals(item.getName())){
+//                                userWxId = item.getCorpwxRealUserid();
+//                                break;
+//                            }
+//                        }
+//                        String msg = info.getMsg();
+//                        String newMsg = msg.replace(name, "$userName=" + userWxId + "$");
+//                        info.setMsg(newMsg);
+//                    }
                 }
             }
 

+ 18 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/VisitPlanServiceImpl.java

@@ -56,6 +56,7 @@ public class VisitPlanServiceImpl extends ServiceImpl<VisitPlanMapper, VisitPlan
             httpRespMsg.setError("用户不存在");
             return httpRespMsg;
         }
+
         if(visitPlan.getVisitTime().before(now)){
             httpRespMsg.setError("拜访时间不能在当前时段之前");
             return httpRespMsg;
@@ -81,6 +82,15 @@ public class VisitPlanServiceImpl extends ServiceImpl<VisitPlanMapper, VisitPlan
 
         if(null != visitPlan.getId()){
             //修改
+//            Integer count = visitPlanMapper.selectCount(new LambdaQueryWrapper<VisitPlan>()
+//                    .eq(VisitPlan::getPlanName, visitPlan.getPlanName())
+//                    .eq(VisitPlan::getCompanyId, visitPlan.getCompanyId())
+//                    .ne(VisitPlan::getId, visitPlan.getId())
+//            );
+//            if(count > 0){
+//                httpRespMsg.setError("已存在同名访客计划");
+//                return httpRespMsg;
+//            }
             VisitPlan oldPlan = visitPlanMapper.selectById(visitPlan.getId());
             if(1 == oldPlan.getFinishState()){
                 httpRespMsg.setError("无法修改已完成的计划");
@@ -148,6 +158,14 @@ public class VisitPlanServiceImpl extends ServiceImpl<VisitPlanMapper, VisitPlan
 
         }else{
             //新增
+//            Integer count = visitPlanMapper.selectCount(new LambdaQueryWrapper<VisitPlan>()
+//                    .eq(VisitPlan::getPlanName, visitPlan.getPlanName())
+//                    .eq(VisitPlan::getCompanyId, visitPlan.getCompanyId())
+//            );
+//            if(count > 0){
+//                httpRespMsg.setError("已存在同名访客计划");
+//                return httpRespMsg;
+//            }
             visitPlan.setInchargerId(user.getId());
             visitPlan.setCompanyId(user.getCompanyId());
             visitPlan.setCorpwxUserid(user.getCorpwxUserid());