xiejun
2023-10-12 111330b2dd0bccc176ab9c6324a6ed01d5bc0e93
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -495,7 +495,6 @@
      return text;
   }
   /**
    * 批量申请编码数据
    *
@@ -538,7 +537,6 @@
//      return null;
      return codeImProtRusultVO;
   }
   /***
    * 从顶层批量申请导入方法
@@ -645,7 +643,6 @@
         });
         //都转换完了。需要批量检查
         //如果出错了,我们依然执行有效的数据,无效的数据写回到excel中
         //2.判断必输项。。需要全部的属性,如果是必输,但是表单里面不显示的,只能是分类注入或者组合规则
@@ -719,10 +716,8 @@
         createRedisDatas(uuid + "-ok",codeImprotDataVOS, newErrorMap,true);
      });
      //往物品节点上加模板
      List<String> needRowIndexList=new ArrayList<>();
      CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO();
      if(errorMap.size()>0) {
@@ -792,6 +787,7 @@
      String uuid=VciBaseUtil.getPk();
      boolean isCreateUUid=false;
      boolean isExport=false;
      long start = System.currentTimeMillis();
      for(int i=0;i<sheetDataSetList.size()-1;i++) {
         if (CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(i).getRowData())
            || sheetDataSetList.get(i).getRowData().size() < 1) {
@@ -809,7 +805,6 @@
         //     5.3 企业编码的长度,和编码规则的长度要对应上
         //     5.4 获取流水码段的值,去除填充的字符,看流水号是多少,然后将流水号和现在的最大流水号判断,小于就直接录入,大于则修改最大流水号
         //     5.5 存储企业编码到allcode中
         //查询分类和模板
         CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
@@ -944,7 +939,7 @@
         ruleRowIndexMap.keySet().parallelStream().forEach(ruleOid -> {
            List<String> rowIndexList = ruleRowIndexMap.get(ruleOid);
            List<ClientBusinessObject> thisCbos = cboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList());
//我们需要先查询一下,内容是否已经存在
            //我们需要先查询一下,内容是否已经存在
            if(!CollectionUtils.isEmpty(thisCbos)){
               List<String> existIds = new ArrayList<>();
               VciBaseUtil.switchCollectionForOracleIn(thisCbos).stream().forEach(cbos -> {
@@ -1043,6 +1038,7 @@
               if (!CollectionUtils.isEmpty(thisCbos)) {
                  try {
                     // TODO 多线程流问题
                     productCodeService.productCodeAndSaveData(classifyFullInfo, finalTemplateVO, ruleVOMap.get(ruleOid), null, dataCBOList);
                  } catch (Throwable e) {
                     log.error("批量产生编码的时候出错了", e);
@@ -1061,6 +1057,8 @@
            engineService.batchSaveSelectChar(templateVO, dataCBOIdList);
         }
      }
      long end = System.currentTimeMillis();
      //log.info("=============for执行时间================="+String.valueOf((end-start)/1000));
      String excelFileName="";
      if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) {
         excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误信息.xls";
@@ -1086,6 +1084,7 @@
      return codeImProtRusultVO;
   }
   /*private void converBaseModels(List<ClientBusinessObject> clientBusinessObjects,List<BaseModel>dataCBOList){
      clientBusinessObjects.stream().forEach(clientBusinessObject -> {
         BaseModel baseModel=new BaseModel();
@@ -1099,6 +1098,7 @@
      });
   }*/
   /***
    * 从execl里构建对象
    * @param rowDataList
@@ -2329,12 +2329,17 @@
      sb.append(" where 1=1 ");
      sb.append(" and lastr=1 and lastv=1" );
      if(isCodeOrGroupCode) {
         sb.append(" and groupcode in (");
         sb.append(" and ( groupcode in (");
         sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])));
         sb.append(")");
         sb.append(" or id in (");
         sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])));
         sb.append("))");
      }else{
         sb.append(" and id in (");
         sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])));
         sb.append(")");
      }
      sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])));
      sb.append(")");
      List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString());
      List<ClientBusinessObject> cboList=   ChangeMapTOClientBusinessObjects(dataMapList);
@@ -2424,7 +2429,7 @@
               List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid()));
               log.info("codeCbos size:" + newCodeAllCodeList.size());
               if (!CollectionUtils.isEmpty(newCodeAllCodeList)) {
                  CodeAllCode codeCbo = codeAllCodeList.get(0);
                  CodeAllCode codeCbo = newCodeAllCodeList.get(0);
                  log.info("codeCbos code:" + codeCbo.getId());
                  codeCbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue());
                  codeAllCodeList.add(codeCbo);
@@ -2489,6 +2494,9 @@
            //是否调用集团接口申请接口
            if(isCodeOrGroupCode){
               List<String> IdList=resultDataObjectDetailDOs.stream().filter(xMLResultDataObjectDetailDO-> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(xMLResultDataObjectDetailDO.getId())).map(XMLResultDataObjectDetailDO::getId).distinct().collect(Collectors.toList());
               if(!CollectionUtils.isEmpty(IdList)) {
                  this.sendApplyGroupcode(IdList, classifyFullInfo.getTopClassifyVO().getBtmTypeId(),sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue());
               }
@@ -2616,7 +2624,21 @@
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()) + " t where 1 = 1 "};
         String tableName="";
         R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
         if(r.isSuccess()) {
            BtmTypeVO btmTypeVO = r.getData();
            if (btmTypeVO != null) {
               tableName = btmTypeVO.getTableName();
            }
         }
         if (StringUtils.isBlank(tableName)) {
            String errormsg="根据业务类型为查询到相关业务表";
            errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+errormsg);
            return;
         }
         final String[] sql = {"select count(*) from " + tableName + " t where 1 = 1 "};
         conditionMap.forEach((key, value) -> {
            if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)){
               sql[0] += " and " + key + " is null ";
@@ -2836,6 +2858,9 @@
         ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code);
         if(isCodeOrGroupCode){
            code=sysDataObject.getAttributeValue("GROUPCODE");
            if(StringUtils.isBlank(code)){
               code=sysDataObject.getId();
            }
         }
         CodeOrderDTO orderDTO = new CodeOrderDTO();
         if(codeDataMap.containsKey(code)){
@@ -2844,11 +2869,7 @@
            orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//分类主键
            orderDTO.setOid(sysDataObject.getOid());//数据oid
            orderDTO.setLcStatus(rowDatas.getStatus());//状态
            if(isCodeOrGroupCode){
               orderDTO.setId(sysDataObject.getId());
            }else{
               orderDTO.setId(code);
            }
            orderDTO.setId(code);
            orderDTO.setTs(sysDataObject.getTs());
            orderDTO.setBtmname(codeClassifyVO.getBtmname());//业务类型
            orderDTO.setDescription("集成调用:更新");//数据描述