xiejun
2025-01-22 d9183aa80ae17d36b79dda48c6b1d7fa22a80ee3
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeMdmInfaceImpl.java
@@ -56,6 +56,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -326,7 +327,15 @@
               String fixedField=fixedFieldMap.getOrDefault("dr","");
               dr = masterData.getOrDefault(fixedField, "").toString();
            }
            object.setCode(masterData.getOrDefault(currentClassifyConfig.get().getSourceCodeKey(),"").toString());//编码
            List<String> sourceCodeKeyList=VciBaseUtil.str2List(currentClassifyConfig.get().getSourceCodeKey());
            //object.setCode(masterData.getOrDefault(currentClassifyConfig.get().getSourceCodeKey(),"").toString());//编码
            if(!CollectionUtils.isEmpty(sourceCodeKeyList)) {
               sourceCodeKeyList.stream().forEach(codekey -> {
                  if (StringUtils.isNotBlank(masterData.getOrDefault(codekey, "").toString())) {
                     object.setCode(masterData.getOrDefault(codekey, "").toString());//编码
                  }
               });
            }
            object.setProp(proppertyVOList);
            if (dr.equals(1)) {
@@ -341,6 +350,9 @@
            codeList.add(object.getCode());
         });
         if(CollectionUtils.isEmpty(codeList)){
            throw  new Throwable("检查配置文件:【sourceCodeKey】,唯一标识字段是否正确");
         }
         String targetCodeKey=currentClassifyConfig.get().getTargetCodeKey();
         StringBuffer sb = new StringBuffer();
         sb.append(" select * from ");
@@ -357,7 +369,7 @@
         ApplyDatasVO editDatasVO = new ApplyDatasVO();
         if (!CollectionUtils.isEmpty(cboList)) {
            //根据MDM编码去判断数据是否重复.
            Map<String, ClientBusinessObject> oldpplyDataVOMap = cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getAttributeValue(targetCodeKey))).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue(targetCodeKey).toLowerCase(Locale.ROOT), t -> t));
            Map<String, ClientBusinessObject> oldpplyDataVOMap = cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getAttributeValue(targetCodeKey))).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue(targetCodeKey), t -> t));
            //数据库不存在的
            List<ApplyDataVO> applyApplyDataVOList = applyDataVOList.stream().filter(cbo -> {
               String code = cbo.getCode();
@@ -368,6 +380,8 @@
            List<ApplyDataVO> editApplyDataVOList = applyDataVOList.stream().filter(cbo -> {
               String code = cbo.getCode();
               if (oldpplyDataVOMap.containsKey(code)) {
                  ClientBusinessObject object=   oldpplyDataVOMap.get(code);
                  cbo.setCode(object.getId());
                  cbo.setOperate("update");
               }
               return oldpplyDataVOMap.containsKey(code);
@@ -482,7 +496,7 @@
                  mesg="集成系统:【"+systemCode+"】申请编码失败:" + e.getMessage();
                  mesg = e.getMessage();
                  e.printStackTrace();
                  throw new ServiceException(e.getMessage());
               //   throw new ServiceException(e.getMessage());
               } finally {
                  XMLResultDataObjectDetailDO x = new XMLResultDataObjectDetailDO();
                  x.setId(rowData.getOid());
@@ -699,6 +713,7 @@
                     String dataValue = sourceKeyValueMap.get(sourceKey);
                     if (attrMapConfigMap.containsKey(sourceKey)) {
                        String targetKey = attrMapConfigMap.get(sourceKey);
                        log.info("xxxxx属性映射值:sourceKey【"+sourceKey+"】——》+targetKey---》"+targetKey+":"+dataValue);
                        keyValueMap.put(targetKey, StringUtils.isBlank(dataValue)?"":dataValue);
                     }
                  });
@@ -835,25 +850,33 @@
    * @param vaule
    * @return
    */
   private String objectToStr(Object vaule){
   private  String objectToStr(Object vaule) {
      String newValue="";
      if(vaule ==null||"".equals(vaule)||vaule==""){
         return "";
      }
      if(vaule instanceof Integer){
         Integer intValue=(Integer)vaule;
         newValue=String.valueOf(intValue);
      }else if (vaule instanceof Boolean){
         boolean boolValue=(Boolean) vaule;
         newValue=Boolean.toString(boolValue);
      }else if(vaule instanceof Timestamp){
         Timestamp timestampValue=(Timestamp)vaule;
         newValue=timestamp2Str(timestampValue);
      }else if(vaule instanceof Date){
         Date dataValue=(Date) vaule;
         newValue = date2Str(dataValue,"yyyy-MM-dd HH:mm:ss");
      }else {
         return vaule.toString();
      try {
         if (vaule instanceof Integer) {
            Integer intValue = (Integer) vaule;
            newValue = String.valueOf(intValue);
         } else if (vaule instanceof Boolean) {
            boolean boolValue = (Boolean) vaule;
            newValue = Boolean.toString(boolValue);
         } else if (vaule instanceof Timestamp) {
            Timestamp timestampValue = (Timestamp) vaule;
            newValue = timestamp2Str(timestampValue);
         } else if (vaule instanceof Date) {
            Date dataValue = (Date) vaule;
            newValue = date2Str(dataValue, "yyyy-MM-dd HH:mm:ss");
         }else if (vaule instanceof BigDecimal){
            BigDecimal bigDecimal=(BigDecimal)vaule;
            newValue =  bigDecimal.toString();
         } else {
            return vaule.toString();
         }
      }catch (Throwable e){
         //   log.error("属性类型转换错误",e);
         e.printStackTrace();
      }
      return newValue;
   }