田源
2023-12-15 e2e754588cd9a3a15222fcb059d42aa10d763d90
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/UniversalInterfaceImpl.java
@@ -55,6 +55,7 @@
import com.vci.ubcs.system.vo.RoleVO;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
@@ -68,6 +69,8 @@
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.atomic.AtomicBoolean;
@@ -280,8 +283,12 @@
         systemId = interParameterVO.getData().getSystemId();
         UserVO userVo = interParameterVO.getData().getUser();
         //免密登录申请token,request中添加用户信息
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT), this.getRequest());
         }catch (Throwable e){
            errorid[0] ="1";
            throw new Throwable("用户鉴权失败.");
         }
         List<ClassfyVO> classVOList = classfysVO.getClassify();
         InterParameterVO finalInterParameterVO = interParameterVO;
         //这是账号信息
@@ -312,7 +319,7 @@
                  //校验是否配置
                  DockingSystemConfig dockingSystemConfig=null;
                  dockingSystemConfig=checkIspass(finalSystemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue(),codeClassifyVO.getOid());
                  if(dockingSystemConfig==null){
                  if(dockingSystemConfig==null||StringUtils.isBlank(dockingSystemConfig.getOid())){
                     errorid[0] ="101";
                     throw new Throwable("系统标识为【"+ finalSystemId +"】,集成分类为【"+codeClassifyVO.getName()+"】以上分类,"+sysIntegrationPushTypeEnum.ACCPET_APPCODE.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
                  }
@@ -326,7 +333,8 @@
               log.info("end:模板查询完毕");
               ApplyDatasVO applyDatasVO = classVO.getObjects();
               DataObjectVO dataObjectVO = new DataObjectVO();
               List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
               List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
                  ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
               ).collect(Collectors.toList());
               this.getConfigDatas(finalSystemId, libray, applyDatasVO, attrVOS, dataObjectVO);
               log.info("end:数据组织完毕");
@@ -412,10 +420,10 @@
            if(!CollectionUtils.isEmpty(resultClassfyVOList)) {
               resultClassfyVOList.stream().forEach(xMLResultClassfyVO -> {
                  xMLResultClassfyVO.getObjects().stream().forEach(objec -> {
                     if (!(objec.getErrorid().equals("0") || objec.getErrorid().equals("204"))) {
                     if (!(objec.getErrorid().equals("0")||objec.getErrorid().equals("201") ||objec.getErrorid().equals("205")|| objec.getErrorid().equals("204"))) {
                        issucess[0] = false;
                        msg=objec.getMsg();
                     }
                     msg=objec.getMsg();
                  });
               });
            }
@@ -457,7 +465,11 @@
            if(personData==null){
               throw new Throwable("传入参数为null");
            }
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(Locale.ROOT),this.getRequest());
            try {
               passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(),this.getRequest());
            }catch (Throwable e){
               throw new Throwable("用户鉴权失败");
            }
            masterDataList = personData.getMasterData();
            String personLibrary = personAndDeptConfig.getPersonLibrary();
            if (StringUtils.isBlank(personLibrary)) {
@@ -482,7 +494,8 @@
               throw  new  Throwable ("根据传输的分类,未获取MDM系统中对应模板");
            }
            List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
            List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
               ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
            ).collect(Collectors.toList());
            List<PersonMasterData> personMasterDataList= personData.getMasterData();
@@ -558,6 +571,7 @@
            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);
            ApplyDatasVO applyDatasVO=new ApplyDatasVO();
            ApplyDatasVO editDatasVO=new ApplyDatasVO();
@@ -733,8 +747,11 @@
               throw new Throwable("传入参数为null");
            }
            systemCode=orgData.getSystemCode();
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(),this.getRequest());
            try {
               passwordFreeLoginService.pwdFreeLoginByBoolean(systemCode.toLowerCase(),this.getRequest());
            }catch (Throwable e){
               throw new Throwable("用户鉴权失败");
            }
            orgMasterDataList = orgData.getMasterData();
            String personLibrary = personAndDeptConfig.getPersonLibrary();
            if (StringUtils.isBlank(personLibrary)) {
@@ -759,7 +776,8 @@
               throw  new  Throwable ("根据传输的分类,未获取MDM系统中对应模板");
            }
            List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
            List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
               ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
            ).collect(Collectors.toList());
            List<Map> dataList=new ArrayList<>();
            List<String> codeList=new ArrayList<>();
@@ -1029,7 +1047,12 @@
         UserVO userVo = interParameterVO.getData().getUser();
         //免密登录申请token,request中添加用户信息
         //passwordFreeLoginService.pwdFreeLoginByBoolean(userVo.getUserName(),this.getRequest());
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(Locale.ROOT),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            throw new Throwable("用户鉴权失败");
         }
         List<ClassfyVO> classVOList = classfysVO.getClassify();
         InterParameterVO finalInterParameterVO = interParameterVO;
         //这是账号信息
@@ -1057,7 +1080,7 @@
               if(CODE_CHECKCONFIG) {
                  //校验是否配置
                  DockingSystemConfig dockingSystemConfig= checkIspass(finalSystemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue(),codeClassifyVO.getOid());
                  if(dockingSystemConfig==null){
                  if(dockingSystemConfig==null||StringUtils.isBlank(dockingSystemConfig.getOid())){
                     objerrorCode ="101";
                     throw new Throwable("系统标识为【"+ finalSystemId +"】,集成分类为【"+codeClassifyVO.getName()+"】以上分类,"+sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
                  }
@@ -1074,7 +1097,8 @@
               ApplyDatasVO applyDatasVO = classVO.getObjects();
               DataObjectVO dataObjectVO = new DataObjectVO();
               //将默认的属性全部替换掉
               List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
               List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
                  ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
               ).collect(Collectors.toList());
               this.getConfigDatas(finalSystemId, libray, applyDatasVO, attrVOS, dataObjectVO);
               log.info("end:数据构建完毕");
@@ -1136,10 +1160,10 @@
            if(!CollectionUtils.isEmpty(resultClassfyVOList)) {
               resultClassfyVOList.stream().forEach(xMLResultClassfyVO -> {
                  xMLResultClassfyVO.getObjects().stream().forEach(objec -> {
                     if (!(objec.getErrorid().equals("0") || objec.getErrorid().equals("204"))) {
                     if (!(objec.getErrorid().equals("0")||objec.getErrorid().equals("201") ||objec.getErrorid().equals("205")|| objec.getErrorid().equals("204"))) {
                        issucess[0] = false;
                        msg=objec.getMsg();
                     }
                     msg=objec.getMsg();
                  });
               });
            }
@@ -1204,7 +1228,12 @@
         systemId=queryData.getSystemId();
         //免密登录申请token,request中添加用户信息
         //passwordFreeLoginService.pwdFreeLoginByBoolean(userVo.getUserName(),this.getRequest());
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            throw new Throwable("用户鉴权失败");
         }
         QueryLibraryVO libraryVO= queryData.getLibrary();
         String libId= libraryVO.getId();
@@ -1365,7 +1394,12 @@
         UserVO userVo=condtionsVO.getUser();
         //免密登录申请token,request中添加用户信息
         //passwordFreeLoginService.pwdFreeLoginByBoolean(userVo.getUserName(),this.getRequest());
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            throw new Throwable("用户鉴权失败");
         }
         CondtionVO condtionVO= condtionsVO.getCondtion();
         SessionInfo sessionInfo = new SessionInfo();
         sessionInfo.setUserId(userVo.getUserName());
@@ -1413,7 +1447,7 @@
               if(CODE_CHECKCONFIG) {
                  //校验是否配置
                  DockingSystemConfig dockingSystemConfig= checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getValue(),currentCodeClassify[0].getOid());
                  if(dockingSystemConfig==null){
                  if(dockingSystemConfig==null||StringUtils.isBlank(dockingSystemConfig.getOid())){
                     errorid ="101";
                     throw new Throwable("系统标识为【"+ systemId +"】,集成分类为【"+currentCodeClassify[0].getName()+"】以上分类,"+sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
                  }
@@ -1583,7 +1617,12 @@
         systemId=queryData.getSystemId();
         //免密登录申请token,request中添加用户信息
         //passwordFreeLoginService.pwdFreeLoginByBoolean(userVo.getUserName(),this.getRequest());
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid = "1";
            throw new Throwable("用户鉴权失败");
         }
         QueryLibraryVO libraryVO= queryData.getLibrary();
         String libId= libraryVO.getId();
@@ -2041,7 +2080,12 @@
         UserVO userVo = applyBZParamVO.getData().getUser();
         //免密登录申请token,request中添加用户信息
         //passwordFreeLoginService.pwdFreeLoginByBoolean(userVo.getUserName(), this.getRequest());
         passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         try {
            passwordFreeLoginService.pwdFreeLoginByBoolean(systemId.toLowerCase(),this.getRequest());
         }catch (Throwable e){
            errorid[0] = "1";
            throw new Throwable("用户鉴权失败");
         }
         //这是账号信息
         SessionInfo sessionInfo = new SessionInfo();
         sessionInfo.setUserId(userVo.getUserName());
@@ -2064,7 +2108,7 @@
            //校验是否配置
            DockingSystemConfig dockingSystemConfig=null;
            dockingSystemConfig=checkIspass(finalSystemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue(),codeClassifyVO.getOid());
            if(dockingSystemConfig==null){
            if(dockingSystemConfig==null||StringUtils.isBlank(dockingSystemConfig.getOid())){
               errorid[0] ="101";
               throw new Throwable("系统标识为【"+ finalSystemId +"】,集成分类为【"+codeClassifyVO.getName()+"】以上分类,"+sysIntegrationPushTypeEnum.ACCPET_APPCODE.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
            }
@@ -2078,7 +2122,8 @@
         log.info("end:模板查询完毕");
         ApplyBZDatasVO applyBZDatasVO = classfyBZVO.getObjects();
            DataObjectVO dataObjectVO = new DataObjectVO();
         List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
         List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
            ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
         ).collect(Collectors.toList());
         List<ApplyBZDataVO> applyBZDataVOList=   applyBZDatasVO.getObject();
         if(applyBZDataVOList.size()>1){
@@ -2180,10 +2225,10 @@
            if(!CollectionUtils.isEmpty(resultClassfyVOList)) {
               resultClassfyVOList.stream().forEach(xMLResultClassfyVO -> {
                  xMLResultClassfyVO.getObjects().stream().forEach(objec -> {
                     if (!(objec.getErrorid().equals("0") || objec.getErrorid().equals("204"))) {
                     if (!(objec.getErrorid().equals("0")||objec.getErrorid().equals("201")||objec.getErrorid().equals("205") || objec.getErrorid().equals("204"))) {
                        issucess[0] = false;
                        msg=objec.getMsg();
                     }
                     msg=objec.getMsg();
                  });
               });
            }
@@ -2293,9 +2338,11 @@
   private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){
      List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>();
      DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true);
      final BladeUser user = AuthUtil.getUser();
      oldDataMap.stream().forEach(dataMap->{
         ClientBusinessObject clientBusinessObject=new ClientBusinessObject();
         DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject,true);
         DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject,false,user);
         for (String key:dataMap.keySet()){
            Object value= dataMap.getOrDefault(key,"");
            clientBusinessObject.setAttributeValue(key.toLowerCase(Locale.ROOT),value==null?"":value.toString());
@@ -2415,7 +2462,7 @@
      }catch (Throwable e){
         objerrorCode="1";
         e.printStackTrace();
         throw new Throwable("MDM集成属性配置文件读取失败");
         throw new Throwable("集成系统标识为:【"+systemId+"】,分类库为:【"+libray+"】的集成属性配置文件读取失败");
      }
      LinkedList<String> rowNameList=new LinkedList<>();
      LinkedHashMap<String,Integer> filedIndexMap=new LinkedHashMap<>();
@@ -2526,13 +2573,18 @@
      }catch (Throwable e){
         objerrorCode="1";
         e.printStackTrace();
         throw new Throwable("MDM集成属性配置文件读取失败");
         throw new Throwable("集成系统标识为:【"+systemId+"】,分类库为:【"+libray+"】的集成属性配置文件读取失败");
      }
      LinkedList<String> rowNameList=new LinkedList<>();
      LinkedHashMap<String,Integer> filedIndexMap=new LinkedHashMap<>();
      //根据分类模板组织数据
      final int[] index = {0};
      try {
         //除去默认的属性.还有只有具有分类注入的才过滤出来
         codeClassifyTemplateAttrVOList = codeClassifyTemplateAttrVOList.stream().filter(
            s ->!DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) &&
               ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
         ).collect(Collectors.toList());
         codeClassifyTemplateAttrVOList.stream().forEach(codeClassifyTemplateAttrVO -> {
            String attrName = codeClassifyTemplateAttrVO.getName();
            String field = codeClassifyTemplateAttrVO.getId();
@@ -2713,8 +2765,15 @@
    */
   private DockingSystemConfig  checkIspass(String systemId,String type,String operationType,String classOid){
      log.info("systemId:"+systemId+",type:"+SysIntegrationDataFlowTypeEnum.getTextByValue(type)+",operationType:"+sysIntegrationPushTypeEnum.getTextByValue(operationType)+",classOid:"+classOid);
      CodeClassifyVO codeClassifyVO= classifyService.getObjectByOid(classOid);
      classOid=codeClassifyVO.getOid();
      //CodeClassifyVO codeClassifyVO= classifyService.getObjectByOid(classOid);
      List<CodeClassify> codeClassifyList=  classifyService.selectAllLevelParentByOid(classOid);
      List<String> classifyOids=new ArrayList<>();
      if(!CollectionUtils.isEmpty(codeClassifyList)) {
         classifyOids = codeClassifyList.stream().map(CodeClassify::getOid).collect(Collectors.toList());
      }else{
         return null;
      }
      //classOid=codeClassifyVO.getOid();
      //根据类型去查询需要集成的分类或者数据
      LambdaQueryWrapper<DockingSystemConfig> queryWrapper = Wrappers.<DockingSystemConfig>lambdaQuery();
      queryWrapper.eq(DockingSystemConfig::getUsedFlag, MdmDuckingConstant.SEND_FLAG_TRUE);
@@ -2722,11 +2781,16 @@
      queryWrapper.eq(DockingSystemConfig::getDataFlowType,type);
      queryWrapper.eq(DockingSystemConfig::getPushType,operationType);
      if(StringUtils.isNotBlank(classOid)){
         queryWrapper.in(DockingSystemConfig::getClassifyOid,classOid);
         queryWrapper.in(DockingSystemConfig::getClassifyOid,classifyOids);
      }
      List<DockingSystemConfig> dockingSystemConfigList=new ArrayList<>();
      dockingSystemConfigList=   dockingSystemConfigList=dockingSystemConfigService.list(queryWrapper);
      if(!CollectionUtils.isEmpty(dockingSystemConfigList)){
         return   dockingSystemConfigList.get(0);
      }else{
         return null;
      }
      /*if(!CollectionUtils.isEmpty(dockingSystemConfigList)){
       return   dockingSystemConfigList.get(0);
      }else{
         if(StringUtils.isNotBlank(codeClassifyVO.getParentCodeClassifyOid())) {
@@ -2737,6 +2801,6 @@
         return dockingSystemConfigList.get(0);
      }else{
         return   new DockingSystemConfig();
      }
      }*/
   }
}