Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -87,6 +87,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@@ -201,6 +202,11 @@
    * 客户现场excel为老版本,导出的总数限制为65535
    */
   public static final int EXPORT_LIMIT = 65535;
   /**
    * 自定义并发ForkJoinPool
    */
   private static final ForkJoinPool customForkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()-1);
   /**
    * 批量申请:选取选中分类下的所有模板关键属性,相似属性,必填属性,写入execl中
@@ -4393,56 +4399,60 @@
      // 查询不需要参与关键属性校验的除自己以外的所有分类oid
      final String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
      final BladeUser user = AuthUtil.getUser();
      //cboList = new CopyOnWriteArrayList<>(cboList);
      // TODO:Thread limit exceeded replacing blocked 异常是这部分代码抛出的,所以暂时将parallelStream改成了stream
      List<ClientBusinessObject> repeatDataMap = cboList.stream().filter(cbo -> {
         //每行都得查询.如果其中出现了错误,我们就直接抛出异常,其余的显示
         //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo);
         Map<String, String> conditionMap = new HashMap<>();
         ketAttrMap.forEach((attrId, attrVO) -> {
            String value =cbo.getAttributeValue(attrId.toLowerCase(Locale.ROOT));
            if (value == null) {
               value = "";
            }
            value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR);
            engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
         });
         if (!CollectionUtils.isEmpty(ketAttrMap)) {
            // 添加不参与关键属性校验的分类oid判断
            if(Func.isNotBlank(isParticipateCheckOids)){
               conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids);
            }
            if(isEdit){//如果是更改则需排除系统本身
               conditionMap.put("t.id",QueryOptionConstant.NOTEQUAL+cbo.getId());
            }
            conditionMap.put("t.lastr", "1");
            conditionMap.put("t.lastv", "1");
            CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null);
            List<String> repeatData = commonsMapper.selectList(sqlBO.getSqlId());
            if(!repeatData.isEmpty()){
               final List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage());
               DefaultAttrAssimtUtil.mapToLowerCase(newDataList,true);
               //List<ClientBusinessObject> newCboList=ChangeMapTOClientBusinessObjects(newDataList);
               List<BaseModel> newCboList = new ArrayList<>();
               newDataList.stream().forEach(stringStringMap -> {
                  BaseModel baseModel=new BaseModel();
                  DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel,false,user);
                  baseModel.setData(stringStringMap);
                  newCboList.add(baseModel);
               });
               // 添加错误值
               String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
               errorMap.put(rowIndex, "重复的记录编号为:"+repeatData.stream().collect(Collectors.joining(",")));
               if(!CollectionUtils.isEmpty(newCboList)) {
                  indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX), newCboList);
      // TODO:Thread limit exceeded replacing blocked 异常是这部分代码抛出的
      //  ,所以暂时将parallelStream改成了stream,改成了stream之后发现巨慢
      // customForkJoinPool控制并发度
      List<ClientBusinessObject> finalCboList = cboList;
      List<ClientBusinessObject> repeatDataMap = (List<ClientBusinessObject>) customForkJoinPool.submit(()->{
         finalCboList.parallelStream().filter(cbo -> {
            //每行都得查询.如果其中出现了错误,我们就直接抛出异常,其余的显示
            //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo);
            Map<String, String> conditionMap = new HashMap<>();
            ketAttrMap.forEach((attrId, attrVO) -> {
               String value =cbo.getAttributeValue(attrId.toLowerCase(Locale.ROOT));
               if (value == null) {
                  value = "";
               }
               value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR);
               engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
            });
            if (!CollectionUtils.isEmpty(ketAttrMap)) {
               // 添加不参与关键属性校验的分类oid判断
               if(Func.isNotBlank(isParticipateCheckOids)){
                  conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids);
               }
               if(isEdit){//如果是更改则需排除系统本身
                  conditionMap.put("t.id",QueryOptionConstant.NOTEQUAL+cbo.getId());
               }
               conditionMap.put("t.lastr", "1");
               conditionMap.put("t.lastv", "1");
               CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null);
               List<String> repeatData = commonsMapper.selectList(sqlBO.getSqlId());
               if(!repeatData.isEmpty()){
                  final List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage());
                  DefaultAttrAssimtUtil.mapToLowerCase(newDataList,true);
                  //List<ClientBusinessObject> newCboList=ChangeMapTOClientBusinessObjects(newDataList);
                  List<BaseModel> newCboList = new ArrayList<>();
                  newDataList.stream().forEach(stringStringMap -> {
                     BaseModel baseModel=new BaseModel();
                     DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel,false,user);
                     baseModel.setData(stringStringMap);
                     newCboList.add(baseModel);
                  });
                  // 添加错误值
                  String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
                  errorMap.put(rowIndex, "重复的记录编号为:"+repeatData.stream().collect(Collectors.joining(",")));
                  if(!CollectionUtils.isEmpty(newCboList)) {
                     indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX), newCboList);
                  }
               }
               return !repeatData.isEmpty();
            }else{
               return false;
            }
            return !repeatData.isEmpty();
         }else{
            return false;
         }
      }).collect(Collectors.toList());
         }).collect(Collectors.toList());
      }).join();
      if(!CollectionUtils.isEmpty(repeatDataMap)){
         resultVO.setKeyAttrRepeatRowIndexList(repeatDataMap.stream().map(s->s.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toSet()));
      }