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;
@@ -20,6 +21,7 @@
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;
@@ -64,9 +66,14 @@
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.Cache;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
@@ -79,7 +86,7 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
@@ -95,12 +102,17 @@
@Service
public class MdmEngineServiceImpl implements MdmEngineService {
   /**
    * 单次sql的最多导入数量
    */
   @Value("${batchadd.single_maxnum:500}")
   private Integer MAX_IMPORT_NUM;
    /**
     * 模板的服务
     */
    @Resource
    private CodeClstemplateServiceImpl templateService;
    private ICodeClstemplateService templateService;
    /**
     * 生成编码的服务
@@ -133,6 +145,11 @@
     */
    @Resource
    IEnumClient enumClient;
   /**
    * 版本规则服务
    */
   @Resource
   private IRevisionRuleClient revisionRuleClient;
    /**
     * 公式的服务
@@ -140,13 +157,11 @@
    @Autowired
    private FormulaServiceImpl formulaService;
    /**
     * 对omd中提供的feign接口进行调用,以及处理相关逻辑
     */
    @Autowired
    ICodeReferBtmTypeService codeReferBtmTypeService;
    /**
     * 相似项查询规则
@@ -170,17 +185,12 @@
     */
    @Autowired
    private IBtmTypeClient btmTypeClient;
    /**
     * 版本规则的服务
     */
    @Resource
    private IRevisionRuleClient revisionRuleClient;
//
    /**
     * 通用查询
     */
    @Resource
    CommonsMapper commonsMapper;
    private CommonsMapper commonsMapper;
    /**
     * 编码规则的服务
@@ -381,14 +391,35 @@
        codeAllCodeService.updateBatchById(codeCbos);
    }
   /**
    * 申请单一编码
    *
    * @param orderDTO 申请的信息,需要包含属性的内容和码段相关的内容
    * @return 返回编码的内容
    */
   @Override
   public String addSaveCode(CodeOrderDTO orderDTO) throws Exception {
      return addSaveCode(orderDTO,true);
   }
   /***
    * 集成可变码段申请接口
    * @param orderDTO 申请的信息,需要包含属性的内容和码段相关的内容
    * @return
    * @throws Exception
    */
   @Override
   public String addSaveCodeNotauthUser(CodeOrderDTO orderDTO, boolean authUser) throws Exception {
      return   addSaveCode(orderDTO,authUser);
   }
    /**
     * 申请单一编码
     *
     * @param orderDTO 申请的信息,需要包含属性的内容和码段相关的内容
     * @return 返回编码的内容
     */
    @Override
    public String addSaveCode(CodeOrderDTO orderDTO) throws Exception {
    private String addSaveCode(CodeOrderDTO orderDTO,boolean authUser) throws Exception {
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
                orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
@@ -410,43 +441,43 @@
        checkEnumOnOrder(templateVO, orderDTO);
        //8.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
        switchDateAttrOnOrder(templateVO, orderDTO);
        //9.生成编码的信息
//      ClientBusinessObject cbo = boService.createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmtypeid());
        BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId());
//      //默认的属性都不用从前端拷贝
//      //设置编码需要的默认属性的内容
        //9.生成编码的信息 ,初始化业务类型:缓存先取消,因为版本规则会出现变动的情况所以无法使用缓存
        // BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId());
      BaseModel cbo = createBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId().trim().toLowerCase());
      //默认的属性都不用从前端拷贝
      //设置编码需要的默认属性的内容
        copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false);
      cbo.setOid(VciBaseUtil.getPk());
      cbo.setRevisionOid(VciBaseUtil.getPk());
      cbo.setNameOid(VciBaseUtil.getPk());
      cbo.setCreateTime(new Date());
      cbo.setLastModifyTime(new Date());
      cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
      cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      //cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));、
      if(authUser) {
         // 要求显示账号,所以做了更改
         cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
         cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      }else{
         cbo.setCreator(orderDTO.getCreator());
         cbo.setLastModifier(orderDTO.getLastModifier());
      }
      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里。增加一个单独处理,以后再看要不要调整
      //TODO:因为默认的属性都不拷贝,目前集团码叫name,并没有从DTO拷贝到cbo里。增加一个单独处理,以后再看要不要调整
        cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName());
//      //end -- modify by lihang @20220407
      //end -- modify by lihang @20220407
        List<BaseModel> cboList = new ArrayList<>();
        //备注
        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;
    }
    /**
@@ -471,7 +502,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);
@@ -492,7 +523,6 @@
            });
        }
    }
    /**
     * 判断编码的码段是否输入或者选择了码值
@@ -560,7 +590,9 @@
      } 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;
    }
@@ -728,7 +760,11 @@
         }
         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.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) {
               sql[0] += " and " + key + " is null";
            }else{
               sql[0] += " and " + key + " = " + value;
            }
         });
         if (StringUtils.isNotBlank(orderDTO.getOid())) {
            //修改的时候,需要排除自己
@@ -749,7 +785,29 @@
      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        当前的值
@@ -895,7 +953,8 @@
            data.put(cbo.getData().containsKey(CODE_FULL_PATH_FILED.toUpperCase())?CODE_FULL_PATH_FILED.toUpperCase():CODE_FULL_PATH_FILED, fullPath);
            cbo.getData().putAll(data);
            cbo.setLastModifyTime(new Date());
            cbo.setLastModifier(AuthUtil.getUser().getUserName());
            //cbo.setLastModifier(AuthUtil.getUser().getUserName());
         cbo.setLastModifier(AuthUtil.getUser().getAccount());
            cbo.setTs(new Date());
            if (!edit && StringUtils.isBlank(orderDTO.getLcStatus())) {
                //TODO 先写固定,后面生命周期好了在编写
@@ -949,7 +1008,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());
        }
    }
@@ -968,22 +1027,22 @@
            List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryIdentification())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(selectAttrVOs)) {
//            SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
            //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
                selectAttrVOs.parallelStream().forEach(attrVO -> {
                    List<String> valuesList = new ArrayList<>();
                    cboList.parallelStream().forEach(cbo -> {
//                  String value = cbo.get.getAttributeValue(attrVO.getId());
                  //String value = cbo.get.getAttributeValue(attrVO.getId());
                        //将bean转为map,mybatis统一处理
                        Map<String, String> map = null;
//                  baseModels.stream().forEach(model-> {
                  //baseModels.stream().forEach(model-> {
                        try {
                            map = VciBaseUtil.convertBean2Map(cbo,null);
                        } catch (Exception e) {
                            throw new VciBaseException("类型转换错误:" + e.getMessage());
                        }
//                  });
                  //});
                        String value = map.get(attrVO.getId());
                        if (StringUtils.isNotBlank(value)) {
@@ -1368,6 +1427,10 @@
      uiTableConfigVO.setQueryColumns(queryColumns);
      //set给表格配置属性
      uiFormReferVO.setTableConfig(uiTableConfigVO);
      //字段名不一致,需要手动set
      uiFormReferVO.setMuti(StringUtils.isBlank(codeReferConfig.getIsMuti())?false:true);
      uiFormReferVO.setInitSort(new UIFieldSortVO(codeReferConfig.getSortField(),codeReferConfig.getSortType()));
      // 筛选条件
      HashMap<String, String> whereMap = new HashMap<>();
      if(!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())){
@@ -1508,7 +1571,6 @@
            conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue);
        }
    }
    /**
     * 查询编码数据的列表
@@ -1915,7 +1977,7 @@
                    //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧
                    return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "'%" + value + "%'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + getStringValueInWhere(field, value, attrVOMap) + "%'" + SPACE;
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + value + "%'" + SPACE;
                }
            } else if (key.endsWith("_notequal")) {
                String field = UBCSSqlKeyword.getColumn(key, "_notequal");
@@ -1950,7 +2012,7 @@
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + " >= " + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(value, field, attrVOMap) + SPACE;
                    return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_le")) {
                //说明是<=的。我们需要先获取一下
@@ -2035,7 +2097,7 @@
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + getStringValueInWhere(field, value, attrVOMap) + "'" + SPACE;
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
                }
            } else {
//                if (referFieldMap.containsKey(key)) {
@@ -2331,9 +2393,12 @@
        }
//      cbo.getData().putAll(orderDTO.getData());
        cbo.setLastModifyTime(new Date());
        cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
        updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo));
        batchSaveSelectChar(templateVO, Collections.singletonList(cbo));
        cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo));
      if(!r.isSuccess()){
         throw new ServiceException(r.getMsg());
      }
      batchSaveSelectChar(templateVO, Collections.singletonList(cbo));
    }
    /**
@@ -2371,7 +2436,7 @@
        }
        //只能删除自己创建的数据
        String userId = String.valueOf(AuthUtil.getUser().getUserId());
        String userId = String.valueOf(AuthUtil.getUser().getAccount());
        for (BaseModel clientBusinessObject : cboList) {
            String creator = clientBusinessObject.getCreator();
            if (!userId.equalsIgnoreCase(creator)) {
@@ -2383,10 +2448,10 @@
//      batchCBO.getDeleteCbos().addAll(cboList);
//      WebUtil.setPersistence(false);
//      batchCBO.copyFromOther(
        productCodeService.recycleCode(classifyFullInfo.getCurrentClassifyVO().getBtmTypeId(), deleteBatchDTO.getOidList());
        productCodeService.recycleCode(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), deleteBatchDTO.getOidList());
//      baseMapper.deleteBatchIds(cboList);
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getCurrentClassifyVO().getBtmTypeId()));
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
@@ -2410,7 +2475,6 @@
        //找阶段
        return phaseAttrService.listAttrByTemplateOidAndPhaseId(templateVO.getOid(), phase);
    }
    /**
     * 路径上包含当前分类的所有分类信息
@@ -2701,7 +2765,7 @@
        cbo.setLastModifyTime(cbo.getLastModifyTime());
      cbo.setTenantId(AuthUtil.getTenantId());
      oldCbo.setLastV("0");
      oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      oldCbo.setLastModifyTime(new Date());
        try {
         updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
@@ -2737,12 +2801,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;
   }
    /**
     * 使用分类的全部信息获取编码规则
@@ -2759,11 +2913,11 @@
        } 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开始获取
            for (int i = 0; i < parentClassifyVOList.size(); i++) {
            for (int i = parentClassifyVOList.size()-1; i >= 0; i--) {
                CodeClassifyVO record = parentClassifyVOList.get(i);
                if (StringUtils.isNotBlank(record.getCodeRuleOid())) {
                    codeRuleOid = record.getCodeRuleOid();
@@ -2771,7 +2925,7 @@
                }
            }
            if (StringUtils.isBlank(codeRuleOid)) {
                throw new VciBaseException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
        }
        return ruleService.getObjectHasSecByOid(codeRuleOid);
@@ -2817,7 +2971,7 @@
        wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
        R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
        //我们要看是否不是升版的,升版的话,需要对比不相等的属性
        String copy = cbo.get("copyfromversion");
/*        String copy = cbo.get("copyfromversion");
//      if (StringUtils.isBlank(copy)) {
//         copy = cbo.getAttributeValue("copyfromversion");
//      }
@@ -2836,11 +2990,12 @@
                Map<String, String> difFieldMap = new HashMap<>();
                Map<String, String> finalOldData = oldData;
                cbo.forEach((key, value) -> {
                    String oldValue = finalOldData.getOrDefault(key, "");
                    if (value == null) {
               // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿
               String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
               if (value == null || value == "null") {
                        value = "";
                    }
                    if (oldValue == null) {
                    if (oldValue == null || oldValue == "null") {
                        oldValue = "";
                    }
                    if (!value.equalsIgnoreCase(oldValue)) {
@@ -2851,7 +3006,7 @@
                difFieldList.add(difFieldMap);
                result.setData(difFieldList);
            }
        }
        }*/
        return result;
    }
@@ -3209,7 +3364,6 @@
        return getTableDefineByTemplateVO(templateService.getObjectHasAttrByOid(templateOid));
    }
    /**
     * 使用模板显示对象转换为表格的信息(包含扩展的按钮)
     *
@@ -3306,6 +3460,7 @@
        }
        return uiInfoVO;
    }
    @Override
   public MdmUIInfoVO getFlowUIInfoByClassifyOid(String codeClassifyOid, String functionId,String templateId,String taskId,String modelKey){
//      MdmUIInfoVO uiInfoVO = getTableDefineByClassifyOid_v2(codeClassifyOid,templateId,taskId,modelKey);
@@ -3377,6 +3532,7 @@
     * @return 处理成功数据条数
     */
    @Override
   @Transactional(rollbackFor = Exception.class)
    public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
@@ -3393,6 +3549,7 @@
      }).collect(Collectors.toSet());
      //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));
@@ -3400,8 +3557,83 @@
                throw new VciBaseException("类型转换错误:" + e.toString());
            }
        });
        return commonsMapper.insertByBaseModel(listR.getData().get(0).getTableName(), maps.get(0), maps);
      try {
         bactchExecuteInsert(listR.getData().get(0).getTableName(),maps);
      }catch (Exception e){
         throw new ServiceException("分批执行insert语句报错:"+e.getMessage());
      }
        return maps.size();
    }
   /**
    * 分批执行insert语句
    * @param tableName
    * @param maps
    * @throws ServiceException
    */
   @Transactional(rollbackFor = Exception.class)
   void bactchExecuteInsert(String tableName, List<Map<String, String>> maps) throws ServiceException{
      ExecutorService executor = Executors.newFixedThreadPool(10); // 创建一个固定大小的线程池
      List<Map<String, String>> threadSafeMaps = new CopyOnWriteArrayList<>(maps);
      for (int i = 0; i < threadSafeMaps.size(); i += MAX_IMPORT_NUM) {
         final int startIndex = i;
         final int endIndex = Math.min(i + MAX_IMPORT_NUM, maps.size());
         executor.execute(() -> {
            List<Map<String, String>> subList = threadSafeMaps.subList(startIndex, endIndex);
            // 调用插入数据库的方法
            commonsMapper.insertByBaseModel(tableName, threadSafeMaps.get(0), subList);
         });
      }
      // 关闭线程池
      executor.shutdown();
      try {
         // 等待所有任务执行完成
         executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
      } catch (InterruptedException e) {
         // 处理异常
         throw new ServiceException("多线程方式执行批量插入时产生错误:"+e.getMessage());
      }
   }
   /**
    * 传入业务类型以及ID查询业务表数据是否重复
    *
    * @param btmType 业务类型
    * @param ids      处理数据
    * @return 查询到数据的总数
    */
    @Override
    public Integer selectIdsCounts(String btmType, List<String> ids) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      return commonsMapper.queryCountBySql("select count(*) from " +
         listR.getData().get(0).getTableName() + " where id in ("+ ids.stream().map(s -> "'" + s + "'").collect(Collectors.joining(",")) +")");
    }
   /**
    * 传入业务类型以及ID、OID查询业务表数据是否重复
    *
    * @param btmType 业务类型
    * @param id      处理数据id
    * @param oid      处理数据oid
    * @return 查询到数据的总数
    */
   @Override
   public Integer selectIdAndOidCounts(String btmType, String id, String oid) {
      //使用传入的业务类型查询表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      return commonsMapper.queryCountBySql("select count(*) from " +
         listR.getData().get(0).getTableName() + " where id ='" + id + "' and oid <> '" + oid + "'");
   }
    /**
     * 传入业务类型以及相oid集合查询数据进行返回
@@ -3467,7 +3699,6 @@
        }
        return baseModels;
    }
    /**
     * 根据业务类型名称创建业务数据源对象
@@ -3577,20 +3808,80 @@
        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.setLastModifier(AuthUtil.getUser().getAccount());
                  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("传入业务类型未查询到相应表单,请检查!");
@@ -3617,6 +3908,7 @@
        if (listR.getData().isEmpty()) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      // TODO:参照配置的模糊查询过滤条件暂未处理
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
            String s = baseQueryObject.getConditionMap().get("name");
@@ -3666,27 +3958,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) {
@@ -3697,10 +3990,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;
@@ -3826,7 +4119,6 @@
        return revisionModelUtil.doList2Trees(codeClassifies, treeWrapperOptions, null);
    }
    @Override
    public boolean checkUnAttrUnEdit(String attrName) {
        return (VciQueryWrapperForDO.OID_FIELD.equalsIgnoreCase(attrName)
@@ -3859,21 +4151,39 @@
        toBo.setNameOid(fromBo.getNameOid());
        toBo.setBtmname(fromBo.getBtmname());
        toBo.setLastR(String.valueOf(1));
      // 升版将FirstR修改为0
        toBo.setFirstR(String.valueOf(0));
        toBo.setFirstV(String.valueOf(1));
        toBo.setLastV(String.valueOf(1));
        toBo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
      // 数据升版不需要重新设置创建人,只对最后修改人做更新就可以了
        //toBo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
        toBo.setCreateTime(new Date());
        toBo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
        // toBo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      toBo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
        toBo.setLastModifyTime(new Date());
        toBo.setRevisionRule(fromBo.getRevisionRule());
        toBo.setVersionRule(fromBo.getVersionRule());R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(fromBo.getBtmname()));
        toBo.setVersionRule(fromBo.getVersionRule());
      //查询业务类型信息,可以获取到版本规则信息(revisionRuleId)
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(fromBo.getBtmname()));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
        toBo.setRevisionSeq(Integer.parseInt(nextRevision.get("REVISIONSEQ").toString()));
        toBo.setRevisionValue(nextRevision.get("REVISIONVAL").toString());
        //Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
      /*
         TODO:这是一个待后期完善的功能,目前实现方式是,先查询出当前数据的大版本规则,
            然后再查询业务表使用的规则的步长是多少然后计算出该升版为多少
      */
      Map<String, Object> nextRevision = commonsMapper.getCurrentRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
      R<RevisionRuleVO> revisionRuleVOR = revisionRuleClient.selectById(listR.getData().get(0).getRevisionRuleId());
      String revisionval = nextRevision.get("REVISIONVAL").toString();
      // 未查询到版本规则,默认直接给大版本加一
      if(!revisionRuleVOR.isSuccess() || Func.isEmpty(revisionRuleVOR.getData())){
         revisionval = String.valueOf((Integer.parseInt(revisionval)+1));
      }else {
         revisionval = String.valueOf(Integer.parseInt(revisionval)+revisionRuleVOR.getData().getSerialStep());
      }
      toBo.setRevisionValue(revisionval);
      toBo.setRevisionSeq(Integer.parseInt(nextRevision.get("REVISIONSEQ").toString()));
        toBo.setVersionSeq(Integer.valueOf(nextRevision.get("VERSIONSEQ").toString()));
        toBo.setVersionValue(nextRevision.get("VERSIONVAL").toString());
        toBo.setLctid(fromBo.getLctid());
@@ -3886,7 +4196,6 @@
        toBo.getData().putAll(fromBo.getData());
        toBo.getData().put("CHECKINBY", String.valueOf(AuthUtil.getUser().getUserId()));
        return toBo;
    }
   /**