ludc
2023-11-24 b267ac7499877043675bbd25d1478b1731c12ec9
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -109,12 +109,15 @@
   @Resource
   private ICodeClassifyService classifyService;
   @Resource
   private MdmEngineService mdmEngineService;
   /**
    * 通用查询
    */
   @Resource
   private CommonsMapper commonsMapper;
   /****
    * 码值服务
    */
@@ -352,10 +355,12 @@
   @Override
   public String createImportExcel(String codeClassifyOid, boolean isHistory) {
      List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>();
      VciBaseUtil.alertNotNull("导出模板","导出的配置",codeClassifyOid,"主题库分类的主键");
      CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid);
      //获取码段宽度
      //String secWidth = getCodeSegmentWidth(codeClassifyVO.getOid());
      if(isHistory){
         templateVOList= templateService.childTemplates(codeClassifyOid);
@@ -467,6 +472,30 @@
      eo.addSheetDataList(templateVOList.size()+"模板信息【请勿删除或移动】",tempEDList);
      ExcelUtil.writeDataToFile(excelName,eo);
      return excelName;
   }
   /**
    * 获取码段宽度
    * @param codeClassifyOid
    * @return
    */
   private String getCodeSegmentWidth(String codeClassifyOid){
      CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid);
      // 要获取码段宽度,先要获取规则,当前没有往上找
      CodeRuleVO codeRuleByClassifyFullInfo = mdmEngineService.getCodeRuleByClassifyFullInfo(classifyService.getClassifyFullInfo(codeClassifyOid));
      List<CodeBasicSecVO> secVOList = codeRuleByClassifyFullInfo.getSecVOList();
      if(secVOList.isEmpty()){
         return "";
      }
      StringBuffer secWidth = new StringBuffer("");
      for (int j = 0; j < secVOList.size(); j++) {
         CodeBasicSecVO secVO = secVOList.get(j);
         int width = VciBaseUtil.getInt(secVO.getCodeSecLength()) + ((secVO.getPrefixCode() + secVO.getSuffixCode()).length());
         secWidth.append(width).append("#");
      }
      return secWidth.toString().substring(0, secWidth.length() - 1);
   }
   /**
@@ -856,7 +885,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 CopyOnWriteArrayList<>();
         List<ClientBusinessObject> cboList = new ArrayList<>();
         String fullPath = getFullPath(classifyFullInfo);
         //我们需要获取到所有的下级分类的oid的路径,因为后面需要
         Map<String/**主键**/, String/**路径**/> childOidPathMap = getChildClassifyPathMap(classifyFullInfo, fullPath);
@@ -1991,9 +2020,10 @@
      //最后弄组合规则
      batchSwitchComponentAttrOnOrder(attrVOS,cboList);
      //3.判断关键属性
      CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList,errorMap);
      CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList,errorKeyMap);
      Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList();
      Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList();
      Map<String,List<String>>keyAttrOkOidTORepeatOidMap= keyResultVO.getKeyAttrOkOidTORepeatOidMap();
      if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){
         selfRepeatRowIndexList.stream().forEach(rowIndex->{
@@ -2023,7 +2053,11 @@
                resultDataObjectDetailDO.setMsg(errorMap.getOrDefault(rowIndex,"") + ";关键属性与系统中的重复" );
                resultDataObjectDetailDOs.add(resultDataObjectDetailDO);
                */
            errorKeyMap.put(rowIndex, "关键属性与系统中的重复;" + errorMap.getOrDefault(rowIndex,""));
            Map<String, List<BaseModel>> indexTODataMap=keyResultVO.getIndexTODataMap();
            if(indexTODataMap.containsKey(rowIndex)){
               List<BaseModel> baseModelList= indexTODataMap.get(rowIndex);
            }
            errorKeyMap.put(rowIndex, "关键属性与系统中的重复;" + errorKeyMap.getOrDefault(rowIndex,""));
         });
      }
      //校验属性是否正确错误信息
@@ -2659,7 +2693,7 @@
            return;
         }
         //final String[] sql = {"select count(*) from " + tableName + " t where 1 = 1 "};
         final String[] sql = {"select id from " + tableName + " t where 1 = 1 "};
         final String[] sql = {"select t.id from " + tableName + " t where 1 = 1 "};
         conditionMap.forEach((key, value) -> {
            if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)){
               sql[0] += " and " + key + " is null ";
@@ -3003,6 +3037,7 @@
         }
      });
   }
   /**
    * excel转换为cbo的对象
    * @param classifyFullInfo 分类的全部信息
@@ -3745,7 +3780,7 @@
         if(!CollectionUtils.isEmpty(nullRowIndex)){
            String checkAttr = requiredAttrMap.values().stream().map(CodeClassifyTemplateAttrVO::getName).collect(Collectors.joining(","));
            nullRowIndex.stream().forEach(rowIndex->{
               errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";校验规则不通过,有校验的属性为" + checkAttr);
               errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";校验规则必填项不通过,如果有必填属性为空,则填【/】代替,有校验的属性为" + checkAttr);
            });
         }
      }
@@ -3989,6 +4024,9 @@
            childOidPathMap.put(childPath.getOid(),thisClassifyPath);
         });
      }
      String path=classifyFullInfo.getCurrentClassifyVO().getId();
      //根据客户选择的分类路径未id,还是name确定路径拼接
      childOidPathMap.put(classifyFullInfo.getCurrentClassifyVO().getOid(),fullPath);
      return childOidPathMap;
   }