xiejun
2023-11-17 6732cd7a4e0fd7ea083d4ae11254bde35adb1ee4
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -856,7 +856,7 @@
         String idFieldName = attrVOS.stream().filter(s -> VciQueryWrapperForDO.ID_FIELD.equalsIgnoreCase(s.getId())).findFirst().orElseGet(() -> new CodeClassifyTemplateAttrVO()).getName();
         getFieldIndexMap(titleRowData, attrNameIdMap, fieldIndexMap);
         //先不用管属性是否都存在,先转换一下数据
         List<ClientBusinessObject> cboList = new ArrayList<>();
         List<ClientBusinessObject> cboList = new CopyOnWriteArrayList<>();
         String fullPath = getFullPath(classifyFullInfo);
         //我们需要获取到所有的下级分类的oid的路径,因为后面需要
         Map<String/**主键**/, String/**路径**/> childOidPathMap = getChildClassifyPathMap(classifyFullInfo, fullPath);
@@ -942,7 +942,7 @@
         if (CollectionUtils.isEmpty(ruleOidMap.values())) {
            throw new VciBaseException("导入的数据所选择的分类都没有设置编码规则");
         }
         // TODO: 改用oid查询规则的,别用id
         // TODO: 该用oid查询规则的,别用id
         Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
         //校验编码规则和码段是否正确
         Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>();
@@ -1538,7 +1538,6 @@
            total += commonsMapper.queryCountBySql(countSql);
         }
      }else{
         total = commonsMapper.queryCountBySql(countSql);
      }
      List<String> selectFieldList = new ArrayList<>();
@@ -1966,7 +1965,6 @@
      //都转换完了。需要批量检查
      //如果出错了,我们依然执行有效的数据,无效的数据写回到excel中
      Map<String,String> errorKeyMap=new HashMap<>();
      //1.分类注入
@@ -3149,6 +3147,7 @@
      });
   }
   /**
    * excel转换为cbo的对象
    * @param classifyFullInfo 分类的全部信息
@@ -3166,7 +3165,7 @@
         ClientBusinessObject cbo=new ClientBusinessObject();
         DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmTypeId());
         rowData.getData().forEach((index,value)->{
            String field = fieldIndexMap.get(index);
               String field = fieldIndexMap.get(index);
            if (StringUtils.isBlank(field)) {
               throw new VciBaseException("第" + (index + 1) + "列的标题在系统中不存在");
            }
@@ -3523,6 +3522,7 @@
         });
      }
   }
   /***
    * 校验分类对应的模板信息
    * @param titleRowData
@@ -3606,6 +3606,7 @@
      }
      return codeClassifyTemplateVOList ;
   }
   /**
    * 从属性上获取参照的内容
    * @param attrVO 属性的信息
@@ -3728,6 +3729,7 @@
         }
      }
   }
   /**
    * 处理分类注入
    * @param attrVOS 模板属性
@@ -3818,6 +3820,8 @@
      //因为数据量很大,所以得想办法并行
      //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
      Map<String,List<BaseModel>> indexTODataMap=new ConcurrentHashMap<>();
      // 查询不需要参与关键属性校验的除自己以外的所有分类oid
      String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
      List<ClientBusinessObject> repeatDataMap = cboList.parallelStream().filter(cbo -> {
         //每行都得查询.如果其中出现了错误,我们就直接抛出异常,其余的显示
         //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo);
@@ -3831,6 +3835,10 @@
            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);
            }
            CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null);
            boolean isKeyCheck= commonsMapper.queryCountBySql(sqlBO.getSqlCount()) > 0;
            if(isKeyCheck){
@@ -3874,7 +3882,7 @@
         if(StringUtils.isBlank(classifyPath)){
            classifyPath = "#current#";
         }
         if ( !pathMap.containsKey(classifyPath)) {
         if (!pathMap.containsKey(classifyPath)) {
            String row_index = cbo.getAttributeValue(IMPORT_ROW_INDEX);
            errorMap.put(row_index,errorMap.getOrDefault(row_index,"") + ";分类路径不存在");
         } else {
@@ -4014,7 +4022,7 @@
               List<String>newOidList=new ArrayList<>();
               newOidList.add(oid);
               if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){
                  List<String> oldOidList=   keyAttrOkOidTORepeatOidMap.get(okOid);
                  List<String> oldOidList = keyAttrOkOidTORepeatOidMap.get(okOid);
                  newOidList.addAll(oldOidList);
               }