ソースを参照

线索导入重名校验

zhouyy 4 ヶ月 前
コミット
04b7ae7b4b

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

@@ -16,6 +16,7 @@ import com.management.platform.service.UserService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -35,6 +36,7 @@ import java.io.*;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -401,6 +403,11 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
         List<SysDict> sysSources = sysDictMapper.selectList(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCompanyId, companyId).eq(SysDict::getCode, "ClueSources"));
         List<SysDict> sysIndutryId = sysDictMapper.selectList(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCompanyId, companyId).eq(SysDict::getCode, "CustomIndustry"));
         List<SysDict> levels = sysDictMapper.selectList(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCompanyId, companyId).eq(SysDict::getCode, "CustomLevel"));
+        List<Clue> companyClues = clueMapper.selectList(new LambdaQueryWrapper<Clue>().eq(Clue::getCompanyId, companyId).eq(Clue::getIsDelete, 0));
+        Map<String, Clue> clueNameMap = new HashMap<>();
+        if(CollectionUtils.isNotEmpty(companyClues)){
+            clueNameMap = companyClues.stream().collect(Collectors.toMap(Clue::getClueName, t -> t, (o1, o2) -> o2));
+        }
 
         InputStream inputStream = null;
         OutputStream outputStream = null;
@@ -587,6 +594,12 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
                 importProductList.add(product);
             }
             if(importProductList.size()>0){
+                for (Clue clue : importProductList) {
+                    if(clueNameMap.containsKey(clue.getClueName())){
+                        msg.setError("已存在同名线索");
+                        return msg;
+                    }
+                }
                 if(!saveOrUpdateBatch(importProductList)){
                     msg.setError("验证失败,请检验数据格式是否正确");
                     return msg;