xiejun
2025-01-22 d9183aa80ae17d36b79dda48c6b1d7fa22a80ee3
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/UniversalInterfaceImpl.java
@@ -69,8 +69,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ForkJoinPool;
@@ -80,6 +78,7 @@
import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST;
import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC;
import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_REFER_SEC;
/***
 * 统一接口
@@ -87,7 +86,7 @@
@Service
@Slf4j
@VciWebservice(path = "/universalInterface")
public class UniversalInterfaceImpl<IDockingLogeServiceing> implements UniversalInterfaceI {
public class UniversalInterfaceImpl implements UniversalInterfaceI {
   /***
    * 操作类型
@@ -285,6 +284,7 @@
            }
         }catch (Throwable e){
            errorid[0] ="101";
            log.error("接口参数:传入数据参数解析失败",e);
            throw new Throwable("接口参数:传入数据参数解析失败");
         }
         ClassfysVO classfysVO = interParameterVO.getData().getClassifys();
@@ -295,7 +295,7 @@
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT), this.getRequest());
         }catch (Throwable e){
            errorid[0] ="1";
            throw new Throwable("用户鉴权失败.");
            throw new Throwable("用户鉴权失败,原因:"+e.getMessage());
         }
         List<ClassfyVO> classVOList = classfysVO.getClassify();
         //InterParameterVO finalInterParameterVO = interParameterVO;
@@ -308,7 +308,7 @@
         //List<XMLResultDataObjectDetailDO> allResultDataObjectDetailDOS=new ArrayList<>();
         String finalSystemId = systemId;
         classVOList.stream().forEach(classVO -> {
            log.info("参数:分类COde:" + classVO.getClassCode());
            log.info("参数:分类Code:" + classVO.getClassCode());
            boolean isCodeOrGroupCode=false;
            LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>();
            String libray ="";
@@ -370,6 +370,7 @@
            } catch (Throwable e) {
               List<ApplyDataVO> applyDataVOList= classVO.getObjects().getObject();
               objerrorCode="1";
               log.error("编码申请失败:",e);
               if(!CollectionUtils.isEmpty(applyDataVOList)) {
                  applyDataVOList.stream().forEach(applyDataVO -> {
                     XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO = new XMLResultDataObjectDetailDO();
@@ -388,7 +389,7 @@
                  resultDataObjectDetailDOs.add(xmlResultDataObjectDetailDO);
               }
               e.printStackTrace();
               log.error(e.getMessage());
               //log.error(e.getMessage());
            }finally {
               XMLResultClassfyVO resultClassfyVO = new XMLResultClassfyVO();
               resultClassfyVO.setClassCode(classVO.getClassCode());
@@ -407,7 +408,8 @@
      }catch (Throwable e){
         e.printStackTrace();
         msg="申请编码失败:"+e.getMessage();
         log.error(msg);
         //log.error(msg);
         log.error("编码申请失败:",e);
          /*  XMLResultSystemVO XMLResultSystemVO=new XMLResultSystemVO();
            XMLResultSystemVO.setErrorid(errorid);
            XMLResultSystemVO.setMsg("申请编码失败:->"+e.getMessage());
@@ -443,7 +445,8 @@
            this.saveLogs(systemId, systemId, data, resultStr, issucess[0], msg, "applyCode");
         }catch (Throwable e){
            e.printStackTrace();
            log.error(e.getMessage());
            //log.error(e.getMessage());
            log.error("保存日志出错,原因:",e);
         }
      }
      log.info("返回参数:"+resultStr);
@@ -477,6 +480,7 @@
            try {
               passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(),this.getRequest());
            }catch (Throwable e){
               log.error("用户鉴权失败:",e);
               throw new Throwable("用户鉴权失败");
            }
            masterDataList = personData.getMasterData();
@@ -490,7 +494,7 @@
            ClassfyVO classfyVO = new ClassfyVO();
            classfyVO.setLibrary(personLibrary);
            classfyVO.setClassCode(personClassCode);
            CodeClassifyVO  codeClassifyVO=this.getClassfy(classfyVO,personLibrary);
            CodeClassifyVO codeClassifyVO=this.getClassfy(classfyVO,personLibrary);
            log.info("end:分类查询完毕");
            //获取分类模板信息
            if(codeClassifyVO==null || StringUtils.isBlank(codeClassifyVO.getOid())){
@@ -508,8 +512,7 @@
            ).collect(Collectors.toList());
            List<PersonMasterData> personMasterDataList= personData.getMasterData();
            List<Map> dataList=new ArrayList<>();
            //List<Map> dataList=new ArrayList<>();
            List<String> codeList=new ArrayList<>();
            List<ApplyDataVO> applyDataVOList=new ArrayList<>();
@@ -528,7 +531,7 @@
                */
               fields.stream().forEach(field->{
                  if(dataMap.containsKey(field)){
                     String enumFiled= dataMap.get(field);
                     String enumFiled = dataMap.get(field);
                     EnumerableData enumerableData=JSONObject.toJavaObject(JSONObject.parseObject(enumFiled),EnumerableData.class);
                     String enumCode=enumerableData.getCode();
                     //String enumCodeValue=enumerableData.getName();
@@ -548,15 +551,15 @@
               object.setProp(proppertyVOList);
               if(personMasterData.getDr()==1){
                  object.setOperate("delete");//操作类型
                  //操作类型
                  object.setOperate("delete");
                  deleteDataVOList.add(object);
               }else{
                  String worker_category=personMasterData.getWorker_category();
                  //String worker_category=personMasterData.getWorker_category();
                  object.setOperate("create");
                  applyDataVOList.add(object);
               }
               codeList.add(personMasterData.getLm_code());
               codeList.add(object.getCode());
            });
            R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
@@ -580,7 +583,7 @@
            sb.append(VciBaseUtil.toInSql(codeList.toArray(new String[0])));
            sb.append(")");
            List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString());
            DefaultAttrAssimtUtil.mapToLowerCase(dataMapList,true);
            List<ClientBusinessObject> cboList=   ChangeMapTOClientBusinessObjects(dataMapList);
            ApplyDatasVO applyDatasVO=new ApplyDatasVO();
            ApplyDatasVO editDatasVO=new ApplyDatasVO();
@@ -611,8 +614,8 @@
               DataObjectVO dataObjectVO = new DataObjectVO();
               this.getConfigDatas(systemCode, personLibrary, editDatasVO, attrVOS, dataObjectVO);
               log.info("start:修改数据执行完毕");
               boolean  personApplyGroupCode =personAndDeptConfig.isPersonApplyGroupCode();
               mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,personApplyGroupCode);
            //   boolean  personApplyGroupCode =personAndDeptConfig.isPersonApplyGroupCode();
               mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,isPersonApplyGroupCode);
               log.info("end:修改数据执行完毕");
            }
            if(applyDatasVO.getObject()!=null&&applyDatasVO.getObject().size()>0) {
@@ -674,9 +677,10 @@
                        }
                     }
                  } catch (Exception e) {
                     log.error("数据保存失败:",e);
                     mesg=e.getMessage();
                     e.printStackTrace();
                     throw new ServiceException(e.getMessage());
                  //   throw new ServiceException(e.getMessage());
                  }finally {
                     XMLResultDataObjectDetailDO x=new XMLResultDataObjectDetailDO();
                     x.setId(rowData.getOid());
@@ -708,6 +712,7 @@
            success.set(false);
            message = "人员数据接收失败:"+e.getMessage();
            msg = "人员数据接收失败:"+e.getMessage();
            log.error( "人员数据接收失败:",e);
            //组织返回结果
            boolean finalSuccess = success.get();
            String finalMessage = message;
@@ -724,7 +729,7 @@
            resultOrgData.setMessage(message);
            resultOrgData.setSuccess(success.get());
            resultOrgData.setMdMappings(resultMdMappingList);
            Object object = JSONObject.toJSON(resultOrgData);
            //Object object = JSONObject.toJSON(resultOrgData);
         }
         String resultStr = JSONObject.toJSONString(resultOrgData);
         String data = JSONObject.toJSONString(personData);
@@ -732,6 +737,7 @@
            //记录日志
            this.saveLogs(systemCode, systemCode, data, resultStr, success.get(), msg, "syncDataForPerson");
         }catch (Throwable e){
            log.error( "日志保存失败:",e);
            e.printStackTrace();
         }
      }
@@ -749,13 +755,13 @@
   public ResultOrgData syncDataForOrg(OrgData orgData) {
      boolean isUsedFlag= personAndDeptConfig.isUsedFlag();
      ResultOrgData resultOrgData=new ResultOrgData();
      //boolean isPersonApplyGroupCode= personAndDeptConfig.isDeptApplyGroupCode();
      // boolean isPersonApplyGroupCode= personAndDeptConfig.isDeptApplyGroupCode();
      List<ResultMdMapping> resultMdMappingList=new ArrayList<>();
      AtomicBoolean success= new AtomicBoolean(true);
      String message="";
      String systemCode="";
      if(isUsedFlag){
         List<OrgMasterData> orgMasterDataList=new ArrayList<>();
         List<OrgMasterData> orgMasterDataList = new ArrayList<>();
         List<String> fields = Func.toStrList(personAndDeptConfig.getDeptFields());
         try {
            if(orgData==null){
@@ -765,6 +771,7 @@
            try {
               passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(),this.getRequest());
            }catch (Throwable e){
               log.error( "用户鉴权失败:",e);
               throw new Throwable("用户鉴权失败");
            }
            orgMasterDataList = orgData.getMasterData();
@@ -778,7 +785,7 @@
            ClassfyVO classfyVO = new ClassfyVO();
            classfyVO.setLibrary(deptLibrary);
            classfyVO.setClassCode(deptClassCode);
            CodeClassifyVO  codeClassifyVO=this.getClassfy(classfyVO,deptLibrary);
            CodeClassifyVO codeClassifyVO = this.getClassfy(classfyVO,deptLibrary);
            log.info("end:分类查询完毕");
            //获取分类模板信息
            if(codeClassifyVO==null || StringUtils.isBlank(codeClassifyVO.getOid())){
@@ -799,13 +806,13 @@
            List<ApplyDataVO> deleteDataVOList=new ArrayList<>();
            orgMasterDataList.stream().forEach(orgMasterData -> {
               ApplyDataVO object=new ApplyDataVO();
               object.setCode(orgMasterData.getMdm_code());//编码
               object.setCode(orgMasterData.getDepartment_code());//编码
               object.setCreator(orgMasterData.getCreator());//创建者
               object.setEditor(orgMasterData.getModifier());//修改者
               object.setId(orgMasterData.getPk_mdm());//主键
               object.setId(orgMasterData.getId());//主键
               object.setStatus(CodeDefaultLC.RELEASED.getValue());//状态则需要判断
               Map<String,String> dataMap= VciBaseUtil.objectToMapString(orgMasterData);
               List<ProppertyVO> proppertyVOList=new ArrayList<>();
               List<ProppertyVO> proppertyVOList = new ArrayList<>();
               /***
                * 根据配置文件获取枚举值
                */
@@ -834,11 +841,10 @@
                  object.setOperate("delete");//操作类型
                  deleteDataVOList.add(object);
               }else{
                  object.setOperate("create");
                  applyDataVOList.add(object);
               }
               codeList.add(orgMasterData.getMdm_code());
               codeList.add(object.getCode());
            });
            R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
@@ -850,10 +856,10 @@
               throw new Throwable("根据业务类型未查询到业务类型对象!");
            }
            String tableName = btmTypeVO.getTableName();
            if (com.alibaba.nacos.common.utils.StringUtils.isBlank(tableName)) {
            if (StringUtils.isBlank(tableName)) {
               throw new Throwable("根据业务类型未查询到业务类型相关联的表");
            }
            StringBuffer sb=new StringBuffer();
            StringBuffer sb = new StringBuffer();
            sb.append(" select * from ");
            sb.append(tableName);
            sb.append(" where 1=1 ");
@@ -861,15 +867,16 @@
            sb.append(" and id in (");
            sb.append(VciBaseUtil.toInSql(codeList.toArray(new String[0])));
            sb.append(")");
            List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString());
            List<ClientBusinessObject> cboList=   ChangeMapTOClientBusinessObjects(dataMapList);
            List<Map<String,String>> dataMapList = commonsMapper.queryByOnlySqlForMap(sb.toString());
            DefaultAttrAssimtUtil.mapToLowerCase(dataMapList,true);
            List<ClientBusinessObject> cboList = ChangeMapTOClientBusinessObjects(dataMapList);
            ApplyDatasVO applyDatasVO=new ApplyDatasVO();
            ApplyDatasVO editDatasVO=new ApplyDatasVO();
            if(!CollectionUtils.isEmpty(cboList)){
               Map<String,ClientBusinessObject> oldpplyDataVOMap=   cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
               Map<String,ClientBusinessObject> oldpplyDataVOMap =   cboList.stream().filter(data -> data != null && StringUtils.isNotBlank(data.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
               //数据库不存在的
               List<ApplyDataVO> applyApplyDataVOList = applyDataVOList.stream().filter(cbo -> {
                  String code =cbo.getCode();
                  String code = cbo.getCode();
                  return !oldpplyDataVOMap.containsKey(code);
               }).collect(Collectors.toList());
               applyDatasVO.setObject(applyApplyDataVOList);
@@ -892,7 +899,7 @@
               DataObjectVO dataObjectVO = new DataObjectVO();
               this.getConfigDatas(systemCode, deptLibrary, editDatasVO, attrVOS, dataObjectVO);
               log.info("start:修改数据执行完毕");
               boolean  personApplyGroupCode = personAndDeptConfig.isPersonApplyGroupCode();
               boolean personApplyGroupCode = false;//personAndDeptConfig.isPersonApplyGroupCode();
               mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,personApplyGroupCode);
               log.info("end:修改数据执行完毕");
            }
@@ -907,8 +914,9 @@
               }
               List<XMLResultDataObjectDetailDO> xDOs=new CopyOnWriteArrayList<>();
               //限制线程并行数量
               customForkJoinPool.submit(()->{
                  dataObjectVO.getRowData().parallelStream().forEach(rowData->{
               //customForkJoinPool.submit(()->{
               //   dataObjectVO.getRowData().parallelStream().forEach(rowData->{
               dataObjectVO.getRowData().forEach(rowData->{
                     String mesg="";
                     try {
                        CodeOrderDTO orderDTO = new CodeOrderDTO();
@@ -924,7 +932,7 @@
                                 //规则之定义为可变码段存储主数据传递过来的数据
                                 CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO();
                                 CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid());
                                 CodeOrderSecDTO.setSecValue(rowData.getOid());
                                 CodeOrderSecDTO.setSecValue(rowData.getCode());
                                 codeOrderSecDTOList.add(CodeOrderSecDTO);
                              }
                           });
@@ -957,9 +965,10 @@
                        }
                     }*/
                     } catch (Exception e) {
                        log.error( "部门数据接收失败:",e);
                        mesg=e.getMessage();
                        e.printStackTrace();
                        throw new ServiceException(e.getMessage());
                     //   throw new ServiceException(e.getMessage());
                     }finally {
                        XMLResultDataObjectDetailDO x=new XMLResultDataObjectDetailDO();
                        x.setId(rowData.getOid());
@@ -969,7 +978,7 @@
                        xDOs.add(x);
                     }
                  });
               }).join();
               //}).join();
               resultDataObjectDetailDOs.addAll(xDOs);
               boolean finalSuccess1 = success.get();
               String finalMessage1 = message;
@@ -989,6 +998,7 @@
            success.set(false);
            message = "部门数据接收失败:"+e.getMessage();
            msg = "部门数据接收失败:"+e.getMessage();
            log.error( "部门数据接收失败:",e);
            //组织返回结果
            boolean finalSuccess = success.get();
            String finalMessage = message;
@@ -1013,6 +1023,7 @@
            //记录日志
            this.saveLogs(systemCode, systemCode, data, resultStr, success.get(), msg, "syncDataForOrg");
         }catch (Throwable e){
            log.error( "保存日志失败:",e);
            e.printStackTrace();
         }
      }
@@ -1069,6 +1080,7 @@
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            log.error("用户鉴权失败",e);
            throw new Throwable("用户鉴权失败");
         }
         List<ClassfyVO> classVOList = classfysVO.getClassify();
@@ -1124,6 +1136,8 @@
               mdmIOService.batchSyncEditDatas(codeClassifyVO,dataObjectVO, resultDataObjectDetailDOs,isCodeOrGroupCode);
               log.info("end:修改数据执行完毕");
            } catch (Throwable e) {
               msg="编码更改/状态更改/删除:";
               log.error(msg,e);
               List<ApplyDataVO> applyDataVOList= classVO.getObjects().getObject();
               objerrorCode="1";
               if(!CollectionUtils.isEmpty(applyDataVOList)) {
@@ -1157,6 +1171,7 @@
      }catch (Throwable e){
         e.printStackTrace();
         msg="编码更改/状态更改/删除:"+e.getMessage();
         log.error(msg,e);
          /*  XMLResultSystemVO XMLResultSystemVO=new XMLResultSystemVO();
            XMLResultSystemVO.setErrorid(errorid);
            XMLResultSystemVO.setMsg("申请编码失败:->"+e.getMessage());
@@ -1191,6 +1206,7 @@
            //记录日志
            this.saveLogs(systemId, systemId, data, resultStr, issucess[0], msg, "syncEditData");
         }catch (Throwable e){
            log.error("保存日志失败",e);
            e.printStackTrace();
         }
      }
@@ -1217,7 +1233,7 @@
      log.info("查询分类的数据类型:->"+dataType);
      ResultClassifyVO resultClassifyVO =new ResultClassifyVO();
      List<ClassifyVO> classifyVOList=new ArrayList<>();
      com.vci.ubcs.code.vo.webserviceModel.classify.ResultData resultData=new com.vci.ubcs.code.vo.webserviceModel.classify.ResultData();
      ResultData resultData=new ResultData();
      try {
         if (StringUtils.isBlank(data)) {
            errorid = "101";
@@ -1239,6 +1255,7 @@
            errorid = "101";
            msg="接口参数:传入数据参数解析失败";
            e.printStackTrace();
            log.error("接口参数:传入数据参数解析失败",e);
            throw new Throwable("接口参数:传入数据参数解析失败");
         }
         QueryData queryData=queryClassifyVO.getData();
@@ -1345,7 +1362,9 @@
         resultData.setLibrary(libraryVo);
      }catch (Throwable e){
         e.printStackTrace();
         msg="查询分类失败:"+e.getMessage();
         log.error(msg,e);
      }finally {
         resultData.setErrorid(errorid);
         resultData.setMsg(msg);
@@ -1366,6 +1385,7 @@
         //记录日志
         this.saveLogs(systemId, systemId, data, resultStr, issucess, msg, "queryClassify");
      }catch (Throwable e){
         log.error("保存日志信息失败:",e);
         e.printStackTrace();
      }
      log.info("返回参数:"+resultStr);
@@ -1405,6 +1425,7 @@
            errorid = "101";
            msg = "接口参数:传入数据参数解析失败";
            e.printStackTrace();
            log.error( "接口参数:传入数据参数解析失败",e);
            throw new Throwable("接口参数:传入数据参数解析失败");
         }
         CondtionsVO condtionsVO=dataCondtionsVO.getCondtions();
@@ -1416,6 +1437,7 @@
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            log.error("用户鉴权失败",e);
            throw new Throwable("用户鉴权失败");
         }
         CondtionVO condtionVO= condtionsVO.getCondtion();
@@ -1514,7 +1536,8 @@
               sb.append(" and lastr=1 and lastv=1" );
               sb.append(" and codeclsfid in (" + VciBaseUtil.toInSql(oidCodeclassifyDOMap.keySet().toArray(new String[0])) +")");
               sb.append(" and Lcstatus in (" + VciBaseUtil.toInSql(statusList.toArray(new String[]{})) +")");
               List<Map<String,String>>  newDataList= commonsMapper.queryByOnlySqlForMap(sb.toString());
               List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sb.toString());
               DefaultAttrAssimtUtil.mapToLowerCase(newDataList,true);
               List<ClientBusinessObject> clientBusinessObjects=   ChangeMapTOClientBusinessObjects(newDataList);
               List<com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO> dataObjectVOS=new ArrayList<>();
               if(!CollectionUtils.isEmpty(clientBusinessObjects)){
@@ -1569,7 +1592,9 @@
         }
      }catch (Throwable e){
         e.printStackTrace();
         msg="查询数据失败:"+e.getMessage();
         log.error(msg,e);
      }finally {
         resultDataVO.setErrorid(errorid);
         resultDataVO.setMsg(msg);
@@ -1589,6 +1614,7 @@
      try {    //记录日志
         this.saveLogs(systemId, systemId, data, resultStr, issucess, msg, "queryData");
      }catch (Throwable e){
         log.error("保存日志信息失败:",e);
         e.printStackTrace();
      }
      log.info("返回参数:"+resultStr);
@@ -1627,6 +1653,7 @@
         } catch (Throwable e) {
            errorid = "101";
            msg = "接口参数:传入数据参数解析失败";
            log.error(msg,e);
            e.printStackTrace();
            throw new Throwable("接口参数:传入数据参数解析失败");
         }
@@ -1639,6 +1666,7 @@
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            log.error("用户鉴权失败",e);
            throw new Throwable("用户鉴权失败");
         }
@@ -2027,6 +2055,7 @@
      }catch (Throwable e){
         e.printStackTrace();
         msg="查询分类失败:"+e.getMessage();
         log.error("查询分类失败:",e);
      }finally {
         resultClassifyRuleData.setErrorid(errorid);
         resultClassifyRuleData.setMsg(msg);
@@ -2047,6 +2076,7 @@
         //记录日志
         this.saveLogs(systemId, systemId, data, resultStr, issucess, msg, "queryClassifyRule");
      }catch (Throwable e){
         log.error("保存日志信息失败:",e);
         e.printStackTrace();
      }
      log.info("返回参数:"+resultStr);
@@ -2091,6 +2121,7 @@
            }
         } catch (Throwable e) {
            errorid[0] = "101";
            log.error("接口参数:传入数据参数解析失败:",e);
            throw new Throwable("接口参数:传入数据参数解析失败");
         }
         classfyBZVO = applyBZParamVO.getData().getClassify();
@@ -2102,6 +2133,7 @@
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid[0] = "1";
            log.error("用户鉴权失败:",e);
            throw new Throwable("用户鉴权失败");
         }
         //这是账号信息
@@ -2207,6 +2239,7 @@
            } catch (Throwable e) {
               objerrorCode = "1";
               msg="编码申请失败:" +e.getMessage();
               log.error(msg,e);
               e.printStackTrace();
            }finally {
               XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO = new XMLResultDataObjectDetailDO();
@@ -2231,6 +2264,7 @@
      }catch (Throwable e){
         e.printStackTrace();
         msg="申请编码失败:"+e.getMessage();
         log.error(msg,e);
      }finally {
         XMLResultSystemVO xmlResultSystemVO=new XMLResultSystemVO();
         xmlResultSystemVO.setClassifys(resultClassfyVOList);
@@ -2256,6 +2290,7 @@
            //记录日志
            this.saveLogs(systemId, systemId, data, resultStr, issucess[0], msg, "applyCodeForBZ");
         }catch (Throwable e){
            log.error("保存日志信息失败:",e);
            e.printStackTrace();
         }
      }
@@ -2310,6 +2345,7 @@
         }
      }catch (Throwable e){
         objerrorCode="100";
         log.error("获取分类信息失败:",e);
         throw    new  Throwable("获取分类信息失败:"+e.getMessage());
      }
      return classifyVO;
@@ -2353,6 +2389,7 @@
         }
      }catch (Throwable e){
         objerrorCode="100";
         log.error("获取分类信息失败:",e);
         throw    new  Throwable("获取分类信息失败:"+e.getMessage());
      }
      return classifyVO;
@@ -2400,7 +2437,7 @@
      Map<String,String> errorMap=new HashMap<>();
      for(CodeBasicSecVO codeBasicSecVO: codeBasicSecVOS) {
         String sectype = codeBasicSecVO.getSecType();
         String newSecName=codeBasicSecVO.getName();
      //   String newSecName=codeBasicSecVO.getName();
         String classifySecOid= codeBasicSecVO.getOid();
         String message="";
         if (!sectype.equals(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())) {
@@ -2413,11 +2450,10 @@
               CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid());
               String sectypeValue = sectionVOMap.get(name);
               log.info("码段值:"+sectypeValue);
               CodeSecTypeEnum secType = CodeSecTypeEnum.forValue(sectype);
               if(CODE_CLASSIFY_SEC.equals(secType)) {//如果是分类的话,则需要匹配传过来的分类代号与
            //   CodeSecTypeEnum secType = CodeSecTypeEnum.forValue(sectype);
               if(CODE_CLASSIFY_SEC.getValue().equals(sectype)) {//如果是分类的话,则需要匹配传过来的分类代号与
                  //先简称是否有关联模板,有模板要先删除
                  List<CodeClassifyValue> codeClassifyValueDOList = codeClassifyValueService.list(Wrappers.<CodeClassifyValue>query().lambda().eq(CodeClassifyValue::getCodeClassifySecOid,classifySecOid));
                  if (!CollectionUtils.isEmpty(codeClassifyValueDOList)) {
                     Map<String, CodeClassifyValue> codeClassifyValueDOMap = codeClassifyValueDOList.stream().collect(Collectors.toMap(s -> s.getId(), t -> t, (o1, o2) -> o2));
                     if(codeClassifyValueDOMap.containsKey(sectypeValue)){
@@ -2429,9 +2465,157 @@
                        errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
                     }
                  }
               }else if(CODE_REFER_SEC.getValue().equals(sectype)){
                  String referBtmId=codeBasicSecVO.getReferBtmId();
                  String btmName=codeBasicSecVO.getReferBtmName();
                  String referConfig= codeBasicSecVO.getReferConfig();
                  CoderefersecSearchVO coderefersecSearchVO=new CoderefersecSearchVO();
                  if(StringUtils.isNotBlank(referConfig)){
                     coderefersecSearchVO = JSONObject.toJavaObject(JSONObject.parseObject(referConfig), CoderefersecSearchVO.class);
                  }
                  String buildSqlwhere="";
                  List<CodeSectionValueVO> codeSectionValueVOList=new ArrayList<>();
                  if(coderefersecSearchVO!=null) {
                     Map<String, Object> condtionMap = new HashMap<>();
                     String valueField= coderefersecSearchVO.getValueField();
                     if(StringUtils.isNotBlank(valueField)){
                        condtionMap.put(valueField,sectypeValue);
                     }
                     if (coderefersecSearchVO.getType().equals(CodeReferConfigTypeEnum.DEFAULT.getValue()) || coderefersecSearchVO.getType().equals(CodeReferConfigTypeEnum.GRID.getValue())) {//默认样式/列表
                        List<CodeSrchCondConfigVO> codeSrchCondConfigVOList = coderefersecSearchVO.getCodeSrchCondConfigVOS();
                        if (!CollectionUtils.isEmpty(codeSrchCondConfigVOList)) {
                           codeSrchCondConfigVOList.stream().forEach(codeSrchCondConfigVO -> {
                              condtionMap.put(codeSrchCondConfigVO.getFilterField() + codeSrchCondConfigVO.getFilterType(), codeSrchCondConfigVO.getFilterValue());
                           });
                        }
                        if(!CollectionUtils.isEmpty(condtionMap)) {
                           buildSqlwhere = UBCSSqlKeyword.buildSqlwhere(condtionMap);
                        }
                        //使用传入的业务类型查询表
                        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referBtmId));
                        if (!listR.isSuccess() || listR.getData().size() == 0) {
                           throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
                        }
                        String referTable = listR.getData().get(0).getTableName();
                        StringBuffer sb = new StringBuffer();
                        sb.append(" select * from  ");
                        sb.append(referTable);
                        sb.append(" where 1=1  ");
                        if (StringUtils.isNotBlank(buildSqlwhere)) {
                           sb.append(buildSqlwhere);
                        }
                        List<Map> ListMap = commonsMapper.selectBySql(sb.toString());
                        //String valueField = coderefersecSearchVO.getValueField();
                        String textField = coderefersecSearchVO.getTextField();
                        final int[] num = {0};
                        if (!CollectionUtils.isEmpty(ListMap)) {
                           ListMap.stream().forEach(map -> {
                              num[0]++;
                              String id = Func.isNull(map.getOrDefault("OID".toUpperCase(Locale.ROOT), "")) ? "" : map.getOrDefault("OID".toUpperCase(Locale.ROOT), "").toString();
                              String value = Func.isNull(map.getOrDefault(valueField.toUpperCase(Locale.ROOT), "")) ? "" : map.getOrDefault(valueField.toUpperCase(Locale.ROOT), "").toString();
                              String text = Func.isNull(map.getOrDefault(textField.toUpperCase(Locale.ROOT), "")) ? "" : map.getOrDefault(textField.toUpperCase(Locale.ROOT), "").toString();
                              String description = Func.isNull(map.getOrDefault("description".toUpperCase(Locale.ROOT), "")) ? "" : map.getOrDefault("description".toUpperCase(Locale.ROOT), "").toString();
                              CodeSectionValueVO sectionValueVO = new CodeSectionValueVO(id, num[0] + "", value, id, "", description);
                              codeSectionValueVOList.add(sectionValueVO);
                           });
                        }
                     }else if (coderefersecSearchVO.getType().equals(CodeReferConfigTypeEnum.TREE.getValue())) {//树形
                        //使用传入的业务类型查询表
                        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referBtmId));
                        if (!listR.isSuccess() || listR.getData().size() == 0) {
                           throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
                        }
                        String referTable = listR.getData().get(0).getTableName();
                        String oidFieldName = StringUtils.isNotBlank(coderefersecSearchVO.getParentUsedField())?coderefersecSearchVO.getParentUsedField():coderefersecSearchVO.getValueField();
                        String parentValue =coderefersecSearchVO.getParentValue();
                        String parentFieldName =StringUtils.isBlank(coderefersecSearchVO.getParentFieldName())?"":coderefersecSearchVO.getParentFieldName();
                        List<CodeSrchCondConfigVO> codeSrchCondConfigVOList = coderefersecSearchVO.getCodeSrchCondConfigVOS();
                        List<CodeShowFieldConfigVO> codeShowFieldConfigVOS=coderefersecSearchVO.getCodeShowFieldConfigVOS();
                        if (!CollectionUtils.isEmpty(codeSrchCondConfigVOList)) {
                           codeSrchCondConfigVOList.stream().forEach(codeSrchCondConfigVO -> {
                              condtionMap.put(codeSrchCondConfigVO.getFilterField() + codeSrchCondConfigVO.getFilterType(), codeSrchCondConfigVO.getFilterValue());
                           });
                        }
                        if(!CollectionUtils.isEmpty(condtionMap)) {
                           buildSqlwhere = UBCSSqlKeyword.buildSqlwhere(condtionMap);
                        }
                        //if("all".equals(coderefersecSearchVO.getLoadType())) {
                        String parentOidSql = "";
                        if(StringUtils.isNotBlank(parentValue)){
                           String temp=parentValue;
                           if(temp.startsWith(QueryOptionConstant.IN)){
                              temp = temp.substring((QueryOptionConstant.IN).length()).trim();
                              parentOidSql = " in " + ((temp.startsWith("(")  && temp.endsWith(")"))?temp:"(" + temp + ")");
                           }else if(temp.startsWith(QueryOptionConstant.NOTIN)){
                              parentOidSql = " not in " + ((temp.startsWith("(")  && temp.endsWith(")"))?temp:"(" + temp + ")");
                           }else if(temp.startsWith(QueryOptionConstant.NOTEQUAL)){
                              temp = temp.substring((QueryOptionConstant.NOTEQUAL).length()).trim();
                              parentOidSql = QueryOptionConstant.NOTEQUAL +  " " + ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }else if(temp.startsWith(QueryOptionConstant.MORETHAN)){
                              temp = temp.substring((QueryOptionConstant.MORETHAN).length()).trim();
                              parentOidSql = QueryOptionConstant.MORETHAN + " " +  ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }else if(temp.startsWith(QueryOptionConstant.MORE)){
                              temp = temp.substring((QueryOptionConstant.MORE).length()).trim();
                              parentOidSql = QueryOptionConstant.MORE + " " +  ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }else if(temp.startsWith(QueryOptionConstant.LESSTHAN)){
                              temp = temp.substring((QueryOptionConstant.LESSTHAN).length()).trim();
                              parentOidSql = QueryOptionConstant.LESSTHAN + " " +  ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }else if(temp.startsWith(QueryOptionConstant.LESS)){
                              temp = temp.substring((QueryOptionConstant.LESS).length()).trim();
                              parentOidSql = QueryOptionConstant.LESS +  " " + ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }else if (temp.startsWith(QueryOptionConstant.ISNOTNULL)) {
                              parentOidSql = " is not null";
                           } else if (temp.startsWith(QueryOptionConstant.ISNULL)) {
                              parentOidSql = " is  null";
                           } else if(temp.contains("*")){
                              parentOidSql = " like " + ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'").replace("*","%");
                           }else {
                              parentOidSql = " = " + ((temp.startsWith("'")  && temp.endsWith("'"))?temp:"'" + temp + "'");
                           }
                        }
                        //查询全部的信息
                        buildSqlwhere+= " and oid  in (select oid from " +referTable + " START WITH " + coderefersecSearchVO.getParentFieldName() + " "+
                           parentOidSql +
                           " CONNECT BY PRIOR " + oidFieldName + " = " + parentFieldName + ")";
                        StringBuffer sb = new StringBuffer();
                        sb.append(" select * from  ");
                        sb.append(referTable);
                        sb.append(" where 1=1  ");
                        if (StringUtils.isNotBlank(buildSqlwhere)) {
                           sb.append(buildSqlwhere);
                        }
                        List<Map> ListMap = commonsMapper.selectBySql(sb.toString());
                        String textField = coderefersecSearchVO.getTextField();
                        final int[] num = {0};
                        if (!CollectionUtils.isEmpty(ListMap)) {
                           ListMap.stream().forEach(map -> {
                              num[0]++;
                              String id =Func.isNull(map.getOrDefault("OID".toUpperCase(Locale.ROOT), ""))?"":map.getOrDefault("OID".toUpperCase(Locale.ROOT), "").toString();
                              String value =Func.isNull(map.getOrDefault(valueField.toUpperCase(Locale.ROOT), ""))?"":map.getOrDefault(valueField.toUpperCase(Locale.ROOT), "").toString();
                              String text =Func.isNull(map.getOrDefault(textField.toUpperCase(Locale.ROOT), ""))?"":map.getOrDefault(textField.toUpperCase(Locale.ROOT), "").toString();
                              String description =Func.isNull(map.getOrDefault("description".toUpperCase(Locale.ROOT), ""))?"":map.getOrDefault("description".toUpperCase(Locale.ROOT), "").toString();
                              String pid =Func.isNull(map.getOrDefault(parentFieldName.toUpperCase(Locale.ROOT), ""))?"":map.getOrDefault(parentFieldName.toUpperCase(Locale.ROOT), "").toString();
                              CodeSectionValueVO sectionValueVO = new CodeSectionValueVO(id, num[0] + "", value, text, pid, description);
                              codeSectionValueVOList.add(sectionValueVO);
                           });
                        }
                     }
                  }
                  if(!CollectionUtils.isEmpty(codeSectionValueVOList)){
                     Map<String, CodeSectionValueVO> codeSectionValueVOMap = codeSectionValueVOList.stream().collect(Collectors.toMap(s -> s.getValue(), t -> t, (o1, o2) -> o2));
                     if(!codeSectionValueVOMap.containsKey(sectypeValue)){
                        message="传入的编码规则码段:【"+name+"】为"+CODE_REFER_SEC.getText()+",其对应的值【"+sectypeValue+"】,在编码系统不存在";
                        errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
                     }
                  }else{
                     message="传入的编码规则码段:【"+name+"】为"+CODE_REFER_SEC.getText()+",其对应的值【"+sectypeValue+"】,在编码系统不存在";
                     errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
                  }
               }
               if(StringUtils.isBlank(sectypeValue)&&!newSecName.equals(secName)){
                  message="传入的分类码段:【" + name + " 】的值不允许为空";
               if(StringUtils.isBlank(sectypeValue)&&!name.equals(secName)){
                  message="传入的码段:【" + name + " 】的值不允许为空";
                  errorMap.put("error",errorMap.getOrDefault("error","")+";"+message);
               }
               CodeOrderSecDTO.setSecValue(sectypeValue);
@@ -2460,7 +2644,7 @@
    */
   public void getConfigDatas(String systemId,String libray, ApplyBZDatasVO applyDatasVO,List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList,DataObjectVO dataObjectVO) throws Throwable {
      LinkedHashMap<String,LinkedHashMap<String,String>> dataKeyValueMap=new LinkedHashMap<>();
      // LinkedHashMap<String,LinkedHashMap<String,String>> dataKeyValueMap=new LinkedHashMap<>();
      //如果将数据转换成所需要的数据对象
      Map<String, String> attrMapConfigMap=new HashMap<>();
      Map<String, String> propMaps=new HashMap<>();
@@ -2477,6 +2661,7 @@
         } catch (Throwable e) {
            objerrorCode = "1";
            e.printStackTrace();
            log.error("集成系统属性配置文件读取失败:",e);
            throw new Throwable("集成系统标识为:【" + systemId + "】,分类库为:【" + libray + "】的集成属性配置文件读取失败");
         }
         // String path = stringStringMap.get(systemId);
@@ -2547,6 +2732,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);
                     }
                  });
@@ -2572,7 +2758,8 @@
         dataObjectVO.setRowData(rowDataList);
      }catch (Throwable e){
         objerrorCode="1";
         throw new   Throwable("组织数据映射值失败");
         log.error("组织属性映射值失败:",e);
         throw new   Throwable("组织属性映射值失败");
      }
   }
@@ -2594,7 +2781,6 @@
      log.info("开始读取系统配置文件 start");
      Map<String, String> stringStringMap=attributeMapConfig.getSystem_attrmap();
      log.info("集成系统属性映射配置文件条目数-》"+stringStringMap.size());
      //stringStringMap.put("RLM","D:\\RLM.xml");
      if(!CollectionUtils.isEmpty(stringStringMap)) {
         List<LibraryClsfDO> libraryClsfDOList=new ArrayList<>();
         try {
@@ -2604,6 +2790,7 @@
         } catch (Throwable e) {
            objerrorCode = "1";
            e.printStackTrace();
            log.error("集成属性配置文件读取失败:",e);
            throw new Throwable("集成系统标识为:【" + systemId + "】,分类库为:【" + libray + "】的集成属性配置文件读取失败");
         }
         // String path = stringStringMap.get(systemId);
@@ -2679,6 +2866,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);
                     }
                  });
@@ -2704,7 +2892,8 @@
         dataObjectVO.setRowData(rowDataList);
      }catch (Throwable e){
         objerrorCode="1";
         throw new   Throwable("组织数据映射值失败");
         log.error("组织属性映射值失败:",e);
         throw new   Throwable("组织属性映射值失败");
      }
   }