fjl
fujunling
2023-07-18 2c6c24281d4c261b172d02a98df9524cffc0c276
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/UniversalInterfaceImpl.java
@@ -11,10 +11,7 @@
import com.vci.ubcs.code.dto.CodeOrderDTO;
import com.vci.ubcs.code.dto.CodeOrderSecDTO;
import com.vci.ubcs.code.entity.*;
import com.vci.ubcs.code.enumpack.CodeDefaultLC;
import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
import com.vci.ubcs.code.enumpack.SysIntegrationDataFlowTypeEnum;
import com.vci.ubcs.code.enumpack.sysIntegrationPushTypeEnum;
import com.vci.ubcs.code.enumpack.*;
import com.vci.ubcs.code.mapper.CommonsMapper;
import com.vci.ubcs.code.service.*;
import com.vci.ubcs.code.util.ClientBusinessObject;
@@ -39,26 +36,26 @@
import com.vci.ubcs.code.wrapper.CodeClassifyWrapper;
import com.vci.ubcs.omd.feign.IBtmTypeClient;
import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.starter.revision.model.BaseModel;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.web.constant.QueryOptionConstant;
import com.vci.ubcs.starter.util.UBCSSqlKeyword;
import com.vci.ubcs.starter.web.pagemodel.SessionInfo;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static com.vci.ubcs.code.constant.MdmDuckingConstant.DOCKING_DEFAULT_CLASSIFY;
import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST;
import static com.vci.ubcs.code.constant.MdmEngineConstant.IMPORT_ROW_INDEX;
import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC;
/***
@@ -68,7 +65,8 @@
@Slf4j
@VciWebservice(path = "/universalInterface")
public class UniversalInterfaceImpl<IDockingLogeServiceing> implements UniversalInterfaceI {
   @Value("${code.universalinterface.checkSystemConfig:true}")
   public boolean CODE_CHECKCONFIG;
   @Autowired(required = false)
   private AttributeMapConfig attributeMapConfig;
   /**
@@ -338,14 +336,12 @@
         ClassfysVO classfysVO = interParameterVO.getData().getClassifys();
         systemId = interParameterVO.getData().getSystemId();
         //校验是否配置
         boolean checkPass= checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue());
         if(!checkPass){
            errorid="101";
            throw new Throwable("系统标识为【"+systemId+"】,"+sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
         boolean checkPass = checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue());
         if (!checkPass) {
            errorid = "101";
            throw new Throwable("系统标识为【" + systemId + "】," + sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getText() + "接口配置已停用或者未配置,请联系编码管理员!");
         }
         UserVO userVo = interParameterVO.getData().getUser();
         List<ClassfyVO> classVOList = classfysVO.getClassify();
         InterParameterVO finalInterParameterVO = interParameterVO;
@@ -497,12 +493,11 @@
         String libId= libraryVO.getId();
         List<String> classifyIdList=  libraryVO.getClassifyid();
         List<CodeClassifyVO> codeClassifyVOS =new ArrayList<>();
         //校验是否配置
         boolean checkPass= checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILY.getValue());
         if(!checkPass){
            errorid="101";
            throw new Throwable("系统标识为【"+systemId+"】,"+sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILY.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
            //校验是否配置
         boolean checkPass = checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILY.getValue());
         if (!checkPass) {
            errorid = "101";
            throw new Throwable("系统标识为【" + systemId + "】," + sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILY.getText() + "接口配置已停用或者未配置,请联系编码管理员!");
         }
         //这是账号信息
@@ -666,12 +661,14 @@
            msg = "接口参数:library 为null";
            throw new Throwable(msg);
         }
         //校验是否配置
         boolean checkPass= checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getValue());
         if(!checkPass){
            errorid="101";
            throw new Throwable("系统标识为【"+systemId+"】,"+sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
         boolean checkPass = checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getValue());
         if (!checkPass) {
            errorid = "101";
            throw new Throwable("系统标识为【" + systemId + "】," + sysIntegrationPushTypeEnum.ACCPET_QUERYDATA.getText() + "接口配置已停用或者未配置,请联系编码管理员!");
         }
         //先简称是否有关联模板,有模板要先删除
         List<CodeClassify> libIdDos =classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId,library));
@@ -858,11 +855,12 @@
         List<CodeClassifyVO> codeClassifyVOS =new ArrayList<>();
         //校验是否配置
         boolean checkPass= checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILYRULE.getValue());
         if(!checkPass){
            errorid="101";
            throw new Throwable("系统标识为【"+systemId+"】,"+sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILYRULE.getText()+"接口配置已停用或者未配置,请联系编码管理员!");
         boolean checkPass = checkIspass(systemId, SysIntegrationDataFlowTypeEnum.ACCEPT.getValue(), sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILYRULE.getValue());
         if (!checkPass) {
            errorid = "101";
            throw new Throwable("系统标识为【" + systemId + "】," + sysIntegrationPushTypeEnum.ACCPET_QUERYCLAFILYRULE.getText() + "接口配置已停用或者未配置,请联系编码管理员!");
         }
         //这是账号信息
         //这是账号信息
         if(userVo!=null) {
@@ -949,10 +947,54 @@
                        }else if(secType.equals("coderefersec")){//引用码段
                           codeBasicSecVO.getReferAttributeId();
                           codeBasicSecVO.getReferCodeClassifyOid();
                           codeBasicSecVO.getReferBtmId();
                           codeBasicSecVO.getReferBtmName();
                           //codeBasicSecVO.getReferValueInfo();
                           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="";
                           if(coderefersecSearchVO!=null){
                              Map<String,Object> condtionMap=new HashMap<>();
                              List<CodeSrchCondConfigVO> codeSrchCondConfigVOList=coderefersecSearchVO.getCodeSrchCondConfigVOS();
                              if(!CollectionUtils.isEmpty(codeSrchCondConfigVOList)) {
                                 codeSrchCondConfigVOList.stream().forEach(codeSrchCondConfigVO -> {
                                    condtionMap.put(codeSrchCondConfigVO.getFilterField()+codeSrchCondConfigVO.getFilterType(),codeSrchCondConfigVO.getFilterValue());
                                 });
                                 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= map.getOrDefault("OID".toUpperCase(Locale.ROOT),"").toString();
                                 String value= map.getOrDefault(valueField.toUpperCase(Locale.ROOT),"").toString();
                                 String text=map.getOrDefault(textField.toUpperCase(Locale.ROOT),"").toString();
                                 String description=map.getOrDefault("description".toUpperCase(Locale.ROOT),"").toString();
                                 CodeSectionValueVO sectionValueVO=new CodeSectionValueVO(id, num[0]+"",value,text,"",description);
                                 codeSectionValueVOList.add(sectionValueVO);
                              });
                           }
                           log.info(libId);
                        }else if(secType.equals("codelevelsec")) {//层级码段
                           int level = codeBasicSecVO.getCodeLevelValue();
                           CodeClassifyVO levelCodeClassifyVO = new CodeClassifyVO();
@@ -1354,6 +1396,9 @@
    * @return
    */
   private boolean checkIspass(String systemId,String type,String operationType){
      if(!CODE_CHECKCONFIG) {
         return true;
      }
      //根据类型去查询需要集成的分类或者数据
      LambdaQueryWrapper<DockingSystemConfig> queryWrapper = Wrappers.<DockingSystemConfig>lambdaQuery();
      queryWrapper.eq(DockingSystemConfig::getUsedFlag, MdmDuckingConstant.SEND_FLAG_TRUE);