xiejun
2023-09-13 81edec7c3bdef059a44e7c5e7b81d35ea09a72ed
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -179,7 +179,7 @@
    * @return excel的文件地址
    */
   @Override
   public  String downloadTopImportExcel(String codeClassifyOid){
   public String downloadTopImportExcel(String codeClassifyOid){
      List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>();
      VciBaseUtil.alertNotNull("导出模板","导出的配置",codeClassifyOid,"主题库分类的主键");
      CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid);
@@ -2090,6 +2090,7 @@
                     XMLResultDataObjectDetailDO resultDataObjectDetailDO = new XMLResultDataObjectDetailDO();
                     if(isCodeOrGroupCode) {
                        if(StringUtils.isBlank(groupCode)){
                           errorid="1";
                           mes+=";申请的编码类型为集团码,等待集团编码赋值";
                        }
                        resultDataObjectDetailDO.setCode(groupCode);
@@ -2157,14 +2158,16 @@
               }
               if(isCodeOrGroupCode) {
                  if(StringUtils.isBlank(groupCode)){
                     resultDataObjectDetailDO.setErrorid("1");
                     msg="申请的编码类型为集团码,等待集团编码赋值";
                  }
                  resultDataObjectDetailDO.setCode(groupCode);
               }else{
                  resultDataObjectDetailDO.setCode(code);
                  resultDataObjectDetailDO.setErrorid("0");
               }
               resultDataObjectDetailDO.setId(sourceOid);
               resultDataObjectDetailDO.setErrorid("0");
               resultDataObjectDetailDO.setMsg(msg);
               resultDataObjectDetailDOs.add(resultDataObjectDetailDO);
               //处理传送的数据中关键属性重复的,直接拿到已经申请到编码的数据编码直接将赋给关键属性重复的数据
@@ -2324,15 +2327,26 @@
      sb.append(" select * from ");
      sb.append(tableName);
      sb.append(" where 1=1 ");
      sb.append(" id in (");
      sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])));
      sb.append(")");
      sb.append(" and lastr=1 and lastv=1" );
      if(isCodeOrGroupCode) {
         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(")");
      }
      List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString());
      List<ClientBusinessObject> cboList=   ChangeMapTOClientBusinessObjects(dataMapList);
      Map<String, ClientBusinessObject> codeSystemObjectMap = cboList.stream().filter(systeDataObject -> systeDataObject != null && StringUtils.isNotBlank(systeDataObject.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t));
      Map<String, String> errorMap = new HashMap<>();
      List<CodeOrderDTO> codeOrderDTOList = new ArrayList<>();
      this.getCodeOrderDTOs(codeClassifyVO, templateVO, codeDataMap, codeSystemObjectMap, codeOrderDTOList, errorMap);
      this.getCodeOrderDTOs(codeClassifyVO, templateVO, codeDataMap, codeSystemObjectMap, codeOrderDTOList, errorMap,isCodeOrGroupCode);
      // List<CodeClassifyProcessTempVO> codeClassifyProcessTempVOS=codeClassifyProcessTempService.listProcessTemplate(templateVO.getOid(),"code_cls_flow_use_order");
      boolean isProcess=false;
      /**  if(!CollectionUtils.isEmpty(codeClassifyProcessTempVOS)){
@@ -2354,7 +2368,7 @@
         RowDatas rowData=codeDataMap.get(code);
         String status=rowData.getStatus();
         String operation=rowData.getOperation();
         if (cbo.getTs().compareTo(orderDTO.getTs())==0?true:false) {
         if (cbo.getTs().compareTo(orderDTO.getTs())==0?false:true) {
            // throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
            errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";数据不是最新的,可能他人已经修改,请刷新后再试");
         }
@@ -2396,7 +2410,7 @@
            List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid()));
            if (!CollectionUtils.isEmpty(newCodeAllCodeList)) {
               CodeAllCode codeCbo = codeAllCodeList.get(0);
               CodeAllCode codeCbo = newCodeAllCodeList.get(0);
               log.info("codeCbos code:" + codeCbo.getId());
               codeCbo.setLcStatus(status);
               codeAllCodeList.add(codeCbo);
@@ -2415,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);
@@ -2473,7 +2487,7 @@
         //存储数据
         try {
            engineService.updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),updateList);
            codeAllCodeService.saveBatch(codeAllCodeList);
            codeAllCodeService.saveOrUpdateBatch(codeAllCodeList);
            if(deleteList.size()>0) {
               commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.array2String(deleteList.toArray(new String[]{})));
            }
@@ -2607,17 +2621,36 @@
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()) + " 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) -> {
            sql[0] += " and " + key + " = " + value;
            if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)){
               sql[0] += " and " + key + " is null ";
            }else{
               sql[0] += " and " + key + " = " + value;
            }
         });
         if (StringUtils.isNotBlank(orderDTO.getOid())) {
            //修改的时候,需要排除自己
            sql[0] += " and oid != '" + orderDTO.getOid() + "'";
            sql[0] += " and t.oid != '" + orderDTO.getOid() + "'";
         } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) {
            sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'";
            sql[0] += " and t.oid != '" + orderDTO.getCopyFromVersion() + "'";
         }
         sql[0] += " and lastR = '1' and lastV = '1' ";
         sql[0] += " and t.lastR = '1' and t.lastV = '1' ";
         if (commonsMapper.queryCountBySql(sql[0]) > 0) {
            String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}";
            String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"};
@@ -2817,13 +2850,19 @@
    * @param errorMap
    * @return
    */
   private void getCodeOrderDTOs(CodeClassifyVO codeClassifyVO,CodeClassifyTemplateVO templateVO,Map<String ,RowDatas>codeDataMap,Map<String, ClientBusinessObject> codeSystemObjectMap,List<CodeOrderDTO> codeOrderDTOList,Map<String,String> errorMap){
      codeDataMap.keySet().forEach(code->{
         RowDatas rowDatas=codeDataMap.get(code);
         Map<String, String> data= rowDatas.getFiledValue();
   private void getCodeOrderDTOs(CodeClassifyVO codeClassifyVO,CodeClassifyTemplateVO templateVO,Map<String ,RowDatas>codeDataMap,Map<String, ClientBusinessObject> codeSystemObjectMap,List<CodeOrderDTO> codeOrderDTOList,Map<String,String> errorMap,boolean isCodeOrGroupCode){
      codeSystemObjectMap.keySet().forEach(code->{
         ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code);
         if(isCodeOrGroupCode){
            code=sysDataObject.getAttributeValue("GROUPCODE");
            if(StringUtils.isBlank(code)){
               code=sysDataObject.getId();
            }
         }
         CodeOrderDTO orderDTO = new CodeOrderDTO();
         if(codeSystemObjectMap.containsKey(code)){
            ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code);
         if(codeDataMap.containsKey(code)){
            RowDatas rowDatas=codeDataMap.get(code);
            Map<String, String> data= rowDatas.getFiledValue();
            orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//分类主键
            orderDTO.setOid(sysDataObject.getOid());//数据oid
            orderDTO.setLcStatus(rowDatas.getStatus());//状态
@@ -4001,7 +4040,7 @@
         DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject);
         for (String key:dataMap.keySet()){
            Object value= dataMap.getOrDefault(key,"");
            clientBusinessObject.setAttributeValue(key,value.toString());
            clientBusinessObject.setAttributeValue(key.toLowerCase(Locale.ROOT),value==null?"":value.toString());
         }
         clientBusinessObjectList.add(clientBusinessObject);
      });
@@ -4434,7 +4473,7 @@
    * @param idList
    * @param btmName
    */
   private void sendApplyGroupcode(List<String> idList,String btmName,String operationType){
   public void sendApplyGroupcode(List<String> idList,String btmName,String operationType){
      String oids=VciBaseUtil.array2String(idList.toArray(new String[]{}));
      if(operationType.equals(sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue())) {
         mdmInterJtClient.applyGroupCode(oids,btmName);