ludc
2023-09-18 de9b95a2f14d42bcde076aeb32f1e1c4396b67f4
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vci.ubcs.code.applyjtcodeservice.vo.BaseModelVO;
import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO;
import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant;
@@ -15,11 +16,13 @@
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;
import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO;
import com.vci.ubcs.code.vo.CodeReferConfigVO;
import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
import com.vci.ubcs.code.vo.pagemodel.UITablePageVO;
import com.vci.ubcs.code.vo.pagemodel.*;
import com.vci.ubcs.code.wrapper.BaseMdodelWrapper;
import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
import com.vci.ubcs.flow.core.feign.IMDMIFlowAttrClient;
import com.vci.ubcs.flow.core.vo.ProcessStageAttrVO;
@@ -36,6 +39,7 @@
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.revision.model.TreeWrapperOptions;
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
import com.vci.ubcs.starter.util.MdmBtmTypeConstant;
import com.vci.ubcs.starter.util.UBCSSqlKeyword;
import com.vci.ubcs.starter.web.constant.QueryOptionConstant;
import com.vci.ubcs.starter.web.constant.RegExpConstant;
@@ -53,6 +57,7 @@
import com.vci.ubcs.system.user.feign.IUserClient;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import oracle.sql.TIMESTAMP;
import org.aspectj.apache.bcel.classfile.Code;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.cache.utils.CacheUtil;
@@ -423,6 +428,9 @@
      cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
      cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      cbo.setTenantId(AuthUtil.getTenantId());
      if(StringUtils.isNotBlank(orderDTO.getLcStatus())||StringUtils.isNotBlank(orderDTO.getData().get("lcStatus"))){
         cbo.setLcStatus(StringUtils.isNotBlank(orderDTO.getLcStatus())?orderDTO.getLcStatus():orderDTO.getData().get("lcStatus"));
      }
//      //TODO:因为默认的属性都不拷贝,目前集团码叫name,并没有从DTO拷贝到cbo里。增加一个单独处理,以后再看要不要调整
        cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName());
//      //end -- modify by lihang @20220407
@@ -431,18 +439,11 @@
        //备注
        cbo.setDescription(orderDTO.getDescription());
        cboList.add(cbo);
//
//      cboList.add(cbo);
        List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList);
//      List<String> charList = new ArrayList<>();
//      for (BaseModel baseModel : cboList) {
//         charList.add(baseModel.getId());
//      }
        batchSaveSelectChar(templateVO, cboList);
        return codeList.size() > 0 ? codeList.get(0) : "";
//      return null;
    }
    /**
@@ -467,7 +468,7 @@
                if (!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyInvokeLevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyInvokeLevel())) {
                    //指定了层级的
                    //注意,因为查询上级分类出来的层级是倒序的,即顶层节点是最大的值
                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> -o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
                    int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
                    if (classifyVOS.size() >= level && level > 0) {
                        classifyVO = classifyVOS.get(level - 1);
@@ -550,10 +551,15 @@
        String value = null;
        if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) {
            value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO));
        } else {
           if(StringUtils.isBlank(value)){
            value = orderDTO.getData().getOrDefault(attrId, "");
         }
      } else {
            //说明是自行配置的
            //前端必须要传递小写的属性
            value = orderDTO.getData().getOrDefault(attrId, "");
         String orDefault = orderDTO.getData().getOrDefault(attrId, "");
         value = Func.isBlank(orDefault) ? orderDTO.getData()
            .getOrDefault(attrId.toUpperCase(Locale.ROOT), ""):orDefault;
        }
        return value;
    }
@@ -659,7 +665,11 @@
            }
            final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
            conditionMap.forEach((key, value) -> {
                sql[0] += " and " + key + " = " + value;
            if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) {
               sql[0] += " and " + key + " is null";
            }else{
               sql[0] += " and " + key + " = " + value;
            }
            });
            if (StringUtils.isNotBlank(orderDTO.getOid())) {
                //修改的时候,需要排除自己
@@ -677,7 +687,90 @@
        }
    }
    /**
   /**
    * 校验关键属性
    *
    * @param orderDTO         编码申请的相关的信息
    */
   @Override
   public List<Map> checkKeyAttrOnOrderFordatas(CodeOrderDTO orderDTO) {
      List<Map>dataList=new ArrayList<>();
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      //先获取关键属性的规则,也利用继承的方式
      CodeKeyAttrRepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo);
      //注意的是keyRuleVO可能为空,表示不使用规则控制
      //获取所有的关键属性
      Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      Map<String, String> conditionMap = new HashMap<>();
      boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
      //全部去空的优先级大于去空
      boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
      boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag());
      boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag());
      ketAttrMap.forEach((attrId, attrVO) -> {
         String value = getValueFromOrderDTO(orderDTO, attrId);
         if (value == null) {
            value = "";
         }
         wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
      });
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
//         final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
//            String referTable = VciBaseUtil.getTableName(referVO.getReferType());
         if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
         }
         final String[] sql = {"select * from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
         conditionMap.forEach((key, value) -> {
            sql[0] += " and " + key + " = " + value;
         });
         if (StringUtils.isNotBlank(orderDTO.getOid())) {
            //修改的时候,需要排除自己
            sql[0] += " and oid != '" + orderDTO.getOid() + "'";
         } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) {
            sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'";
         }
         sql[0] += " and lastR = '1' and lastV = '1' ";
//         if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
         dataList=commonsMapper.selectBySql(sql[0]);
         if (!CollectionUtils.isEmpty(dataList)) {
//            String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}";
//            String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"};
//            throw new VciBaseException("根据您填写的关键属性的内容,结合关键属性查询规则,发现这个数据已经在系统中存在了。请修正!。" + ruleInfoMsg, objs);
            return dataList;
         }
      }
      return dataList;
   }
   /**
    * 根据当前申请编码的分类,逐层往上校验是否符合属于配置的中的分类子节点的分
    * 类,如果符合,则该分类申请的编码为集团码返回true,反之则为企业编码返回false
    * @param parameter 传入数据,classifyGroupCode:配置的中的分类顶节点,oid:选择节点的oid
    */
   @Override
   public R checkGroupCode(Map<String, String> parameter) {
      List<CodeClassify> codeClassifyList = classifyService.selectAllLevelParentByOid(parameter.get("oid"));
      Set<String> configGroupCode = Arrays.stream(parameter.get("classifyGroupCode").split("#")).collect(Collectors.toSet());
//      Boolean checkGroupFlag = false;//是否查询到配置的顶层分类中
      for (int i = codeClassifyList.size()-1; i >= 0; i--) {
         if(configGroupCode.contains(codeClassifyList.get(i).getId())){
//            checkGroupFlag = true;
            return R.data("true");
         }
//         if(checkGroupFlag && parameter.get("nowApplyCode").equals(codeClassifyList.get(i).getId())){
//            return R.data(true);
//         }
      }
      return R.data("false");
   }
   /**
     * 封装关键属性的查询语句
     *
     * @param value        当前的值
@@ -696,7 +789,7 @@
        boolean ignoreSpace = trim || trimAll;
        if (StringUtils.isBlank(value)) {
            //为空的时候,不能用QueryOperation.ISNULL,平台不知道啥时候不处理这种了
            conditionMap.put("t." + attrId, "null");
         conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
        } else {
            if (keyRuleVO != null) {
                String queryKey = "";
@@ -732,8 +825,12 @@
                queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'");
                conditionMap.put(queryKey, queryValue);
            } else {
                //为空的时候不代表不校验,只是不去除相关的信息
                conditionMap.put("t." + attrId, "'" +value+ "'");
            if(StringUtils.isNotBlank(value)) {
               //为空的时候不代表不校验,只是不去除相关的信息
               conditionMap.put("t." + attrId, "'" + value + "'");
            }else{
               conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
            }
            }
        }
    }
@@ -873,7 +970,7 @@
            return (BaseModel) valueWrapper.get();
        } catch (Exception e) {
            logger.error("创建业务类型对象", e);
            throw new VciBaseException("initBtmError", new String[]{btmName});
            throw new ServiceException("initBtmError:"+"业务类型:"+btmName+":"+e.getMessage());
        }
    }
@@ -1251,6 +1348,7 @@
        }
        fieldVO.setOptionJsMap(eventJsMap);
        fieldVO.setStyle(attrVO.getTableDisplayStyle());
        fieldVO.setTableDisplayFlag(attrVO.getTableDisplayFlag());
        //列表里不允许直接编辑
        fieldVO.setDateFormate(attrVO.getCodeDateFormat());
        return fieldVO;
@@ -1293,7 +1391,7 @@
      uiFormReferVO.setTableConfig(uiTableConfigVO);
      // 筛选条件
      HashMap<String, String> whereMap = new HashMap<>();
      if(!codeReferConfig.getCodeSrchCondConfigVOS().isEmpty()){
      if(!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())){
         codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{
            whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue());
         });
@@ -2334,7 +2432,6 @@
        return phaseAttrService.listAttrByTemplateOidAndPhaseId(templateVO.getOid(), phase);
    }
    /**
     * 路径上包含当前分类的所有分类信息
     *
@@ -2386,16 +2483,18 @@
        if (conditionMap == null) {
            conditionMap = new HashMap<>();
        }
        //pageHelper.addDefaultDesc("createTime");
        pageHelper.addDefaultDesc("id");
        pageHelper.addDefaultDesc("createTime");
//        pageHelper.addDefaultDesc("id");
        if (!classifyService.checkHasChild(codeClassifyOid)) {
            conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, codeClassifyOid);
        } else {
//         conditionMap.put(CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " + VciBaseUtil.getTableName(MdmBtmTypeConstant.CODE_CLASSIFY)
         List<BtmTypeVO> classifyData = btmTypeClient.selectByIdCollection(Collections.singletonList(MdmBtmTypeConstant.CODE_CLASSIFY)).getData();
         if(Func.isEmpty(classifyData)){
            throw new ServiceException("业务类型中英文名称和查询条件配置不一致,请修改业务类型中分类表英文名称为"+MdmBtmTypeConstant.CODE_CLASSIFY);
         }
            conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " +
                    btmTypeClient.selectByIdCollection(Collections.singletonList("classify"))
                            .getData().get(0).getTableName() + " where lcstatus='" + FrameWorkDefaultValueConstant
            classifyData.get(0).getTableName() + " where lcstatus='" + FrameWorkDefaultValueConstant
                    .FRAMEWORK_DATA_ENABLED + "' start with parentCodeClassifyOid = '" + codeClassifyOid +
                    "' CONNECT BY PRIOR OID = parentCodeClassifyOid )");
        }
@@ -2441,27 +2540,22 @@
        List<BaseModel> updateList = new ArrayList<>();
        // 应该都是一个分类下的业务数据,找第一条的就行
        CodeClassifyFullInfoBO topClassifyFullInfo = classifyService.getClassifyFullInfo(orderDTOList.get(0).getCodeClassifyOid());
//      Map<String,String> cboOidMap = new HashMap<>();
        if (CollectionUtils.isEmpty(orderDTOMap.keySet())) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        List<BaseModel> cboList = selectByTypeAndOid(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), VciBaseUtil.array2String(orderDTOMap.keySet().toArray(new String[0])));
//      cboOidMap.put("oid",QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(orderDTOMap.keySet().toArray(new String[0])) + ")");
//      List<ClientBusinessObject> cboList = boService.queryCBO(classifyFullInfo.getTopClassifyVO().getBtmtypeid(), cboOidMap);
        if (CollectionUtils.isEmpty(cboList)) {
      if (CollectionUtils.isEmpty(cboList)) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
//      BatchCBO batchCBO = new BatchCBO();
//      CodeClassifyTemplateVO firstTemplateVO = templateService.getObjectHasAttrByOid(orderDTOMap.values().stream().findFirst().get().getTemplateOid());
        Map<String, BaseModel> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
      Map<String, BaseModel> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
        orderDTOMap.keySet().stream().forEach(oid -> {
            CodeOrderDTO orderDTO = orderDTOMap.get(oid);
            CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
            CodeClassifyTemplateVO firstTemplateVO = templateService.getObjectHasAttrByOid(orderDTOMap.values().stream().findFirst().get().getTemplateOid());
            BaseModel cbo = cboMap.get(oid);
            String code = cbo.getId();
            if (!cbo.getTs().toString().contains(orderDTO.getTs().toString())) {
            if (!cbo.getTs().toString().contains(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) {
                throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
            }
            if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) {
@@ -2487,21 +2581,13 @@
            //企业码和集团码的不修改
            cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
            cbo.setName(orderDTO.getName());
//         try {
//            cbo.setAttributeValue("id",code);
            cbo.setId(code);
            cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
//            cbo.setAttributeValueWithNoCheck("description", StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription());
//            cbo.setAttributeValue("name", orderDTO.getName());
            cbo.setName(orderDTO.getName());
//         } catch (VCIError e) {
//            e.printStackTrace();
//         }
//         batchCBO.getUpdateCbos().add(cbo);
            updateList.add(cbo);
            batchSaveSelectChar(firstTemplateVO, cboList);
        });
//      boService.persistenceBatch(batchCBO);
        updateBatchByBaseModel(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), updateList);
        return R.success("操作成功!");
    }
@@ -2607,17 +2693,10 @@
                orderDTO.getCodeClassifyOid(), "主题库分类的主键");
        //需要升版
//      ClientBusinessObjectOperation cboOperation = new ClientBusinessObjectOperation();
        BaseModel cbo = null;
//      try {
//         //cbo = cboOperation.createBusinessObjectVersion(oldCbo,VciBaseUtil.getCurrentUserId());
        cbo = reviseBusinessObject(oldCbo);
//      } catch (VCIError e) {
//         throw new VciBaseException("初始化相关的内容出现了错误", new String[0], e);
//      }
        //1. 判断必输项
        //CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        checkRequiredAttrOnOrder(templateVO, orderDTO);
      checkRequiredAttrOnOrder(templateVO, orderDTO);
        //2.先注入,再组合,最后校验
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
@@ -2635,20 +2714,17 @@
        //企业码和集团码的不修改
        cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
        cbo.setName(orderDTO.getName());
//      try {
        cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
//      cbo.setAttributeValueWithNoCheck("description", StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription());
        cbo.setName(orderDTO.getName());
//      } catch (VCIError e) {
//         e.printStackTrace();
//      }
        //数据的时候,编码是不变的
        cbo.setCreateTime(cbo.getCreateTime());
        cbo.setLastModifyTime(cbo.getLastModifyTime());
//      List<ClientBusinessObject> cboList = new ArrayList<>();
//      cboList.add(cbo);
      cbo.setTenantId(AuthUtil.getTenantId());
      oldCbo.setLastV("0");
      oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      oldCbo.setLastModifyTime(new Date());
        try {
//         cboOperation.saveRevisionBuinessObject(cbo);
         updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
            insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
        } catch (Exception vciError) {
            throw new VciBaseException("数据更改保存出错了", new String[0], vciError);
@@ -2681,12 +2757,102 @@
        String codeRuleOid = classifyVO.getCodeRuleOid();
        if (StringUtils.isBlank(codeRuleOid)) {
            //往上找
            CodeClassifyFullInfoBO fullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
            return getCodeRuleByClassifyFullInfo(fullInfo);
         CodeRuleVO classifyFullInfoCodeRule = getCodeRuleByClassifyFullInfo(classifyService.getClassifyFullInfo(codeClassifyOid));
         return toCodeValueApplyStatus(classifyFullInfoCodeRule);
        }
        //我们查询编码规则
        return ruleService.getObjectHasSecByOid(codeRuleOid);
        //查询编码规则
      CodeRuleVO objectHasSecByOid = ruleService.getObjectHasSecByOid(codeRuleOid);
      return toCodeValueApplyStatus(objectHasSecByOid);
    }
   /**
    * 编码申请表单,隐藏、可输、只读转换
    * @param codeRuleVO
    * @return
    */
   private CodeRuleVO toCodeValueApplyStatus(CodeRuleVO codeRuleVO){
      if(codeRuleVO.getSecVOList().isEmpty()){
         return codeRuleVO;
      }
      // 可输码段类型
      List<String> inputTypes = Arrays.asList(
         CodeSecTypeEnum.CODE_FIXED_SEC.getValue(),
         CodeSecTypeEnum.CODE_VARIABLE_SEC.getValue(),
         CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue(),
         CodeSecTypeEnum.CODE_REFER_SEC.getValue(),
         CodeSecTypeEnum.CODE_DATE_SEC.getValue()
      );
      // 只读码段类型
      List<String> readOnlyTypes = Arrays.asList(
         CodeSecTypeEnum.CODE_LEVEL_SEC.getValue(),
         CodeSecTypeEnum.CODE_ATTR_SEC.getValue()
      );
      // 隐藏码段类型
      /*List<String> hideType = Arrays.asList(
         CodeSecTypeEnum.CODE_SERIAL_SEC.getValue()
      );*/
      // 当前规则的所有类型码段
      List<String> secTypeList = codeRuleVO.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.toList());
      // 情况一 全部是只读的码段类型
      boolean hasAllReadOnlyType =secTypeList.stream().allMatch(item -> readOnlyTypes.stream().anyMatch(item1-> item.equals(item1)));
      // 全部是只读的码段类型
      if(hasAllReadOnlyType){
         List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> {
            secVO.setCodeValueApplyStatus(3);
            // 日期码段设置默认值
            if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
               try {
                  secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
               }catch (Exception e){
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
               }
            }
            return secVO;
         }).collect(Collectors.toList());
         codeRuleVO.setSecVOList(basicSecVOS);
         return codeRuleVO;
      }
      // 情况二 全部都是可输入类型的
      boolean hasAllInputType = secTypeList.stream().allMatch(item -> inputTypes.stream().anyMatch(item1-> item.equals(item1)));
      if(hasAllInputType){
         List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> {
            secVO.setCodeValueApplyStatus(1);
            // 日期码段设置默认值
            if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
               try {
                  secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
               }catch (Exception e){
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
               }
            }
            return secVO;
         }).collect(Collectors.toList());
         codeRuleVO.setSecVOList(basicSecVOS);
         return codeRuleVO;
      }
      // 情况三包含人为选择的码段,又有只读类型码段的,所有码段都要显示出来,可输设置为1,只读设置为2,隐藏设置为3
      List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> {
         if(inputTypes.contains(secVO.getSecType())){
            secVO.setCodeValueApplyStatus(1);
         }else if(readOnlyTypes.contains(secVO.getSecType())){
            secVO.setCodeValueApplyStatus(2);
         }else{
            secVO.setCodeValueApplyStatus(3);
         }
         // 日期码段设置默认值
         if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
            try {
               secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
            }catch (Exception e){
               throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
            }
         }
         return secVO;
      }).collect(Collectors.toList());
      codeRuleVO.setSecVOList(basicSecVOS);
      codeRuleVO.setIsShowHideStatus(hasAllReadOnlyType ? "readOnly":(hasAllInputType ? "input":"readAndInput"));
      return codeRuleVO;
   }
    /**
     * 使用分类的全部信息获取编码规则
@@ -2703,7 +2869,7 @@
        } else {
            if (CollectionUtils.isEmpty(fullInfoBO.getParentClassifyVOs())) {
                //说明已经是最高层级,
                throw new VciBaseException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
            List<CodeClassifyVO> parentClassifyVOList = fullInfoBO.getParentClassifyVOs().stream().sorted((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())).collect(Collectors.toList());
            //从最高的level开始获取
@@ -2715,7 +2881,7 @@
                }
            }
            if (StringUtils.isBlank(codeRuleOid)) {
                throw new VciBaseException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
        }
        return ruleService.getObjectHasSecByOid(codeRuleOid);
@@ -3412,7 +3578,6 @@
        return baseModels;
    }
    /**
     * 根据业务类型名称创建业务数据源对象
     *
@@ -3521,20 +3686,79 @@
        return R.success("更新成功!");
    }
   /**
    * 更新业务数据同时对码值表数据操作接口
    *
    * @param btmType 业务类型
    * @param baseModels      处理数据
    * @return 处理状态
    */
   @Transactional(rollbackFor = VciBaseException.class)
   @Override
   public R<Integer> updateBatchBtypeDatas(String btmType, List<BaseModel> baseModels) {
    /**
      //使用传入的业务类型查询表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      //获取当前业务类型所有字段用来做对比
      R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType);
      if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应字段信息,请检查!");
      }
      Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
         return btmTypeAttributeVO.getId();
      }).collect(Collectors.toSet());
      if(!CollectionUtils.isEmpty(baseModels)){
         List<String> oidList=baseModels.stream().filter(data-> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getOid())).map(BaseModel::getOid).distinct().collect(Collectors.toList());
         LambdaQueryWrapper<CodeAllCode> lqw = new LambdaQueryWrapper<>();
         lqw.in(CodeAllCode::getCreateCodeOid,oidList);
         List<CodeAllCode> codeAllCodeList= codeAllCodeService.selectByWrapper(lqw);
         Map<String, CodeAllCode> cboMap = codeAllCodeList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getCreateCodeOid(), t -> t));
         List<CodeAllCode> newCodeAllCodeList=new ArrayList<>();
         //将bean转为map,mybatis统一处理
         List<Map<String, String>> maps = new ArrayList<>();
         try {
            baseModels.stream().forEach(baseModel->{
               String oid=baseModel.getOid();
               try {
                  maps.add(VciBaseUtil.convertBean2Map(baseModel,existFild));
               } catch (Exception e) {
                  throw new VciBaseException("类型转换错误:" + e.getMessage());
               }
               if(cboMap.containsKey(oid)){
                  CodeAllCode codeAllCode=   cboMap.get(oid);
                  codeAllCode.setId(baseModel.getId());
                  codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
                  codeAllCode.setLastModifyTime(new Date());
                  codeAllCode.setLcStatus(baseModel.getLcStatus());
                  newCodeAllCodeList.add(codeAllCode);
               }
            });
            commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps);
            codeAllCodeService.saveOrUpdateBatch(newCodeAllCodeList);
         } catch (Exception e) {
            throw new VciBaseException("类型转换错误:" + e.getMessage());
         }
      }
      return R.success("更新成功!");
   }
   /**
     * 获取参照的信息
     *
     * @param referConfigVO 参照的配置
     * @return 列表数据
     */
    @Override
    public IPage<BaseModel> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) throws VciBaseException {
    public IPage<BaseModelVO> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) throws VciBaseException {
        //checkReferConfig(referConfigVO);
        //使用业务类型查询
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
        if (!allAttributeByBtmId.isSuccess()) {
            throw new ServiceException("业务类型feign接口调用错误!");
            throw new ServiceException("业务类型feign接口调用错误;"+allAttributeByBtmId.getMsg());
        }
        if (Func.isEmpty(allAttributeByBtmId.getData())) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
@@ -3561,6 +3785,7 @@
        if (listR.getData().isEmpty()) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      // TODO:参照配置的模糊查询过滤条件暂未处理
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
            String s = baseQueryObject.getConditionMap().get("name");
@@ -3591,8 +3816,8 @@
        List<Map> maps = commonsMapper.selectBySql("select * from ( select rownum rn, t.* from (select * from " + listR.getData().get(0).getTableName() + SPACE
                + (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId()) ? (" where lastr = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastr").toString())
                + " and lastv =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and" : "where") + SPACE + "1=1 "
                + lcstatusSql + namesql + codesql + ") t where rownum <=" + num1 + ") where rn >=" + num2
        );
                + lcstatusSql + namesql + codesql + ") t "+ (baseQueryObject.getLimit()==-1?")": ("where rownum <=" + num1 + ") where rn >=" + num2)
      ));
        List<BaseModel> baseModels = new ArrayList<>();
        //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
        try {
@@ -3610,27 +3835,28 @@
                            ZonedDateTime zdt = localDateTime.atZone(zoneId);
                            Date date = Date.from(zdt.toInstant());
                            setter.invoke(obj, date);
                            map.remove(property.getName().toUpperCase());
                            //map.remove(property.getName().toUpperCase());
                        } //oracle的数字为BigDecimal的,需要进行转换成Integer,否则将报错
                        else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal
                                && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())) {
                            setter.invoke(obj, ((BigDecimal) map.get(property.getName().toUpperCase())).intValue());
                            map.remove(property.getName().toUpperCase());
                            //map.remove(property.getName().toUpperCase());
                        } else if (map.get(property.getName().toUpperCase()) != null) {
                     if(setter.getParameterTypes()[0].getSimpleName().equals("String")){
                        setter.invoke(obj, map.get(property.getName().toUpperCase()) == null ? null:String.valueOf(map.get(property.getName().toUpperCase())));
                     }else{
                        setter.invoke(obj, map.get(property.getName().toUpperCase()));
                     }
                            map.remove(property.getName().toUpperCase());
                            //map.remove(property.getName().toUpperCase());
                        }
                    }
                }
                for (Object key : map.keySet()) {
                    map.put(key, String.valueOf(map.get(key)));
                }
                ((BaseModel) obj).setData(map);
            Map<String, String> newMap = new HashMap<>();
            map.forEach((key, value) -> newMap.put(String.valueOf(key).toLowerCase(), String.valueOf(value)));
            ((BaseModel) obj).setData(newMap);
                baseModels.add((BaseModel) obj);
            }
        } catch (Exception e) {
@@ -3641,10 +3867,10 @@
                + "and lastv = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and" : "where") + SPACE + "1=1 "
                + lcstatusSql + namesql + codesql
        );
        IPage<BaseModel> objectDataGrid = new Page<>();
        IPage<BaseModelVO> objectDataGrid = new Page<>();
        objectDataGrid.setPages(baseQueryObject.getPage());
        objectDataGrid.setCurrent(baseQueryObject.getPage());
        objectDataGrid.setRecords(baseModels);
        objectDataGrid.setRecords(BaseMdodelWrapper.build().listVO(baseModels));
        objectDataGrid.setSize(baseQueryObject.getLimit());
        objectDataGrid.setTotal(total);
        return objectDataGrid;
@@ -3769,7 +3995,6 @@
        treeWrapperOptions.setParentOid(queryObject.getParentOid());
        return revisionModelUtil.doList2Trees(codeClassifies, treeWrapperOptions, null);
    }
    @Override
    public boolean checkUnAttrUnEdit(String attrName) {