田源
2024-04-18 3aae81075a18a11d6b605c7583eb03b75366b466
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -147,6 +147,7 @@
    */
   @Value("${bzApply.seriesFlow:seriesFlow}")
   private String seriesFlow;
   /***
    * 是否变更系列
    */
@@ -316,6 +317,12 @@
   public static final String BTM_NAME = "btm:name";
   /**
    * 配置的用来申请集团码的用户
    */
   @Value("${docking.apply.personUserAccount:28201728}")
   public String applyCodeUserAccount;
   /**
    * 密级的字段
    */
   public static final String SECRET_FILED = "secretgrade";
@@ -451,7 +458,7 @@
            }
            R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels);
            if (!r.isSuccess()) {
               throw new VciBaseException("更新数据出错,重试!" + r.getMsg());
               throw new VciBaseException("更新数据出错,请重试!" + r.getMsg());
            }
         }
         // 刚好顺序是一致的,所以直接按照codeallcode的顺序来拿业务数据
@@ -1553,7 +1560,6 @@
      wrapperResemble(templateVO, uiInfoVO);
      return uiInfoVO;
   }
   /**
    * 模板属性转换为表单定义的信息
@@ -3468,19 +3474,19 @@
         cbos.add(data);
      });
//      List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
      // List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
      if (CollectionUtils.isEmpty(cbos)) {
         throw new VciBaseException("数据在系统中不存在,是否因为修改过业务类型?");
         return R.fail("数据在系统中不存在,是否因为修改过业务类型?");
      }
//      Map<String, String> data = new HashMap<>();
      // Map<String, String> data = new HashMap<>();
      Map<String, String> cbo = cbos.get(0);
//      WebUtil.copyValueToMapFromCbos(cbo, data);
      // WebUtil.copyValueToMapFromCbos(cbo, data);
      List<Map<String, String>> dataList = new ArrayList<>();
      dataList.add(cbo);
      wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
      R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
      if(templateVO.getAttributes().isEmpty()){
         throw new ServiceException(String.format("主键为:{}的模板下,模板属性配置为空!",templateVO.getOid()));
         return R.fail(String.format("主键为:%s的模板下,模板属性配置为空!",templateVO.getOid()));
      }
      //处理返回数据与模板数据配置的字段不一样问题
      templateVO.getAttributes().stream().forEach(e -> {
@@ -3493,42 +3499,42 @@
      });
      //我们要看是否不是升版的,升版的话,需要对比不相等的属性
/*        String copy = cbo.get("copyfromversion");
//      if (StringUtils.isBlank(copy)) {
//         copy = cbo.getAttributeValue("copyfromversion");
//      }
        if (StringUtils.isNotBlank(copy)) {
            //说明有变更的内容
      /*        String copy = cbo.get("copyfromversion");
      //      if (StringUtils.isBlank(copy)) {
      //         copy = cbo.getAttributeValue("copyfromversion");
      //      }
            if (StringUtils.isNotBlank(copy)) {
               //说明有变更的内容
            CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
            //我们使用和业务类型的来查询
//         List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
            List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
            if (!CollectionUtils.isEmpty(oldCbos)) {
//            Map<String, String> newData = new HashMap<>();
//            WebUtil.copyValueToMapFromCbos(cbo, newData);
                Map<String, String> oldData = new HashMap<>();
                oldData = oldCbos.get(0);
                Map<String, String> difFieldMap = new HashMap<>();
                Map<String, String> finalOldData = oldData;
                cbo.forEach((key, value) -> {
               // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿
               String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
               if (value == null || value == "null") {
                        value = "";
                    }
                    if (oldValue == null || oldValue == "null") {
                        oldValue = "";
                    }
                    if (!value.equalsIgnoreCase(oldValue)) {
                        difFieldMap.put(key, oldValue);
                    }
                });
                List<Map<String, String>> difFieldList = new ArrayList<>();
                difFieldList.add(difFieldMap);
                result.setData(difFieldList);
            }
        }*/
               CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
               //我们使用和业务类型的来查询
      //         List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
               List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
               if (!CollectionUtils.isEmpty(oldCbos)) {
      //            Map<String, String> newData = new HashMap<>();
      //            WebUtil.copyValueToMapFromCbos(cbo, newData);
                  Map<String, String> oldData = new HashMap<>();
                  oldData = oldCbos.get(0);
                  Map<String, String> difFieldMap = new HashMap<>();
                  Map<String, String> finalOldData = oldData;
                  cbo.forEach((key, value) -> {
                     // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿
                     String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
                     if (value == null || value == "null") {
                        value = "";
                     }
                     if (oldValue == null || oldValue == "null") {
                        oldValue = "";
                     }
                     if (!value.equalsIgnoreCase(oldValue)) {
                        difFieldMap.put(key, oldValue);
                     }
                  });
                  List<Map<String, String>> difFieldList = new ArrayList<>();
                  difFieldList.add(difFieldMap);
                  result.setData(difFieldList);
               }
      }*/
      return result;
   }
@@ -4399,8 +4405,8 @@
               if (cboMap.containsKey(oid)) {
                  CodeAllCode codeAllCode = cboMap.get(oid);
                  codeAllCode.setId(baseModel.getId());
                  // codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
                  codeAllCode.setLastModifier(AuthUtil.getUser().getAccount());
                  // 主数据推送形式,是拿不到用户信息的
                  codeAllCode.setLastModifier(Func.isBlank(AuthUtil.getUserAccount()) ? applyCodeUserAccount:AuthUtil.getUserAccount());
                  codeAllCode.setLastModifyTime(new Date());
                  codeAllCode.setLcStatus(baseModel.getLcStatus());
                  newCodeAllCodeList.add(codeAllCode);