ludc
2024-10-17 d02571d59633367ac76b7f58ab38584698b1aa1b
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -1,5 +1,6 @@
package com.vci.ubcs.code.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -24,7 +25,6 @@
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.code.wrapper.CodeAllcodeWrapper;
import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
import com.vci.ubcs.flow.core.feign.IMDMIFlowAttrClient;
import com.vci.ubcs.flow.core.vo.ProcessStageAttrVO;
@@ -41,8 +41,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.util.*;
import com.vci.ubcs.starter.web.constant.QueryOptionConstant;
import com.vci.ubcs.starter.web.constant.RegExpConstant;
import com.vci.ubcs.starter.web.enumpck.BooleanEnum;
@@ -59,15 +58,18 @@
import com.vci.ubcs.system.user.feign.IUserClient;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import oracle.sql.TIMESTAMP;
import org.hibernate.validator.constraints.NotEmpty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.cache.utils.CacheUtil;
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.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.Cache;
@@ -145,6 +147,7 @@
    */
   @Value("${bzApply.seriesFlow:seriesFlow}")
   private String seriesFlow;
   /***
    * 是否变更系列
    */
@@ -162,288 +165,325 @@
   @Value("${bzApply.yearSecName:年代号}")
   private String yearSecName;
    /**
     * 模板的服务
     */
    @Resource
    private ICodeClstemplateService templateService;
   /**
    * 模板的服务
    */
   @Resource
   private ICodeClstemplateService templateService;
    /**
     * 生成编码的服务
     */
    @Resource
    private MdmProductCodeService productCodeService;
   /**
    * 生成编码的服务
    */
   @Resource
   private MdmProductCodeService productCodeService;
    /**
     * 可输可选的服务
     */
    @Resource
    IDictBizClient iDictBizClient;
    /**
     * 系统的服务
     */
    @Resource
    ISysClient iSysClient;
    /**
     * 密级服务
     */
    @Resource
    private IWebSecretClient secretService;
    /**
     * 用户服务
     */
    @Resource
    IUserClient iUserClient;
    /**
     * 字典的服务
     */
    @Resource
    IEnumClient enumClient;
   /**
    * 近义词规则查询服务
    */
   @Autowired ICodeSynonymService codeSynonymService;
   /**
    * 可输可选的服务
    */
   @Resource
   IDictBizClient iDictBizClient;
   /**
    * 系统的服务
    */
   @Resource
   ISysClient iSysClient;
   /**
    * 密级服务
    */
   @Resource
   private IWebSecretClient secretService;
   /**
    * 用户服务
    */
   @Resource
   IUserClient iUserClient;
   /**
    * 字典的服务
    */
   @Resource
   IEnumClient enumClient;
   /**
    * 版本规则服务
    */
   @Resource
   private IRevisionRuleClient revisionRuleClient;
    /**
     * 公式的服务
     */
    @Autowired
    private FormulaServiceImpl formulaService;
   /**
    * 公式的服务
    */
   @Autowired
   private FormulaServiceImpl formulaService;
    /**
     * 对omd中提供的feign接口进行调用,以及处理相关逻辑
     */
    @Autowired
    ICodeReferBtmTypeService codeReferBtmTypeService;
   /**
    * 对omd中提供的feign接口进行调用,以及处理相关逻辑
    */
   @Autowired
   ICodeReferBtmTypeService codeReferBtmTypeService;
    /**
     * 相似项查询规则
     */
    @Autowired
    private ICodeResembleRuleService resembleRuleService;
   /**
    * 相似项查询规则
    */
   @Autowired
   private ICodeResembleRuleService resembleRuleService;
    /**
     * 对象的操作
     */
    @Autowired
    private RevisionModelUtil revisionModelUtil;
   /**
    * 对象的操作
    */
   @Autowired
   private RevisionModelUtil revisionModelUtil;
    /**
     * 阶段的服务
     */
    @Autowired
    private ICodePhaseAttrService phaseAttrService;
    /**
     * 业务类型的服务
     */
    @Autowired
    private IBtmTypeClient btmTypeClient;
   /**
    * 阶段的服务
    */
   @Autowired
   private ICodePhaseAttrService phaseAttrService;
   /**
    * 业务类型的服务
    */
   @Autowired
   private IBtmTypeClient btmTypeClient;
    /**
     * 通用查询
     */
    @Resource
    private CommonsMapper commonsMapper;
   /**
    * 通用查询
    */
   @Resource
   private CommonsMapper commonsMapper;
    /**
     * 编码规则的服务
     */
    @Autowired
    private ICodeRuleService ruleService;
    /**
     * 编码规则的服务
     */
    @Autowired
    private ICodeAllCodeService codeAllCodeService;
   /**
    * 编码规则的服务
    */
   @Autowired
   private ICodeRuleService ruleService;
    /**
     * 分类码值的服务
     */
    @Autowired
    private ICodeClassifyValueService classifyValueService;
   /**
    * 码值的服务
    */
   @Autowired
   private ICodeAllCodeService codeAllCodeService;
    /**
     * 分类的服务
     */
    @Resource
    private ICodeClassifyService classifyService;
   /**
    * 分类码值的服务
    */
   @Autowired
   private ICodeClassifyValueService classifyValueService;
    /**
     * 模板按钮服务
     */
    @Autowired
    private ICodeClassifyTemplateButtonService templateButtonService;
   /**
    * 分类的服务
    */
   @Resource
   private ICodeClassifyService classifyService;
    @Autowired
    private ICodeClassifyTemplateAttrService codeClassifyTemplateAttrService;
   /**
    * 模板按钮服务
    */
   @Autowired
   private ICodeClassifyTemplateButtonService templateButtonService;
   @Autowired
   private ICodeClassifyTemplateAttrService codeClassifyTemplateAttrService;
//   /**
//    * 用户查询的服务,需要问一下是否需要重写,使用查询此平台的用户表
//    */
//   @Autowired
//   private SmUserQueryServiceI userQueryService;
    /**
     * 关键属性的配置
     */
    @Autowired
    private ICodeKeyAttrRepeatService keyRuleService;
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
   /**
    * 关键属性的配置
    */
   @Autowired
   private ICodeKeyAttrRepeatService keyRuleService;
   /**
    * 日志
    */
   private Logger logger = LoggerFactory.getLogger(getClass());
    /**
     * 空格
     */
    public static final String SPACE = " ";
    /**
     * 缓存key
     */
    public static final String BTM_INIT_CACHE = "ubcs-code:btm";
    /**
     *
     */
    public static final String BTM_NAME = "btm:name";
   /**
    * 空格
    */
   public static final String SPACE = " ";
    /**
     * 密级的字段
     */
    public static final String SECRET_FILED = "secretgrade";
    /**
     * 用户新增数据的时候可以查看的密级
     */
    public static final String MY_DATA_SECRET = "myDataSecret";
    /**
     * 拷贝的版本
     */
    public static final String COPY_FROM_VERSION = "copyfromversion";
    /**
     * 只是sql
     */
    public static final String ONLY = "${vcionly}";
   /**
    * 缓存key
    */
   public static final String BTM_INIT_CACHE = "ubcs-code:btm";
   /**
    *
    */
   public static final String BTM_NAME = "btm:name";
    /**
     * 默认的时间格式
     */
    private static final String DATETIME_FORMAT = "yyyy-mm-dd hh24:mi:ss";
   /**
    * 配置的用来申请集团码的用户
    */
   @Value("${docking.apply.personUserAccount:28201728}")
   public String applyCodeUserAccount;
    /**
     * 日期格式
     */
    private static final String DATE_FORMAT = "yyyy-mm-dd";
   /**
    * 密级的字段
    */
   public static final String SECRET_FILED = "secretgrade";
   /**
    * 用户新增数据的时候可以查看的密级
    */
   public static final String MY_DATA_SECRET = "myDataSecret";
   /**
    * 拷贝的版本
    */
   public static final String COPY_FROM_VERSION = "copyfromversion";
   /**
    * 只是sql
    */
   public static final String ONLY = "${vcionly}";
    /**
     * 必输
     */
    public static final String REQUIRED_CHAR = "*";
    /**
     * 替换字符
     */
    public static final String SPECIAL_CHAR = "VCI";
   /**
    * 默认的时间格式
    */
   private static final String DATETIME_FORMAT = "yyyy-mm-dd hh24:mi:ss";
   /**
    * 日期格式
    */
   private static final String DATE_FORMAT = "yyyy-mm-dd";
   /**
    * 必输
    */
   public static final String REQUIRED_CHAR = "*";
   /**
    * 替换字符
    */
   public static final String SPECIAL_CHAR = "VCI";
   /**
    * 主数据流程阶段服务
    */
   @Autowired
   private IMDMIFlowAttrClient imdmiFlowAttrClient;
//   @Autowired
//   private CodeOsbtmtypeMapper codeOsbtmtypeMapper;----
   //   @Autowired
   //   private CodeOsbtmtypeMapper codeOsbtmtypeMapper;
    /**
     * 使用分类的主键获取可以使用的模板对象
     *
     * @param codeClassifyOid 分类的主键
     * @return 模板的显示对象
     */
    @Override
    public CodeClassifyTemplateVO getUsedTemplateByClassifyOid(String codeClassifyOid) {
        return getUsedTemplateByClassifyOid(codeClassifyOid, true);
    }
   /**
    * 日志保存工具类
    */
   @Autowired
   private SaveLogUtil saveLogUtil;
    /**
     * 使用分类的主键获取可以使用的模板对象
     *
     * @param codeClassifyOid 分类的主键
     * @param hasAttr         包含属性
     * @return 模板的显示对象
     */
    @Override
    public CodeClassifyTemplateVO getUsedTemplateByClassifyOid(String codeClassifyOid, boolean hasAttr) {
        List<CodeClassifyTemplateVO> templateVOs = templateService.listReleaseTemplateByClassifyOid(codeClassifyOid, hasAttr);
        return templateVOs.get(templateVOs.size() - 1);
    }
   /**
    * 使用分类的主键获取可以使用的模板对象
    *
    * @param codeClassifyOid 分类的主键
    * @return 模板的显示对象
    */
   @Override
   public CodeClassifyTemplateVO getUsedTemplateByClassifyOid(String codeClassifyOid) {
      return getUsedTemplateByClassifyOid(codeClassifyOid, true);
   }
    /**
     * 获取枚举的下拉选项
     *
     * @param attrVO 模板属性的对象
     * @return 下拉选项
     */
    @Override
    public List<KeyValue> listComboboxItems(CodeClassifyTemplateAttrVO attrVO) {
        List<KeyValue> comboboxKVs = new ArrayList<>();
        if (StringUtils.isNotBlank(attrVO.getEnumString())) {
            comboboxKVs = JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class);
        } else {
   /**
    * 使用分类的主键获取可以使用的模板对象
    *
    * @param codeClassifyOid 分类的主键
    * @param hasAttr         包含属性
    * @return 模板的显示对象
    */
   @Override
   public CodeClassifyTemplateVO getUsedTemplateByClassifyOid(String codeClassifyOid, boolean hasAttr) {
      List<CodeClassifyTemplateVO> templateVOs = templateService.listReleaseTemplateByClassifyOid(codeClassifyOid, hasAttr);
      return templateVOs.get(templateVOs.size() - 1);
   }
   /**
    * 获取枚举的下拉选项
    *
    * @param attrVO 模板属性的对象
    * @return 下拉选项
    */
   @Override
   public List<KeyValue> listComboboxItems(CodeClassifyTemplateAttrVO attrVO) {
      List<KeyValue> comboboxKVs = new ArrayList<>();
      if (StringUtils.isNotBlank(attrVO.getEnumString())) {
         comboboxKVs = JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class);
      } else {
//         comboboxKVs = enumService.getEnum(attrVO.getEnumid());
//          Dict dict = new Dict();
//         dict.setParentId(Long.valueOf(attrVO.getEnumid()));
            R<List<EnumVO>> list = enumClient.getList(attrVO.getEnumId());
            if (list.isSuccess()) {
                for (EnumVO datum : list.getData()) {
                    KeyValue keyValue = new KeyValue();
                    keyValue.setKey(datum.getItemValue());
                    keyValue.setValue(datum.getItemName());
                    comboboxKVs.add(keyValue);
                }
            }
        }
        return comboboxKVs;
    }
    /**
     * 修改状态
     *
     * @param baseModelDTO 数据传输对象
     */
    @Transactional
    @Override
    public void changeStatus(BaseModelDTO baseModelDTO) {
        VciBaseUtil.alertNotNull(baseModelDTO, "数据信息", baseModelDTO.getOid(), "主键", baseModelDTO.getBtmname(), "业务类型", baseModelDTO.getLcStatus(), "目标状态");
        List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid());
        List<BaseModel> baseModels = new ArrayList<>();
        baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
        if (baseModels.size() == 0) {
            throw new VciBaseException("未查询到相关数据。");
        }
        //还需要修改allCode的生命周期
        QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
        allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname());
        allCodeWrapper.in("createcodeoid", oids);
        List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 回收需要业务数据删除
        if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
            R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname()));
            if (!listR.isSuccess() || listR.getData().size() == 0) {
                throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
         // 直接删除,不给状态
         commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()));
         // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue());
        } else {
            for (BaseModel baseModel : baseModels) {
                baseModel.setLcStatus(baseModelDTO.getLcStatus());
            }
         R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels);
         if(!r.isSuccess()){
            throw new VciBaseException("更新数据出错,重试!"+r.getMsg());
         R<List<EnumVO>> list = enumClient.getList(attrVO.getEnumId());
         if (list.isSuccess()) {
            for (EnumVO datum : list.getData()) {
               KeyValue keyValue = new KeyValue();
               keyValue.setKey(datum.getItemValue());
               keyValue.setValue(datum.getItemName());
               comboboxKVs.add(keyValue);
            }
         }
      }
        for (CodeAllCode codeCbo : codeCbos) {
            codeCbo.setLcStatus(baseModelDTO.getLcStatus());
        }
        codeAllCodeService.updateBatchById(codeCbos);
    }
      return comboboxKVs;
   }
   /**
    * 修改状态
    *
    * @param baseModelDTO 数据传输对象
    */
   @Transactional
   @Override
   public void changeStatus(BaseModelDTO baseModelDTO) {
      try {
         VciBaseUtil.alertNotNull(baseModelDTO, "数据信息", baseModelDTO.getOid(), "主键", baseModelDTO.getBtmname(), "业务类型", baseModelDTO.getLcStatus(), "目标状态");
         List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid());
         List<BaseModel> baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
         if (baseModels.size() == 0) {
            throw new VciBaseException("未查询到相关数据。");
         }
         //还需要修改allCode的生命周期
         QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
         allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname());
         allCodeWrapper.in("createcodeoid", oids);
         List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 回收需要业务数据删除
         if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
            R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname()));
            if (!listR.isSuccess() || listR.getData().size() == 0) {
               throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            // 直接删除,不给状态
            commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()));
            // commonsMapper.updateByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()),CodeDefaultLC.TASK_BACK.getValue());
         } else {
            for (BaseModel baseModel : baseModels) {
               baseModel.setLcStatus(baseModelDTO.getLcStatus());
            }
            R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels);
            if (!r.isSuccess()) {
               throw new VciBaseException("更新数据出错,请重试!" + r.getMsg());
            }
         }
         // 刚好顺序是一致的,所以直接按照codeallcode的顺序来拿业务数据
         int i = -1;
         for (CodeAllCode codeCbo : codeCbos) {
            codeCbo.setLcStatus(baseModelDTO.getLcStatus());
            // 如果是回收,就需要将业务数据存储到码值表中
            if (baseModelDTO.getLcStatus().equals(FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_TAKEBACK)) {
               codeCbo.setBusinessData(JSON.toJSONString(baseModels.get(++i)));
            }
         }
         codeAllCodeService.updateBatchById(codeCbos);
         //记录日志信息
         saveLogUtil.operateLog(
            CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()),
            false,
            JSON.toJSONString(baseModels)
         );
      } catch (Exception e) {
         // 插入更改日志记录
         saveLogUtil.operateLog(CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()), true, e.toString());
         throw e;
      }
   }
   /**
    * 申请单一编码
@@ -453,7 +493,7 @@
    */
   @Override
   public String addSaveCode(CodeOrderDTO orderDTO) throws Exception {
      return addSaveCode(orderDTO,true);
      return addSaveCode(orderDTO, true);
   }
   /***
@@ -464,331 +504,341 @@
    */
   @Override
   public String addSaveCodeNotauthUser(CodeOrderDTO orderDTO, boolean authUser) throws Exception {
      return   addSaveCode(orderDTO,authUser);
      return addSaveCode(orderDTO, authUser);
   }
    /**
     * 申请单一编码
     *
     * @param orderDTO 申请的信息,需要包含属性的内容和码段相关的内容
     * @return 返回编码的内容
     */
   /**
    * 申请单一编码
    *
    * @param orderDTO 申请的信息,需要包含属性的内容和码段相关的内容
    * @return 返回编码的内容
    */
   private String addSaveCode(CodeOrderDTO orderDTO, boolean authUser) throws Exception {
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
                orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid());
        //1.判断规则中除了流水码段,是否有其他码段
        checkSecValueOnOrder(ruleVO, orderDTO);
        //2.判断必输项
        checkRequiredAttrOnOrder(templateVO, orderDTO);
        //3.先注入,再组合,最后校验
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        //4.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
        switchComponentAttrOnOrder(templateVO, orderDTO);
        //5.校验规则
        checkVerifyOnOrder(templateVO, orderDTO);
        //6.关键属性
        checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
        //7.枚举转换
        checkEnumOnOrder(templateVO, orderDTO);
        //8.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
        switchDateAttrOnOrder(templateVO, orderDTO);
        //9.生成编码的信息 ,初始化业务类型:缓存先取消,因为版本规则会出现变动的情况所以无法使用缓存
        // BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId());
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
         orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid());
      final BladeUser user = AuthUtil.getUser();
      //1.判断规则中除了流水码段,是否有其他码段
      checkSecValueOnOrder(ruleVO, orderDTO);
      //2.判断必输项
      checkRequiredAttrOnOrder(templateVO, orderDTO);
      //3.先注入,再组合,最后校验
      switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
      //4.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
      switchComponentAttrOnOrder(templateVO, orderDTO);
      //5.校验规则
      checkVerifyOnOrder(templateVO, orderDTO);
      //6.关键属性
      checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
      //7.枚举转换
      checkEnumOnOrder(templateVO, orderDTO);
      //8.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
      switchDateAttrOnOrder(templateVO, orderDTO);
      //9.生成编码的信息 ,初始化业务类型:缓存先取消,因为版本规则会出现变动的情况所以无法使用缓存
      // BaseModel cbo = createCBOByBtmName(classifyFullInfo.getTopClassifyVO().getBtmTypeId());
      BaseModel cbo = createBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId().trim().toLowerCase());
      //默认的属性都不用从前端拷贝
      //设置编码需要的默认属性的内容
        copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, false);
      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()));、
      if(authUser) {
      if (authUser) {
         // 要求显示账号,所以做了更改
         cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
         cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      }else{
         cbo.setCreator(String.valueOf(user.getAccount()));
         cbo.setLastModifier(String.valueOf(user.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"));
      cbo.setTenantId(user.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());
      cbo.setName(orderDTO.getName() == null ? "" : orderDTO.getName());
      //end -- modify by lihang @20220407
        List<BaseModel> cboList = new ArrayList<>();
      List<BaseModel> cboList = new ArrayList<>();
        //备注
        cbo.setDescription(orderDTO.getDescription());
        cboList.add(cbo);
      //备注
      cbo.setDescription(orderDTO.getDescription());
      cboList.add(cbo);
        List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList);
      List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList, user);
        batchSaveSelectChar(templateVO, cboList);
        return codeList.size() > 0 ? codeList.get(0) : "";
    }
      batchSaveSelectChar(templateVO, cboList);
      return codeList.size() > 0 ? codeList.get(0) : "";
   }
    /**
     * 处理分类注入的信息
     *
     * @param templateVO         模板的显示对象,必须要后模板的属性
     * @param classifyFullInfoBO 分类的全路径
     * @param orderDTO           编码申请的信息
     */
    private void switchClassifyLevelOnOrder(CodeClassifyTemplateVO templateVO, CodeClassifyFullInfoBO classifyFullInfoBO, CodeOrderDTO orderDTO) {
        Map<String, CodeClassifyTemplateAttrVO> classifyAttrVOMap = templateVO.getAttributes().stream().filter(
                s -> StringUtils.isNotBlank(s.getClassifyInvokeAttr()) && StringUtils.isNotBlank(s.getClassifyInvokeLevel())
        ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (classifyFullInfoBO.getTopClassifyVO() == null) {
            //需要重新查询一下,因为这个是指定的分类进来的
        }
        if (!CollectionUtils.isEmpty(classifyAttrVOMap)) {
            classifyAttrVOMap.forEach((attrId, attrVO) -> {
                //分类注入的编号或者名称,
                //层级包含指定层和最小层
                CodeClassifyVO classifyVO = null;
                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());
                    int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
                    if (classifyVOS.size() >= level && level > 0) {
                        classifyVO = classifyVOS.get(level - 1);
                    }
                } else {
                    //当前的分类
                    classifyVO = classifyFullInfoBO.getCurrentClassifyVO();
                }
                if (classifyVO == null) {
                    //说明层级有误
                    orderDTO.getData().put(attrId, "分类树上没有层级[" + attrVO.getClassifyInvokeLevel() + "]");
                    // classifyVO = classifyFullInfoBO.getCurrentClassifyVO();
                } else {
                    Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO);
                    String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), "");
                    orderDTO.getData().put(attrId, value);
                }
            });
        }
    }
   /**
    * 处理分类注入的信息
    *
    * @param templateVO         模板的显示对象,必须要后模板的属性
    * @param classifyFullInfoBO 分类的全路径
    * @param orderDTO           编码申请的信息
    */
   private void switchClassifyLevelOnOrder(CodeClassifyTemplateVO templateVO, CodeClassifyFullInfoBO classifyFullInfoBO, CodeOrderDTO orderDTO) {
      Map<String, CodeClassifyTemplateAttrVO> classifyAttrVOMap = templateVO.getAttributes().stream().filter(
         s -> StringUtils.isNotBlank(s.getClassifyInvokeAttr()) && StringUtils.isNotBlank(s.getClassifyInvokeLevel())
      ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (classifyFullInfoBO.getTopClassifyVO() == null) {
         //需要重新查询一下,因为这个是指定的分类进来的
      }
      if (!CollectionUtils.isEmpty(classifyAttrVOMap)) {
         classifyAttrVOMap.forEach((attrId, attrVO) -> {
            //分类注入的编号或者名称,
            //层级包含指定层和最小层
            CodeClassifyVO classifyVO = null;
            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());
               int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
               if (classifyVOS.size() >= level && level > 0) {
                  classifyVO = classifyVOS.get(level - 1);
               }
            } else {
               //当前的分类
               classifyVO = classifyFullInfoBO.getCurrentClassifyVO();
            }
            if (classifyVO == null) {
               //说明层级有误
               orderDTO.getData().put(attrId, "分类树上没有层级[" + attrVO.getClassifyInvokeLevel() + "]");
               // classifyVO = classifyFullInfoBO.getCurrentClassifyVO();
            } else {
               Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO);
               String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), "");
               orderDTO.getData().put(attrId, value);
            }
         });
      }
   }
    /**
     * 判断编码的码段是否输入或者选择了码值
     *
     * @param ruleVO   规则的显示对象
     * @param orderDTO 编码申请的内容
     */
    @Override
    public void checkSecValueOnOrder(CodeRuleVO ruleVO, CodeOrderDTO orderDTO) {
        List<String> unSerialSecOidList = ruleVO.getSecVOList().stream().filter(
                s -> !(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue().equalsIgnoreCase(s.getSecType())
                        || CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(s.getSecType())
                        || CodeSecTypeEnum.CODE_DATE_SEC.getValue().equalsIgnoreCase(s.getSecType())
                        || CodeSecTypeEnum.CODE_LEVEL_SEC.getValue().equalsIgnoreCase(s.getSecType())
                        || VciBaseUtil.getBoolean(s.getNullableFlag()))
        ).map(CodeBasicSecVO::getOid).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(unSerialSecOidList)) {
            if (CollectionUtils.isEmpty(orderDTO.getSecDTOList())) {
                throw new VciBaseException("非流水码段(或者必输码段)必须要输入(或选择)码值");
            }
            if (orderDTO.getSecDTOList().stream().anyMatch(s -> !unSerialSecOidList.contains(s.getSecOid())
                    && StringUtils.isBlank(s.getSecValue()))) {
                throw new VciBaseException("非流水码段(或者必输码段)必须要输入(或选择)码值");
            }
        }
    }
   /**
    * 判断编码的码段是否输入或者选择了码值
    *
    * @param ruleVO   规则的显示对象
    * @param orderDTO 编码申请的内容
    */
   @Override
   public void checkSecValueOnOrder(CodeRuleVO ruleVO, CodeOrderDTO orderDTO) {
      List<String> unSerialSecOidList = ruleVO.getSecVOList().stream().filter(
         s -> !(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue().equalsIgnoreCase(s.getSecType())
            || CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(s.getSecType())
            || CodeSecTypeEnum.CODE_DATE_SEC.getValue().equalsIgnoreCase(s.getSecType())
            || CodeSecTypeEnum.CODE_LEVEL_SEC.getValue().equalsIgnoreCase(s.getSecType())
            || VciBaseUtil.getBoolean(s.getNullableFlag()))
      ).map(CodeBasicSecVO::getOid).collect(Collectors.toList());
      if (!CollectionUtils.isEmpty(unSerialSecOidList)) {
         if (CollectionUtils.isEmpty(orderDTO.getSecDTOList())) {
            throw new VciBaseException("非流水码段(或者必输码段)必须要输入(或选择)码值");
         }
         if (orderDTO.getSecDTOList().stream().anyMatch(s -> !unSerialSecOidList.contains(s.getSecOid())
            && StringUtils.isBlank(s.getSecValue()))) {
            throw new VciBaseException("非流水码段(或者必输码段)必须要输入(或选择)码值");
         }
      }
   }
    /**
     * 校验属性是否为必输
     *
     * @param templateVO 模板的显示对象,需要包含模板属性
     * @param orderDTO   编码申请的信息
     */
    private void checkRequiredAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
   /**
    * 校验属性是否为必输
    *
    * @param templateVO 模板的显示对象,需要包含模板属性
    * @param orderDTO   编码申请的信息
    */
   private void checkRequiredAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        Map<String, CodeClassifyTemplateAttrVO> requiredAttrMap = templateVO.getAttributes().stream().filter(
                        s -> VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule())
                                && StringUtils.isBlank(s.getClassifyInvokeAttr()))
                .collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (!CollectionUtils.isEmpty(requiredAttrMap)) {
            requiredAttrMap.forEach((attrId, attrVO) -> {
                //只有企业编码,状态,备注,模板主键,分类主键这几个是固定的,其余都是自行配置的
                if (StringUtils.isBlank(getValueFromOrderDTO(orderDTO, attrId))) {
                    throw new VciBaseException("属性【{0}】必须要输入(选择)内容", new String[]{attrVO.getName()});
                }
            });
        }
    }
      Map<String, CodeClassifyTemplateAttrVO> requiredAttrMap = templateVO.getAttributes().stream().filter(
            s -> VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule())
               && StringUtils.isBlank(s.getClassifyInvokeAttr()))
         .collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (!CollectionUtils.isEmpty(requiredAttrMap)) {
         requiredAttrMap.forEach((attrId, attrVO) -> {
            //只有企业编码,状态,备注,模板主键,分类主键这几个是固定的,其余都是自行配置的
            if (StringUtils.isBlank(getValueFromOrderDTO(orderDTO, attrId))) {
               throw new VciBaseException("属性【{0}】必须要输入(选择)内容", new String[]{attrVO.getName()});
            }
         });
      }
   }
    /**
     * 从编码申请信息对象上获取某个属性的值
     *
     * @param orderDTO 编码申请对象
     * @param attrId   属性的编号
     * @return 值
     */
    private String getValueFromOrderDTO(CodeOrderDTO orderDTO, String attrId) {
        attrId = attrId.toLowerCase(Locale.ROOT);
        String value = null;
        if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) {
            value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO));
           if(StringUtils.isBlank(value)){
   /**
    * 从编码申请信息对象上获取某个属性的值
    *
    * @param orderDTO 编码申请对象
    * @param attrId   属性的编号
    * @return 值
    */
   private String getValueFromOrderDTO(CodeOrderDTO orderDTO, String attrId) {
      attrId = attrId.toLowerCase(Locale.ROOT);
      String value = null;
      if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) {
         value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO));
         if (StringUtils.isBlank(value)) {
            value = orderDTO.getData().getOrDefault(attrId, "");
         }
      } else {
            //说明是自行配置的
            //前端必须要传递小写的属性
         //说明是自行配置的
         //前端必须要传递小写的属性
         String orDefault = orderDTO.getData().getOrDefault(attrId, "");
         value = Func.isBlank(orDefault) ? orderDTO.getData()
            .getOrDefault(attrId.toUpperCase(Locale.ROOT), ""):orDefault;
        }
        return value;
    }
            .getOrDefault(attrId.toUpperCase(Locale.ROOT), "") : orDefault;
      }
      return value;
   }
    /**
     * 转换组合规则的值
     *
     * @param templateVO 模板的显示对象,需要包含模板属性
     * @param orderDTO   编码申请的信息
     */
    private void switchComponentAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        Map<String, CodeClassifyTemplateAttrVO> compAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getComponentRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (!CollectionUtils.isEmpty(compAttrVOMap)) {
            Map<String, String> dataMap = WebUtil.objectToMapString(orderDTO);
   /**
    * 转换组合规则的值
    *
    * @param templateVO 模板的显示对象,需要包含模板属性
    * @param orderDTO   编码申请的信息
    */
   private void switchComponentAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClassifyTemplateAttrVO> compAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getComponentRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (!CollectionUtils.isEmpty(compAttrVOMap)) {
         Map<String, String> dataMap = WebUtil.objectToMapString(orderDTO);
            Map<String, String> dataLowMap = new HashMap<>();
            if (!CollectionUtils.isEmpty(dataMap)) {
                dataMap.forEach((key, value) -> {
                    dataLowMap.put(key.toLowerCase(Locale.ROOT), value);
                });
            }
            dataLowMap.putAll(orderDTO.getData());
            compAttrVOMap.forEach((attrId, attrVO) -> {
                dataLowMap.put(attrId, formulaService.getValueByFormula(dataLowMap, attrVO.getComponentRule()));
            });
            dataLowMap.forEach((key, value) -> {
                setValueToOrderDTO(orderDTO, key, value);
            });
        }
    }
    /**
     * 设置新的值到申请对象上
     *
     * @param orderDTO 编码申请对象
     * @param attrId   属性的编号
     * @param value    值
     */
    private void setValueToOrderDTO(CodeOrderDTO orderDTO, String attrId, String value) {
        attrId = attrId.toLowerCase(Locale.ROOT);
        if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) {
            WebUtil.setValueToField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO, value);
        } else {
            orderDTO.getData().put(attrId, value);
        }
    }
    /**
     * 校验正则表达式是否正确
     *
     * @param templateVO 模板的信息,必须包含属性的内容
     * @param orderDTO   编码申请的相关的信息
     */
    private void checkVerifyOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        Map<String, CodeClassifyTemplateAttrVO> verifyAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getVerifyRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (!CollectionUtils.isEmpty(verifyAttrVOMap)) {
            verifyAttrVOMap.forEach((attrId, attrVO) -> {
                String value = getValueFromOrderDTO(orderDTO, attrId);
                if (StringUtils.isNotBlank(value) && !value.matches(attrVO.getVerifyRule())) {
                    //校验正则表达式
                    throw new VciBaseException("属性[{0}]的值不符合校验规则的要求", new String[]{attrVO.getName()});
                }
            });
        }
    }
    /**
     * 校验关键属性
     *
     * @param classifyFullInfo 分类的全部信息
     * @param templateVO       模板的内容,必须包含模板属性
     * @param orderDTO         编码申请的相关的信息
     */
    private void checkKeyAttrOnOrder(CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        //先获取关键属性的规则,也利用继承的方式
        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)) {
         // TODO: 同一个库判重不需要区分分类oid
         // 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 count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
         final String[] sql = {"select id from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
            conditionMap.forEach((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())) {
                //修改的时候,需要排除自己
                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' ";
         String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
         if(Func.isNotEmpty(isParticipateCheckOids)){
            sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
         Map<String, String> dataLowMap = new HashMap<>();
         if (!CollectionUtils.isEmpty(dataMap)) {
            dataMap.forEach((key, value) -> {
               dataLowMap.put(key.toLowerCase(Locale.ROOT), value);
            });
         }
//         if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
         List<String> repeatData = commonsMapper.selectList(sql[0]);
         if (!repeatData.isEmpty()) {
                String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}";
                String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"};
                throw new VciBaseException("根据您填写的关键属性的内容,结合关键属性查询规则,发现该数据已经与系统中编号为"+repeatData.stream().collect(Collectors.joining(","))+"的数据重复。请修正!。" + ruleInfoMsg, objs);
            }
        }
    }
         dataLowMap.putAll(orderDTO.getData());
         compAttrVOMap.forEach((attrId, attrVO) -> {
            dataLowMap.put(attrId, formulaService.getValueByFormula(dataLowMap, attrVO.getComponentRule()));
         });
         dataLowMap.forEach((key, value) -> {
            setValueToOrderDTO(orderDTO, key, value);
         });
      }
   }
   /**
    * 设置新的值到申请对象上
    *
    * @param orderDTO 编码申请对象
    * @param attrId   属性的编号
    * @param value    值
    */
   private void setValueToOrderDTO(CodeOrderDTO orderDTO, String attrId, String value) {
      attrId = attrId.toLowerCase(Locale.ROOT);
      if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) {
         WebUtil.setValueToField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO, value);
      } else {
         orderDTO.getData().put(attrId, value);
      }
   }
   /**
    * 校验正则表达式是否正确
    *
    * @param templateVO 模板的信息,必须包含属性的内容
    * @param orderDTO   编码申请的相关的信息
    */
   private void checkVerifyOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClassifyTemplateAttrVO> verifyAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getVerifyRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (!CollectionUtils.isEmpty(verifyAttrVOMap)) {
         verifyAttrVOMap.forEach((attrId, attrVO) -> {
            String value = getValueFromOrderDTO(orderDTO, attrId);
            if (StringUtils.isNotBlank(value) && !value.matches(attrVO.getVerifyRule())) {
               //校验正则表达式
               throw new VciBaseException("属性[{0}]的值不符合校验规则的要求", new String[]{attrVO.getName()});
            }
         });
      }
   }
   /**
    * 校验关键属性
    *
    * @param classifyFullInfo 分类的全部信息
    * @param templateVO       模板的内容,必须包含模板属性
    * @param orderDTO         编码申请的相关的信息
    */
   private void checkKeyAttrOnOrder(CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
      //先获取关键属性的规则,也利用继承的方式
      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));
      // TODO:2024-02-01 先获取配置了近义词查询规则的属性,不同于关键属性,设置了近义词查询规则的属性可能是多条不同的近义词查询规则
      Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      // 获取是否有配置近义词查询规则属性
      Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
      if(!sysonymAttrMaps.isEmpty()){
         // 查询近义词规则,存储方式key:属性id,value近义词查询规则列表
         codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
      }
      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());
      Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
      ketAttrMap.forEach((attrId, attrVO) -> {
         String value = getValueFromOrderDTO(orderDTO, attrId);
         if (value == null) {
            value = "";
         }
         wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
      });
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         // TODO: 同一个库判重不需要区分分类oid
         // 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 count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
         final String[] sql = {"select id from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
         conditionMap.forEach((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())) {
            //修改的时候,需要排除自己
            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' ";
         // 获取不参与校验的分类oid
         String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
         if (Func.isNotEmpty(isParticipateCheckOids)) {
            sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
         }
         // if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
         List<String> repeatData = commonsMapper.selectList(sql[0]);
         if (!repeatData.isEmpty()) {
            String ruleInfoMsg = keyRuleVO == null ? "" : "查询规则:去除空格--{0},忽略大小写--{1},忽略全半角--{2},忽略全部空格--{3}";
            String[] objs = new String[]{trim ? "是" : "否", ignoreCase ? "是" : "否", ignoreWidth ? "是" : "否", trimAll ? "是" : "否"};
            throw new VciBaseException("根据您填写的关键属性的内容,结合关键属性查询规则,发现该数据已经与系统中编号为" + repeatData.stream().collect(Collectors.joining(",")) + "的数据重复。请修正!。" + ruleInfoMsg, objs);
         }
      }
   }
   /**
    * 校验关键属性
    *
    * @param orderDTO 编码申请的相关的信息
    */
   @Override
   public List<Map> checkKeyAttrOnOrderFordatas(CodeOrderDTO orderDTO) {
      List<Map>dataList=new ArrayList<>();
      List<Map> dataList = new ArrayList<>();
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      //先获取关键属性的规则,也利用继承的方式
@@ -796,23 +846,32 @@
      //注意的是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));
      // TODO:2024-02-01 先获取配置了近义词查询规则的属性,不同于关键属性,设置了近义词查询规则的属性可能是多条不同的近义词查询规则
      Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      // 获取是否有配置近义词查询规则属性
      Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
      if(!sysonymAttrMaps.isEmpty()){
         // 查询近义词规则,存储方式key:属性id,value近义词查询规则列表
         codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
      }
      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());
      Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
      ketAttrMap.forEach((attrId, attrVO) -> {
         String value = getValueFromOrderDTO(orderDTO, attrId);
         if (value == null) {
            value = "";
         }
         wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
         wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
      });
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
         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());
@@ -821,9 +880,9 @@
         }
         final String[] sql = {"select * from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
         conditionMap.forEach((key, value) -> {
            if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) {
            if (StringUtils.isBlank(value) || value.equals(QueryOptionConstant.ISNULL)) {
               sql[0] += " and " + key + " is null";
            }else{
            } else {
               sql[0] += " and " + key + " = " + value;
            }
         });
@@ -835,7 +894,7 @@
         }
         sql[0] += " and lastR = '1' and lastV = '1' ";
//         if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
         dataList=commonsMapper.selectBySql(sql[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 ? "是" : "否"};
@@ -849,6 +908,7 @@
   /**
    * 根据当前申请编码的分类,逐层往上校验是否符合属于配置的中的分类子节点的分
    * 类,如果符合,则该分类申请的编码为集团码返回true,反之则为企业编码返回false
    *
    * @param parameter 传入数据,classifyGroupCode:配置的中的分类顶节点,oid:选择节点的oid
    */
   @Override
@@ -856,8 +916,8 @@
      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())){
      for (int i = codeClassifyList.size() - 1; i >= 0; i--) {
         if (configGroupCode.contains(codeClassifyList.get(i).getId())) {
//            checkGroupFlag = true;
            return R.data("true");
         }
@@ -876,7 +936,7 @@
    */
   @Override
   public String addSaveBZ(CodeBZApplyDTO codeBZApplyDTO) throws Exception {
      return addSaveBZCode(codeBZApplyDTO,true);
      return addSaveBZCode(codeBZApplyDTO, true);
   }
   /**
@@ -887,57 +947,57 @@
    * @return
    */
   public String addSaveBZCode(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
      String code="";
      String code = "";
      VciBaseUtil.alertNotNull(codeBZApplyDTO.getCodeClassifyOid(), "主题库分类的主键",
         codeBZApplyDTO.getTemplateOid(), "模板的主键", codeBZApplyDTO.getCodeRuleOid(), "编码规则的主键");
      //操作类型
      if(StringUtils.isBlank(codeBZApplyDTO.getOperationType())){
         String operationTypeValue=codeBZApplyDTO.getData().get(operationType);
      if (StringUtils.isBlank(codeBZApplyDTO.getOperationType())) {
         String operationTypeValue = codeBZApplyDTO.getData().get(operationType);
         codeBZApplyDTO.setOperationType(operationTypeValue);
      }
      //是否系列
      if(!codeBZApplyDTO.isSeries()){
         boolean isSeriesValue=codeBZApplyDTO.getData().get(isSeries).equals("true")?true:false;
      if (!codeBZApplyDTO.isSeries()) {
         boolean isSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isSeries));
         codeBZApplyDTO.setSeries(isSeriesValue);
      }
      //原标准号
      if(StringUtils.isBlank(codeBZApplyDTO.getOldCode())){
         String oldCodeValue=codeBZApplyDTO.getData().get(oldCode);
      if (StringUtils.isBlank(codeBZApplyDTO.getOldCode())) {
         String oldCodeValue = codeBZApplyDTO.getData().get(oldCode);
         codeBZApplyDTO.setOldCode(oldCodeValue);
      }
      //系列流水
      if(StringUtils.isBlank(codeBZApplyDTO.getSeriesFlow())){
         String seriesFlowValue=codeBZApplyDTO.getData().get(seriesFlow);
      if (StringUtils.isBlank(codeBZApplyDTO.getSeriesFlow())) {
         String seriesFlowValue = codeBZApplyDTO.getData().get(seriesFlow);
         codeBZApplyDTO.setSeriesFlow(seriesFlowValue);
      }
      //发布时间
      if(StringUtils.isBlank(codeBZApplyDTO.getReleaseTime())){
         String releaseTimeValue=codeBZApplyDTO.getData().get(releaseTime);
      if (StringUtils.isBlank(codeBZApplyDTO.getReleaseTime())) {
         String releaseTimeValue = codeBZApplyDTO.getData().get(releaseTime);
         codeBZApplyDTO.setReleaseTime(releaseTimeValue);
      }
      //是否变更系列
      if(!codeBZApplyDTO.isEditSeries()){
         boolean isEditSeriesValue=codeBZApplyDTO.getData().get(isEditSeries).equals("true")?true:false;
      if (!codeBZApplyDTO.isEditSeries()) {
         boolean isEditSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isEditSeries));
         codeBZApplyDTO.setEditSeries(isEditSeriesValue);
      }
      VciBaseUtil.alertNotNull(codeBZApplyDTO.getOperationType(), "操作类型",
         codeBZApplyDTO.isSeries(), "是否系列", codeBZApplyDTO.getReleaseTime(), "发布时间");
      if(codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_FORMULATE.getValue())){//制定
         code=   addsaveDataBZ(codeBZApplyDTO,authUser);
      }else if(codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())){//修订
      if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_FORMULATE.getValue())) {//制定
         code = addsaveDataBZ(codeBZApplyDTO, authUser);
      } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())) {//修订
         VciBaseUtil.alertNotNull(codeBZApplyDTO.getOldCode(), "源标准号");
         code=   amendmentDataBZ(codeBZApplyDTO,authUser);
         createChangeOder(code,codeBZApplyDTO,authUser);
      }else if(codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_EDIT.getValue())){//更改
         code=   amendmentDataBZ(codeBZApplyDTO,authUser);
         createChangeOder(code,codeBZApplyDTO,authUser);
      }else if(codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_DISABLE.getValue())) {//作废
         code=   amendmentDataBZ(codeBZApplyDTO,authUser);
         createChangeOder(code,codeBZApplyDTO,authUser);
      }else if(codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())) {//备查
         code=   amendmentDataBZ(codeBZApplyDTO,authUser);
         createChangeOder(code,codeBZApplyDTO,authUser);
         code = amendmentDataBZ(codeBZApplyDTO, authUser);
         createChangeOder(code, codeBZApplyDTO, authUser);
      } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_EDIT.getValue())) {//更改
         code = amendmentDataBZ(codeBZApplyDTO, authUser);
         createChangeOder(code, codeBZApplyDTO, authUser);
      } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_DISABLE.getValue())) {//作废
         code = amendmentDataBZ(codeBZApplyDTO, authUser);
         createChangeOder(code, codeBZApplyDTO, authUser);
      } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_FOR_REFERENCE.getValue())) {//备查
         code = amendmentDataBZ(codeBZApplyDTO, authUser);
         createChangeOder(code, codeBZApplyDTO, authUser);
      }
      return code;
   }
@@ -949,34 +1009,35 @@
    * @return
    */
   private String amendmentDataBZ(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
      CodeOrderDTO orderDTO=new CodeOrderDTO();
      BeanUtil.convert(codeBZApplyDTO,orderDTO);
      CodeOrderDTO orderDTO = new CodeOrderDTO();
      BeanUtil.convert(codeBZApplyDTO, orderDTO);
      CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(codeBZApplyDTO.getCodeRuleOid());
      Map<String, CodeBasicSecVO> codeCodeBasicSecMap = ruleVO.getSecVOList().stream().filter(s -> StringUtils.isNotBlank(s.getOid())).collect(Collectors.toMap(s -> s.getOid().toLowerCase(Locale.ROOT), t -> t));
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
         orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
      String oldCode=codeBZApplyDTO.getOldCode();//源标准编码
      String releaseTime=codeBZApplyDTO.getReleaseTime();
      List<CodeOrderSecDTO> secDTOS=   orderDTO.getSecDTOList();
      LinkedList<CodeOrderSecDTO> newSecDTOList=new LinkedList<>();
      changeCodeOrderSecDTO(ruleVO,secDTOS,oldCode,newSecDTOList);//根据要求重新算码段码值
      if(!codeBZApplyDTO.isEditSeries()){//变更为标准
      String oldCode = codeBZApplyDTO.getOldCode();//源标准编码
      String releaseTime = codeBZApplyDTO.getReleaseTime();
      List<CodeOrderSecDTO> secDTOS = orderDTO.getSecDTOList();
      LinkedList<CodeOrderSecDTO> newSecDTOList = new LinkedList<>();
      changeCodeOrderSecDTO(ruleVO, secDTOS, oldCode, newSecDTOList);//根据要求重新算码段码值
      if (!codeBZApplyDTO.isEditSeries()) {//变更为标准
         //if(!codeBZApplyDTO.isSeries()){//如果是表准,则需要将系列好流水置为null
            //因为是标准则控制码段中的系列流水码段值为空
            newSecDTOList.stream().forEach(codeOrderSecDTO -> {
               if(codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid())&&codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)){
                  codeOrderSecDTO.setSecValue("");
               }
            });
         //因为是标准则控制码段中的系列流水码段值为空
         newSecDTOList.stream().forEach(codeOrderSecDTO -> {
            if (codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid()) && codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)) {
               codeOrderSecDTO.setSecValue("");
            }
         });
         //}
         orderDTO.setSecDTOList(newSecDTOList);
         return createDataBZ(orderDTO,ruleVO,authUser);
      }else{//变更为系列.则按照逻辑去处理
         return createDataBZ(orderDTO, ruleVO, authUser);
      } else {//变更为系列.则按照逻辑去处理
         orderDTO.setSecDTOList(newSecDTOList);
         return createDataBZ(orderDTO,ruleVO,authUser);
         return createDataBZ(orderDTO, ruleVO, authUser);
      }
   }
   private String createDataBZ(CodeOrderDTO orderDTO,   CodeRuleVO ruleVO,boolean authUser) throws Exception {
   private String createDataBZ(CodeOrderDTO orderDTO, CodeRuleVO ruleVO, boolean authUser) throws Exception {
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      //1.判断规则中除了流水码段,是否有其他码段
@@ -1007,17 +1068,17 @@
      cbo.setCreateTime(new Date());
      cbo.setLastModifyTime(new Date());
      //cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));、
      if(authUser) {
      if (authUser) {
         // 要求显示账号,所以做了更改
         cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
         cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      }else{
      } 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"));
      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());
@@ -1031,42 +1092,44 @@
      return codeList.size() > 0 ? codeList.get(0) : "";
   }
   /***
    * 根据编号获取码段码值
    * @param secDTOList
    */
   private void changeCodeOrderSecDTO(CodeRuleVO ruleVO,List<CodeOrderSecDTO> secDTOList,String oldCode,LinkedList<CodeOrderSecDTO> newSecDTOList) throws Exception {
   private void changeCodeOrderSecDTO(CodeRuleVO ruleVO, List<CodeOrderSecDTO> secDTOList, String oldCode, LinkedList<CodeOrderSecDTO> newSecDTOList) throws Exception {
      //还需要修改allCode的生命周期
      QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
      allCodeWrapper.in("id", VciBaseUtil.str2List(oldCode));
      Map<String,String> secDTOMap=secDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), t -> t.getSecValue(),(o1, o2)->o2));
      List<CodeAllCode>codeAllcodeList=codeAllCodeService.selectByWrapper(allCodeWrapper);
      if(!CollectionUtils.isEmpty(codeAllcodeList)){
         String codeDelimit=codeAllcodeList.get(0).getCodeDelimit();
         String[] secValues=StringUtils.splitByWholeSeparatorPreserveAllTokens(codeDelimit,SERIAL_VALUE_SPACE);
      Map<String, String> secDTOMap = secDTOList.stream().collect(Collectors.toMap(s -> s.getSecOid(), t -> t.getSecValue(), (o1, o2) -> o2));
      List<CodeAllCode> codeAllcodeList = codeAllCodeService.selectByWrapper(allCodeWrapper);
      if (!CollectionUtils.isEmpty(codeAllcodeList)) {
         String codeDelimit = codeAllcodeList.get(0).getCodeDelimit();
         String[] secValues = StringUtils.splitByWholeSeparatorPreserveAllTokens(codeDelimit, SERIAL_VALUE_SPACE);
         //VciBaseUtil.str2List()
         for (int i=0; i<ruleVO.getSecVOList().size();i++){
            CodeBasicSecVO codeBasicSecVO=ruleVO.getSecVOList().get(i);
            CodeOrderSecDTO codeOrderSecDTO=new CodeOrderSecDTO();
            String secValue=secValues[i];
            boolean isRoman=VciBaseUtil.isRoman(secValue);
            if(isRoman){
         for (int i = 0; i < ruleVO.getSecVOList().size(); i++) {
            CodeBasicSecVO codeBasicSecVO = ruleVO.getSecVOList().get(i);
            CodeOrderSecDTO codeOrderSecDTO = new CodeOrderSecDTO();
            String secValue = secValues[i];
            boolean isRoman = VciBaseUtil.isRoman(secValue);
            if (isRoman) {
               continue;
            }
            if(secDTOMap.containsKey(codeBasicSecVO.getOid())){
               secValue=   secDTOMap.get(codeBasicSecVO.getOid())   ;
            if (secDTOMap.containsKey(codeBasicSecVO.getOid())) {
               secValue = secDTOMap.get(codeBasicSecVO.getOid());
            }
            if(StringUtils.isNotBlank(secValue)) {
            if (StringUtils.isNotBlank(secValue)) {
               codeOrderSecDTO.setSecOid(codeBasicSecVO.getOid());
               codeOrderSecDTO.setSecValue(secValue);
               newSecDTOList.add(codeOrderSecDTO);
            }
         }
      }else{
      } else {
         throw new Exception("根据原标准编号,在系统中未查询到相应的信息");
      }
   }
   /***
    * 制定,则不需要产生更改单直接生成编码
    * @param codeBZApplyDTO
@@ -1074,23 +1137,23 @@
    * @return
    */
   private String addsaveDataBZ(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
      String code="";
      CodeOrderDTO orderDTO=new CodeOrderDTO();
      BeanUtil.convert(codeBZApplyDTO,orderDTO);
      String code = "";
      CodeOrderDTO orderDTO = new CodeOrderDTO();
      BeanUtil.convert(codeBZApplyDTO, orderDTO);
      CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(codeBZApplyDTO.getCodeRuleOid());
      Map<String, CodeBasicSecVO> codeCodeBasicSecMap = ruleVO.getSecVOList().stream().filter(s -> StringUtils.isNotBlank(s.getOid())).collect(Collectors.toMap(s -> s.getOid(), t -> t));
      //是否是标准,不是标准的不会去管
      if(!codeBZApplyDTO.isSeries()){
      if (!codeBZApplyDTO.isSeries()) {
         //因为是标准则控制码段中的系列流水码段值为空
         orderDTO.getSecDTOList().stream().forEach(codeOrderSecDTO -> {
            if(codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid())&&codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)){
            if (codeCodeBasicSecMap.containsKey(codeOrderSecDTO.getSecOid()) && codeCodeBasicSecMap.get(codeOrderSecDTO.getSecOid()).getName().equals(secName)) {
               codeOrderSecDTO.setSecValue("");
            }
         });
      }
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
         orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
      return createDataBZ(orderDTO,ruleVO,authUser);
      return createDataBZ(orderDTO, ruleVO, authUser);
   }
   /***
@@ -1100,11 +1163,12 @@
    * @param authUser
    * @return
    */
   private String createChangeOder(String code,CodeBZApplyDTO codeBZApplyDTO, boolean authUser){
   private String createChangeOder(String code, CodeBZApplyDTO codeBZApplyDTO, boolean authUser) {
      return "";
   }
   /***
    * 集成可变码段申请接口
    * @param codeBZApplyDTO 申请的信息,需要包含属性的内容和码段相关的内容
@@ -1114,314 +1178,406 @@
    */
   @Override
   public String addSaveBZCodeNotauthUser(CodeBZApplyDTO codeBZApplyDTO, boolean authUser) throws Exception {
      return   addSaveBZCode(codeBZApplyDTO,authUser);
      return addSaveBZCode(codeBZApplyDTO, authUser);
   }
   /**
     * 封装关键属性的查询语句
     *
     * @param value        当前的值
     * @param keyRuleVO    关键属性的控制规则,可以为空
     * @param attrId       属性的编号
     * @param trim         是否去除空格
     * @param ignoreCase   是否不区分大小写
     * @param ignoreWidth  是否忽略全半角
     * @param trimAll      是否忽略全部空格
     * @param conditionMap 查询条件
     */
    @Override
    public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId,
                                           boolean trim, boolean ignoreCase, boolean ignoreWidth,
                                           boolean trimAll, Map<String, String> conditionMap) {
        boolean ignoreSpace = trim || trimAll;
        if (StringUtils.isBlank(value)) {
            //为空的时候,不能用QueryOperation.ISNULL,平台不知道啥时候不处理这种了
         conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
        } else {
            if (keyRuleVO != null) {
                String queryKey = "";
                String queryValue = "";
    * 获取统计分析数据
    *
    * @param btmNames 业务类型
    * @return 数据集
    */
   @Override
   public R getStatisticAnalysis(String btmNames) {
      //查询业务类型对应的数据库表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmNames.split(",")));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new ServiceException("传入业务类型未查询到相应表单,请检查!");
      }
      List tableData = new ArrayList();
      for (BtmTypeVO datum : listR.getData()) {
         String sql = "select count(*) countNum, to_char(CREATETIME, 'mm') countDate\n" +
            "from " + datum.getTableName() + "\n" +
            "where CREATETIME >= to_date(EXTRACT(YEAR FROM SYSDATE) || '-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND LASTV = '1'\n" +
            "group by to_char(CREATETIME, 'mm')\n" +
            "order by to_char(CREATETIME, 'mm')";
         //查询出需要处理的数据
         List<Map> maps = commonsMapper.selectBySql(sql);
                String temp = "";
                if (ignoreCase && ignoreSpace && ignoreWidth) {
                    //忽略大小写,且去空,忽略全半角
                    temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte(%s)) " + (trimAll ? ",' ','')" : ")");
                } else if (ignoreCase && ignoreSpace && !ignoreWidth) {
                    //忽略大小写、去空、不忽略全半角
                    temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")");
                } else if (ignoreCase && !ignoreSpace && ignoreWidth) {
                    //忽略大小写、不去空、忽略全半角
                    temp = "UPPER(to_single_byte(%s))";
                } else if (!ignoreCase && ignoreSpace && ignoreWidth) {
                    //不忽略大小写、去空、忽略全半角
                    temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte(%s) " + (trimAll ? ",' ','')" : ")");
                } else if (ignoreCase && !ignoreSpace && !ignoreWidth) {
                    //忽略大小写、不去空、不忽略全半角
                    temp = "UPPER(%s)";
                } else if (!ignoreCase && !ignoreCase && ignoreWidth) {
                    //不忽略大小写、不去空、忽略全半角
                    temp = "to_single_byte(%s)";
                } else if (!ignoreCase && ignoreSpace && !ignoreWidth) {
                    //不忽略大小写、去空、不忽略全半角
                    temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")");
                } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) {
                    //不忽略大小写、不去空、不忽略全半角
                    temp = "%s";
                }
                queryKey = String.format(temp, "nvl("+ "t." + attrId +",'/')");
                queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'");
                conditionMap.put(queryKey, queryValue);
            } else {
            if(StringUtils.isNotBlank(value)) {
               //为空的时候不代表不校验,只是不去除相关的信息
               conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + value + "'");
            }else{
         //当年每月月份之前之和
         List<Integer> monthCount = new ArrayList<>(12);
         //当年每月的月份数据
         List<Integer> month = new ArrayList<>();
         //获取当前月的数字
         Calendar instance = Calendar.getInstance();
         int nowmonth = instance.get(Calendar.MONTH) + 1;
         if (maps.size() == 0) {
            nowmonth = 0;
         }
         //从1到12月进行处理
         for (Integer i = 1; i <= 12; i++) {
            //当前月后所有数据设置为0
            if (i > nowmonth) {
               monthCount.add(0);
               month.add(0);
               continue;
            }
            //当前月份之前之和
            Integer count = 0;
            //当前月份数据
            Integer sameMonth = 0;
            //对数据库查的数据进行处理,对当前月份进行累加
            for (Map map : maps) {
               Integer mounDate = Integer.parseInt(String.valueOf(map.get("COUNTDATE")));
               if (mounDate <= i) {
                  count += Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
               }
               if (mounDate == i) {
                  sameMonth = Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
               }
            }
            monthCount.add(count);
            month.add(sameMonth);
         }
         //对数据进行整合
         HashMap<String, Object> menuData = new HashMap<>();
         menuData.put("menuName", datum.getName());
         menuData.put("codeType", null);
         ArrayList monthData = new ArrayList();
         monthData.add(monthCount);
         monthData.add(month);
         menuData.put("menuData", monthData);
         tableData.add(menuData);
      }
      return R.data(tableData);
   }
   /**
    * 封装关键属性的查询语句
    *
    * @param value        当前的值
    * @param keyRuleVO    关键属性的控制规则,可以为空
    * @param attrId       属性的编号
    * @param trim         是否去除空格
    * @param ignoreCase   是否不区分大小写
    * @param ignoreWidth  是否忽略全半角
    * @param trimAll      是否忽略全部空格
    * @param conditionMap 查询条件
    */
   @Override
   public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO,
                                 List<CodeSynonym> codeSynonymMaps, String attrId,
                                 boolean trim, boolean ignoreCase, boolean ignoreWidth,
                                 boolean trimAll, Map<String, String> conditionMap) {
      boolean ignoreSpace = trim || trimAll;
      if (StringUtils.isBlank(value)) {
         //值为空的时候,不能用QueryOperation.ISNULL,平台不知道啥时候不处理这种了
         conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
      } else {
         //近义词查询规则valu值转换
         value = this.getValueToSynony(codeSynonymMaps, value);
         if (keyRuleVO != null) {
            String queryKey = "";
            String queryValue = "";
            String temp = "";
            if (ignoreCase && ignoreSpace && ignoreWidth) {
               //忽略大小写,且去空,忽略全半角
               temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte(%s)) " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && ignoreSpace && !ignoreWidth) {
               //忽略大小写、去空、不忽略全半角
               temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && !ignoreSpace && ignoreWidth) {
               //忽略大小写、不去空、忽略全半角
               temp = "UPPER(to_single_byte(%s))";
            } else if (!ignoreCase && ignoreSpace && ignoreWidth) {
               //不忽略大小写、去空、忽略全半角
               temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte(%s) " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && !ignoreSpace && !ignoreWidth) {
               //忽略大小写、不去空、不忽略全半角
               temp = "UPPER(%s)";
            } else if (!ignoreCase && !ignoreCase && ignoreWidth) {
               //不忽略大小写、不去空、忽略全半角
               temp = "to_single_byte(%s)";
            } else if (!ignoreCase && ignoreSpace && !ignoreWidth) {
               //不忽略大小写、去空、不忽略全半角
               temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")");
            } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) {
               //不忽略大小写、不去空、不忽略全半角
               temp = "%s";
            }
            queryKey = String.format(temp, "nvl(" + "t." + attrId + ",'/')");
            queryValue = String.format(temp, "'" + (trim ? SpecialCharacterConverter.escapeSpecialCharacters(value.trim()) : SpecialCharacterConverter.escapeSpecialCharacters(value)) + "'");
            conditionMap.put(queryKey, queryValue);
         } else {
            if (StringUtils.isNotBlank(value)) {
               //关键属性查重规则为空的时候不代表不校验,只是不去除相关的信息
               conditionMap.put("nvl(" + "t." + attrId + ",'/')", "'" + SpecialCharacterConverter.escapeSpecialCharacters(value) + "'");
            } else {
               conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
            }
            }
        }
    }
         }
      }
   }
    /**
     * 校验枚举的内容
     *
     * @param templateVO 模板的显示对象,需要包含属性
     * @param orderDTO   编码申请的信息
     */
    private void checkEnumOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        //如果枚举可以修改,则不需要校验是否符合枚举的选项
   /**
    * 近义词查询规则转换
    * @param codeSynonymMaps
    * @param value
    * @return
    */
   public String getValueToSynony(/*近义词查询规则*/List<CodeSynonym> codeSynonymMaps,String value){
      // 获取并判断是否配置了近义词查询规则
      // TODO:近义词替换成源值(源值是正确的值,近义词是相当于输错笔误的字符)
      if(Func.isNotEmpty(codeSynonymMaps)){
         for (int i = 0; i < codeSynonymMaps.size(); i++) {
            value = value.replace(codeSynonymMaps.get(i).getSynonymValue(),codeSynonymMaps.get(i).getSourceValue());
         }
      }
      return value;
   }
        Map<String, CodeClassifyTemplateAttrVO> enumAttrVOMap = templateVO.getAttributes().stream().filter(s -> (StringUtils.isNotBlank(s.getEnumString()) || StringUtils.isNotBlank(s.getEnumId())) && !VciBaseUtil.getBoolean(s.getEnumEditFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (!CollectionUtils.isEmpty(enumAttrVOMap)) {
            enumAttrVOMap.forEach((attrId, attrVO) -> {
                String value = getValueFromOrderDTO(orderDTO, attrId);
                if (StringUtils.isNotBlank(value)) {
                    //有值才能校验
                    List<KeyValue> comboboxKVs = listComboboxItems(attrVO);
                    if (!comboboxKVs.stream().anyMatch(s -> value.equalsIgnoreCase(s.getKey()))) {
                        throw new VciBaseException("属性【{0}】的值不符合枚举的要求", new String[]{attrVO.getName()});
                    }
                }
            });
        }
    }
   /**
    * 校验枚举的内容
    *
    * @param templateVO 模板的显示对象,需要包含属性
    * @param orderDTO   编码申请的信息
    */
   private void checkEnumOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
      //如果枚举可以修改,则不需要校验是否符合枚举的选项
    /**
     * 转换时间的格式
     *
     * @param templateVO 模板的显示对象,需要包含属性
     * @param orderDTO   编码申请的信息
     */
    private void switchDateAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
        Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getCodeDateFormat())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
        if (!CollectionUtils.isEmpty(dateAttrVOMap)) {
            dateAttrVOMap.forEach((attrId, attrVO) -> {
                String value = getValueFromOrderDTO(orderDTO, attrId);
                if (StringUtils.isNotBlank(value)) {
                    DateConverter dateConverter = new DateConverter();
                    dateConverter.setAsText(value);
                    value = VciDateUtil.date2Str(dateConverter.getValue(), VciDateUtil.DateTimeMillFormat);
                    setValueToOrderDTO(orderDTO, attrId, value);
                }
            });
        }
    }
      Map<String, CodeClassifyTemplateAttrVO> enumAttrVOMap = templateVO.getAttributes().stream().filter(s -> (StringUtils.isNotBlank(s.getEnumString()) || StringUtils.isNotBlank(s.getEnumId())) && !VciBaseUtil.getBoolean(s.getEnumEditFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (!CollectionUtils.isEmpty(enumAttrVOMap)) {
         enumAttrVOMap.forEach((attrId, attrVO) -> {
            String value = getValueFromOrderDTO(orderDTO, attrId);
            if (StringUtils.isNotBlank(value)) {
               //有值才能校验
               List<KeyValue> comboboxKVs = listComboboxItems(attrVO);
               if (!comboboxKVs.stream().anyMatch(s -> value.equalsIgnoreCase(s.getKey()))) {
                  throw new VciBaseException("属性【{0}】的值不符合枚举的要求", new String[]{attrVO.getName()});
               }
            }
         });
      }
   }
    /**
     * 拷贝数据到cbo对象上
     *
     * @param classifyFullInfo 分类的全部信息
     * @param cbo              业务数据
     * @param orderDTO         编码申请的信息
     * @param templateVO       模板的显示对象
     * @param edit             是否为修改
     */
    private void copyValueToCBO(CodeClassifyFullInfoBO classifyFullInfo, BaseModel cbo,
                                CodeOrderDTO orderDTO, CodeClassifyTemplateVO templateVO,
                                boolean edit) {
        String fullPath = "";
        if (!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())) {
            fullPath = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel())))
                    .map(CodeClassifyVO::getOid).collect(Collectors.joining("##"));
        } else {
            fullPath = classifyFullInfo.getCurrentClassifyVO().getOid();
        }
   /**
    * 转换时间的格式
    *
    * @param templateVO 模板的显示对象,需要包含属性
    * @param orderDTO   编码申请的信息
    */
   private void switchDateAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getCodeDateFormat())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      if (!CollectionUtils.isEmpty(dateAttrVOMap)) {
         dateAttrVOMap.forEach((attrId, attrVO) -> {
            String value = getValueFromOrderDTO(orderDTO, attrId);
            if (StringUtils.isNotBlank(value)) {
               DateConverter dateConverter = new DateConverter();
               dateConverter.setAsText(value);
               value = VciDateUtil.date2Str(dateConverter.getValue(), VciDateUtil.DateTimeMillFormat);
               setValueToOrderDTO(orderDTO, attrId, value);
            }
         });
      }
   }
   /**
    * 拷贝数据到cbo对象上
    *
    * @param classifyFullInfo 分类的全部信息
    * @param cbo              业务数据
    * @param orderDTO         编码申请的信息
    * @param templateVO       模板的显示对象
    * @param edit             是否为修改
    */
   private void copyValueToCBO(CodeClassifyFullInfoBO classifyFullInfo, BaseModel cbo,
                        CodeOrderDTO orderDTO, CodeClassifyTemplateVO templateVO,
                        boolean edit) {
      String fullPath = "";
      if (!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())) {
         fullPath = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel())))
            .map(CodeClassifyVO::getOid).collect(Collectors.joining("##"));
      } else {
         fullPath = classifyFullInfo.getCurrentClassifyVO().getOid();
      }
      orderDTO.getData().forEach((key, value) -> {
         if (!edit || (!checkUnAttrUnEdit(key) &&
            !VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(key))) {
            try {
               cbo.getData().put(cbo.getData().containsKey(key.toUpperCase())?key.toUpperCase():key, value);
               cbo.getData().put(cbo.getData().containsKey(key.toUpperCase()) ? key.toUpperCase() : key, value);
            } catch (Exception e) {
               logger.error("设置属性的值错误", e);
            }
         }
      });
        try {
      try {
         Map<String, String> data = new HashMap<>();
            data.put(cbo.getData().containsKey(CODE_CLASSIFY_OID_FIELD.toUpperCase())?CODE_CLASSIFY_OID_FIELD.toUpperCase():CODE_CLASSIFY_OID_FIELD, classifyFullInfo.getCurrentClassifyVO().getOid());
            data.put(cbo.getData().containsKey(CODE_TEMPLATE_OID_FIELD.toUpperCase())?CODE_TEMPLATE_OID_FIELD.toUpperCase():CODE_TEMPLATE_OID_FIELD, templateVO.getOid());
            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());
         data.put(cbo.getData().containsKey(CODE_CLASSIFY_OID_FIELD.toUpperCase()) ? CODE_CLASSIFY_OID_FIELD.toUpperCase() : CODE_CLASSIFY_OID_FIELD, classifyFullInfo.getCurrentClassifyVO().getOid());
         data.put(cbo.getData().containsKey(CODE_TEMPLATE_OID_FIELD.toUpperCase()) ? CODE_TEMPLATE_OID_FIELD.toUpperCase() : CODE_TEMPLATE_OID_FIELD, templateVO.getOid());
         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().getAccount());
            cbo.setTs(new Date());
            if (!edit && StringUtils.isBlank(orderDTO.getLcStatus())) {
                //TODO 先写固定,后面生命周期好了在编写
                if (StringUtils.isNotBlank(cbo.getLctid())) {
         cbo.setTs(new Date());
         if (!edit && StringUtils.isBlank(orderDTO.getLcStatus())) {
            //TODO 先写固定,后面生命周期好了在编写
            if (StringUtils.isNotBlank(cbo.getLctid())) {
//               OsLifeCycleVO lifeCycleVO = lifeCycleService.getLifeCycleById(cbo.getLctid());
//               if (lifeCycleVO != null) {
//                  cbo.setLcStatus("Editing");
////                  cbo.setLcStatus(lifeCycleVO.getStartStatus());
//               } else {
                    cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
               cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
//               }
                } else {
                    cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
                }
            } else {
               cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
            }
            }
         }
            int secret = VciBaseUtil.getInt(String.valueOf(cbo.getSecretGrade()));
            if (secret == 0 || !secretService.checkDataSecret(secret).getData()) {
                Integer userSecret = VciBaseUtil.getCurrentUserSecret();
         int secret = VciBaseUtil.getInt(String.valueOf(cbo.getSecretGrade()));
         if (secret == 0 || !secretService.checkDataSecret(secret).getData()) {
            Integer userSecret = VciBaseUtil.getCurrentUserSecret();
//            cbo.setAttributeValue(SECRET_FIELD, String.valueOf((userSecret == null || userSecret == 0) ? UserSecretEnum.NONE.getValue() : userSecret));
                cbo.setSecretGrade(userSecret == null || userSecret == 0 ? UserSecretEnum.NONE.getValue() : userSecret);
            }
        } catch (Throwable e) {
            logger.error("设置默认的属性的值错误", e);
        }
    }
            cbo.setSecretGrade(userSecret == null || userSecret == 0 ? UserSecretEnum.NONE.getValue() : userSecret);
         }
      } catch (Throwable e) {
         logger.error("设置默认的属性的值错误", e);
      }
   }
    /**
     * 初始化业务类型
     * --创建人默认为当前用户,如果需要修改,可以在获取后自行处理
     *
     * @param btmName 业务类型的名称,会自动变成小写
     * @return CodeWupinEntity
     * @throws VciBaseException 初始化出错的是会抛出异常
     */
    @Override
    public BaseModel createCBOByBtmName(String btmName)
            throws VciBaseException {
        if (btmName != null) {
            btmName = btmName.trim().toLowerCase();
        }
        try {
            String keyPrefix = BTM_INIT_CACHE.concat(StringPool.COLON).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
            Cache.ValueWrapper valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
            if (valueWrapper == null) {
                CacheUtil.getCache(keyPrefix).put(keyPrefix.concat(String.valueOf(btmName)), createBaseModel(btmName));
                valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
            }
            return (BaseModel) valueWrapper.get();
        } catch (Exception e) {
            logger.error("创建业务类型对象", e);
            throw new ServiceException("initBtmError:"+"业务类型:"+btmName+":"+e.getMessage());
        }
    }
   /**
    * 初始化业务类型
    * --创建人默认为当前用户,如果需要修改,可以在获取后自行处理
    *
    * @param btmName 业务类型的名称,会自动变成小写
    * @return CodeWupinEntity
    * @throws VciBaseException 初始化出错的是会抛出异常
    */
   @Override
   public BaseModel createCBOByBtmName(String btmName)
      throws VciBaseException {
      if (btmName != null) {
         btmName = btmName.trim().toLowerCase();
      }
      try {
         String keyPrefix = BTM_INIT_CACHE.concat(StringPool.COLON).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
         Cache.ValueWrapper valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
         if (valueWrapper == null) {
            CacheUtil.getCache(keyPrefix).put(keyPrefix.concat(String.valueOf(btmName)), createBaseModel(btmName));
            valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
         }
         return (BaseModel) valueWrapper.get();
      } catch (Exception e) {
         logger.error("创建业务类型对象", e);
         throw new ServiceException("initBtmError:" + "业务类型:" + btmName + ":" + e.getMessage());
      }
   }
    /**
     * 保存可输可选的信息
     *
     * @param templateVO 模板的对象
     * @param cboList    数据的内容
     */
    @Override
    public void batchSaveSelectChar(CodeClassifyTemplateVO templateVO, /*List<ClientBusinessObject> cboList*/
                                    List<BaseModel> cboList) {
        if (templateVO != null && !CollectionUtils.isEmpty(cboList)) {
            //是异步的,所以直接循环
            List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryIdentification())).collect(Collectors.toList());
   /**
    * 保存可输可选的信息
    *
    * @param templateVO 模板的对象
    * @param cboList    数据的内容
    */
   @Override
   public void batchSaveSelectChar(CodeClassifyTemplateVO templateVO, /*List<ClientBusinessObject> cboList*/
                           List<BaseModel> cboList) {
      if (templateVO != null && !CollectionUtils.isEmpty(cboList)) {
         //是异步的,所以直接循环
         List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryIdentification())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(selectAttrVOs)) {
         if (!CollectionUtils.isEmpty(selectAttrVOs)) {
            //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
                selectAttrVOs.parallelStream().forEach(attrVO -> {
                    List<String> valuesList = new ArrayList<>();
                    cboList.parallelStream().forEach(cbo -> {
            selectAttrVOs.parallelStream().forEach(attrVO -> {
               List<String> valuesList = new ArrayList<>();
               cboList.parallelStream().forEach(cbo -> {
                  //String value = cbo.get.getAttributeValue(attrVO.getId());
                        //将bean转为map,mybatis统一处理
                        Map<String, String> map = null;
                  //将bean转为map,mybatis统一处理
                  Map<String, String> map = null;
                  //baseModels.stream().forEach(model-> {
                        try {
                            map = VciBaseUtil.convertBean2Map(cbo,null);
                        } catch (Exception e) {
                            throw new VciBaseException("类型转换错误:" + e.getMessage());
                        }
                  try {
                     map = VciBaseUtil.convertBean2Map(cbo, null);
                  } catch (Exception e) {
                     throw new VciBaseException("类型转换错误:" + e.getMessage());
                  }
                  //});
                        String value = map.get(attrVO.getId());
                        if (StringUtils.isNotBlank(value)) {
                            valuesList.add(value);
                        }
                    });
                    if (!CollectionUtils.isEmpty(valuesList)) {
                        for (String s : valuesList) {
                            DictBiz dictBiz = new DictBiz();
                            dictBiz.setCode(templateVO.getBtmTypeId());
                            dictBiz.setDictKey(s);
                            dictBiz.setDictValue(s);
                            //从原来的charService(可输可选)更改为调用omd中的接口来实现
                            iDictBizClient.getCheck(dictBiz);
                        }
                  String value = map.get(attrVO.getId());
                  if (StringUtils.isNotBlank(value)) {
                     valuesList.add(value);
                  }
               });
               if (!CollectionUtils.isEmpty(valuesList)) {
                  for (String s : valuesList) {
                     DictBiz dictBiz = new DictBiz();
                     dictBiz.setCode(templateVO.getBtmTypeId());
                     dictBiz.setDictKey(s);
                     dictBiz.setDictValue(s);
                     //从原来的charService(可输可选)更改为调用omd中的接口来实现
                     iDictBizClient.getCheck(dictBiz);
                  }
//                  charService.saveBySameNamespaceAndFlag(templateVO.getBtmTypeId(), attrVO.getLibraryIdentification(), valuesList, sessionInfo);
                    }
                });
            }
        }
    }
               }
            });
         }
      }
   }
   /**
    * 封装开关的内容,常用于导出
    * @param dataMap 数据的内容
    *
    * @param dataMap    数据的内容
    * @param templateVO 模板的显示
    */
   @Override
   public void wrapperBoolean(List<Map<String, String>> dataMap, CodeClassifyTemplateVO templateVO){
   public void wrapperBoolean(List<Map<String, String>> dataMap, CodeClassifyTemplateVO templateVO) {
      List<String> booleanAttributes = templateVO.getAttributes().stream().filter(s -> VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(s.getAttributeDataType())).map(s -> s.getId().toLowerCase(Locale.ROOT)).collect(Collectors.toList());
      if(!CollectionUtils.isEmpty(booleanAttributes)){
      if (!CollectionUtils.isEmpty(booleanAttributes)) {
         dataMap.stream().forEach(data -> {
            booleanAttributes.stream().forEach(attrId->{
               if(data.containsKey(attrId)){
            booleanAttributes.stream().forEach(attrId -> {
               if (data.containsKey(attrId)) {
                  String value = data.get(attrId);
                  data.put(attrId,BooleanEnum.TRUE.getValue().equalsIgnoreCase(value)?"是":"否");
                  data.put(attrId, BooleanEnum.TRUE.getValue().equalsIgnoreCase(value) ? "是" : "否");
               }
            });
         });
      }
   }
    @Override
    public MdmUIInfoVO getFormDefineByTemplateOid(String templateOid, String codeClassifyOid) {
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
        MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
        uiInfoVO.setTemplateVO(templateVO);
        uiInfoVO.setFormDefineVO(wrapperFormDefineByTemplate(templateVO, codeClassifyOid));
        wrapperResemble(templateVO, uiInfoVO);
        return uiInfoVO;
    }
   @Override
   public MdmUIInfoVO getFormDefineByTemplateOid(String templateOid, String codeClassifyOid) {
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
      MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
      uiInfoVO.setTemplateVO(templateVO);
      uiInfoVO.setFormDefineVO(wrapperFormDefineByTemplate(templateVO, codeClassifyOid));
      wrapperResemble(templateVO, uiInfoVO);
      return uiInfoVO;
   }
   /**
    * 模板属性转换为表单定义的信息
    *
    * @param templateVO      模板的显示对象
    * @param codeClassifyOid 分类的主键,为空的时候,获取模板所属的分类主键.用于产生分类注入
    * @return 表格的信息
    */
   private UIFormDefineVO wrapperFormDefineByTemplate(CodeClassifyTemplateVO templateVO, String codeClassifyOid) {
      UIFormDefineVO formDefineVO = new UIFormDefineVO();
      formDefineVO.setOid(templateVO.getOid());
      formDefineVO.setBtmType(templateVO.getBtmTypeId());
      if (StringUtils.isBlank(codeClassifyOid)) {
         codeClassifyOid = templateVO.getCodeclassifyoid();
      }
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
    /**
     * 模板属性转换为表单定义的信息
     *
     * @param templateVO      模板的显示对象
     * @param codeClassifyOid 分类的主键,为空的时候,获取模板所属的分类主键.用于产生分类注入
     * @return 表格的信息
     */
    private UIFormDefineVO wrapperFormDefineByTemplate(CodeClassifyTemplateVO templateVO, String codeClassifyOid) {
        UIFormDefineVO formDefineVO = new UIFormDefineVO();
        formDefineVO.setOid(templateVO.getOid());
        formDefineVO.setBtmType(templateVO.getBtmTypeId());
        if (StringUtils.isBlank(codeClassifyOid)) {
            codeClassifyOid = templateVO.getCodeclassifyoid();
        }
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
        List<UIFormItemVO> itemVOS = new ArrayList<>();
      List<UIFormItemVO> itemVOS = new ArrayList<>();
      Map<String, List<CodeClassifyTemplateAttrVO>> attrGroupMap = new HashMap<>();
      if (Func.isNotEmpty(templateVO.getAttributes())) {
@@ -1432,300 +1588,301 @@
            itemVOS.add(formItemVO);
         });
      }
        //处理属性分组
        if (!CollectionUtils.isEmpty(attrGroupMap)) {
            //按照分组的属性排列,找到每一个分组的第一个属性
            for (String key : attrGroupMap.keySet()) {
                List<CodeClassifyTemplateAttrVO> value = attrGroupMap.get(key);
                //找到这个分组的属性的第一个
                CodeClassifyTemplateAttrVO attrVO = value.stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).findFirst().get();
                //我们找到这个属性在最终的itemVOs里的位置
                UIFormItemVO lineVO = new UIFormItemVO();
                lineVO.setField(attrVO.getId() + "_line");
                lineVO.setType("line");
                lineVO.setText(key);
      //处理属性分组
      if (!CollectionUtils.isEmpty(attrGroupMap)) {
         //按照分组的属性排列,找到每一个分组的第一个属性
         for (String key : attrGroupMap.keySet()) {
            List<CodeClassifyTemplateAttrVO> value = attrGroupMap.get(key);
            //找到这个分组的属性的第一个
            CodeClassifyTemplateAttrVO attrVO = value.stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).findFirst().get();
            //我们找到这个属性在最终的itemVOs里的位置
            UIFormItemVO lineVO = new UIFormItemVO();
            lineVO.setField(attrVO.getId() + "_line");
            lineVO.setType("line");
            lineVO.setText(key);
            List<CodeClassifyTemplateAttrVO> collect = value.stream().filter(s -> "true".equals(s.getFormDisplayFlag())).collect(Collectors.toList());
            if(collect.size() == 0){
            if (collect.size() == 0) {
               continue;
            }
            //找位置
                for (int i = 0; i < itemVOS.size(); i++) {
                    UIFormItemVO record = itemVOS.get(i);
                    if (record.getField().equalsIgnoreCase(attrVO.getId())) {
                        itemVOS.add(i, lineVO);
                        break;
                    }
                }
            }
        }
            for (int i = 0; i < itemVOS.size(); i++) {
               UIFormItemVO record = itemVOS.get(i);
               if (record.getField().equalsIgnoreCase(attrVO.getId())) {
                  itemVOS.add(i, lineVO);
                  break;
               }
            }
         }
      }
        CodeOrderDTO orderDTO = new CodeOrderDTO();
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        if (!CollectionUtils.isEmpty(orderDTO.getData())) {
            orderDTO.getData().forEach((key, value) -> {
                for (int i = 0; i < itemVOS.size(); i++) {
                    UIFormItemVO itemVO = itemVOS.get(i);
                    if (itemVO.getField().equalsIgnoreCase(key)) {
                        itemVO.setDefaultValue(value);
                        break;
                    }
                }
            });
        }
        formDefineVO.setItems(itemVOS);
        //查询是否有分类注入的
        return formDefineVO;
    }
      CodeOrderDTO orderDTO = new CodeOrderDTO();
      switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
      if (!CollectionUtils.isEmpty(orderDTO.getData())) {
         orderDTO.getData().forEach((key, value) -> {
            for (int i = 0; i < itemVOS.size(); i++) {
               UIFormItemVO itemVO = itemVOS.get(i);
               if (itemVO.getField().equalsIgnoreCase(key)) {
                  itemVO.setDefaultValue(value);
                  break;
               }
            }
         });
      }
      formDefineVO.setItems(itemVOS);
      //查询是否有分类注入的
      return formDefineVO;
   }
    /**
     * 属性类型与js中的字段类型的映射
     */
    private static Map<String, String> vciFieldTypeMap = new HashMap<String, String>() {{
        put(VciFieldTypeEnum.VTString.name(), "text");
        put(VciFieldTypeEnum.VTInteger.name(), "text");
        put(VciFieldTypeEnum.VTLong.name(), "text");
        put(VciFieldTypeEnum.VTDouble.name(), "text");
        put(VciFieldTypeEnum.VTClob.name(), "text");
        put(VciFieldTypeEnum.VTBoolean.name(), "truefalse");
        put(VciFieldTypeEnum.VTDateTime.name(), "datetime");
        put(VciFieldTypeEnum.VTDate.name(), "datetime");
        put(VciFieldTypeEnum.VTTime.name(), "datetime");
        put(VciFieldTypeEnum.VTFilePath.name(), "file");
    }};
   /**
    * 属性类型与js中的字段类型的映射
    */
   private static Map<String, String> vciFieldTypeMap = new HashMap<String, String>() {{
      put(VciFieldTypeEnum.VTString.name(), "text");
      put(VciFieldTypeEnum.VTInteger.name(), "text");
      put(VciFieldTypeEnum.VTLong.name(), "text");
      put(VciFieldTypeEnum.VTDouble.name(), "text");
      put(VciFieldTypeEnum.VTClob.name(), "text");
      put(VciFieldTypeEnum.VTBoolean.name(), "truefalse");
      put(VciFieldTypeEnum.VTDateTime.name(), "datetime");
      put(VciFieldTypeEnum.VTDate.name(), "datetime");
      put(VciFieldTypeEnum.VTTime.name(), "datetime");
      put(VciFieldTypeEnum.VTFilePath.name(), "file");
   }};
    /**
     * 模板属性转换为表单的字段
     *
     * @param attrVO  模板属性
     * @param btmType 业务类型
     * @return 表单的字段
     */
    @Override
    public UIFormItemVO templateAttr2FormField(CodeClassifyTemplateAttrVO attrVO, String btmType) {
   /**
    * 模板属性转换为表单的字段
    *
    * @param attrVO  模板属性
    * @param btmType 业务类型
    * @return 表单的字段
    */
   @Override
   public UIFormItemVO templateAttr2FormField(CodeClassifyTemplateAttrVO attrVO, String btmType) {
        UIFormItemVO itemVO = new UIFormItemVO();
        if (SECRET_FILED.equalsIgnoreCase(attrVO.getId())) {
      UIFormItemVO itemVO = new UIFormItemVO();
      if (SECRET_FILED.equalsIgnoreCase(attrVO.getId())) {
//         attrVO.setEnumid(OsEnumServiceImpl.MY_DATA_SECRET);
            attrVO.setEnumId(MY_DATA_SECRET);
        }
        itemVO.setField(attrVO.getId());
        itemVO.setText(attrVO.getName());
        itemVO.setType(vciFieldTypeMap.getOrDefault(attrVO.getAttributeDataType(), "text"));
        if (VciBaseUtil.getBoolean(attrVO.getTextAreaFlag())) {
            itemVO.setType("textarea");
        }
        if (VciFieldTypeEnum.VTLong.name().equalsIgnoreCase(attrVO.getAttributeDataType())
                || VciFieldTypeEnum.VTInteger.name().equalsIgnoreCase(attrVO.getAttributeDataType())
                || VciFieldTypeEnum.VTDouble.name().equalsIgnoreCase(attrVO.getAttributeDataType())) {
            itemVO.setVerify("number");
        }
        itemVO.setReadOnly(VciBaseUtil.getBoolean(attrVO.getReadOnlyFlag()));
        itemVO.setKeyAttr(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag()));
        itemVO.setRequired(VciBaseUtil.getBoolean(attrVO.getRequireFlag()));
        itemVO.setDefaultValue(attrVO.getDefaultValue());
        itemVO.setDateFormate(attrVO.getCodeDateFormat());
        itemVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getFormDisplayFlag()));
        itemVO.setVerify(attrVO.getVerifyRule());
        itemVO.setPrefix(attrVO.getPrefixValue());
        itemVO.setSuffix(attrVO.getSuffixValue());
        itemVO.setTooltips(attrVO.getExplain());
        itemVO.setInputTip(attrVO.getInputTip());
        itemVO.setSelectLibFlag(attrVO.getLibraryIdentification());
        //看看是否有枚举
        if ((StringUtils.isNotBlank(attrVO.getEnumString())
                && !"[]".equalsIgnoreCase(attrVO.getEnumString())) ||
                StringUtils.isNotBlank(attrVO.getEnumId())) {
            itemVO.setType("combox");
            itemVO.setComboxKey(attrVO.getEnumId());
            if (StringUtils.isNotBlank(attrVO.getEnumString())) {
                //指定的下拉框内容
                itemVO.setData(JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class));
                if (StringUtils.isBlank(attrVO.getEnumId())) {
                    itemVO.setComboxKey(itemVO.getField() + "_data");
                }
            }
        }
        //看是否有参照
        if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) {
            itemVO.setType("refer");
            itemVO.setShowField(itemVO.getField() + "name");
            if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
                // 配置的内容
                // itemVO.setReferConfig(JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class));
         attrVO.setEnumId(MY_DATA_SECRET);
      }
      itemVO.setField(attrVO.getId());
      itemVO.setText(attrVO.getName());
      itemVO.setType(vciFieldTypeMap.getOrDefault(attrVO.getAttributeDataType(), "text"));
      if (VciBaseUtil.getBoolean(attrVO.getTextAreaFlag())) {
         itemVO.setType("textarea");
      }
      if (VciFieldTypeEnum.VTLong.name().equalsIgnoreCase(attrVO.getAttributeDataType())
         || VciFieldTypeEnum.VTInteger.name().equalsIgnoreCase(attrVO.getAttributeDataType())
         || VciFieldTypeEnum.VTDouble.name().equalsIgnoreCase(attrVO.getAttributeDataType())) {
         itemVO.setVerify("number");
      }
      itemVO.setReadOnly(VciBaseUtil.getBoolean(attrVO.getReadOnlyFlag()));
      itemVO.setKeyAttr(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag()));
      itemVO.setRequired(VciBaseUtil.getBoolean(attrVO.getRequireFlag()));
      itemVO.setDefaultValue(attrVO.getDefaultValue());
      itemVO.setDateFormate(attrVO.getCodeDateFormat());
      itemVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getFormDisplayFlag()));
      itemVO.setVerify(attrVO.getVerifyRule());
      itemVO.setPrefix(attrVO.getPrefixValue());
      itemVO.setSuffix(attrVO.getSuffixValue());
      itemVO.setTooltips(attrVO.getExplain());
      itemVO.setInputTip(attrVO.getInputTip());
      itemVO.setSelectLibFlag(attrVO.getLibraryIdentification());
      //看看是否有枚举
      if ((StringUtils.isNotBlank(attrVO.getEnumString())
         && !"[]".equalsIgnoreCase(attrVO.getEnumString())) ||
         StringUtils.isNotBlank(attrVO.getEnumId())) {
         itemVO.setType("combox");
         itemVO.setComboxKey(attrVO.getEnumId());
         if (StringUtils.isNotBlank(attrVO.getEnumString())) {
            //指定的下拉框内容
            itemVO.setData(JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class));
            if (StringUtils.isBlank(attrVO.getEnumId())) {
               itemVO.setComboxKey(itemVO.getField() + "_data");
            }
         }
      }
      //看是否有参照
      if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) {
         itemVO.setType("refer");
         itemVO.setShowField(itemVO.getField() + "name");
         if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
            // 配置的内容
            // itemVO.setReferConfig(JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class));
            itemVO.setReferConfig(referConfigToUIUiTable(attrVO.getReferConfig()));
            } else {
                UIFormReferVO formReferVO = new UIFormReferVO();
                formReferVO.setType("default");
                formReferVO.setReferType(attrVO.getReferBtmId());
                itemVO.setReferConfig(formReferVO);
            }
        }
         } else {
            UIFormReferVO formReferVO = new UIFormReferVO();
            formReferVO.setType("default");
            formReferVO.setReferType(attrVO.getReferBtmId());
            itemVO.setReferConfig(formReferVO);
         }
      }
        //如果是组合规则,分类注入的,显示为只读
        if (StringUtils.isNotBlank(attrVO.getComponentRule())) {
            itemVO.setReadOnly(true);
            itemVO.setTooltips("本属性为组合规则");
            itemVO.setRequired(false);
        }
        if (StringUtils.isNotBlank(attrVO.getClassifyInvokeAttr())) {
            itemVO.setReadOnly(!VciBaseUtil.getBoolean(attrVO.getClassifyInvokeEditFlag()));
            itemVO.setTooltips("本属性是分类注入");
            itemVO.setRequired(false);
        }
      //如果是组合规则,分类注入的,显示为只读
      if (StringUtils.isNotBlank(attrVO.getComponentRule())) {
         itemVO.setReadOnly(true);
         itemVO.setTooltips("本属性为组合规则");
         itemVO.setRequired(false);
      }
      if (StringUtils.isNotBlank(attrVO.getClassifyInvokeAttr())) {
         itemVO.setReadOnly(!VciBaseUtil.getBoolean(attrVO.getClassifyInvokeEditFlag()));
         itemVO.setTooltips("本属性是分类注入");
         itemVO.setRequired(false);
      }
        if (VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(itemVO.getField())) {
            //是生命周期状态
            itemVO.setType("combox");
            itemVO.setComboxKey(btmType + LC_STATUS_SUBFIX);
        }
        return itemVO;
    }
      if (VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(itemVO.getField())) {
         //是生命周期状态
         itemVO.setType("combox");
         itemVO.setComboxKey(btmType + LC_STATUS_SUBFIX);
      }
      return itemVO;
   }
    /**
     * 封装相似项查询的列表
     *
     * @param templateVO 模板的显示对象
     * @param uiInfoVO   页面的信息
     */
    private void wrapperResemble(CodeClassifyTemplateVO templateVO, MdmUIInfoVO uiInfoVO) {
        List<CodeClassifyTemplateAttrVO> resembleAttrList = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getSameRepeatAttrFlag())
                || VciQueryWrapperForDO.ID_FIELD.equalsIgnoreCase(s.getId())).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(resembleAttrList) && resembleAttrList.size() > 1) {
            UITableDefineVO resembleTable = new UITableDefineVO();
            resembleTable.setOid(templateVO.getOid());
            resembleTable.setBtmType(templateVO.getBtmTypeId());
            resembleTable.setDisplayQueryArea(false);
            resembleTable.setPageVO(new UITablePageVO());
            //处理所有的列,这个模板没有合并的表头的情况
            List<UITableFieldVO> fieldVOList = new ArrayList<>();
            resembleAttrList.forEach(attrVO -> {
                UITableFieldVO tableFieldVO = templateAttr2TableField(attrVO, false);
                tableFieldVO.setHidden(false);
                fieldVOList.add(tableFieldVO);
            });
            List<List<UITableFieldVO>> cols = new ArrayList<>();
            cols.add(fieldVOList);
            resembleTable.setCols(cols);
            uiInfoVO.setResembleTableVO(resembleTable);
        }
    }
   /**
    * 封装相似项查询的列表
    *
    * @param templateVO 模板的显示对象
    * @param uiInfoVO   页面的信息
    */
   private void wrapperResemble(CodeClassifyTemplateVO templateVO, MdmUIInfoVO uiInfoVO) {
      List<CodeClassifyTemplateAttrVO> resembleAttrList = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getSameRepeatAttrFlag())
         || VciQueryWrapperForDO.ID_FIELD.equalsIgnoreCase(s.getId())).collect(Collectors.toList());
      if (!CollectionUtils.isEmpty(resembleAttrList) && resembleAttrList.size() > 1) {
         UITableDefineVO resembleTable = new UITableDefineVO();
         resembleTable.setOid(templateVO.getOid());
         resembleTable.setBtmType(templateVO.getBtmTypeId());
         resembleTable.setDisplayQueryArea(false);
         resembleTable.setPageVO(new UITablePageVO());
         //处理所有的列,这个模板没有合并的表头的情况
         List<UITableFieldVO> fieldVOList = new ArrayList<>();
         resembleAttrList.forEach(attrVO -> {
            UITableFieldVO tableFieldVO = templateAttr2TableField(attrVO, false);
            tableFieldVO.setHidden(false);
            fieldVOList.add(tableFieldVO);
         });
         List<List<UITableFieldVO>> cols = new ArrayList<>();
         cols.add(fieldVOList);
         resembleTable.setCols(cols);
         uiInfoVO.setResembleTableVO(resembleTable);
      }
   }
    /**
     * 模板属性转换为表格显示的配置
     *
     * @param attrVO  模板属性
     * @param forEdit 是否是编辑所需
     * @return 表格的字段
     */
    @Override
    public UITableFieldVO templateAttr2TableField(CodeClassifyTemplateAttrVO attrVO, boolean forEdit) {
        UITableFieldVO fieldVO = new UITableFieldVO();
        if (SECRET_FILED.equalsIgnoreCase(attrVO.getId())) {
            attrVO.setEnumId(MY_DATA_SECRET);
        }
        fieldVO.setField(attrVO.getId());
        fieldVO.setTitle(attrVO.getName());
        fieldVO.setFieldType(vciFieldTypeMap.getOrDefault(attrVO.getAttributeDataType(), "text"));
        fieldVO.setSort(true);
        fieldVO.setSortField(fieldVO.getField());
        fieldVO.setQueryField(fieldVO.getField());
        if (forEdit) {
            fieldVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getFormDisplayFlag()));
        } else {
            fieldVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getTableDisplayFlag()));
        }
        if (attrVO.getAttrTableWidth() != null && attrVO.getAttrTableWidth() > 0) {
            fieldVO.setMinWidth(Integer.valueOf(attrVO.getAttrTableWidth()));
            fieldVO.setWidth(Integer.valueOf(attrVO.getAttrTableWidth()));
        }
        //看看是否有枚举
        if ((StringUtils.isNotBlank(attrVO.getEnumString())
                && !"[]".equalsIgnoreCase(attrVO.getEnumString())) ||
                StringUtils.isNotBlank(attrVO.getEnumId())) {
            fieldVO.setFieldType("combox");
            fieldVO.setField(fieldVO.getField() + "Text");
            fieldVO.setComboxKey(attrVO.getEnumId());
            if (StringUtils.isNotBlank(attrVO.getEnumString())) {
                //指定的下拉框内容
                fieldVO.setData(JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class));
                if (StringUtils.isBlank(attrVO.getEnumId())) {
                    fieldVO.setComboxKey(fieldVO.getField() + "_data");
                }
            } else {
                List<KeyValue> osEnumItemVOList = VciOmdUtil.enumsToListKeyVale(EnumCache.getList(attrVO.getEnumId()));
                fieldVO.setData(osEnumItemVOList);
            }
        }
        //看是否有参照
        if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) {
            fieldVO.setFieldType("refer");
            fieldVO.setQueryField(fieldVO.getField());
            fieldVO.setField(fieldVO.getField() + "name");
            fieldVO.setShowField(fieldVO.getField());
            if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
                //配置的内容
                // fieldVO.setReferConfig(JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class));
   /**
    * 模板属性转换为表格显示的配置
    *
    * @param attrVO  模板属性
    * @param forEdit 是否是编辑所需
    * @return 表格的字段
    */
   @Override
   public UITableFieldVO templateAttr2TableField(CodeClassifyTemplateAttrVO attrVO, boolean forEdit) {
      UITableFieldVO fieldVO = new UITableFieldVO();
      if (SECRET_FILED.equalsIgnoreCase(attrVO.getId())) {
         attrVO.setEnumId(MY_DATA_SECRET);
      }
      fieldVO.setField(attrVO.getId());
      fieldVO.setTitle(attrVO.getName());
      fieldVO.setFieldType(vciFieldTypeMap.getOrDefault(attrVO.getAttributeDataType(), "text"));
      fieldVO.setSort(true);
      fieldVO.setSortField(fieldVO.getField());
      fieldVO.setQueryField(fieldVO.getField());
      if (forEdit) {
         fieldVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getFormDisplayFlag()));
      } else {
         fieldVO.setHidden(!VciBaseUtil.getBoolean(attrVO.getTableDisplayFlag()));
      }
      if (attrVO.getAttrTableWidth() != null && attrVO.getAttrTableWidth() > 0) {
         fieldVO.setMinWidth(Integer.valueOf(attrVO.getAttrTableWidth()));
         fieldVO.setWidth(Integer.valueOf(attrVO.getAttrTableWidth()));
      }
      //看看是否有枚举
      if ((StringUtils.isNotBlank(attrVO.getEnumString())
         && !"[]".equalsIgnoreCase(attrVO.getEnumString())) ||
         StringUtils.isNotBlank(attrVO.getEnumId())) {
         fieldVO.setFieldType("combox");
         fieldVO.setField(fieldVO.getField() + "Text");
         fieldVO.setComboxKey(attrVO.getEnumId());
         if (StringUtils.isNotBlank(attrVO.getEnumString())) {
            //指定的下拉框内容
            fieldVO.setData(JSONObject.parseArray(attrVO.getEnumString(), KeyValue.class));
            if (StringUtils.isBlank(attrVO.getEnumId())) {
               fieldVO.setComboxKey(fieldVO.getField() + "_data");
            }
         } else {
            List<KeyValue> osEnumItemVOList = VciOmdUtil.enumsToListKeyVale(EnumCache.getList(attrVO.getEnumId()));
            fieldVO.setData(osEnumItemVOList);
         }
      }
      //看是否有参照
      if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) {
         fieldVO.setFieldType("refer");
         fieldVO.setQueryField(fieldVO.getField());
         fieldVO.setField(fieldVO.getField() + "name");
         fieldVO.setShowField(fieldVO.getField());
         if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
            //配置的内容
            // fieldVO.setReferConfig(JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class));
            fieldVO.setReferConfig(referConfigToUIUiTable(attrVO.getReferConfig()));
            } else {
                UIFormReferVO formReferVO = new UIFormReferVO();
                formReferVO.setType("default");
                formReferVO.setReferType(attrVO.getReferBtmId());
                fieldVO.setReferConfig(formReferVO);
            }
        }
        if (VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(fieldVO.getSortField())) {
            fieldVO.setField("lcstatus_text");
        }
        Map<String, String> eventJsMap = new HashMap<>();
        //超链接与模板是互斥
        if (StringUtils.isNotBlank(attrVO.getTableHref())) {
            String event = fieldVO.getSortField() + "_href";
            eventJsMap.put(event, attrVO.getTableHref());
            fieldVO.setTemplet("function(d){ return '<a class=\"layui-btn layui-btn-intable \" lay-event=\"" + event + "\">d." + fieldVO.getField() + "</a>';}");
        }
        if (StringUtils.isNotBlank(attrVO.getTableDisplayJs())) {
            //直接写function(d){ return xxxxx;}
            fieldVO.setTemplet(attrVO.getTableDisplayJs());
        }
        if (StringUtils.isBlank(fieldVO.getTemplet()) && VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())) {
            fieldVO.setTemplet("function(row,column){return row[column.property]=='true' || row[column.property]=='1'?'是':'否'}");
         } else {
            UIFormReferVO formReferVO = new UIFormReferVO();
            formReferVO.setType("default");
            formReferVO.setReferType(attrVO.getReferBtmId());
            fieldVO.setReferConfig(formReferVO);
         }
      }
      if (VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(fieldVO.getSortField())) {
         fieldVO.setField("lcstatus_text");
      }
      Map<String, String> eventJsMap = new HashMap<>();
      //超链接与模板是互斥
      if (StringUtils.isNotBlank(attrVO.getTableHref())) {
         String event = fieldVO.getSortField() + "_href";
         eventJsMap.put(event, attrVO.getTableHref());
         fieldVO.setTemplet("function(d){ return '<a class=\"layui-btn layui-btn-intable \" lay-event=\"" + event + "\">d." + fieldVO.getField() + "</a>';}");
      }
      if (StringUtils.isNotBlank(attrVO.getTableDisplayJs())) {
         //直接写function(d){ return xxxxx;}
         fieldVO.setTemplet(attrVO.getTableDisplayJs());
      }
      if (StringUtils.isBlank(fieldVO.getTemplet()) && VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())) {
         fieldVO.setTemplet("function(row,column){return row[column.property]=='true' || row[column.property]=='1'?'是':'否'}");
//            fieldVO.setTemplet("function(d){return $webUtil.formateBoolean(d." + fieldVO.getField() + ");}");
        }
        fieldVO.setOptionJsMap(eventJsMap);
        fieldVO.setStyle(attrVO.getTableDisplayStyle());
        fieldVO.setTableDisplayFlag(attrVO.getTableDisplayFlag());
        //列表里不允许直接编辑
        fieldVO.setDateFormate(attrVO.getCodeDateFormat());
        return fieldVO;
    }
      }
      fieldVO.setOptionJsMap(eventJsMap);
      fieldVO.setStyle(attrVO.getTableDisplayStyle());
      fieldVO.setTableDisplayFlag(attrVO.getTableDisplayFlag());
      //列表里不允许直接编辑
      fieldVO.setDateFormate(attrVO.getCodeDateFormat());
      return fieldVO;
   }
   /**
    * 将referconfig转换为JSON格式的UIFormReferVO
    *
    * @param codeReferConfigVO
    * @return
    */
   private UIFormReferVO referConfigToUIUiTable(String codeReferConfigVO){
   private UIFormReferVO referConfigToUIUiTable(String codeReferConfigVO) {
      CodeReferConfigVO codeReferConfig = JSONObject.parseObject(codeReferConfigVO, CodeReferConfigVO.class);
      // 拷贝为以前的老对象
      UIFormReferVO uiFormReferVO = new UIFormReferVO();
      org.springblade.core.tool.utils.BeanUtil.copy(codeReferConfig,uiFormReferVO);
      org.springblade.core.tool.utils.BeanUtil.copy(codeReferConfig, uiFormReferVO);
      // 表格的自定义定义
      UITableCustomDefineVO uiTableConfigVO = new UITableCustomDefineVO();
      uiTableConfigVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1));
      uiTableConfigVO.setPage(new UITablePageVO(codeReferConfig.getLimit(), 1));
      // 列表的列的信息转换
      List<UITableFieldVO> uiTableFieldVOs = new ArrayList<>();
      // 快速查询列
      List<UITableFieldVO> queryColumns = new ArrayList<>();
      if(!CollectionUtils.isEmpty(codeReferConfig.getCodeShowFieldConfigVOS())){
         codeReferConfig.getCodeShowFieldConfigVOS().stream().forEach(showField ->{
      if (!CollectionUtils.isEmpty(codeReferConfig.getCodeShowFieldConfigVOS())) {
         codeReferConfig.getCodeShowFieldConfigVOS().stream().forEach(showField -> {
            UITableFieldVO tableColVO = new UITableFieldVO();
            org.springblade.core.tool.utils.BeanUtil.copy(showField,tableColVO);
            org.springblade.core.tool.utils.BeanUtil.copy(showField, tableColVO);
            tableColVO.setSortField(showField.getAttrSortField());
            uiTableFieldVOs.add(tableColVO);
            if(showField.getIsQuery().equals("true")){
            if (showField.getIsQuery().equals("true")) {
               queryColumns.add(tableColVO);
            }
         });
@@ -1738,234 +1895,234 @@
      uiFormReferVO.setTableConfig(uiTableConfigVO);
      //字段名不一致,需要手动set
      uiFormReferVO.setMuti(StringUtils.isBlank(codeReferConfig.getIsMuti())?false:true);
      uiFormReferVO.setInitSort(new UIFieldSortVO(codeReferConfig.getSortField(),codeReferConfig.getSortType()));
      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())){
         codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{
            whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue());
      if (!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())) {
         codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch -> {
            whereMap.put(srch.getFilterField() + srch.getFilterType(), srch.getFilterValue());
         });
      }
      uiFormReferVO.setWhere(whereMap);
      return uiFormReferVO;
   }
    /**
     * 相似项查询
     *
     * @param orderDTO 编码的相关信息
     * @return 数据列表
     */
    @Override
    public DataGrid<Map<String, String>> resembleQuery(CodeOrderDTO orderDTO) {
        VciBaseUtil.alertNotNull(orderDTO, "申请的信息", orderDTO.getCodeClassifyOid(), "分类主键", orderDTO.getTemplateOid(), "模板主键");
        CodeClassifyFullInfoBO fullInfoBO = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        switchClassifyLevelOnOrder(templateVO, fullInfoBO, orderDTO);
        switchDateAttrOnOrder(templateVO, orderDTO);
        switchComponentAttrOnOrder(templateVO, orderDTO);
        //需要获取是否有相似查询属性
        Map<String, CodeClassifyTemplateAttrVO> attrVOs = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getSameRepeatAttrFlag())).collect(Collectors.toMap(s -> s.getId(), t -> t));
        if (CollectionUtils.isEmpty(attrVOs)) {
            //都没有属性,肯定不能查询了
            return new DataGrid<>();
        }
        Map<String, String> conditionMap = new HashMap<>();
        //我们首先获取有没有查询规则
        CodeResembleRuleVO resembleRuleVO = Optional.ofNullable(getUseResembleRule(fullInfoBO, fullInfoBO.getCurrentClassifyVO())).orElseGet(() -> new CodeResembleRuleVO());
        attrVOs.forEach((attrId, attrVO) -> {
            String value = getValueFromOrderDTO(orderDTO, attrId);
            if (value == null) {
                value = "";
            }
            wrapperResembleConditionMap(value, resembleRuleVO, attrId, conditionMap);
        });
   /**
    * 相似项查询
    *
    * @param orderDTO 编码的相关信息
    * @return 数据列表
    */
   @Override
   public DataGrid<Map<String, String>> resembleQuery(CodeOrderDTO orderDTO) {
      VciBaseUtil.alertNotNull(orderDTO, "申请的信息", orderDTO.getCodeClassifyOid(), "分类主键", orderDTO.getTemplateOid(), "模板主键");
      CodeClassifyFullInfoBO fullInfoBO = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      switchClassifyLevelOnOrder(templateVO, fullInfoBO, orderDTO);
      switchDateAttrOnOrder(templateVO, orderDTO);
      switchComponentAttrOnOrder(templateVO, orderDTO);
      //需要获取是否有相似查询属性
      Map<String, CodeClassifyTemplateAttrVO> attrVOs = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getSameRepeatAttrFlag())).collect(Collectors.toMap(s -> s.getId(), t -> t));
      if (CollectionUtils.isEmpty(attrVOs)) {
         //都没有属性,肯定不能查询了
         return new DataGrid<>();
      }
      Map<String, String> conditionMap = new HashMap<>();
      //我们首先获取有没有查询规则
      CodeResembleRuleVO resembleRuleVO = Optional.ofNullable(getUseResembleRule(fullInfoBO, fullInfoBO.getCurrentClassifyVO())).orElseGet(() -> new CodeResembleRuleVO());
      attrVOs.forEach((attrId, attrVO) -> {
         String value = getValueFromOrderDTO(orderDTO, attrId);
         if (value == null) {
            value = "";
         }
         wrapperResembleConditionMap(value, resembleRuleVO, attrId, conditionMap);
      });
        //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
        if (!CollectionUtils.isEmpty(conditionMap)) {
            Map<String, String> andConditionMap = new HashMap<>();
            andConditionMap.put("t.lastr", "1");
            andConditionMap.put("t.lastv", "1");
            if (StringUtils.isNotBlank(orderDTO.getOid())) {
                andConditionMap.put("t.oid", QueryOptionConstant.NOTEQUAL + orderDTO.getOid());
            }
            conditionMap.putAll(andConditionMap);
            PageHelper pageHelper = new PageHelper(-1);
            pageHelper.addDefaultDesc("id");
            return queryGrid(fullInfoBO.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, pageHelper);
        }
        return new DataGrid<>();
    }
      //没有限制分类,但是一个模板只可能在一个业务类型里面,所以直接查询这个业务类型即可
      if (!CollectionUtils.isEmpty(conditionMap)) {
         Map<String, String> andConditionMap = new HashMap<>();
         andConditionMap.put("t.lastr", "1");
         andConditionMap.put("t.lastv", "1");
         if (StringUtils.isNotBlank(orderDTO.getOid())) {
            andConditionMap.put("t.oid", QueryOptionConstant.NOTEQUAL + orderDTO.getOid());
         }
         conditionMap.putAll(andConditionMap);
         PageHelper pageHelper = new PageHelper(-1);
         pageHelper.addDefaultDesc("id");
         return queryGrid(fullInfoBO.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, pageHelper);
      }
      return new DataGrid<>();
   }
    /**
     * 获取使用的相似查询规则
     *
     * @param fullInfoBO        类全部信息
     * @param currentClassifyVO 当前的分类
     * @return 规则,如果不存在会返回Null
     */
    @Override
    public CodeResembleRuleVO getUseResembleRule(CodeClassifyFullInfoBO fullInfoBO, CodeClassifyVO currentClassifyVO) {
        if (currentClassifyVO == null) {
            return null;
        }
        if (currentClassifyVO != null && StringUtils.isNotBlank(currentClassifyVO.getCodeResembleRuleOid())) {
            //说明已经存在
            return resembleRuleService.getObjectByOid(currentClassifyVO.getCodeResembleRuleOid());
        }
        if (StringUtils.isBlank(currentClassifyVO.getParentCodeClassifyOid())) {
            return null;
        }
        Map<String, CodeClassifyVO> classifyVOMap = fullInfoBO.getParentClassifyVOs().stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
        return getUseResembleRule(fullInfoBO, classifyVOMap.getOrDefault(currentClassifyVO.getParentCodeClassifyOid(), null));
    }
   /**
    * 获取使用的相似查询规则
    *
    * @param fullInfoBO        类全部信息
    * @param currentClassifyVO 当前的分类
    * @return 规则,如果不存在会返回Null
    */
   @Override
   public CodeResembleRuleVO getUseResembleRule(CodeClassifyFullInfoBO fullInfoBO, CodeClassifyVO currentClassifyVO) {
      if (currentClassifyVO == null) {
         return null;
      }
      if (currentClassifyVO != null && StringUtils.isNotBlank(currentClassifyVO.getCodeResembleRuleOid())) {
         //说明已经存在
         return resembleRuleService.getObjectByOid(currentClassifyVO.getCodeResembleRuleOid());
      }
      if (StringUtils.isBlank(currentClassifyVO.getParentCodeClassifyOid())) {
         return null;
      }
      Map<String, CodeClassifyVO> classifyVOMap = fullInfoBO.getParentClassifyVOs().stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
      return getUseResembleRule(fullInfoBO, classifyVOMap.getOrDefault(currentClassifyVO.getParentCodeClassifyOid(), null));
   }
    /**
     * 封装相似项查询的查询条件的映射
     *
     * @param value          值
     * @param resembleRuleVO 相似项规则
     * @param attrId         属性的编号
     * @param conditionMap   查询条件
     */
    @Override
    public void wrapperResembleConditionMap(String value, CodeResembleRuleVO resembleRuleVO, String attrId, Map<String, String> conditionMap) {
        boolean ignoreSpace = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorespaceflag()) || VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
        if (StringUtils.isBlank(value)) {
            //为空的时候就不查询它就是
        } else {
            String queryKey = "";
            String queryValue = "";
            boolean ignoreCase = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
            boolean ignoreWidth = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorewidthflag());
            boolean trimAll = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
            boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
            String temp = "";
            if (ignoreCase && ignoreSpace && ignoreWidth) {
                //忽略大小写,且去空,忽略全半角
                temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte('%s')) " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && ignoreSpace && !ignoreWidth) {
                //忽略大小写、去空、不忽略全半角
                temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && !ignoreSpace && ignoreWidth) {
                //忽略大小写、不去空、忽略全半角
                temp = "UPPER(to_single_byte('%s'))";
            } else if (!ignoreCase && ignoreSpace && ignoreWidth) {
                //不忽略大小写、去空、忽略全半角
                temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte('%s') " + (trimAll ? ",' ','')" : ")");
            } else if (ignoreCase && !ignoreSpace && !ignoreWidth) {
                //忽略大小写、不去空、不忽略全半角
                temp = "UPPER(%s)";
            } else if (!ignoreCase && !ignoreCase && ignoreWidth) {
                //不忽略大小写、不去空、忽略全半角
                temp = "to_single_byte('%s')";
            } else if (!ignoreCase && ignoreSpace && !ignoreWidth) {
                //不忽略大小写、去空、不忽略全半角
                temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")");
            } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) {
                //不忽略大小写、不去空、不忽略全半角
                temp = "%s";
            }
            if (StringUtils.isNotBlank(resembleRuleVO.getLinkCharacter())) {
                List<String> chars = VciBaseUtil.str2List(resembleRuleVO.getLinkCharacter());
                for (int i = 0; i < chars.size(); i++) {
                    String s = chars.get(i);
                    temp = "replace(" + temp + ",'" + s + "','')";
                }
            }
            queryValue = String.format(temp, (trim ? value.trim() : value));
            temp = temp.replace("to_single_byte('%s')", "to_single_byte(%s)");
            queryKey = String.format(temp, "t." + attrId);
            conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue);
        }
    }
   /**
    * 封装相似项查询的查询条件的映射
    *
    * @param value          值
    * @param resembleRuleVO 相似项规则
    * @param attrId         属性的编号
    * @param conditionMap   查询条件
    */
   @Override
   public void wrapperResembleConditionMap(String value, CodeResembleRuleVO resembleRuleVO, String attrId, Map<String, String> conditionMap) {
      boolean ignoreSpace = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorespaceflag()) || VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
      if (StringUtils.isBlank(value)) {
         //为空的时候就不查询它就是
      } else {
         String queryKey = "";
         String queryValue = "";
         boolean ignoreCase = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
         boolean ignoreWidth = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorewidthflag());
         boolean trimAll = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
         boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
         String temp = "";
         if (ignoreCase && ignoreSpace && ignoreWidth) {
            //忽略大小写,且去空,忽略全半角
            temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(to_single_byte('%s')) " + (trimAll ? ",' ','')" : ")");
         } else if (ignoreCase && ignoreSpace && !ignoreWidth) {
            //忽略大小写、去空、不忽略全半角
            temp = (trimAll ? "REPLACE" : "TRIM") + "(UPPER(%s) " + (trimAll ? ",' ','')" : ")");
         } else if (ignoreCase && !ignoreSpace && ignoreWidth) {
            //忽略大小写、不去空、忽略全半角
            temp = "UPPER(to_single_byte('%s'))";
         } else if (!ignoreCase && ignoreSpace && ignoreWidth) {
            //不忽略大小写、去空、忽略全半角
            temp = (trimAll ? "REPLACE" : "TRIM") + "(to_single_byte('%s') " + (trimAll ? ",' ','')" : ")");
         } else if (ignoreCase && !ignoreSpace && !ignoreWidth) {
            //忽略大小写、不去空、不忽略全半角
            temp = "UPPER(%s)";
         } else if (!ignoreCase && !ignoreCase && ignoreWidth) {
            //不忽略大小写、不去空、忽略全半角
            temp = "to_single_byte('%s')";
         } else if (!ignoreCase && ignoreSpace && !ignoreWidth) {
            //不忽略大小写、去空、不忽略全半角
            temp = (trimAll ? "REPLACE" : "TRIM") + "(%s " + (trimAll ? ",' ','')" : ")");
         } else if (!ignoreCase && !ignoreSpace && !ignoreWidth) {
            //不忽略大小写、不去空、不忽略全半角
            temp = "%s";
         }
         if (StringUtils.isNotBlank(resembleRuleVO.getLinkCharacter())) {
            List<String> chars = VciBaseUtil.str2List(resembleRuleVO.getLinkCharacter());
            for (int i = 0; i < chars.size(); i++) {
               String s = chars.get(i);
               temp = "replace(" + temp + ",'" + s + "','')";
            }
         }
         queryValue = String.format(temp, (trim ? "'"+value.trim()+"'" : "'"+value+"'"));
         temp = temp.replace("to_single_byte('%s')", "to_single_byte(%s)");
         queryKey = String.format(temp, "t." + attrId);
         conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue);
      }
   }
    /**
     * 查询编码数据的列表
     *
     * @param btmType      业务类型
     * @param templateVO   模板的对象,需要包含模板的属性
     * @param conditionMap 查询条件
     * @param pageHelper   分页对象
     * @return 数据列表
     */
    @Override
    public DataGrid<Map<String, String>> queryGrid(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
        CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmType, templateVO, conditionMap, pageHelper);
//      List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
   /**
    * 查询编码数据的列表
    *
    * @param btmType      业务类型
    * @param templateVO   模板的对象,需要包含模板的属性
    * @param conditionMap 查询条件
    * @param pageHelper   分页对象
    * @return 数据列表
    */
   @Override
   public DataGrid<Map<String, String>> queryGrid(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
      CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmType, templateVO, conditionMap, pageHelper);
      // List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
      List<Map<String, String>> maps = null;
      try {
         maps = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
      }catch (Exception e){
      } catch (Exception e) {
         String errorMessage = e.getMessage();
         if (errorMessage.contains("无法解析的成员访问表达式")) {
            throw new ServiceException("缺少"+errorMessage.substring(errorMessage.indexOf("[t.") + 1, errorMessage.indexOf("]"))+"字段");
            throw new ServiceException("缺少" + errorMessage.substring(errorMessage.indexOf("[T.") + 1, errorMessage.indexOf("]")) + "字段");
         }
         throw new ServiceException(e.getMessage());
      }
        DataGrid<Map<String, String>> dataGrid = new DataGrid<>();
        List<Map<String, String>> dataList = new ArrayList<>();
        if (!CollectionUtils.isEmpty(maps)) {
            maps.stream().forEach(map -> {
                Map<String, String> data = new HashMap<>();
                for (String s : map.keySet()) {
                    data.put(s.toLowerCase(Locale.ROOT), map.get(s)==null?null:String.valueOf(map.get(s)));
                }
//            map.forEach((key, value) -> {
//               data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
//            });
                dataList.add(data);
            });
            wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), false);
//         maps.stream().forEach(map -> {
//            Map<String, String> data = new HashMap<>();
////            map.forEach((key, value) -> {
////               data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
////            });
//            for (String s : map.keySet()) {
//               data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
//            }
//            dataList.add(data);
//         });
        }
//      dataGrid.setData(dataList);
//      if (!CollectionUtils.isEmpty(maps)) {
//         wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
//         maps.stream().forEach(map -> {
//            Map<String, String> data = new HashMap<>();
////            map.forEach((key, value) -> {
////               data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
////            });
//            for (String s : map.keySet()) {
//               data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
//            }
//            dataList.add(data);
//         });
        dataGrid.setData(dataList);
        dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString()));
//      }
        return dataGrid;
    }
      DataGrid<Map<String, String>> dataGrid = new DataGrid<>();
      List<Map<String, String>> dataList = new ArrayList<>();
      if (!CollectionUtils.isEmpty(maps)) {
         maps.stream().forEach(map -> {
            Map<String, String> data = new HashMap<>();
            for (String s : map.keySet()) {
               data.put(s.toLowerCase(Locale.ROOT), map.get(s) == null ? null : String.valueOf(map.get(s)));
            }
            //   map.forEach((key, value) -> {
            //      data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
            //   });
            dataList.add(data);
         });
         wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), false);
         // maps.stream().forEach(map -> {
         //    Map<String, String> data = new HashMap<>();
         //    map.forEach((key, value) -> {
         //       data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
         //    });
         //    for (String s : map.keySet()) {
         //       data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
         //    }
         //    dataList.add(data);
         // });
      }
      //      dataGrid.setData(dataList);
      //      if (!CollectionUtils.isEmpty(maps)) {
      //         wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
      //         maps.stream().forEach(map -> {
      //            Map<String, String> data = new HashMap<>();
      ////            map.forEach((key, value) -> {
      ////               data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
      ////            });
      //            for (String s : map.keySet()) {
      //               data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
      //            }
      //            dataList.add(data);
      //         });
      dataGrid.setData(dataList);
      dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString()));
      //      }
      return dataGrid;
   }
    /**
     * 封装查询出来的数据
     *
     * @param dataMap              数据的映射
     * @param templateVO           模板的属性
     * @param onlySelectAttrIdList 仅仅查询的属性字段
     * @param form                 表单里使用
     */
    @Override
    public void wrapperData(List<Map<String, String>> dataMap, CodeClassifyTemplateVO templateVO,
                            Collection<String> onlySelectAttrIdList, boolean form) {
        if (onlySelectAttrIdList == null) {
            onlySelectAttrIdList = new ArrayList<>();
        }
        //先转换一下时间格式
        List<String> finalOnlySelectAttrIdList = onlySelectAttrIdList.stream().collect(Collectors.toList());
   /**
    * 封装查询出来的数据
    *
    * @param dataMap              数据的映射
    * @param templateVO           模板的属性
    * @param onlySelectAttrIdList 仅仅查询的属性字段
    * @param form                 表单里使用
    */
   @Override
   public void wrapperData(List<Map<String, String>> dataMap, CodeClassifyTemplateVO templateVO,
                     Collection<String> onlySelectAttrIdList, boolean form) {
      if (onlySelectAttrIdList == null) {
         onlySelectAttrIdList = new ArrayList<>();
      }
      //先转换一下时间格式
      List<String> finalOnlySelectAttrIdList = onlySelectAttrIdList.stream().collect(Collectors.toList());
      List<CodeClassifyTemplateAttrVO> dateFormatAttrVOs = new ArrayList<>();
      List<CodeClassifyTemplateAttrVO> enumAttrVOs = new ArrayList<>();
      if (Func.isNotEmpty(templateVO.getAttributes())) {
@@ -1981,445 +2138,461 @@
         ).collect(Collectors.toList());
      }
        List<String> userIds = new ArrayList<>();
      List<String> userIds = new ArrayList<>();
      List<CodeClassifyTemplateAttrVO> finalDateFormatAttrVOs = dateFormatAttrVOs;
      List<CodeClassifyTemplateAttrVO> finalEnumAttrVOs = enumAttrVOs;
      dataMap.stream().forEach(data -> {
            //处理时间
            if (!form) {
                //表单的时候只能用统一的时间格式
                wrapperDateFormat(finalDateFormatAttrVOs, data);
            }
            //处理枚举
            wrapperEnum(finalEnumAttrVOs, data);
            String lcstatus = data.get(VciQueryWrapperForDO.LC_STATUS_FIELD);
            String copyFromVersion = data.getOrDefault(COPY_FROM_VERSION, "");
            if ((CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(lcstatus) || CodeDefaultLC.AUDITING.getValue().equalsIgnoreCase(lcstatus))
                    && StringUtils.isBlank(copyFromVersion)
            ) {
                data.put(VciQueryWrapperForDO.ID_FIELD, "******");
            }
            data.put(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT), CodeDefaultLC.getTextByValue(lcstatus));
            if (CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(lcstatus)
                    && StringUtils.isNotBlank(copyFromVersion)) {
                data.put(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT), "修改中");
            }
            if (data.containsKey("creator")) {
                userIds.add(data.get("creator"));
            }
            if (data.containsKey("lastmodifier")) {
                userIds.add(data.get("lastmodifier"));
            }
        });
        if (!CollectionUtils.isEmpty(userIds)) {
            Map<String, User> userVOMap = new HashMap<>();
            for (String userId : userIds) {
                if (!StringUtils.isNumeric(userId)) {
                    continue;
                }
                User data = iUserClient.userInfoById(Long.valueOf(userId)).getData();
                if (data != null) {
                    userVOMap.put(String.valueOf(data.getId()), data);
                }
            }
//         Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
            dataMap.stream().forEach(data -> {
                String creator = data.getOrDefault("creator", null);
                if (StringUtils.isNotBlank(creator) && userVOMap.containsKey(creator.toLowerCase(Locale.ROOT))) {
                    data.put("creator", creator + "(" + userVOMap.get(creator.toLowerCase(Locale.ROOT)).getRealName() + ")");
                }
                String lastmodifier = data.getOrDefault("lastmodifier", null);
                if (StringUtils.isNotBlank(lastmodifier) && userVOMap.containsKey(lastmodifier.toLowerCase(Locale.ROOT))) {
                    data.put("lastmodifier", lastmodifier + "(" + userVOMap.get(lastmodifier.toLowerCase(Locale.ROOT)).getRealName() + ")");
                }
            });
        }
    }
         //处理时间
         if (!form) {
            //表单的时候只能用统一的时间格式
            wrapperDateFormat(finalDateFormatAttrVOs, data);
         }
         //处理枚举
         wrapperEnum(finalEnumAttrVOs, data);
         String lcstatus = data.get(VciQueryWrapperForDO.LC_STATUS_FIELD);
         String copyFromVersion = data.getOrDefault(COPY_FROM_VERSION, "");
         if ((CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(lcstatus) || CodeDefaultLC.AUDITING.getValue().equalsIgnoreCase(lcstatus))
            && StringUtils.isBlank(copyFromVersion)
         ) {
            data.put(VciQueryWrapperForDO.ID_FIELD, "******");
         }
         data.put(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT), CodeDefaultLC.getTextByValue(lcstatus));
         if (CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(lcstatus)
            && StringUtils.isNotBlank(copyFromVersion)) {
            data.put(VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT), "修改中");
         }
         if (data.containsKey("creator")) {
            userIds.add(data.get("creator"));
         }
         if (data.containsKey("lastmodifier")) {
            userIds.add(data.get("lastmodifier"));
         }
      });
      if (!CollectionUtils.isEmpty(userIds)) {
         Map<String, User> userVOMap = new HashMap<>();
         for (String userId : userIds) {
            if (!StringUtils.isNumeric(userId)) {
               continue;
            }
            User data = iUserClient.userInfoById(Long.valueOf(userId)).getData();
            if (data != null) {
               userVOMap.put(String.valueOf(data.getId()), data);
            }
         }
         // Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
         dataMap.stream().forEach(data -> {
            String creator = data.getOrDefault("creator", null);
            if (StringUtils.isNotBlank(creator) && userVOMap.containsKey(creator.toLowerCase(Locale.ROOT))) {
               data.put("creator", creator + "(" + userVOMap.get(creator.toLowerCase(Locale.ROOT)).getRealName() + ")");
            }
            String lastmodifier = data.getOrDefault("lastmodifier", null);
            if (StringUtils.isNotBlank(lastmodifier) && userVOMap.containsKey(lastmodifier.toLowerCase(Locale.ROOT))) {
               data.put("lastmodifier", lastmodifier + "(" + userVOMap.get(lastmodifier.toLowerCase(Locale.ROOT)).getRealName() + ")");
            }
         });
      }
   }
   /**
    * 处理时间格式
    *
    * @param dateFormatAttrVOs 时间格式的属性
    * @param data              当前行数据
    */
   private void wrapperDateFormat(Collection<CodeClassifyTemplateAttrVO> dateFormatAttrVOs, Map<String, String> data) {
      if (!CollectionUtils.isEmpty(dateFormatAttrVOs)) {
         dateFormatAttrVOs.stream().forEach(dateFormatAttrVO -> {
            String attrId = dateFormatAttrVO.getId().toLowerCase(Locale.ROOT);
            String oldValue = data.getOrDefault(attrId, null);
            if (StringUtils.isNotBlank(oldValue)) {
               DateConverter dateConverter = new DateConverter();
               try {
                  dateConverter.setAsText(oldValue);
                  Date value = dateConverter.getValue();
                  if (value != null) {
                     data.put(attrId, VciDateUtil.date2Str(value, dateFormatAttrVO.getCodeDateFormat()));
                  }
               } catch (Throwable e) {
                  //转换可能有问题,这就使用原本存储的值
               }
            }
         });
      }
   }
    /**
     * 处理时间格式
     *
     * @param dateFormatAttrVOs 时间格式的属性
     * @param data              当前行数据
     */
    private void wrapperDateFormat(Collection<CodeClassifyTemplateAttrVO> dateFormatAttrVOs, Map<String, String> data) {
        if (!CollectionUtils.isEmpty(dateFormatAttrVOs)) {
            dateFormatAttrVOs.stream().forEach(dateFormatAttrVO -> {
                String attrId = dateFormatAttrVO.getId().toLowerCase(Locale.ROOT);
                String oldValue = data.getOrDefault(attrId, null);
                if (StringUtils.isNotBlank(oldValue)) {
                    DateConverter dateConverter = new DateConverter();
                    try {
                        dateConverter.setAsText(oldValue);
                        Date value = dateConverter.getValue();
                        if (value != null) {
                            data.put(attrId, VciDateUtil.date2Str(value, dateFormatAttrVO.getCodeDateFormat()));
                        }
                    } catch (Throwable e) {
                        //转换可能有问题,这就使用原本存储的值
                    }
                }
            });
        }
    }
    /**
     * 处理枚举的内容,如果不在枚举中,会返回原本的值
     *
     * @param enumAttrVOs 枚举属性
     * @param data        当前行数据
     */
    private void wrapperEnum(Collection<CodeClassifyTemplateAttrVO> enumAttrVOs, Map<String, String> data) {
        //处理枚举的内容,为了兼容以前的数据,如果数据不能使用枚举转换的话,那还是显示以前的值
        if (!CollectionUtils.isEmpty(enumAttrVOs)) {
            enumAttrVOs.stream().forEach(enumAttrVO -> {
   /**
    * 处理枚举的内容,如果不在枚举中,会返回原本的值
    *
    * @param enumAttrVOs 枚举属性
    * @param data        当前行数据
    */
   private void wrapperEnum(Collection<CodeClassifyTemplateAttrVO> enumAttrVOs, Map<String, String> data) {
      //处理枚举的内容,为了兼容以前的数据,如果数据不能使用枚举转换的话,那还是显示以前的值
      if (!CollectionUtils.isEmpty(enumAttrVOs)) {
         enumAttrVOs.stream().forEach(enumAttrVO -> {
//            String attrId = enumAttrVO.getId().toUpperCase(Locale.ROOT);
                String attrId = enumAttrVO.getId().toLowerCase(Locale.ROOT);
                String oldValue = String.valueOf(data.getOrDefault(attrId, null));
                if (StringUtils.isNotBlank(oldValue)) {
                    List<KeyValue> comboxKVs = listComboboxItems(enumAttrVO);
                    String newValue = oldValue;
                    KeyValue keyValue = Optional.ofNullable(comboxKVs).orElseGet(() -> new ArrayList<>()).stream().filter(s -> s.getKey().equalsIgnoreCase(oldValue)).findFirst().orElseGet(() -> null);
                    if (keyValue != null) {
                        newValue = keyValue.getValue();
                    }
                    data.put(attrId + "Text", newValue);
                }
            });
        }
    }
            String attrId = enumAttrVO.getId().toLowerCase(Locale.ROOT);
            String oldValue = String.valueOf(data.getOrDefault(attrId, null));
            if (StringUtils.isNotBlank(oldValue)) {
               List<KeyValue> comboxKVs = listComboboxItems(enumAttrVO);
               String newValue = oldValue;
               KeyValue keyValue = Optional.ofNullable(comboxKVs).orElseGet(() -> new ArrayList<>()).stream().filter(s -> s.getKey().equalsIgnoreCase(oldValue)).findFirst().orElseGet(() -> null);
               if (keyValue != null) {
                  newValue = keyValue.getValue();
               }
               data.put(attrId + "Text", newValue);
            }
         });
      }
   }
    /**
     * 根据模板属性生成相应的sql信息
     *
     * @param btmType      业务类型
     * @param templateVO   模板显示对象,必须包含属性
     * @param conditionMap 查询条件
     * @param pageHelper   分页和排序对象
     * @return sql的相关信息
     */
    @Override
    public CodeTemplateAttrSqlBO getSqlByTemplateVO(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
        //因为参照不一定是在平台的属性池里面设置,所以我们得需要自行处理
        //参考VciQueryWrapper来处理
        //1. 找到所有的字段,
   /**
    * 根据模板属性生成相应的sql信息
    *
    * @param btmType      业务类型
    * @param templateVO   模板显示对象,必须包含属性
    * @param conditionMap 查询条件
    * @param pageHelper   分页和排序对象
    * @return sql的相关信息
    */
   @Override
   public CodeTemplateAttrSqlBO getSqlByTemplateVO(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
      //因为参照不一定是在平台的属性池里面设置,所以我们得需要自行处理
      //参考VciQueryWrapper来处理
      //1. 找到所有的字段,
      Map<String, CodeClassifyTemplateAttrVO> attrVOMap = new HashMap<>();
      List<String> selectFieldList = new ArrayList<>();
      if(Func.isNotEmpty(templateVO.getAttributes())){
      if (Func.isNotEmpty(templateVO.getAttributes())) {
         attrVOMap = templateVO.getAttributes().stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
         selectFieldList = attrVOMap.keySet().stream().collect(Collectors.toList());
      }
        //所有的参照的字段
        Map<String/**属性字段**/, String> joinTableList = new ConcurrentHashMap<>();
      //所有的参照的字段
      Map<String/**属性字段**/, String> joinTableList = new ConcurrentHashMap<>();
      List<CodeClassifyTemplateAttrVO> referAttrVOs = null;
      if (Func.isNotEmpty(templateVO.getAttributes())) {
         referAttrVOs = templateVO.getAttributes().stream().filter(
            s -> StringUtils.isNotBlank(s.getReferBtmId()) || StringUtils.isNotBlank(s.getReferConfig())
         ).collect(Collectors.toList());
      }
        Map<String/**参照的属性**/, String/**实际的字段**/> referFieldMap = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(referAttrVOs)) {
      Map<String/**参照的属性**/, String/**实际的字段**/> referFieldMap = new ConcurrentHashMap<>();
      if (!CollectionUtils.isEmpty(referAttrVOs)) {
         List<String> finalSelectFieldList = selectFieldList;
         referAttrVOs.parallelStream().forEach(attrVO -> {
                UIFormReferVO referVO = null;
                if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
                    referVO = JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class);
                } else {
                    referVO = new UIFormReferVO();
                    referVO.setReferType(attrVO.getReferBtmId());
                    referVO.setValueField(VciQueryWrapperForDO.OID_FIELD);
                    referVO.setTextField("name");
                }
                //使用传入的业务类型查询表
                R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referVO.getReferType()));
            UIFormReferVO referVO = null;
            if (StringUtils.isNotBlank(attrVO.getReferConfig())) {
               referVO = JSONObject.parseObject(attrVO.getReferConfig(), UIFormReferVO.class);
            } else {
               referVO = new UIFormReferVO();
               referVO.setReferType(attrVO.getReferBtmId());
               referVO.setValueField(VciQueryWrapperForDO.OID_FIELD);
               referVO.setTextField("name");
            }
            //使用传入的业务类型查询表
            R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referVO.getReferType()));
//            String referTable = VciBaseUtil.getTableName(referVO.getReferType());
                if (!listR.isSuccess() || listR.getData().size() == 0) {
                    throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
                }
                String referTable = listR.getData().get(0).getTableName();
            if (!listR.isSuccess() || listR.getData().size() == 0) {
               throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            String referTable = listR.getData().get(0).getTableName();
//            String referTable = "pl_code_classify";
                String referTableNick = attrVO.getId() + "0";
                String left = " left join " + referTable + " " + referTableNick + " on " + referTableNick + "." + referVO.getValueField() + " =  t." + attrVO.getId();
                joinTableList.put(attrVO.getId(), left);
                String referShowField = attrVO.getId() + "Name";
                List<String> textFields = VciBaseUtil.str2List(referVO.getTextField());
                String showFieldInSource = "";
                if (textFields.contains("name")) {
                    showFieldInSource = "name";
                } else {
                    showFieldInSource = textFields.get(0);
                }
                referFieldMap.put(attrVO.getId(), referTableNick + "." + showFieldInSource);
                finalSelectFieldList.add(referTableNick + "." + showFieldInSource + " as " + referShowField);
            });
        }
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getDefaultAttrByBtmId(btmType);
            String referTableNick = attrVO.getId() + "0";
            String left = " left join " + referTable + " " + referTableNick + " on " + referTableNick + "." + referVO.getValueField() + " =  t." + attrVO.getId();
            joinTableList.put(attrVO.getId(), left);
            String referShowField = attrVO.getId() + "Name";
            List<String> textFields = VciBaseUtil.str2List(referVO.getTextField());
            String showFieldInSource = "";
            if (textFields.contains("name")) {
               showFieldInSource = "name";
            } else {
               showFieldInSource = textFields.get(0);
            }
            referFieldMap.put(attrVO.getId(), referTableNick + "." + showFieldInSource);
            finalSelectFieldList.add(referTableNick + "." + showFieldInSource + " as " + referShowField);
         });
      }
      R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getDefaultAttrByBtmId(btmType);
        if (allAttributeByBtmId.getData() != null) {
            for (BtmTypeAttributeVO attribute : allAttributeByBtmId.getData().getAttributes()) {
                if (!selectFieldList.contains(attribute.getId()) && !"secretgrade".equalsIgnoreCase(attribute.getId())) {
                    selectFieldList.add(attribute.getId());
                }
            }
        }
      if (allAttributeByBtmId.getData() != null) {
         for (BtmTypeAttributeVO attribute : allAttributeByBtmId.getData().getAttributes()) {
            if (!selectFieldList.contains(attribute.getId()) && !"secretgrade".equalsIgnoreCase(attribute.getId())) {
               selectFieldList.add(attribute.getId());
            }
         }
      }
        if (!selectFieldList.contains(CODE_FIELD)) {
            selectFieldList.add(CODE_FIELD);
        }
        if (!selectFieldList.contains(CODE_CLASSIFY_OID_FIELD)) {
            selectFieldList.add(CODE_CLASSIFY_OID_FIELD);
        }
        if (!selectFieldList.contains(CODE_TEMPLATE_OID_FIELD)) {
            selectFieldList.add(CODE_TEMPLATE_OID_FIELD);
        }
        if (!selectFieldList.contains(CODE_FULL_PATH_FILED)) {
            selectFieldList.add(CODE_FULL_PATH_FILED);
        }
      if (!selectFieldList.contains(CODE_FIELD)) {
         selectFieldList.add(CODE_FIELD);
      }
      if (!selectFieldList.contains(CODE_CLASSIFY_OID_FIELD)) {
         selectFieldList.add(CODE_CLASSIFY_OID_FIELD);
      }
      if (!selectFieldList.contains(CODE_TEMPLATE_OID_FIELD)) {
         selectFieldList.add(CODE_TEMPLATE_OID_FIELD);
      }
      if (!selectFieldList.contains(CODE_FULL_PATH_FILED)) {
         selectFieldList.add(CODE_FULL_PATH_FILED);
      }
        //处理查询条件
        //TODO 验证sql注入
        List<String> andSql = new ArrayList<>();
        List<String> orSql = new ArrayList<>();
        if (!CollectionUtils.isEmpty(conditionMap)) {
            Map<String, String> orConditionMap = new HashMap<>();
            Map<String, String> andCondtionMap = new HashMap<>();
            //先分离or的查询条件,另外当查询条件是空的时候也不查询
            conditionMap.forEach((k, v) -> {
                if (StringUtils.isNotBlank(v)) {
                    if (v.startsWith(QueryOptionConstant.OR)) {
                        orConditionMap.put(k, v.substring(QueryOptionConstant.OR.length()));
                    } else {
                        andCondtionMap.put(k, v);
                    }
                }
            });
      //处理查询条件
      //TODO 验证sql注入
      List<String> andSql = new ArrayList<>();
      List<String> orSql = new ArrayList<>();
      if (!CollectionUtils.isEmpty(conditionMap)) {
         Map<String, String> orConditionMap = new HashMap<>();
         Map<String, String> andCondtionMap = new HashMap<>();
         //先分离or的查询条件,另外当查询条件是空的时候也不查询
         conditionMap.forEach((k, v) -> {
            if (StringUtils.isNotBlank(v)) {
               if (v.startsWith(QueryOptionConstant.OR)) {
                  orConditionMap.put(k, v.substring(QueryOptionConstant.OR.length()));
               } else {
                  andCondtionMap.put(k, v);
               }
            }
         });
         Map<String, CodeClassifyTemplateAttrVO> finalAttrVOMap = attrVOMap;
         andCondtionMap.forEach((k, v) -> {
                andSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, finalAttrVOMap, btmType));
            });
            orConditionMap.forEach((k, v) -> {
                orSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, finalAttrVOMap, btmType));
            });
        }
        //组合起来
        StringBuilder andSb = new StringBuilder();
        andSql.stream().forEach(s -> {
            andSb.append(s).append(SPACE).append(QueryOptionConstant.AND).append(SPACE);
        });
            andSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, finalAttrVOMap, btmType));
         });
         orConditionMap.forEach((k, v) -> {
            orSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, finalAttrVOMap, btmType));
         });
      }
      //组合起来
      StringBuilder andSb = new StringBuilder();
      andSql.stream().forEach(s -> {
         andSb.append(s).append(SPACE).append(QueryOptionConstant.AND).append(SPACE);
      });
        String andString = andSb.toString().trim();
        String endWithSql = QueryOptionConstant.AND;
        if (andString.endsWith(endWithSql)) {
            andString = andString.substring(0, andString.length() - endWithSql.length());
        }
      String andString = andSb.toString().trim();
      String endWithSql = QueryOptionConstant.AND;
      if (andString.endsWith(endWithSql)) {
         andString = andString.substring(0, andString.length() - endWithSql.length());
      }
        String orString = orSql.stream().collect(Collectors.joining(" or "));
        String whereSql = "";
        if (StringUtils.isNotBlank(orString)) {
            if (StringUtils.isBlank(andString)) {
                andString = " 1 = 1 ";
            }
            whereSql = SPACE + "(" + SPACE + andString + SPACE + ") and (" + SPACE + orString + SPACE + ")" + SPACE;
        } else {
            whereSql = andString + SPACE;
        }
        if (attrVOMap.keySet().contains("secretgrade")) {
            Integer userSecret = VciBaseUtil.getCurrentUserSecret();
            if (userSecret == null || userSecret == 0) {
                userSecret = secretService.getMinUserSecret().getData();
            }
            whereSql += " and ( t.secretGrade <= " + userSecret + ") ";
        }
      String orString = orSql.stream().collect(Collectors.joining(" or "));
      String whereSql = "";
      if (StringUtils.isNotBlank(orString)) {
         if (StringUtils.isBlank(andString)) {
            andString = " 1 = 1 ";
         }
         whereSql = SPACE + "(" + SPACE + andString + SPACE + ") and (" + SPACE + orString + SPACE + ")" + SPACE;
      } else {
         whereSql = andString + SPACE;
      }
      if (attrVOMap.keySet().contains("secretgrade")) {
         Integer userSecret = VciBaseUtil.getCurrentUserSecret();
         if (userSecret == null || userSecret == 0) {
            userSecret = secretService.getMinUserSecret().getData();
         }
         whereSql += " and ( t.secretGrade <= " + userSecret + ") ";
      }
//      String tableName = VciBaseUtil.getTableName(btmType);
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
//            String referTable = VciBaseUtil.getTableName(referVO.getReferType());
        String tableName = listR.getData().get(0).getTableName();
        String sql = "select " + selectFieldList.stream().map(s -> (s.contains(".") ? s : ("t." + s))).collect(Collectors.joining(","))
                + " from " + tableName + SPACE + "t" + SPACE
                + joinTableList.values().stream().collect(Collectors.joining(SPACE))
                + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
        if (pageHelper == null) {
            pageHelper = new PageHelper(-1);
        }
        //看看排序
        String orderSql = pageHelper.getOrderSql("t");
        sql += (orderSql == null ? "" : orderSql);
        String whereSubfixForPage = " ) A where rownum < " + (pageHelper.getLimit() * pageHelper.getPage() + 1) + ") where RN >= "
                + (pageHelper.getLimit() * (pageHelper.getPage() - 1) + 1);
        String sqlHasPage = pageHelper.getLimit() > 0 ? ("select * from (select A.*,rownum RN from (" + sql + whereSubfixForPage) : sql;
        String sqlCount = "select count(1) from " + tableName + SPACE + "t" + SPACE + joinTableList.values().stream().collect(Collectors.joining(SPACE))
                + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
      String tableName = listR.getData().get(0).getTableName();
      String sql = "select " + selectFieldList.stream().map(s -> (s.contains(".") ? s : ("t." + s))).collect(Collectors.joining(","))
         + " from " + tableName + SPACE + "t" + SPACE
         + joinTableList.values().stream().collect(Collectors.joining(SPACE))
         + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
      if (pageHelper == null) {
         pageHelper = new PageHelper(-1);
      }
      //看看排序
      String orderSql = pageHelper.getOrderSql("t");
      sql += (orderSql == null ? "" : orderSql);
      String whereSubfixForPage = " ) A where rownum < " + (pageHelper.getLimit() * pageHelper.getPage() + 1) + ") where RN >= "
         + (pageHelper.getLimit() * (pageHelper.getPage() - 1) + 1);
      String sqlHasPage = pageHelper.getLimit() > 0 ? ("select * from (select A.*,rownum RN from (" + sql + whereSubfixForPage) : sql;
      String sqlCount = "select count(1) from " + tableName + SPACE + "t" + SPACE + joinTableList.values().stream().collect(Collectors.joining(SPACE))
         + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
      String sqlId = "select t.ID from " + tableName + SPACE + "t" + SPACE + joinTableList.values().stream().collect(Collectors.joining(SPACE))
         + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
        CodeTemplateAttrSqlBO sqlBO = new CodeTemplateAttrSqlBO();
        sqlBO.setTableName(tableName);
        sqlBO.setJoinTable(joinTableList);
        sqlBO.setNickName("t");
      CodeTemplateAttrSqlBO sqlBO = new CodeTemplateAttrSqlBO();
      sqlBO.setTableName(tableName);
      sqlBO.setJoinTable(joinTableList);
      sqlBO.setNickName("t");
//      sqlBO.setPageHelper(pageHelper);
        sqlBO.setSqlHasPage(sqlHasPage);
        sqlBO.setSqlCount(sqlCount);
        sqlBO.setSqlUnPage(sql);
      sqlBO.setSqlHasPage(sqlHasPage);
      sqlBO.setSqlCount(sqlCount);
      sqlBO.setSqlUnPage(sql);
      sqlBO.setSqlId(sqlId);
        return sqlBO;
    }
      return sqlBO;
   }
    /**
     * 组合查询条件的sql
     *
     * @param key           字段
     * @param value         名字
     * @param referFieldMap 参照的字段
     * @param attrVOMap     属性的映射
     * @return Sql语句
     */
    private String getConditionSql(String key, String value, Map<String/**参照的属性**/, String/**实际的属性**/> referFieldMap, Map<String, CodeClassifyTemplateAttrVO> attrVOMap, String btmType) {
        if (!Func.hasEmpty(new Object[]{key, value}) && !key.endsWith("_ignore")) {
            if (key.endsWith("_like")) {
                String field = UBCSSqlKeyword.getColumn(key, "_like");
                if (referFieldMap.containsKey(field)) {
                    //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧
                    return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "'%" + value + "%'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + value + "%'" + SPACE;
                }
            } else if (key.endsWith("_notequal")) {
                String field = UBCSSqlKeyword.getColumn(key, "_notequal");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + " != " + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + " != " + getStringValueInWhere(field, value, attrVOMap);
                }
            } else if (key.endsWith("_likeleft")) {
                String field = UBCSSqlKeyword.getColumn(key, "_likeleft");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "%" + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "%" + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_likeright")) {
                String field = UBCSSqlKeyword.getColumn(key, "_likeright");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + value + "%" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + getStringValueInWhere(field, value, attrVOMap) + "%" + SPACE;
                }
            } else if (key.endsWith("_notlike")) {
                String field = UBCSSqlKeyword.getColumn(key, "_notlike");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "NO LIKE" + SPACE + "%" + value + "%" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "NO LIKE " + "%" + getStringValueInWhere(field, value, attrVOMap) + "%" + SPACE;
                }
            } else if (key.endsWith("_ge")) {
                String field = UBCSSqlKeyword.getColumn(key, "_ge");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + " >= " + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_le")) {
                //说明是<=的。我们需要先获取一下
                String field = UBCSSqlKeyword.getColumn(key, "_le");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + " <= " + value + "" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + " <= " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_gt")) {
                String field = UBCSSqlKeyword.getColumn(key, "_gt");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "> " + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "> " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_lt")) {
                String field = UBCSSqlKeyword.getColumn(key, "_lt");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "< " + value + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "< " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
                }
            } else if (key.endsWith("_datege")) {
                String field = UBCSSqlKeyword.getColumn(key, "_datege");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + ">= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + ">= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_dategt")) {
                String field = UBCSSqlKeyword.getColumn(key, "_dategt");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "> '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "> '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_dateequal")) {
                String field = UBCSSqlKeyword.getColumn(key, "_dateequal");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_datele")) {
                String field = UBCSSqlKeyword.getColumn(key, "_datele");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "<= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "<= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_datelt")) {
                String field = UBCSSqlKeyword.getColumn(key, "_datelt");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "< '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "< '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_null")) {
                String field = UBCSSqlKeyword.getColumn(key, "_null");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "IS NULL" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "IS NULL" + SPACE;
                }
            } else if (key.endsWith("_notnull")) {
                String field = UBCSSqlKeyword.getColumn(key, "_null");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "IS NOT NULL" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "IS NOT NULL" + SPACE;
                }
            } else if (key.endsWith("_dateequal")) {
                String field = UBCSSqlKeyword.getColumn(key, "_dateequal");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
                }
            } else if (key.endsWith("_equal")) {
                String field = UBCSSqlKeyword.getColumn(key, "_equal");
                if (referFieldMap.containsKey(field)) {
                    return referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
                } else {
                    return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
                }
            } else {
   /**
    * 组合查询条件的sql
    *
    * @param key           字段
    * @param value         名字
    * @param referFieldMap 参照的字段
    * @param attrVOMap     属性的映射
    * @return Sql语句
    */
   private String getConditionSql(String key, String value, Map<String/**参照的属性**/, String/**实际的属性**/> referFieldMap, Map<String, CodeClassifyTemplateAttrVO> attrVOMap, String btmType) {
      if (!Func.hasEmpty(new Object[]{key, value}) && !key.endsWith("_ignore")) {
         if (key.endsWith("_like")) {
            String field = UBCSSqlKeyword.getColumn(key, "_like");
            if (referFieldMap.containsKey(field)) {
               //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧
               return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "'%" + value + "%'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "'%" + value + "%'" + SPACE;
            }
         } else if (key.endsWith("_notequal")) {
            String field = UBCSSqlKeyword.getColumn(key, "_notequal");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + " != " + value + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + " != " + getStringValueInWhere(field, value, attrVOMap);
            }
         } else if (key.endsWith("_likeleft")) {
            String field = UBCSSqlKeyword.getColumn(key, "_likeleft");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "%" + value + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + "%" + getStringValueInWhere(field, value, attrVOMap) + SPACE;
            }
         } else if (key.endsWith("_likeright")) {
            String field = UBCSSqlKeyword.getColumn(key, "_likeright");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + value + "%" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "LIKE " + getStringValueInWhere(field, value, attrVOMap) + "%" + SPACE;
            }
         } else if (key.endsWith("_notlike")) {
            String field = UBCSSqlKeyword.getColumn(key, "_notlike");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "NO LIKE" + SPACE + "%" + value + "%" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "NO LIKE " + "%" + getStringValueInWhere(field, value, attrVOMap) + "%" + SPACE;
            }
         } else if (key.endsWith("_ge")) {
            String field = UBCSSqlKeyword.getColumn(key, "_ge");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + " >= " + value + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
            }
         } else if (key.endsWith("_le")) {
            //说明是<=的。我们需要先获取一下
            String field = UBCSSqlKeyword.getColumn(key, "_le");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + " <= " + value + "" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + " <= " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
            }
         } else if (key.endsWith("_gt")) {
            String field = UBCSSqlKeyword.getColumn(key, "_gt");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "> " + value + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "> " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
            }
         } else if (key.endsWith("_lt")) {
            String field = UBCSSqlKeyword.getColumn(key, "_lt");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "< " + value + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "< " + getStringValueInWhere(field, value, attrVOMap) + SPACE;
            }
         } else if (key.endsWith("_datege")) {
            String field = UBCSSqlKeyword.getColumn(key, "_datege");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + ">= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + ">= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_dategt")) {
            String field = UBCSSqlKeyword.getColumn(key, "_dategt");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "> '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "> '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_dateequal")) {
            String field = UBCSSqlKeyword.getColumn(key, "_dateequal");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_datele")) {
            String field = UBCSSqlKeyword.getColumn(key, "_datele");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "<= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "<= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_datelt")) {
            String field = UBCSSqlKeyword.getColumn(key, "_datelt");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "< '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "< '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_null")) {
            String field = UBCSSqlKeyword.getColumn(key, "_null");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "IS NULL" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "IS NULL" + SPACE;
            }
         } else if (key.endsWith("_notnull")) {
            String field = UBCSSqlKeyword.getColumn(key, "_null");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "IS NOT NULL" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "IS NOT NULL" + SPACE;
            }
         } else if (key.endsWith("_dateequal")) {
            String field = UBCSSqlKeyword.getColumn(key, "_dateequal");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "= '" + DateUtil.parse(String.valueOf(value), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + DateUtil.parse(String.valueOf(getStringValueInWhere(field, value, attrVOMap)), "yyyy-MM-dd HH:mm:ss") + "'" + SPACE;
            }
         } else if (key.endsWith("_equal")) {
            String field = UBCSSqlKeyword.getColumn(key, "_equal");
            if (referFieldMap.containsKey(field)) {
               return referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
            } else {
               return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
            }
         } else if (key.endsWith("_in")) {
            String field = UBCSSqlKeyword.getColumn(key, "_in");
            if (referFieldMap.containsKey(field)) {
               return VciBaseUtil.toInSql(referFieldMap.get(field), value);  //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
            } else {
               //TODO:暂时没考虑IN>1000条的问题
               //return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
               return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
            }
         } else if (key.endsWith("_notin")) {
            String field = UBCSSqlKeyword.getColumn(key, "_in");
            if (referFieldMap.containsKey(field)) {
               return VciBaseUtil.toInSql(referFieldMap.get(field), value);  //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
            } else {
               //return (field.contains(".") ? "" : "t.") + field + SPACE + "not in (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
               return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
            }
         } else {
//                if (referFieldMap.containsKey(key)) {
//                    //说明是参照的,我们参照的查询都认为是字符串,如果是时间格式的查询肯定有问题,
//                    String selectKey = referFieldMap.get(key);
//                    return getSqlByValue(selectKey, value, null, btmType);
//                } else {
                return getSqlByValue(key, value, attrVOMap, btmType);
            return getSqlByValue(key, value, attrVOMap, btmType);
//                }
            }
        }
        return "";
         }
      }
      return "";
      /*if (key.endsWith("_begin")) {
         //说明是>=的。我们需要先获取一下
@@ -2448,685 +2621,735 @@
            return getSqlByValue(key, value, attrVOMap,btmType);
         }
      }*/
   }
    }
   /**
    * 获取查询条件中的值的,处理不同的类型
    *
    * @param value 值
    * @param field 字段名称
    * @return 日期或者时间格式会包括to_date,字符串会加'
    */
   private String getStringValueInWhere(String field, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap) {
      if ((field.contains(".") && !field.toLowerCase(Locale.ROOT).startsWith("t.")) || attrVOMap == null
         || !field.replace("t.", "").matches(RegExpConstant.LETTER) || value.startsWith(ONLY)) {
         //说明可能是指定的某个条件,直接返回
         if (value.startsWith(ONLY)) {
            value = value.replace(ONLY, "");
         }
         if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
            return value;
         }
         if (field.contains(".") && attrVOMap != null && attrVOMap.containsKey(field.split("\\.")[0].toLowerCase(Locale.ROOT))) {
            //是参照
            return "'" + value + "'";
         } else {
            return value;
         }
      } else {
         //看看是不是这个对象里的属性
         if (attrVOMap.containsKey(field)) {
            VciFieldTypeEnum fieldTypeEnum = VciFieldTypeEnum.valueOf(attrVOMap.get(field).getAttributeDataType());
            if ("ts".equalsIgnoreCase(field)) {
               return "to_timestamp('" + value + "', '" + DATETIME_FORMAT + ".ff')";
            }
            DateConverter dateConverter = new DateConverter();
            if (VciFieldTypeEnum.VTDateTime.equals(fieldTypeEnum)) {
               //实际上,数据库都是timestamp的类型. TODO:虽然没能解决查询日期的问题,但是能暂时解决报错问题
               if (value.contains("*")) {
                  value = value.replace("*", "%");
                  return "'" + value + "'";
               } else {
                  value = value.replace("*", "");
                  dateConverter.setAsText(value);
                  return "to_date('" + dateConverter.getAsText(VciDateUtil.DateTimeFormat) + "','" + DATETIME_FORMAT + "')";
               }
            } else if (VciFieldTypeEnum.VTDate.equals(fieldTypeEnum)) {
               if (value.contains("*")) {
                  value = value.replace("*", "%");
                  return "'" + value + "'";
               } else {
                  value = value.replace("*", "");
                  dateConverter.setAsText(value);
                  return "to_date('" + dateConverter.getAsText(VciDateUtil.DateFormat) + "','" + DATE_FORMAT + "')";
               }
            } else if (VciFieldTypeEnum.VTDouble.equals(fieldTypeEnum)
               || VciFieldTypeEnum.VTLong.equals(fieldTypeEnum)
               || VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
               return value;
            } else {
               if(value.contains("IN//")){
                  return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
               }
               return "'" + value + "'";
            }
         } else {
            if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
               return value;
            }else if(value.contains("IN//")){
               //暂时不考虑>1000的情况,因为搜索一般也不会出现搜索1000条的情况
               //return MybatisParameterUtil.convertToOrConditions(field, Func.toStrList(value.replace("IN//","")));
               return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
            }else{
               return "'" + value + "'";
            }
         }
      }
    /**
     * 获取查询条件中的值的,处理不同的类型
     *
     * @param value 值
     * @param field 字段名称
     * @return 日期或者时间格式会包括to_date,字符串会加'
     */
    private String getStringValueInWhere(String field, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap) {
        if ((field.contains(".") && !field.toLowerCase(Locale.ROOT).startsWith("t.")) || attrVOMap == null
                || !field.replace("t.", "").matches(RegExpConstant.LETTER) || value.startsWith(ONLY)) {
            //说明可能是指定的某个条件,直接返回
            if (value.startsWith(ONLY)) {
                value = value.replace(ONLY, "");
            }
            if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
                return value;
            }
            if (field.contains(".") && attrVOMap != null && attrVOMap.containsKey(field.split("\\.")[0].toLowerCase(Locale.ROOT))) {
                //是参照
                return "'" + value + "'";
            } else {
                return value;
            }
        } else {
            //看看是不是这个对象里的属性
            if (attrVOMap.containsKey(field)) {
                VciFieldTypeEnum fieldTypeEnum = VciFieldTypeEnum.valueOf(attrVOMap.get(field).getAttributeDataType());
                if ("ts".equalsIgnoreCase(field)) {
                    return "to_timestamp('" + value + "', '" + DATETIME_FORMAT + ".ff')";
                }
                DateConverter dateConverter = new DateConverter();
                if (VciFieldTypeEnum.VTDateTime.equals(fieldTypeEnum)) {
                    //实际上,数据库都是timestamp的类型.
                    dateConverter.setAsText(value);
                    return "to_date('" + dateConverter.getAsText(VciDateUtil.DateTimeFormat) + "','" + DATETIME_FORMAT + "')";
                } else if (VciFieldTypeEnum.VTDate.equals(fieldTypeEnum)) {
                    dateConverter.setAsText(value);
                    return "to_date('" + dateConverter.getAsText(VciDateUtil.DateFormat) + "','" + DATE_FORMAT + "')";
                } else if (VciFieldTypeEnum.VTDouble.equals(fieldTypeEnum)
                        || VciFieldTypeEnum.VTLong.equals(fieldTypeEnum)
                        || VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
                    return value;
                } else {
                    return "'" + value + "'";
                }
            } else {
                if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
                    return value;
                }
                return "'" + value + "'";
            }
        }
   }
    }
   /**
    * 查看是否默认属性
    *
    * @param selectKey
    * @param btmType
    * @return
    */
   private boolean isDefaultAttr(String selectKey, String btmType) {
      if (StringUtils.isBlank(btmType)) {
         return false;
      }
      R<BtmTypeVO> r = btmTypeClient.getDefaultAttrByBtmId(btmType);
      List<BtmTypeAttributeVO> attributes = r.getData().getAttributes();
      if (!r.isSuccess() || attributes.isEmpty()) {
         return false;
      }
      return attributes.stream().anyMatch(item -> item.getId().equals(selectKey));
   }
    /**
     * 查看是否默认属性
     *
     * @param selectKey
     * @param btmType
     * @return
     */
    private boolean isDefaultAttr(String selectKey, String btmType) {
        if (StringUtils.isBlank(btmType)) {
            return false;
        }
        R<BtmTypeVO> r = btmTypeClient.getDefaultAttrByBtmId(btmType);
        List<BtmTypeAttributeVO> attributes = r.getData().getAttributes();
        if (!r.isSuccess() || attributes.isEmpty()) {
            return false;
        }
        return attributes.stream().anyMatch(item -> item.getId().equals(selectKey));
    }
    /**
     * 封装最终的sql语句中的值部分
     *
     * @param selectKey 查询的字段
     * @param value     值
     * @param attrVOMap 属性的显示对象映射
     * @return sql里的值
     */
    private String getSqlByValue(String selectKey, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap, String btmType) {
        StringBuilder sql = new StringBuilder();
        // TODO 已完善
        if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || isDefaultAttr(selectKey, btmType) || selectKey.matches(RegExpConstant.LETTER))) {
            sql.append("t.");
        }
        if (value.startsWith(QueryOptionConstant.IN)) {
            if(value.startsWith(QueryOptionConstant.IN+"('") && value.endsWith("')")){
   /**
    * 封装最终的sql语句中的值部分
    *
    * @param selectKey 查询的字段
    * @param value     值
    * @param attrVOMap 属性的显示对象映射
    * @return sql里的值
    */
   private String getSqlByValue(String selectKey, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap, String btmType) {
      StringBuilder sql = new StringBuilder();
      // TODO 已完善
      if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || isDefaultAttr(selectKey, btmType) || selectKey.matches(RegExpConstant.LETTER))) {
         sql.append("t.");
      }
      if (value.startsWith(QueryOptionConstant.IN)) {
         if (value.startsWith(QueryOptionConstant.IN + "('") && value.endsWith("')")) {
            sql.append(selectKey)
               .append(SPACE)
               .append("in")
               .append(SPACE)
               .append(value.replace(QueryOptionConstant.IN, ""));
         }else{
         } else {
            sql.append(selectKey)
                    .append(SPACE)
                    .append("in")
                    .append(SPACE)
                    .append("(")
                    .append(value.replace(QueryOptionConstant.IN, ""))
                    .append(")");
               .append(SPACE)
               .append("in")
               .append(SPACE)
               .append("(")
               .append(value.replace(QueryOptionConstant.IN, ""))
               .append(")");
         }
        } else if (value.startsWith(QueryOptionConstant.NOTIN)) {
            sql.append(selectKey)
                    .append(SPACE)
                    .append("not in")
                    .append(SPACE)
                    .append("(")
                    .append(value.replace(QueryOptionConstant.NOTIN, ""))
                    .append(")");
        } else if (value.startsWith(QueryOptionConstant.NOTEQUAL)) {
            value = value.replace(QueryOptionConstant.NOTEQUAL, "");
            value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.NOTEQUAL)
                    .append(SPACE)
                    .append(value);
        } else if (value.startsWith(QueryOptionConstant.MORETHAN)) {
            value = value.replace(QueryOptionConstant.MORETHAN, "");
            value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.MORETHAN)
                    .append(SPACE)
                    .append(value);
        } else if (value.startsWith(QueryOptionConstant.MORE)) {
            value = value.replace(QueryOptionConstant.MORE, "");
            value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.MORE)
                    .append(SPACE)
                    .append(value);
        } else if (value.startsWith(QueryOptionConstant.LESSTHAN)) {
            value = value.replace(QueryOptionConstant.LESSTHAN, "");
            value = getStringValueInWhere(selectKey, value, attrVOMap);
      } else if (value.startsWith(QueryOptionConstant.NOTIN)) {
         sql.append(selectKey)
            .append(SPACE)
            .append("not in")
            .append(SPACE)
            .append("(")
            .append(value.replace(QueryOptionConstant.NOTIN, ""))
            .append(")");
      } else if (value.startsWith(QueryOptionConstant.NOTEQUAL)) {
         value = value.replace(QueryOptionConstant.NOTEQUAL, "");
         value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.NOTEQUAL)
            .append(SPACE)
            .append(value);
      } else if (value.startsWith(QueryOptionConstant.MORETHAN)) {
         value = value.replace(QueryOptionConstant.MORETHAN, "");
         value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.MORETHAN)
            .append(SPACE)
            .append(value);
      } else if (value.startsWith(QueryOptionConstant.MORE)) {
         value = value.replace(QueryOptionConstant.MORE, "");
         value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.MORE)
            .append(SPACE)
            .append(value);
      } else if (value.startsWith(QueryOptionConstant.LESSTHAN)) {
         value = value.replace(QueryOptionConstant.LESSTHAN, "");
         value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.LESSTHAN)
                    .append(SPACE)
                    .append(value);
        } else if (value.startsWith(QueryOptionConstant.LESS)) {
            value = value.replace(QueryOptionConstant.LESS, "");
            value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.LESSTHAN)
            .append(SPACE)
            .append(value);
      } else if (value.startsWith(QueryOptionConstant.LESS)) {
         value = value.replace(QueryOptionConstant.LESS, "");
         value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.LESS)
                    .append(SPACE)
                    .append(value);
        } else if (value.startsWith(QueryOptionConstant.ISNOTNULL)) {
            sql.append(selectKey)
                    .append(SPACE)
                    .append(" is not null");
        } else if (value.startsWith(QueryOptionConstant.ISNULL)) {
            sql.append(selectKey)
                    .append(SPACE)
                    .append(" is null");
        } else if (value.contains("*")) {
            //说明是like,或者lefe like ,right like
            value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append("like")
                    .append(SPACE)
                    //   .append("'")
                    .append(value.replace("*", "%"))
                    //  .append("'")
                    .append(SPACE);
        } else {
            value = value.replace(SPECIAL_CHAR, REQUIRED_CHAR);
            value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.LESS)
            .append(SPACE)
            .append(value);
      } else if (value.startsWith(QueryOptionConstant.ISNOTNULL)) {
         sql.append(selectKey)
            .append(SPACE)
            .append(" is not null");
      } else if (value.startsWith(QueryOptionConstant.ISNULL)) {
         sql.append(selectKey)
            .append(SPACE)
            .append(" is null");
      } else if (value.contains("*")) {
         //说明是like,或者lefe like ,right like
         value = getStringValueInWhere(selectKey, value, attrVOMap);
         sql.append(selectKey)
            .append(SPACE)
            .append("like")
            .append(SPACE)
            //   .append("'")
            .append(value.replace("*", "%"))
            //  .append("'")
            .append(SPACE);
      } else {
         value = value.replace(SPECIAL_CHAR, REQUIRED_CHAR);
         value = getStringValueInWhere(selectKey, value, attrVOMap);
            sql.append(selectKey)
                    .append(SPACE)
                    .append(QueryOptionConstant.EQUAL)
                    .append(SPACE)
                    .append(value);
        }
        sql.append(SPACE);
        return sql.toString();
    }
         sql.append(selectKey)
            .append(SPACE)
            .append(QueryOptionConstant.EQUAL)
            .append(SPACE)
            .append(value);
      }
      sql.append(SPACE);
      return sql.toString();
   }
    /**
     * 修改主题库数据
     *
     * @param orderDTO 数据的内容,不用包含码段的内容了
     */
    @Override
    public void editSaveCode(CodeOrderDTO orderDTO) {
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容都为空", orderDTO.getOid(), "数据主键",
                orderDTO.getCodeClassifyOid(), "主题库分类的主键");
   /**
    * 修改主题库数据
    *
    * @param orderDTO 数据的内容,不用包含码段的内容了
    */
   @Override
   public void editSaveCode(CodeOrderDTO orderDTO) {
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容都为空", orderDTO.getOid(), "数据主键",
         orderDTO.getCodeClassifyOid(), "主题库分类的主键");
//      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        //找业务类型,然后使用主键去获取数据库里的数据
        List<BaseModel> cbos = selectByTypeAndOid(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), orderDTO.getOid());
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      //找业务类型,然后使用主键去获取数据库里的数据
      List<BaseModel> cbos = selectByTypeAndOid(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), orderDTO.getOid());
        if (CollectionUtils.isEmpty(cbos)) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        BaseModel cbo = cbos.get(0);
        if (cbo == null) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        if (!cbo.getTs().toString().contains(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) {
            throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
        }
        if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) {
            throw new VciBaseException("数据不是{0}的状态,不允许修改", new String[]{CodeDefaultLC.EDITING.getText()});
        }
      if (CollectionUtils.isEmpty(cbos)) {
         throw new VciBaseException(DATA_OID_NOT_EXIST);
      }
      BaseModel cbo = cbos.get(0);
      if (cbo == null) {
         throw new VciBaseException(DATA_OID_NOT_EXIST);
      }
      if (!cbo.getTs().toString().contains(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) {
         throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
      }
      if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) {
         throw new VciBaseException("数据不是{0}的状态,不允许修改", new String[]{CodeDefaultLC.EDITING.getText()});
      }
        //注意模板不能使用数据存储的时候的模板,因为可能会变化
      //注意模板不能使用数据存储的时候的模板,因为可能会变化
      String codeClassifyOid=cbo.getData().get(CODE_CLASSIFY_OID_FIELD.toUpperCase());
      String codeClassifyOid = cbo.getData().get(CODE_CLASSIFY_OID_FIELD.toUpperCase());
      orderDTO.setCodeClassifyOid(codeClassifyOid);
//      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
//      CodeClassifyTemplateVO templateVO= this.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      orderDTO.setTemplateOid(templateVO.getOid());
      //1. 判断必输项
      checkRequiredAttrOnOrder(templateVO, orderDTO);
        //2.先注入,再组合,最后校验
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
        switchComponentAttrOnOrder(templateVO, orderDTO);
        //4.校验规则
        checkVerifyOnOrder(templateVO, orderDTO);
        //5.判断关键属性
        checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
        //6.校验枚举的内容是否正确
        checkEnumOnOrder(templateVO, orderDTO);
        //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
        switchDateAttrOnOrder(templateVO, orderDTO);
        //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
        copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
        //企业码和集团码的不修改
        cbo.setDescription(orderDTO.getDescription());
      //2.先注入,再组合,最后校验
      switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
      //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
      switchComponentAttrOnOrder(templateVO, orderDTO);
      //4.校验规则
      checkVerifyOnOrder(templateVO, orderDTO);
      //5.判断关键属性
      checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
      //6.校验枚举的内容是否正确
      checkEnumOnOrder(templateVO, orderDTO);
      //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
      switchDateAttrOnOrder(templateVO, orderDTO);
      //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
      copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
      //企业码和集团码的不修改
      cbo.setDescription(orderDTO.getDescription());
//        cbo.setName(orderDTO.getName());
        try {
            cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
            cbo.setName(orderDTO.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
      try {
         cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
         cbo.setName(orderDTO.getName());
      } catch (Exception e) {
         e.printStackTrace();
      }
//      cbo.getData().putAll(orderDTO.getData());
        cbo.setLastModifyTime(new Date());
        cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      cbo.setLastModifyTime(new Date());
      cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      R r = updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), Collections.singletonList(cbo));
      if(!r.isSuccess()){
      if (!r.isSuccess()) {
         throw new ServiceException(r.getMsg());
      }
      batchSaveSelectChar(templateVO, Collections.singletonList(cbo));
    }
   }
    /**
     * 删除主题库数据
     *
     * @param deleteBatchDTO 数据的内容,必须要有主键和分类主键
     */
    @Override
    public void deleteCode(CodeDeleteBatchDTO deleteBatchDTO) {
        VciBaseUtil.alertNotNull(deleteBatchDTO, "编码申请相关的属性和码段的内容都为空", deleteBatchDTO.getOidList(), "数据主键",
                deleteBatchDTO.getCodeClassifyOid(), "主题库分类的主键");
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(deleteBatchDTO.getCodeClassifyOid());
        //找业务类型,然后使用主键去获取数据库里的数据
        Collection<String> oidCollection = new ArrayList<>();
        for (Collection<String> strings : VciBaseUtil.switchCollectionForOracleIn(deleteBatchDTO.getOidList())) {
            oidCollection.addAll(strings);
        }
   /**
    * 删除主题库数据
    *
    * @param deleteBatchDTO 数据的内容,必须要有主键和分类主键
    */
   @Override
   public void deleteCode(CodeDeleteBatchDTO deleteBatchDTO) {
      VciBaseUtil.alertNotNull(deleteBatchDTO, "编码申请相关的属性和码段的内容都为空", deleteBatchDTO.getOidList(), "数据主键",
         deleteBatchDTO.getCodeClassifyOid(), "主题库分类的主键");
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(deleteBatchDTO.getCodeClassifyOid());
      //找业务类型,然后使用主键去获取数据库里的数据
      Collection<String> oidCollection = new ArrayList<>();
      for (Collection<String> strings : VciBaseUtil.switchCollectionForOracleIn(deleteBatchDTO.getOidList())) {
         oidCollection.addAll(strings);
      }
//      List<CodeWupin> cboList = codeWupinMapper.selectBatchIds(oidCollection);
        List<BaseModel> cboList = new ArrayList<>();
        oidCollection.stream().forEach(oids -> {
            Map<String, String> conditionMap = new HashMap<>();
      List<BaseModel> cboList = new ArrayList<>();
      oidCollection.stream().forEach(oids -> {
         Map<String, String> conditionMap = new HashMap<>();
//         conditionMap.put("oid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oids.toArray(new String[0])) + ")");
            List<BaseModel> cbos = selectByTypeAndOid(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), oids);
         List<BaseModel> cbos = selectByTypeAndOid(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), oids);
//            boService.queryCBO(classifyFullInfo.getTopClassifyVO().getBtmtypeid(), conditionMap);
            cboList.addAll(cbos);
        });
        if (CollectionUtils.isEmpty(cboList)) {
            throw new VciBaseException("数据全部在系统中不存在");
        }
        List<BaseModel> editCBOs = cboList.stream().filter(s -> !CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList());
        if (!CollectionUtils.isEmpty(editCBOs)) {
            BaseModel cbo = editCBOs.get(0);
            throw new VciBaseException("编码为{0}等共{1}条数据的状态不是[{2}],不允许删除", new String[]{cbo.getId(), String.valueOf(editCBOs.size()), CodeDefaultLC.EDITING.getText()});
        }
         cboList.addAll(cbos);
      });
      if (CollectionUtils.isEmpty(cboList)) {
         throw new VciBaseException("数据全部在系统中不存在");
      }
      List<BaseModel> editCBOs = cboList.stream().filter(s -> !CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList());
      if (!CollectionUtils.isEmpty(editCBOs)) {
         BaseModel cbo = editCBOs.get(0);
         throw new VciBaseException("编码为{0}等共{1}条数据的状态不是[{2}],不允许删除", new String[]{cbo.getId(), String.valueOf(editCBOs.size()), CodeDefaultLC.EDITING.getText()});
      }
        //只能删除自己创建的数据
        String userId = String.valueOf(AuthUtil.getUser().getAccount());
        for (BaseModel clientBusinessObject : cboList) {
            String creator = clientBusinessObject.getCreator();
            if (!userId.equalsIgnoreCase(creator)) {
                throw new VciBaseException("编码为" + clientBusinessObject.getId() + "的数据不是当前用户创建,不能删除!");
            }
      //只能删除自己创建的数据
      String userId = String.valueOf(AuthUtil.getUser().getAccount());
      for (BaseModel clientBusinessObject : cboList) {
         String creator = clientBusinessObject.getCreator();
         if (!userId.equalsIgnoreCase(creator)) {
            throw new VciBaseException("编码为" + clientBusinessObject.getId() + "的数据不是当前用户创建,不能删除!");
         }
        }
      }
//      BatchCBO batchCBO = new BatchCBO();
//      batchCBO.getDeleteCbos().addAll(cboList);
//      WebUtil.setPersistence(false);
//      batchCBO.copyFromOther(
        productCodeService.recycleCode(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), deleteBatchDTO.getOidList());
      productCodeService.recycleCode(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), deleteBatchDTO.getOidList());
//      baseMapper.deleteBatchIds(cboList);
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(),
                "'" + (StringUtils.join(cboList.stream().map(BaseModel::getOid).collect(Collectors.toSet()), "','")) + "'");
        //      );
      //使用传入的业务类型查询表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(),
         "'" + (StringUtils.join(cboList.stream().map(BaseModel::getOid).collect(Collectors.toSet()), "','")) + "'");
      //      );
//      WebUtil.setPersistence(true);
//      boService.persistenceBatch(batchCBO);
    }
   }
    /**
     * 使用分类和阶段的编号,获取包含的属性
     *
     * @param codeClassifyOid 分类的主键
     * @param phase           阶段的名称
     * @return 属性的英文名称
     */
    @Override
    public List<String> listPhaseAttrByClassifyOid(String codeClassifyOid, String phase) {
        CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid, false);
        //找阶段
        return phaseAttrService.listAttrByTemplateOidAndPhaseId(templateVO.getOid(), phase);
    }
   /**
    * 使用分类和阶段的编号,获取包含的属性
    *
    * @param codeClassifyOid 分类的主键
    * @param phase           阶段的名称
    * @return 属性的英文名称
    */
   @Override
   public List<String> listPhaseAttrByClassifyOid(String codeClassifyOid, String phase) {
      CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid, false);
      //找阶段
      return phaseAttrService.listAttrByTemplateOidAndPhaseId(templateVO.getOid(), phase);
   }
    /**
     * 路径上包含当前分类的所有分类信息
     *
     * @param codeClassifyOid 分类的主键
     * @return 分类树
     */
    @Override
    public List<Tree> hasSelfClassifyTree(String codeClassifyOid) {
        if (StringUtils.isBlank(codeClassifyOid)) {
            return new ArrayList<>();
        }
        CodeClassifyFullInfoBO fullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
        //查询子
        List<CodeClassifyVO> childrenClassifys = classifyService.listChildrenClassify(codeClassifyOid, true, "id", true);
        Map<String, CodeClassifyVO> classifyVOMap = new HashMap<>();
        classifyVOMap.putAll(Optional.ofNullable(fullInfo.getParentClassifyVOs()).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)));
        classifyVOMap.putAll(Optional.ofNullable(childrenClassifys).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)));
        TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(CodeClassifyServiceImpl.PARENT_FIELD_NAME.toLowerCase(Locale.ROOT));
        return revisionModelUtil.doList2Trees(classifyVOMap.values().stream().collect(Collectors.toList()), treeWrapperOptions, (CodeClassifyVO s) -> {
            return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
                    .getLcStatus()) ? (" 【停用】 ") : "");
        });
    }
   /**
    * 路径上包含当前分类的所有分类信息
    *
    * @param codeClassifyOid 分类的主键
    * @return 分类树
    */
   @Override
   public List<Tree> hasSelfClassifyTree(String codeClassifyOid) {
      if (StringUtils.isBlank(codeClassifyOid)) {
         return new ArrayList<>();
      }
      CodeClassifyFullInfoBO fullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
      //查询子
      List<CodeClassifyVO> childrenClassifys = classifyService.listChildrenClassify(codeClassifyOid, true, "id", true);
      Map<String, CodeClassifyVO> classifyVOMap = new HashMap<>();
      classifyVOMap.putAll(Optional.ofNullable(fullInfo.getParentClassifyVOs()).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)));
      classifyVOMap.putAll(Optional.ofNullable(childrenClassifys).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)));
      TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(CodeClassifyServiceImpl.PARENT_FIELD_NAME.toLowerCase(Locale.ROOT));
      return revisionModelUtil.doList2Trees(classifyVOMap.values().stream().collect(Collectors.toList()), treeWrapperOptions, (CodeClassifyVO s) -> {
         return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
            .getLcStatus()) ? (" 【停用】 ") : "");
      });
   }
    /**
     * 使用分类获取对应的数据
     *
     * @param codeClassifyOid 分类的主键
     * @param templateOid     模板的主键
     * @param conditionMap    查询条件
     * @param pageHelper      分页的对象
     * @return 数据(包含下级分类)
     */
    @Override
    public DataGrid<Map<String, String>> gridTableDataByClassifyOid(String codeClassifyOid, String templateOid, Map<String, String> conditionMap, PageHelper pageHelper) {
        //1. 使用分类获取所有的下级分类,然后根据分类查询对应的数据
        //2. 全部使用当前分类的当前模板来展示内容
        //3. 如果模板上有枚举注入,组合规则,和参照的,需要执行转换
        //4. 查询的时候,直接使用codeclsfpath来查询
        CodeClassifyVO topClassifyVO = classifyService.getTopClassifyVO(codeClassifyOid);
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
        if (topClassifyVO == null || StringUtils.isBlank(topClassifyVO.getBtmTypeId())) {
            throw new VciBaseException("当前主题库分类没有顶层分类,或者顶层分类没有设置业务类型");
        }
        String btmTypeId = topClassifyVO.getBtmTypeId();
        if (StringUtils.isBlank(btmTypeId)) {
            return new DataGrid<>("这个分类所属顶层分类没有添加业务类型");
        }
        if (conditionMap == null) {
            conditionMap = new HashMap<>();
        }
        pageHelper.addDefaultDesc("createTime");
//        pageHelper.addDefaultDesc("id");
        if (!classifyService.checkHasChild(codeClassifyOid)) {
            conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, codeClassifyOid);
        } else {
   /**
    * 使用分类获取对应的数据
    *
    * @param codeClassifyOid 分类的主键
    * @param templateOid     模板的主键
    * @param conditionMap    查询条件
    * @param pageHelper      分页的对象
    * @return 数据(包含下级分类)
    */
   @Override
   public DataGrid<Map<String, String>> gridTableDataByClassifyOid(String codeClassifyOid, String templateOid, Map<String, String> conditionMap, PageHelper pageHelper) {
      //1. 使用分类获取所有的下级分类,然后根据分类查询对应的数据
      //2. 全部使用当前分类的当前模板来展示内容
      //3. 如果模板上有枚举注入,组合规则,和参照的,需要执行转换
      //4. 查询的时候,直接使用codeclsfpath来查询
      CodeClassifyVO topClassifyVO = classifyService.getTopClassifyVO(codeClassifyOid);
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
      if (topClassifyVO == null || StringUtils.isBlank(topClassifyVO.getBtmTypeId())) {
         throw new VciBaseException("当前主题库分类没有顶层分类,或者顶层分类没有设置业务类型");
      }
      String btmTypeId = topClassifyVO.getBtmTypeId();
      if (StringUtils.isBlank(btmTypeId)) {
         return new DataGrid<>("这个分类所属顶层分类没有添加业务类型");
      }
      if (conditionMap == null) {
         conditionMap = new HashMap<>();
      }
      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);
         if (Func.isEmpty(classifyData)) {
            throw new ServiceException("业务类型中英文名称和查询条件配置不一致,请修改业务类型中分类表英文名称为" + MdmBtmTypeConstant.CODE_CLASSIFY);
         }
            conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " +
         conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, QueryOptionConstant.IN + "(select oid from " +
            classifyData.get(0).getTableName() + " where lcstatus='" + FrameWorkDefaultValueConstant
                    .FRAMEWORK_DATA_ENABLED + "' start with parentCodeClassifyOid = '" + codeClassifyOid +
                    "' CONNECT BY PRIOR OID = parentCodeClassifyOid )");
        }
        conditionMap.put("t.lastr", "1");
        conditionMap.put("t.lastv", "1");
        return queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
//        List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
//        //参照让平台直接查询就行
//        List<String> finalSelectFieldList = selectFieldList;
//        List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
//                s -> StringUtils.isNotBlank(s.getReferbtmid())
//                        &&
//                        (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
//        ).collect(Collectors.toList());
//        if(!CollectionUtils.isEmpty(referAttrVOs)){
//            for (int i = 0; i < referAttrVOs.size(); i++) {
//                selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
//            }
//        }
//        //我们使用和业务类型的来查询
//        DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
//        //我们需要使用模板来转换
//        if(!CollectionUtils.isEmpty(dataGrid.getData())){
//            wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
//        }
//        return dataGrid;
    }
            .FRAMEWORK_DATA_ENABLED + "' start with parentCodeClassifyOid = '" + codeClassifyOid +
            "' CONNECT BY PRIOR OID = parentCodeClassifyOid )");
      }
      conditionMap.put("t.lastr", "1");
      conditionMap.put("t.lastv", "1");
      DataGrid<Map<String, String>> mapDataGrid = queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
      if(templateVO.getAttributes().isEmpty()){
         throw new ServiceException(String.format("主键为:{}的模板下,模板属性配置为空!",templateVO.getOid()));
      }
      //处理返回数据与模板数据配置的字段不一样问题
      templateVO.getAttributes().stream().forEach(e -> {
         for (Map<String, String> datum : mapDataGrid.getData()) {
            if (datum.containsKey(e.getId().toLowerCase()) && !datum.containsKey(e.getId())) {
               datum.put(e.getId(), datum.get(e.getId().toLowerCase()));
               datum.remove(e.getId().toLowerCase());
            }
         }
      });
      return mapDataGrid;
      //        List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
      //        //参照让平台直接查询就行
      //        List<String> finalSelectFieldList = selectFieldList;
      //        List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
      //                s -> StringUtils.isNotBlank(s.getReferbtmid())
      //                        &&
      //                        (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
      //        ).collect(Collectors.toList());
      //        if(!CollectionUtils.isEmpty(referAttrVOs)){
      //            for (int i = 0; i < referAttrVOs.size(); i++) {
      //                selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
      //            }
      //        }
      //        //我们使用和业务类型的来查询
      //        DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
      //        //我们需要使用模板来转换
      //        if(!CollectionUtils.isEmpty(dataGrid.getData())){
      //            wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
      //        }
      //        return dataGrid;
   }
    /**
     * 批量保存流程执行页面修改的内容
     *
     * @param orderDTOList 编码相关的信息,不需要码段的信息
     * @return 执行结果
     */
    @Override
    public R batchUpdateCode(List<CodeOrderDTO> orderDTOList) {
        VciBaseUtil.alertNotNull(orderDTOList, "编码申请相关的属性内容");
        orderDTOList.forEach(orderDTO -> {
            VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容都为空", orderDTO.getOid(), "数据主键",
                    orderDTO.getCodeClassifyOid(), "主题库分类的主键");
        });
        Map<String, CodeOrderDTO> orderDTOMap = orderDTOList.stream().filter(orderDTO -> orderDTO != null && StringUtils.isNotBlank(orderDTO.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
        List<BaseModel> updateList = new ArrayList<>();
        // 应该都是一个分类下的业务数据,找第一条的就行
        CodeClassifyFullInfoBO topClassifyFullInfo = classifyService.getClassifyFullInfo(orderDTOList.get(0).getCodeClassifyOid());
        if (CollectionUtils.isEmpty(orderDTOMap.keySet())) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
   /**
    * 批量保存流程执行页面修改的内容
    *
    * @param orderDTOList 编码相关的信息,不需要码段的信息
    * @return 执行结果
    */
   @Override
   public R batchUpdateCode(List<CodeOrderDTO> orderDTOList) {
      VciBaseUtil.alertNotNull(orderDTOList, "编码申请相关的属性内容");
      orderDTOList.forEach(orderDTO -> {
         VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容都为空", orderDTO.getOid(), "数据主键",
            orderDTO.getCodeClassifyOid(), "主题库分类的主键");
      });
      Map<String, CodeOrderDTO> orderDTOMap = orderDTOList.stream().filter(orderDTO -> orderDTO != null && StringUtils.isNotBlank(orderDTO.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
      List<BaseModel> updateList = new ArrayList<>();
      // 应该都是一个分类下的业务数据,找第一条的就行
      CodeClassifyFullInfoBO topClassifyFullInfo = classifyService.getClassifyFullInfo(orderDTOList.get(0).getCodeClassifyOid());
      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])));
      List<BaseModel> cboList = selectByTypeAndOid(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), VciBaseUtil.array2String(orderDTOMap.keySet().toArray(new String[0])));
      if (CollectionUtils.isEmpty(cboList)) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
         throw new VciBaseException(DATA_OID_NOT_EXIST);
      }
      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(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) {
                throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
            }
            if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) {
                throw new VciBaseException("数据不是{0}的状态,不允许修改", new String[]{CodeDefaultLC.EDITING.getText()});
            }
            //1. 判断必输项
            CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
            checkRequiredAttrOnOrder(templateVO, orderDTO);
            //2.先注入,再组合,最后校验
            switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
            //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
            switchComponentAttrOnOrder(templateVO, orderDTO);
            //4.校验规则
            checkVerifyOnOrder(templateVO, orderDTO);
            //5.判断关键属性
            checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
            //6.校验枚举的内容是否正确
            checkEnumOnOrder(templateVO, orderDTO);
            //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
            switchDateAttrOnOrder(templateVO, orderDTO);
            //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
            copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
            //企业码和集团码的不修改
            cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
            cbo.setName(orderDTO.getName());
            cbo.setId(code);
            cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
            cbo.setName(orderDTO.getName());
      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(VciDateUtil.date2Str(orderDTO.getTs(), VciDateUtil.DateTimeFormat))) {
            throw new VciBaseException("数据不是最新的,可能他人已经修改,请刷新后再试");
         }
         if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) {
            throw new VciBaseException("数据不是{0}的状态,不允许修改", new String[]{CodeDefaultLC.EDITING.getText()});
         }
         //1. 判断必输项
         CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
         checkRequiredAttrOnOrder(templateVO, orderDTO);
         //2.先注入,再组合,最后校验
         switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
         //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
         switchComponentAttrOnOrder(templateVO, orderDTO);
         //4.校验规则
         checkVerifyOnOrder(templateVO, orderDTO);
         //5.判断关键属性
         checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
         //6.校验枚举的内容是否正确
         checkEnumOnOrder(templateVO, orderDTO);
         //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
         switchDateAttrOnOrder(templateVO, orderDTO);
         //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
         copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
         //企业码和集团码的不修改
         cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
         cbo.setName(orderDTO.getName());
         cbo.setId(code);
         cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
         cbo.setName(orderDTO.getName());
            updateList.add(cbo);
            batchSaveSelectChar(firstTemplateVO, cboList);
        });
        updateBatchByBaseModel(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), updateList);
        return R.success("操作成功!");
    }
         updateList.add(cbo);
         batchSaveSelectChar(firstTemplateVO, cboList);
      });
      updateBatchByBaseModel(topClassifyFullInfo.getTopClassifyVO().getBtmTypeId(), updateList);
      return R.success("操作成功!");
   }
    /**
     * 标记流程中业务数据是否通过
     *
     * @param oid     业务数据主键
     * @param btmName 业务类型
     * @param pass    是否通过
     * @return 执行结果
     */
    @Override
    public R markDataPassing(String oid, String btmName, Boolean pass) {
        VciBaseUtil.alertNotNull(oid, "业务数据主键", btmName, "业务类型", pass, "标记类型");
        boolean flag = true;
        try {
            List<BaseModel> datas = selectByTypeAndOid(btmName, oid);
            if (datas.size() == 0) {
                return R.fail(DATA_OID_NOT_EXIST);
            }
            datas.stream().forEach(data -> data.getData().put("PASSING", String.valueOf(pass)));
            R r = updateBatchByBaseModel(btmName, datas);
            if (!r.isSuccess()) {
                flag = false;
            }
        } catch (Exception e) {
            flag = false;
            e.printStackTrace();
        }
        if (flag) {
            return R.success("标记成功!");
        } else {
            return R.fail("标记失败!");
        }
    }
   /**
    * 标记流程中业务数据是否通过
    *
    * @param oid     业务数据主键
    * @param btmName 业务类型
    * @param pass    是否通过
    * @return 执行结果
    */
   @Override
   public R markDataPassing(String oid, String btmName, Boolean pass) {
      VciBaseUtil.alertNotNull(oid, "业务数据主键", btmName, "业务类型", pass, "标记类型");
      boolean flag = true;
      try {
         List<BaseModel> datas = selectByTypeAndOid(btmName, oid);
         if (datas.size() == 0) {
            return R.fail(DATA_OID_NOT_EXIST);
         }
         datas.stream().forEach(data -> data.getData().put("PASSING", String.valueOf(pass)));
         R r = updateBatchByBaseModel(btmName, datas);
         if (!r.isSuccess()) {
            flag = false;
         }
      } catch (Exception e) {
         flag = false;
         e.printStackTrace();
      }
      if (flag) {
         return R.success("标记成功!");
      } else {
         return R.fail("标记失败!");
      }
   }
    /**
     * 预览组合规则
     *
     * @param orderDTO 预览的信息,包含模板的主键
     * @return key是组合规则的属性。value是组合后的值,。如果缺少某个属性的值,会作为value返回
     */
    @Override
    public Map<String, String> previewCompRule(CodeOrderDTO orderDTO) {
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关信息", orderDTO.getTemplateOid(), "模板的主键");
        //查询分类的信息,查询模板的信息
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        switchComponentAttrOnOrder(templateVO, orderDTO);
        return orderDTO.getData();
    }
   /**
    * 预览组合规则
    *
    * @param orderDTO 预览的信息,包含模板的主键
    * @return key是组合规则的属性。value是组合后的值,。如果缺少某个属性的值,会作为value返回
    */
   @Override
   public Map<String, String> previewCompRule(CodeOrderDTO orderDTO) {
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关信息", orderDTO.getTemplateOid(), "模板的主键");
      //查询分类的信息,查询模板的信息
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
      switchComponentAttrOnOrder(templateVO, orderDTO);
      return orderDTO.getData();
   }
    /**
     * 分类注入的内容预览
     *
     * @param codeClassifyOid 分类的主键
     * @param codeTemplateOid 模板的主键
     * @return key是分类注入的属性,value是注入后的值
     */
    @Override
    public Map<String, String> previewClassify(String codeClassifyOid, String codeTemplateOid) {
        if (StringUtils.isBlank(codeClassifyOid) || StringUtils.isBlank(codeTemplateOid)) {
            return new HashMap<>();
        }
        //查询分类的信息,查询模板的信息
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(codeTemplateOid);
        //
   /**
    * 分类注入的内容预览
    *
    * @param codeClassifyOid 分类的主键
    * @param codeTemplateOid 模板的主键
    * @return key是分类注入的属性,value是注入后的值
    */
   @Override
   public Map<String, String> previewClassify(String codeClassifyOid, String codeTemplateOid) {
      if (StringUtils.isBlank(codeClassifyOid) || StringUtils.isBlank(codeTemplateOid)) {
         return new HashMap<>();
      }
      //查询分类的信息,查询模板的信息
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(codeTemplateOid);
      //
        CodeOrderDTO orderDTO = new CodeOrderDTO();
        orderDTO.setData(new HashMap<>());
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        return orderDTO.getData();
    }
      CodeOrderDTO orderDTO = new CodeOrderDTO();
      orderDTO.setData(new HashMap<>());
      switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
      return orderDTO.getData();
   }
    /**
     * 升版的主题库数据
     *
     * @param orderDTO 数据的内容,不需要包含码段的内容
     */
    @Override
    public void upSaveCode(CodeOrderDTO orderDTO) {
        VciBaseUtil.alertNotNull(orderDTO, "编码数据所在业务类名称", orderDTO.getBtmname());
        String btmName = orderDTO.getBtmname();
        //找业务类型,然后使用主键去获取数据库里的数据
        List<BaseModel> cbos = selectByTypeAndOid(btmName, orderDTO.getCopyFromVersion());
        if (CollectionUtils.isEmpty(cbos)) {
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        BaseModel oldCbo = cbos.get(0);
   /**
    * 升版的主题库数据
    *
    * @param orderDTO 数据的内容,不需要包含码段的内容
    */
   @Override
   public void upSaveCode(CodeOrderDTO orderDTO) {
      VciBaseUtil.alertNotNull(orderDTO, "编码数据所在业务类名称", orderDTO.getBtmname());
      String btmName = orderDTO.getBtmname();
      //找业务类型,然后使用主键去获取数据库里的数据
      List<BaseModel> cbos = selectByTypeAndOid(btmName, orderDTO.getCopyFromVersion());
      if (CollectionUtils.isEmpty(cbos)) {
         throw new VciBaseException(DATA_OID_NOT_EXIST);
      }
      BaseModel oldCbo = cbos.get(0);
        if (!CodeDefaultLC.RELEASED.getValue().equalsIgnoreCase(oldCbo.getLcStatus())) {
            throw new VciBaseException("数据不是{0}的状态,不允许数据更改", new String[]{CodeDefaultLC.RELEASED.getText()});
        }
      if (!CodeDefaultLC.RELEASED.getValue().equalsIgnoreCase(oldCbo.getLcStatus())) {
         throw new VciBaseException("数据不是{0}的状态,不允许数据更改", new String[]{CodeDefaultLC.RELEASED.getText()});
      }
        //根据数据获取分类oid
        String codeClassifyOid = oldCbo.getData().get(CODE_CLASSIFY_OID_FIELD.toUpperCase());
        orderDTO.setCodeClassifyOid(codeClassifyOid);
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = this.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid());
        orderDTO.setTemplateOid(templateVO.getOid());
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容为空", orderDTO.getCopyFromVersion(), "原始数据的主键",
                orderDTO.getCodeClassifyOid(), "主题库分类的主键");
      //根据数据获取分类oid
      String codeClassifyOid = oldCbo.getData().get(CODE_CLASSIFY_OID_FIELD.toUpperCase());
      orderDTO.setCodeClassifyOid(codeClassifyOid);
      CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
      CodeClassifyTemplateVO templateVO = this.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid());
      orderDTO.setTemplateOid(templateVO.getOid());
      VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性的内容为空", orderDTO.getCopyFromVersion(), "原始数据的主键",
         orderDTO.getCodeClassifyOid(), "主题库分类的主键");
        //需要升版
        BaseModel cbo = null;
        cbo = reviseBusinessObject(oldCbo);
        //1. 判断必输项
      //需要升版
      BaseModel cbo = null;
      cbo = reviseBusinessObject(oldCbo);
      //1. 判断必输项
      checkRequiredAttrOnOrder(templateVO, orderDTO);
        //2.先注入,再组合,最后校验
        switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
        //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
        switchComponentAttrOnOrder(templateVO, orderDTO);
        //4.校验规则
        checkVerifyOnOrder(templateVO, orderDTO);
        //5.判断关键属性
        checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
        //6.校验枚举的内容是否正确
        checkEnumOnOrder(templateVO, orderDTO);
        //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
        switchDateAttrOnOrder(templateVO, orderDTO);
        //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
        copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
        //企业码和集团码的不修改
        cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
        cbo.setName(orderDTO.getName());
        cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
        cbo.setName(orderDTO.getName());
        //数据的时候,编码是不变的
        cbo.setCreateTime(cbo.getCreateTime());
      //2.先注入,再组合,最后校验
      switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO);
      //3.处理组合规则。组合规则不能使用编码的属性,因为编码的生成可能是需要属性的
      switchComponentAttrOnOrder(templateVO, orderDTO);
      //4.校验规则
      checkVerifyOnOrder(templateVO, orderDTO);
      //5.判断关键属性
      checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO);
      //6.校验枚举的内容是否正确
      checkEnumOnOrder(templateVO, orderDTO);
      //7.处理时间格式,在数据库里面不论是字符串还是日期格式,都使用相同的格式存储
      switchDateAttrOnOrder(templateVO, orderDTO);
      //默认的内容不能变,所以只需要拷贝自定义的相关属性即可
      copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true);
      //企业码和集团码的不修改
      cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
      cbo.setName(orderDTO.getName());
      cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription()) ? "" : orderDTO.getDescription());
      cbo.setName(orderDTO.getName());
      //数据的时候,编码是不变的
      cbo.setCreateTime(cbo.getCreateTime());
      cbo.setCreator(cbo.getCreator());
        cbo.setLastModifyTime(cbo.getLastModifyTime());
      cbo.setLastModifyTime(cbo.getLastModifyTime());
      cbo.setTenantId(AuthUtil.getTenantId());
      oldCbo.setLastV("0");
      oldCbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
      oldCbo.setLastModifyTime(new Date());
        try {
      try {
         // 修改版次号
         updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
            insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
        } catch (Exception vciError) {
            throw new VciBaseException("数据更改保存出错了", new String[0], vciError);
        }
        batchSaveSelectChar(templateVO, Collections.singletonList(cbo));
    }
         // 插入新的数据
         insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
         //处理码值表,对码值表进行处理替换创建数据的oid
         QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>();
         wrapper.eq("CREATECODEOID", orderDTO.getCopyFromVersion());
         CodeAllCode codeAllCode = codeAllCodeService.getOne(wrapper);
         codeAllCode.setCreateCodeOid(cbo.getOid());
         codeAllCode.setLastModifyTime(new Date());
         codeAllCode.setTs(new Date());
         codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
         codeAllCodeService.updateById(codeAllCode);
         // 记录数据更改日志
         saveLogUtil.operateLog("数据更改", false, StringUtil.format("{}\n修改为:\n{}", JSON.toJSONString(Collections.singletonList(oldCbo)), JSON.toJSONString(Collections.singletonList(cbo))));
      } catch (Exception vciError) {
         // 记录数据更改报错时的日志
         saveLogUtil.operateLog("数据更改", true, vciError.toString());
         throw new VciBaseException("数据更改保存出错了", new String[0], vciError);
      }
    /**
     * 使用码段的主键获取分类的码值内容
     *
     * @param classifySecOid         码段的主键
     * @param parentClassifyValueOid 上级分类的主键
     * @return 分类码值的内容
     */
    @Override
    public List<CodeClassifyValueVO> listCodeClassifyValueBySecOid(String classifySecOid, String parentClassifyValueOid) {
        return classifyValueService.listCodeClassifyValueBySecOid(classifySecOid, parentClassifyValueOid);
    }
      batchSaveSelectChar(templateVO, Collections.singletonList(cbo));
   }
    /**
     * 使用主题库分类获取编码规则
     *
     * @param codeClassifyOid 分类的主键
     * @return 编码规则的内容
     */
    @Override
    public CodeRuleVO getCodeRuleByClassifyOid(String codeClassifyOid) {
        VciBaseUtil.alertNotNull(codeClassifyOid, "分类的主键");
        CodeClassifyVO classifyVO = classifyService.getObjectByOid(codeClassifyOid);
        String codeRuleOid = classifyVO.getCodeRuleOid();
        if (StringUtils.isBlank(codeRuleOid)) {
            //往上找
   /**
    * 使用码段的主键获取分类的码值内容
    *
    * @param classifySecOid         码段的主键
    * @param parentClassifyValueOid 上级分类的主键
    * @return 分类码值的内容
    */
   @Override
   public List<CodeClassifyValueVO> listCodeClassifyValueBySecOid(String classifySecOid, String parentClassifyValueOid) {
      return classifyValueService.listCodeClassifyValueBySecOid(classifySecOid, parentClassifyValueOid);
   }
   /**
    * 使用主题库分类获取编码规则
    *
    * @param codeClassifyOid 分类的主键
    * @return 编码规则的内容
    */
   @Override
   public CodeRuleVO getCodeRuleByClassifyOid(String codeClassifyOid) {
      VciBaseUtil.alertNotNull(codeClassifyOid, "分类的主键");
      CodeClassifyVO classifyVO = classifyService.getObjectByOid(codeClassifyOid);
      String codeRuleOid = classifyVO.getCodeRuleOid();
      if (StringUtils.isBlank(codeRuleOid)) {
         //往上找
         CodeRuleVO classifyFullInfoCodeRule = getCodeRuleByClassifyFullInfo(classifyService.getClassifyFullInfo(codeClassifyOid));
         return toCodeValueApplyStatus(classifyFullInfoCodeRule);
        }
        //查询编码规则
      }
      //查询编码规则
      CodeRuleVO objectHasSecByOid = ruleService.getObjectHasSecByOid(codeRuleOid);
      return toCodeValueApplyStatus(objectHasSecByOid);
    }
   }
   /**
    * 编码申请表单,隐藏、可输、只读转换
    *
    * @param codeRuleVO
    * @return
    */
   private CodeRuleVO toCodeValueApplyStatus(CodeRuleVO codeRuleVO){
      if(codeRuleVO.getSecVOList().isEmpty()){
   private CodeRuleVO toCodeValueApplyStatus(CodeRuleVO codeRuleVO) {
      if (codeRuleVO.getSecVOList().isEmpty()) {
         return codeRuleVO;
      }
      // 可输码段类型
@@ -3149,17 +3372,17 @@
      // 当前规则的所有类型码段
      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)));
      boolean hasAllReadOnlyType = secTypeList.stream().allMatch(item -> readOnlyTypes.stream().anyMatch(item1 -> item.equals(item1)));
      // 全部是只读的码段类型
      if(hasAllReadOnlyType){
      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());
                  secVO.setCodeDateValue(Func.format(new Date(), secVO.getCodeDateFormatStr()));
               } catch (Exception e) {
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:" + e.getMessage());
               }
            }
            return secVO;
@@ -3168,16 +3391,16 @@
         return codeRuleVO;
      }
      // 情况二 全部都是可输入类型的
      boolean hasAllInputType = secTypeList.stream().allMatch(item -> inputTypes.stream().anyMatch(item1-> item.equals(item1)));
      if(hasAllInputType){
      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());
                  secVO.setCodeDateValue(Func.format(new Date(), secVO.getCodeDateFormatStr()));
               } catch (Exception e) {
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:" + e.getMessage());
               }
            }
            return secVO;
@@ -3187,298 +3410,312 @@
      }
      // 情况三包含人为选择的码段,又有只读类型码段的,所有码段都要显示出来,可输设置为1,只读设置为2,隐藏设置为3
      List<CodeBasicSecVO> basicSecVOS = codeRuleVO.getSecVOList().stream().map(secVO -> {
         if(inputTypes.contains(secVO.getSecType())){
         if (inputTypes.contains(secVO.getSecType())) {
            secVO.setCodeValueApplyStatus(1);
         }else if(readOnlyTypes.contains(secVO.getSecType())){
         } else if (readOnlyTypes.contains(secVO.getSecType())) {
            secVO.setCodeValueApplyStatus(2);
         }else{
         } 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());
               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"));
      codeRuleVO.setIsShowHideStatus(hasAllReadOnlyType ? "readOnly" : (hasAllInputType ? "input" : "readAndInput"));
      return codeRuleVO;
   }
    /**
     * 使用分类的全部信息获取编码规则
     *
     * @param fullInfoBO 分类的全部信息
     * @return 规则的内容
     */
    @Override
    public CodeRuleVO getCodeRuleByClassifyFullInfo(CodeClassifyFullInfoBO fullInfoBO) {
        //往上找
        String codeRuleOid = "";
        if (StringUtils.isNotBlank(fullInfoBO.getCurrentClassifyVO().getCodeRuleOid())) {
            codeRuleOid = fullInfoBO.getCurrentClassifyVO().getCodeRuleOid();
        } else {
            if (CollectionUtils.isEmpty(fullInfoBO.getParentClassifyVOs())) {
                //说明已经是最高层级,
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
            List<CodeClassifyVO> parentClassifyVOList = fullInfoBO.getParentClassifyVOs().stream().sorted((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())).collect(Collectors.toList());
            //从最高的level开始获取
            for (int i = parentClassifyVOList.size()-1; i >= 0; i--) {
                CodeClassifyVO record = parentClassifyVOList.get(i);
                if (StringUtils.isNotBlank(record.getCodeRuleOid())) {
                    codeRuleOid = record.getCodeRuleOid();
                    break;
                }
            }
            if (StringUtils.isBlank(codeRuleOid)) {
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
        }
        return ruleService.getObjectHasSecByOid(codeRuleOid);
    }
   /**
    * 使用分类的全部信息获取编码规则
    *
    * @param fullInfoBO 分类的全部信息
    * @return 规则的内容
    */
   @Override
   public CodeRuleVO getCodeRuleByClassifyFullInfo(CodeClassifyFullInfoBO fullInfoBO) {
      //往上找
      String codeRuleOid = "";
      if (StringUtils.isNotBlank(fullInfoBO.getCurrentClassifyVO().getCodeRuleOid())) {
         codeRuleOid = fullInfoBO.getCurrentClassifyVO().getCodeRuleOid();
      } else {
         if (CollectionUtils.isEmpty(fullInfoBO.getParentClassifyVOs())) {
            //说明已经是最高层级,
            throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
         }
         List<CodeClassifyVO> parentClassifyVOList = fullInfoBO.getParentClassifyVOs().stream().sorted((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())).collect(Collectors.toList());
         //从最高的level开始获取
         for (int i = parentClassifyVOList.size() - 1; i >= 0; i--) {
            CodeClassifyVO record = parentClassifyVOList.get(i);
            if (StringUtils.isNotBlank(record.getCodeRuleOid())) {
               codeRuleOid = record.getCodeRuleOid();
               break;
            }
         }
         if (StringUtils.isBlank(codeRuleOid)) {
            throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
         }
      }
      return ruleService.getObjectHasSecByOid(codeRuleOid);
   }
    /**
     * 使用数据主键获取数据的全部信息
     *
     * @param oid         主键
     * @param templateOid 模板的主键
     * @return 数据的内容
     */
    @Override
    public R<List<Map<String, String>>> getDataByOid(String oid, String templateOid) {
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
        //为了防止模板上的业务类型与分类上不对应
        CodeClassifyVO topClassifyVO = classifyService.getTopClassifyVO(templateVO.getCodeclassifyoid());
        String btmId = topClassifyVO.getBtmTypeId();
        //查询数据
        Map<String, String> conditionMap = new HashMap<>();
        conditionMap.put("t.oid", oid);
        CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmId, templateVO, conditionMap, new PageHelper(-1));
        //我们使用和业务类型的来查询
        List<Map> cbosB = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
        List<Map<String, String>> cbos = new ArrayList<>();
        cbosB.stream().forEach(map -> {
            Map<String, String> data = new HashMap<>();
            for (Object o : map.keySet()) {
                data.put(((String) o).toLowerCase(Locale.ROOT), map.get(o)==null?"":String.valueOf(map.get(o)));
            }
            cbos.add(data);
        });
   /**
    * 使用数据主键获取数据的全部信息
    *
    * @param oid         主键
    * @param templateOid 模板的主键
    * @return 数据的内容
    */
   @Override
   public R<List<Map<String, String>>> getDataByOid(String oid, String templateOid) {
      CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(templateOid);
      //为了防止模板上的业务类型与分类上不对应
      CodeClassifyVO topClassifyVO = classifyService.getTopClassifyVO(templateVO.getCodeclassifyoid());
      String btmId = topClassifyVO.getBtmTypeId();
      //查询数据
      Map<String, String> conditionMap = new HashMap<>();
      conditionMap.put("t.oid", oid);
      CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmId, templateVO, conditionMap, new PageHelper(-1));
      //我们使用和业务类型的来查询
      List<Map> cbosB = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
      List<Map<String, String>> cbos = new ArrayList<>();
      cbosB.stream().forEach(map -> {
         Map<String, String> data = new HashMap<>();
         for (Object o : map.keySet()) {
            data.put(((String) o).toLowerCase(Locale.ROOT), map.get(o) == null ? "" : String.valueOf(map.get(o)));
         }
         cbos.add(data);
      });
//      List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
        if (CollectionUtils.isEmpty(cbos)) {
            throw new VciBaseException("数据在系统中不存在,是否因为修改过业务类型?");
        }
//      Map<String, String> data = new HashMap<>();
        Map<String, String> cbo = cbos.get(0);
//      WebUtil.copyValueToMapFromCbos(cbo, data);
        List<Map<String, String>> dataList = new ArrayList<>();
        dataList.add(cbo);
        wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
        R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
        //我们要看是否不是升版的,升版的话,需要对比不相等的属性
/*        String copy = cbo.get("copyfromversion");
//      if (StringUtils.isBlank(copy)) {
//         copy = cbo.getAttributeValue("copyfromversion");
//      }
        if (StringUtils.isNotBlank(copy)) {
            //说明有变更的内容
      // List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
      if (CollectionUtils.isEmpty(cbos)) {
         return R.fail("数据在系统中不存在,是否因为修改过业务类型?");
      }
      // Map<String, String> data = new HashMap<>();
      Map<String, String> cbo = cbos.get(0);
      // WebUtil.copyValueToMapFromCbos(cbo, data);
      List<Map<String, String>> dataList = new ArrayList<>();
      dataList.add(cbo);
      wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
      R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
      if(templateVO.getAttributes().isEmpty()){
         return R.fail(String.format("主键为:%s的模板下,模板属性配置为空!",templateVO.getOid()));
      }
      //处理返回数据与模板数据配置的字段不一样问题
      templateVO.getAttributes().stream().forEach(e -> {
         for (Map<String, String> datum : result.getData()) {
            if (datum.containsKey(e.getId().toLowerCase()) && !datum.containsKey(e.getId())) {
               datum.put(e.getId(), datum.get(e.getId().toLowerCase()));
               datum.remove(e.getId().toLowerCase());
            }
         }
      });
            CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
            //我们使用和业务类型的来查询
//         List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
            List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
            if (!CollectionUtils.isEmpty(oldCbos)) {
//            Map<String, String> newData = new HashMap<>();
//            WebUtil.copyValueToMapFromCbos(cbo, newData);
                Map<String, String> oldData = new HashMap<>();
                oldData = oldCbos.get(0);
                Map<String, String> difFieldMap = new HashMap<>();
                Map<String, String> finalOldData = oldData;
                cbo.forEach((key, value) -> {
               // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿
               String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
               if (value == null || value == "null") {
                        value = "";
                    }
                    if (oldValue == null || oldValue == "null") {
                        oldValue = "";
                    }
                    if (!value.equalsIgnoreCase(oldValue)) {
                        difFieldMap.put(key, oldValue);
                    }
                });
                List<Map<String, String>> difFieldList = new ArrayList<>();
                difFieldList.add(difFieldMap);
                result.setData(difFieldList);
            }
        }*/
        return result;
    }
      //我们要看是否不是升版的,升版的话,需要对比不相等的属性
      /*        String copy = cbo.get("copyfromversion");
      //      if (StringUtils.isBlank(copy)) {
      //         copy = cbo.getAttributeValue("copyfromversion");
      //      }
            if (StringUtils.isNotBlank(copy)) {
               //说明有变更的内容
    /**
     * 使用模板的主键获取表单的信息
     *
     * @param templateOid 模板的主键
     * @param executionId 流程执行id
     * @param processUse  流程模板的用途
     * @return ui相关的内容
     */
    @Override
    public List<String> getFieldByProcessTemplate(String templateOid, String executionId, String processUse) {
        VciBaseUtil.alertNotNull(templateOid, "模板主键", executionId, "流程的执行Id", processUse, "流程模板用途");
        while (StringUtils.countMatches(executionId, ".") > 1) {
            executionId = executionId.substring(0, executionId.lastIndexOf("."));
        }
        String sql = "select wm_concat(distinct (t.codetempattrOidArr)) codetempattroidarr\n" +
                "from pl_code_clsflowtemp t\n" +
                "join PLFLOWINSTANCE plfi on t.ID = plfi.PLTEMPLATEPUID\n" +
                "where plfi.PLEXECUTIONID = '" + executionId + "' and t.CLASSIFYTEMPLATEOID = '" + templateOid + "' and t.CODEPROCESSUSE = '" + processUse + "'";
               CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
               //我们使用和业务类型的来查询
      //         List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
               List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
               if (!CollectionUtils.isEmpty(oldCbos)) {
      //            Map<String, String> newData = new HashMap<>();
      //            WebUtil.copyValueToMapFromCbos(cbo, newData);
                  Map<String, String> oldData = new HashMap<>();
                  oldData = oldCbos.get(0);
                  Map<String, String> difFieldMap = new HashMap<>();
                  Map<String, String> finalOldData = oldData;
                  cbo.forEach((key, value) -> {
                     // 这儿oldmap中的全是大写,而cbo中的全是小写所以会拿不到只,这儿直接处理成小写拿不到就用大写拿
                     String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
                     if (value == null || value == "null") {
                        value = "";
                     }
                     if (oldValue == null || oldValue == "null") {
                        oldValue = "";
                     }
                     if (!value.equalsIgnoreCase(oldValue)) {
                        difFieldMap.put(key, oldValue);
                     }
                  });
                  List<Map<String, String>> difFieldList = new ArrayList<>();
                  difFieldList.add(difFieldMap);
                  result.setData(difFieldList);
               }
      }*/
      return result;
   }
   /**
    * 使用模板的主键获取表单的信息
    *
    * @param templateOid 模板的主键
    * @param executionId 流程执行id
    * @param processUse  流程模板的用途
    * @return ui相关的内容
    */
   @Override
   public List<String> getFieldByProcessTemplate(String templateOid, String executionId, String processUse) {
      VciBaseUtil.alertNotNull(templateOid, "模板主键", executionId, "流程的执行Id", processUse, "流程模板用途");
      while (StringUtils.countMatches(executionId, ".") > 1) {
         executionId = executionId.substring(0, executionId.lastIndexOf("."));
      }
      String sql = "select wm_concat(distinct (t.codetempattrOidArr)) codetempattroidarr\n" +
         "from pl_code_clsflowtemp t\n" +
         "join PLFLOWINSTANCE plfi on t.ID = plfi.PLTEMPLATEPUID\n" +
         "where plfi.PLEXECUTIONID = '" + executionId + "' and t.CLASSIFYTEMPLATEOID = '" + templateOid + "' and t.CODEPROCESSUSE = '" + processUse + "'";
//      List<ClientBusinessObject> tempAttrOidArr = boService.queryByOnlySql(sql);
        List<Map> tempAttrOidArr = commonsMapper.selectBySql(sql);
        if (CollectionUtils.isEmpty(tempAttrOidArr) || StringUtils.isBlank((CharSequence) tempAttrOidArr.get(0).get("codetempattroidarr"))) {
            return new ArrayList<>();
        }
        return VciBaseUtil.str2List(tempAttrOidArr.get(0).get("CODETEMPATTROIDARR").toString());
    }
      List<Map> tempAttrOidArr = commonsMapper.selectBySql(sql);
      if (CollectionUtils.isEmpty(tempAttrOidArr) || StringUtils.isBlank((CharSequence) tempAttrOidArr.get(0).get("codetempattroidarr"))) {
         return new ArrayList<>();
      }
      return VciBaseUtil.str2List(tempAttrOidArr.get(0).get("CODETEMPATTROIDARR").toString());
   }
    /**
     * 使用分类的主键获取业务数据
     *
     * @param btmType     业务类型
     * @param queryObject 查询对象
     * @return 表格的显示对象值
     */
    @Override
    public DataGrid<Map<String, String>> getTableDataByExecutionId(String btmType, BaseQueryObject queryObject) {
        VciBaseUtil.alertNotNull(btmType, "业务类型");
        if (queryObject == null) {
            queryObject = new BaseQueryObject();
        }
        if (queryObject.getConditionMap() == null) {
            queryObject.setConditionMap(new HashMap<>());
        }
        Map<String, String> conditionMap = queryObject.getConditionMap();
        PageHelper pageHelper = queryObject.getPageHelper();
        if (!conditionMap.containsKey("oid")) {
            throw new VciBaseException("业务数据主键不能为空");
        }
        List<String> oidList = VciBaseUtil.str2List(conditionMap.get("oid"));
   /**
    * 使用分类的主键获取业务数据
    *
    * @param btmType     业务类型
    * @param queryObject 查询对象
    * @return 表格的显示对象值
    */
   @Override
   public DataGrid<Map<String, String>> getTableDataByExecutionId(String btmType, BaseQueryObject queryObject) {
      VciBaseUtil.alertNotNull(btmType, "业务类型");
      if (queryObject == null) {
         queryObject = new BaseQueryObject();
      }
      if (queryObject.getConditionMap() == null) {
         queryObject.setConditionMap(new HashMap<>());
      }
      Map<String, String> conditionMap = queryObject.getConditionMap();
      PageHelper pageHelper = queryObject.getPageHelper();
      if (!conditionMap.containsKey("oid")) {
         throw new VciBaseException("业务数据主键不能为空");
      }
      List<String> oidList = VciBaseUtil.str2List(conditionMap.get("oid"));
        List<BaseModel> cbos = selectByTypeAndOid(btmType, conditionMap.get("oid"));
        if (CollectionUtils.isEmpty(cbos)) {
            throw new VciBaseException("未找到业务数据");
        }
        BaseModel cbo = cbos.get(0);
        String templateOid = cbo.getData().get("CODETEMPLATEOID");
      List<BaseModel> cbos = selectByTypeAndOid(btmType, conditionMap.get("oid"));
      if (CollectionUtils.isEmpty(cbos)) {
         throw new VciBaseException("未找到业务数据");
      }
      BaseModel cbo = cbos.get(0);
      String templateOid = cbo.getData().get("CODETEMPLATEOID");
        QueryWrapper<CodeClassifyTemplate> codeClassifyTemplateWrapper = new QueryWrapper<>();
        codeClassifyTemplateWrapper.eq("oid", templateOid);
        List<CodeClassifyTemplate> templateDOList = templateService.list(codeClassifyTemplateWrapper);
      QueryWrapper<CodeClassifyTemplate> codeClassifyTemplateWrapper = new QueryWrapper<>();
      codeClassifyTemplateWrapper.eq("oid", templateOid);
      List<CodeClassifyTemplate> templateDOList = templateService.list(codeClassifyTemplateWrapper);
        QueryWrapper<CodeClassifyTemplateAttr> codeClassifyTemplateAttrWrapper = new QueryWrapper<>();
        codeClassifyTemplateAttrWrapper.eq("CLASSIFYTEMPLATEOID", templateOid);
      QueryWrapper<CodeClassifyTemplateAttr> codeClassifyTemplateAttrWrapper = new QueryWrapper<>();
      codeClassifyTemplateAttrWrapper.eq("CLASSIFYTEMPLATEOID", templateOid);
        List<CodeClassifyTemplateAttr> attrDOList = codeClassifyTemplateAttrService.list(codeClassifyTemplateAttrWrapper);
      List<CodeClassifyTemplateAttr> attrDOList = codeClassifyTemplateAttrService.list(codeClassifyTemplateAttrWrapper);
        if (CollectionUtils.isEmpty(templateDOList)) {
            logger.error("找不到业务数据关联的模板,模板主键:" + templateOid);
            throw new VciBaseException("找不到业务数据关联的模板");
        }
        CodeClassifyTemplateVO templateVO = templateService.codeClassifyTemplateDO2VO(templateDOList.get(0));
        templateVO.setAttributes(codeClassifyTemplateAttrService.codeClassifyTemplateAttrDO2VOs(attrDOList));
        try {
            if (oidList.size() > 1) {
                DataGrid<Map<String, String>> allDataGrid = new DataGrid<>();
                List<Map<String, String>> allData = new ArrayList<>();
                oidList.forEach(oid -> {
                    Map<String, String> condition = new HashMap<>();
                    condition.put("oid", oid);
                    DataGrid<Map<String, String>> dataGrid = queryGrid(btmType, templateVO, condition, pageHelper);
                    allData.addAll(dataGrid.getData());
                });
                allDataGrid.setData(allData);
                return allDataGrid;
            } else {
                return queryGrid(btmType, templateVO, conditionMap, pageHelper);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }
      if (CollectionUtils.isEmpty(templateDOList)) {
         logger.error("找不到业务数据关联的模板,模板主键:" + templateOid);
         throw new VciBaseException("找不到业务数据关联的模板");
      }
      CodeClassifyTemplateVO templateVO = templateService.codeClassifyTemplateDO2VO(templateDOList.get(0));
      templateVO.setAttributes(codeClassifyTemplateAttrService.codeClassifyTemplateAttrDO2VOs(attrDOList));
      try {
         if (oidList.size() > 1) {
            DataGrid<Map<String, String>> allDataGrid = new DataGrid<>();
            List<Map<String, String>> allData = new ArrayList<>();
            oidList.forEach(oid -> {
               Map<String, String> condition = new HashMap<>();
               condition.put("oid", oid);
               DataGrid<Map<String, String>> dataGrid = queryGrid(btmType, templateVO, condition, pageHelper);
               allData.addAll(dataGrid.getData());
            });
            allDataGrid.setData(allData);
            return allDataGrid;
         } else {
            return queryGrid(btmType, templateVO, conditionMap, pageHelper);
         }
      } catch (Exception e) {
         System.out.println(e.getMessage());
         return null;
      }
   }
    /**
     * 使用分类的主键获取表格的定义
     *
     * @param codeClassifyOid 分类主键
     * @param phase           阶段的名称
     * @return UI相关的信息(仅包含表单)
     */
    @Override
    public MdmUIInfoVO getTableDefineByClassifyOid_v2(String codeClassifyOid, String phase) {
        MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
        CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
        uiInfoVO.setTemplateVO(templateVO);
        UITableDefineVO uiTableDefineVO = wrapperTableDefineByTemplate(templateVO, true);
        List<String> phaseAttrIdList = listPhaseAttrByClassifyOid(codeClassifyOid, phase);
        uiTableDefineVO.getCols().stream().forEach(list -> {
            List<UITableFieldVO> visiableTableField = new ArrayList<>();
            if (StringUtils.isNotBlank(phase)) {
                visiableTableField = list.stream().filter(col ->
                        phaseAttrIdList.stream().anyMatch(s -> StringUtils.equalsIgnoreCase(col.getField(), s) ||
                                (StringUtils.equalsIgnoreCase(col.getFieldType(), "combox") && StringUtils.equalsIgnoreCase(col.getSortField(), s))
                                || (StringUtils.equalsIgnoreCase(col.getFieldType(), "refer") && StringUtils.equalsIgnoreCase(col.getQueryField(), s))
                        )).collect(Collectors.toList());
            } else {
                visiableTableField = list.stream().filter(col ->
                        templateVO.getAttributes().stream().anyMatch(s ->
                                (!s.getReadOnlyFlag().equalsIgnoreCase("true") && StringUtils.equalsIgnoreCase(col.getField(), s.getId())) ||
                                        (StringUtils.equalsIgnoreCase(col.getFieldType(), "combox") && StringUtils.equalsIgnoreCase(col.getSortField(), s.getId()))
                                        || (StringUtils.equalsIgnoreCase(col.getFieldType(), "refer") && StringUtils.equalsIgnoreCase(col.getQueryField(), s.getId()))
                        )).collect(Collectors.toList());
            }
   /**
    * 使用分类的主键获取表格的定义
    *
    * @param codeClassifyOid 分类主键
    * @param phase           阶段的名称
    * @return UI相关的信息(仅包含表单)
    */
   @Override
   public MdmUIInfoVO getTableDefineByClassifyOid_v2(String codeClassifyOid, String phase) {
      MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
      CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
      uiInfoVO.setTemplateVO(templateVO);
      UITableDefineVO uiTableDefineVO = wrapperTableDefineByTemplate(templateVO, true);
      List<String> phaseAttrIdList = listPhaseAttrByClassifyOid(codeClassifyOid, phase);
      uiTableDefineVO.getCols().stream().forEach(list -> {
         List<UITableFieldVO> visiableTableField = new ArrayList<>();
         if (StringUtils.isNotBlank(phase)) {
            visiableTableField = list.stream().filter(col ->
               phaseAttrIdList.stream().anyMatch(s -> StringUtils.equalsIgnoreCase(col.getField(), s) ||
                  (StringUtils.equalsIgnoreCase(col.getFieldType(), "combox") && StringUtils.equalsIgnoreCase(col.getSortField(), s))
                  || (StringUtils.equalsIgnoreCase(col.getFieldType(), "refer") && StringUtils.equalsIgnoreCase(col.getQueryField(), s))
               )).collect(Collectors.toList());
         } else {
            visiableTableField = list.stream().filter(col ->
               templateVO.getAttributes().stream().anyMatch(s ->
                  (!s.getReadOnlyFlag().equalsIgnoreCase("true") && StringUtils.equalsIgnoreCase(col.getField(), s.getId())) ||
                     (StringUtils.equalsIgnoreCase(col.getFieldType(), "combox") && StringUtils.equalsIgnoreCase(col.getSortField(), s.getId()))
                     || (StringUtils.equalsIgnoreCase(col.getFieldType(), "refer") && StringUtils.equalsIgnoreCase(col.getQueryField(), s.getId()))
               )).collect(Collectors.toList());
         }
            visiableTableField.stream().forEach(vo -> {
                uiTableDefineVO.setHasEditor(true);
                if ("refer".equalsIgnoreCase(vo.getFieldType())) {
                    setReferConfig2EditConfig(vo);
                } else if ("combox".equalsIgnoreCase(vo.getFieldType())) {
                    setComboxConfig2EditConfig(vo);
                } else if (StringUtils.isNotBlank(vo.getDateFormate())) {
                    vo.setEdit("date");
                } else {
                    vo.setEdit(vo.getFieldType());
                }
            });
        });
        uiInfoVO.setTableDefineVO(uiTableDefineVO);
        wrapperResemble(templateVO, uiInfoVO);
        return uiInfoVO;
    }
         visiableTableField.stream().forEach(vo -> {
            uiTableDefineVO.setHasEditor(true);
            if ("refer".equalsIgnoreCase(vo.getFieldType())) {
               setReferConfig2EditConfig(vo);
            } else if ("combox".equalsIgnoreCase(vo.getFieldType())) {
               setComboxConfig2EditConfig(vo);
            } else if (StringUtils.isNotBlank(vo.getDateFormate())) {
               vo.setEdit("date");
            } else {
               vo.setEdit(vo.getFieldType());
            }
         });
      });
      uiInfoVO.setTableDefineVO(uiTableDefineVO);
      wrapperResemble(templateVO, uiInfoVO);
      return uiInfoVO;
   }
   /**
    * 使用分类的主键获取表格的定义-ubcs后修改获取流程阶段熟悉获取方法
    *
    * @param codeClassifyOid
    * @param templateId
    * @param taskId
    * @param modelKey
    * @return
    */
   public MdmUIInfoVO getTableDefineByClassifyOid_v2(String codeClassifyOid,String templateId,String taskId,String modelKey) {
   public MdmUIInfoVO getTableDefineByClassifyOid_v2(String codeClassifyOid, String templateId, String taskId, String modelKey) {
      MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
      CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
      uiInfoVO.setTemplateVO(templateVO);
      UITableDefineVO uiTableDefineVO = wrapperTableDefineByTemplate(templateVO, true);
      R<List<ProcessStageAttrVO>> r = imdmiFlowAttrClient.ssslist(templateId,modelKey,taskId);
      R<List<ProcessStageAttrVO>> r = imdmiFlowAttrClient.ssslist(templateId, modelKey, taskId);
      List<ProcessStageAttrVO> stageAttrVOS = r.getData();
      List<String> attrList = new ArrayList<>();
      stageAttrVOS.stream().forEach(attr->{
      stageAttrVOS.stream().forEach(attr -> {
         attrList.add(attr.getAttrId());
      });
      uiTableDefineVO.getCols().stream().forEach(list -> {
@@ -3507,24 +3744,24 @@
      return uiInfoVO;
   }
    /**
     * 模板属性转换为表格定义的信息
     *
     * @param templateVO 模板的显示对象
     * @param forEdit    是否是编辑所需
     * @return 表格的信息
     */
    private UITableDefineVO wrapperTableDefineByTemplate(CodeClassifyTemplateVO templateVO, boolean forEdit) {
        //封装信息
        UITableDefineVO tableDefineVO = new UITableDefineVO();
        tableDefineVO.setOid(templateVO.getOid());
        tableDefineVO.setBtmType(templateVO.getBtmTypeId());
        tableDefineVO.setDisplayQueryArea(true);
        //前端会默认分页的信息
   /**
    * 模板属性转换为表格定义的信息
    *
    * @param templateVO 模板的显示对象
    * @param forEdit    是否是编辑所需
    * @return 表格的信息
    */
   private UITableDefineVO wrapperTableDefineByTemplate(CodeClassifyTemplateVO templateVO, boolean forEdit) {
      //封装信息
      UITableDefineVO tableDefineVO = new UITableDefineVO();
      tableDefineVO.setOid(templateVO.getOid());
      tableDefineVO.setBtmType(templateVO.getBtmTypeId());
      tableDefineVO.setDisplayQueryArea(true);
      //前端会默认分页的信息
        //处理所有的列,这个模板没有合并的表头的情况
        List<UITableFieldVO> fieldVOList = new ArrayList<>();
        Map<String, String> comboxOrReferFieldMap = new HashMap<>();
      //处理所有的列,这个模板没有合并的表头的情况
      List<UITableFieldVO> fieldVOList = new ArrayList<>();
      Map<String, String> comboxOrReferFieldMap = new HashMap<>();
      if (Func.isNotEmpty(templateVO.getAttributes())) {
         templateVO.getAttributes().forEach(attrVO -> {
@@ -3541,10 +3778,10 @@
            fieldVOList.add(tableFieldVO);
         });
      }
        List<List<UITableFieldVO>> cols = new ArrayList<>();
        cols.add(fieldVOList);
        tableDefineVO.setCols(cols);
        Map<String, UITableFieldVO> fieldVOMap = fieldVOList.stream().collect(Collectors.toMap(s -> s.getField().toLowerCase(Locale.ROOT), t -> t));
      List<List<UITableFieldVO>> cols = new ArrayList<>();
      cols.add(fieldVOList);
      tableDefineVO.setCols(cols);
      Map<String, UITableFieldVO> fieldVOMap = fieldVOList.stream().collect(Collectors.toMap(s -> s.getField().toLowerCase(Locale.ROOT), t -> t));
      List<CodeClassifyTemplateAttrVO> seniorQueryAttrVOs = null;
      if (Func.isNotEmpty(templateVO.getAttributes())) {
         //查询属性
@@ -3563,223 +3800,222 @@
         //高级属性
         seniorQueryAttrVOs = templateVO.getAttributes().stream().filter(s -> BooleanEnum.TRUE.getValue().equalsIgnoreCase(s.getSeniorQueryAttrFlag())).collect(Collectors.toList());
      }
        if (!CollectionUtils.isEmpty(seniorQueryAttrVOs)) {
            List<UITableFieldVO> queryFieldVOs = new ArrayList<>();
            seniorQueryAttrVOs.stream().forEach(attrVO -> {
                String attrId = attrVO.getId().toLowerCase(Locale.ROOT);
                attrId = comboxOrReferFieldMap.getOrDefault(attrId, attrId).toLowerCase(Locale.ROOT);
                if (fieldVOMap.containsKey(attrId)) {
                    queryFieldVOs.add(fieldVOMap.get(attrId));
                }
            });
            tableDefineVO.setSeniorQueryColumns(queryFieldVOs);
        }
        return tableDefineVO;
    }
      if (!CollectionUtils.isEmpty(seniorQueryAttrVOs)) {
         List<UITableFieldVO> queryFieldVOs = new ArrayList<>();
         seniorQueryAttrVOs.stream().forEach(attrVO -> {
            String attrId = attrVO.getId().toLowerCase(Locale.ROOT);
            attrId = comboxOrReferFieldMap.getOrDefault(attrId, attrId).toLowerCase(Locale.ROOT);
            if (fieldVOMap.containsKey(attrId)) {
               queryFieldVOs.add(fieldVOMap.get(attrId));
            }
         });
         tableDefineVO.setSeniorQueryColumns(queryFieldVOs);
      }
      return tableDefineVO;
   }
    /**
     * 加载成参照的修改配置
     *
     * @param vo 表格字段显示对象
     */
    private void setReferConfig2EditConfig(UITableFieldVO vo) {
        if (!CollectionUtils.isEmpty(vo.getReferConfig().getWhere())) {
            vo.getReferConfig().getWhere().keySet().forEach(key -> {
                vo.getReferConfig().getWhere().put(key, "'" + vo.getReferConfig().getWhere().get(key) + "'");
            });
        }
        if (StringUtils.isNotBlank(vo.getReferConfig().getParentValue())) {
            String parentValue = vo.getReferConfig().getParentValue();
            parentValue = "\\" + parentValue.replaceAll("'", "{vci-quote}").replaceAll("=", "{vci-equals}");
            vo.getReferConfig().setParentValue(parentValue);
        }
        String referConfig = vo.getReferConfig().toString()
                .replaceAll("=", ":")
                .replaceAll("UITableCustomDefineVO", "")
                .replaceAll("UIFieldSortVO", "")
                .replaceAll("UITablePageVO", "")
                .replaceAll("UITableFieldVO", "")
                .replaceAll("UIFormReferVO", "")
                .replaceAll("\\{vci-equals}", "=")
                .replaceAll("\\{vci-quote}", "\\\\'")
                .replaceAll("'null'", "null");
        referConfig = referConfig + ",fieldMap:{" + vo.getQueryField() + ":'" + vo.getReferConfig().getValueField() + "'}";
        vo.setEditConfig("{referConfig:" + referConfig + "}");
        vo.setEdit(vo.getFieldType());
    }
   /**
    * 加载成参照的修改配置
    *
    * @param vo 表格字段显示对象
    */
   private void setReferConfig2EditConfig(UITableFieldVO vo) {
      if (!CollectionUtils.isEmpty(vo.getReferConfig().getWhere())) {
         vo.getReferConfig().getWhere().keySet().forEach(key -> {
            vo.getReferConfig().getWhere().put(key, "'" + vo.getReferConfig().getWhere().get(key) + "'");
         });
      }
      if (StringUtils.isNotBlank(vo.getReferConfig().getParentValue())) {
         String parentValue = vo.getReferConfig().getParentValue();
         parentValue = "\\" + parentValue.replaceAll("'", "{vci-quote}").replaceAll("=", "{vci-equals}");
         vo.getReferConfig().setParentValue(parentValue);
      }
      String referConfig = vo.getReferConfig().toString()
         .replaceAll("=", ":")
         .replaceAll("UITableCustomDefineVO", "")
         .replaceAll("UIFieldSortVO", "")
         .replaceAll("UITablePageVO", "")
         .replaceAll("UITableFieldVO", "")
         .replaceAll("UIFormReferVO", "")
         .replaceAll("\\{vci-equals}", "=")
         .replaceAll("\\{vci-quote}", "\\\\'")
         .replaceAll("'null'", "null");
      referConfig = referConfig + ",fieldMap:{" + vo.getQueryField() + ":'" + vo.getReferConfig().getValueField() + "'}";
      vo.setEditConfig("{referConfig:" + referConfig + "}");
      vo.setEdit(vo.getFieldType());
   }
    /**
     * 加载成下拉框的修改配置
     *
     * @param vo 表格字段显示对象
     */
    private void setComboxConfig2EditConfig(UITableFieldVO vo) {
        vo.setEditConfig("{editable:true,comboxKey:'" + vo.getComboxKey() + "'");
        if (!CollectionUtils.isEmpty(vo.getData())) {
            vo.setEditConfig(vo.getEditConfig() + ", comboxConfig:");
            for (int i = 0; i < vo.getData().size(); i++) {
                KeyValue data = vo.getData().get(i);
                if (i == vo.getData().size() - 1) {
                    vo.setEditConfig(vo.getEditConfig() + "{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'}]}");
                } else if (i == 0) {
                    vo.setEditConfig(vo.getEditConfig() + "{data:[{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'},");
                } else {
                    vo.setEditConfig(vo.getEditConfig() + "{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'},");
                }
            }
            vo.setEditConfig(vo.getEditConfig() + ",valueField:'" + vo.getQueryField() + "'");
        }
        vo.setEditConfig(vo.getEditConfig() + "}");
        vo.setEdit(vo.getFieldType());
    }
   /**
    * 加载成下拉框的修改配置
    *
    * @param vo 表格字段显示对象
    */
   private void setComboxConfig2EditConfig(UITableFieldVO vo) {
      vo.setEditConfig("{editable:true,comboxKey:'" + vo.getComboxKey() + "'");
      if (!CollectionUtils.isEmpty(vo.getData())) {
         vo.setEditConfig(vo.getEditConfig() + ", comboxConfig:");
         for (int i = 0; i < vo.getData().size(); i++) {
            KeyValue data = vo.getData().get(i);
            if (i == vo.getData().size() - 1) {
               vo.setEditConfig(vo.getEditConfig() + "{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'}]}");
            } else if (i == 0) {
               vo.setEditConfig(vo.getEditConfig() + "{data:[{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'},");
            } else {
               vo.setEditConfig(vo.getEditConfig() + "{attributes:" + data.getAttributes() + ",key:'" + data.getKey() + "',value:'" + data.getValue() + "'},");
            }
         }
         vo.setEditConfig(vo.getEditConfig() + ",valueField:'" + vo.getQueryField() + "'");
      }
      vo.setEditConfig(vo.getEditConfig() + "}");
      vo.setEdit(vo.getFieldType());
   }
    /**
     * 使用分类的编号路径,获取表单的相关定义
     *
     * @param idPath 编号的路径,必须从顶层节点开始,xx/yyy/zz
     * @return UI相关的信息(仅包含表单)
     */
    @Override
    public MdmUIInfoVO getFormDefineByClassifyIdPath(String idPath) {
        CodeClassifyVO classifyVO = classifyService.getObjectByIdPath(idPath);
        if (classifyVO != null) {
            return getFormDefineByClassifyOid(classifyVO.getOid());
        }
        return null;
    }
   /**
    * 使用分类的编号路径,获取表单的相关定义
    *
    * @param idPath 编号的路径,必须从顶层节点开始,xx/yyy/zz
    * @return UI相关的信息(仅包含表单)
    */
   @Override
   public MdmUIInfoVO getFormDefineByClassifyIdPath(String idPath) {
      CodeClassifyVO classifyVO = classifyService.getObjectByIdPath(idPath);
      if (classifyVO != null) {
         return getFormDefineByClassifyOid(classifyVO.getOid());
      }
      return null;
   }
    /**
     * 使用主题库分类的主键获取表单的信息
     *
     * @param codeClassifyOid 分类的主键
     * @return ui相关的内容
     */
    @Override
    public MdmUIInfoVO getFormDefineByClassifyOid(String codeClassifyOid) {
        MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
        CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
        uiInfoVO.setTemplateVO(templateVO);
        uiInfoVO.setFormDefineVO(wrapperFormDefineByTemplate(templateVO, codeClassifyOid));
        wrapperResemble(templateVO, uiInfoVO);
        return uiInfoVO;
    }
   /**
    * 使用主题库分类的主键获取表单的信息
    *
    * @param codeClassifyOid 分类的主键
    * @return ui相关的内容
    */
   @Override
   public MdmUIInfoVO getFormDefineByClassifyOid(String codeClassifyOid) {
      MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
      CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
      uiInfoVO.setTemplateVO(templateVO);
      uiInfoVO.setFormDefineVO(wrapperFormDefineByTemplate(templateVO, codeClassifyOid));
      wrapperResemble(templateVO, uiInfoVO);
      return uiInfoVO;
   }
    /**
     * 使用模板主键获取ui相关的内容
     *
     * @param templateOid 模板的主键
     * @return ui相关的内容
     */
    @Override
    public MdmUIInfoVO getTableDefineByTemplateOid(String templateOid) {
        return getTableDefineByTemplateVO(templateService.getObjectHasAttrByOid(templateOid));
    }
   /**
    * 使用模板主键获取ui相关的内容
    *
    * @param templateOid 模板的主键
    * @return ui相关的内容
    */
   @Override
   public MdmUIInfoVO getTableDefineByTemplateOid(String templateOid) {
      return getTableDefineByTemplateVO(templateService.getObjectHasAttrByOid(templateOid));
   }
    /**
     * 使用模板显示对象转换为表格的信息(包含扩展的按钮)
     *
     * @param templateVO 模板的信息
     * @return UI相关的内容(仅包含表格信息)
     */
    private MdmUIInfoVO getTableDefineByTemplateVO(CodeClassifyTemplateVO templateVO) {
        //先看这个分类本身是否有模板
        MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
        uiInfoVO.setTemplateVO(templateVO);
        //我们需要将模板转换为表格相关的显示信息
        uiInfoVO.setTableDefineVO(wrapperTableDefineByTemplate(uiInfoVO.getTemplateVO(), false));
        //需要去看扩展的按钮,只有列表里面本身才添加进去,工具栏上的单独获取
        List<CodeClassifyTemplateButtonVO> buttonVOS = templateButtonService.listButtonByTemplateOid(templateVO.getOid(), true);
        if (!CollectionUtils.isEmpty(buttonVOS)) {
            //我们要分开为按钮,还是在操作列里面
            List<CodeClassifyTemplateButtonVO> tableButtonVOs = buttonVOS.stream().filter(s -> CodeUseButtonPositionTypeEnum.TABLE.getValue().equalsIgnoreCase(s.getButtonUse())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(tableButtonVOs)) {
                UITableFieldVO optionFieldVO = new UITableFieldVO();
                optionFieldVO.setField("options");
                optionFieldVO.setTitle("操作");
                optionFieldVO.setFieldType("text");
                optionFieldVO.setOptionField(true);
                List<KeyValue> buttons = new ArrayList<>();
                Map<String, String> optionJsMap = new HashMap<>();
                tableButtonVOs.stream().forEach(buttonVO -> {
                    KeyValue kv = new KeyValue();
                    kv.setKey(buttonVO.getId());
                    kv.setValue(buttonVO.getClassifyButtonOidName());
                    kv.setAttributes(VciBaseUtil.objectToMap(buttonVO));
                    buttons.add(kv);
                    optionJsMap.put(buttonVO.getId(), buttonVO.getButtonVO().getExecuteJs());
                });
                optionFieldVO.setOptionJsMap(optionJsMap);
                uiInfoVO.getTableDefineVO().getCols().get(0).add(optionFieldVO);
            }
        }
        return uiInfoVO;
    }
   /**
    * 使用模板显示对象转换为表格的信息(包含扩展的按钮)
    *
    * @param templateVO 模板的信息
    * @return UI相关的内容(仅包含表格信息)
    */
   private MdmUIInfoVO getTableDefineByTemplateVO(CodeClassifyTemplateVO templateVO) {
      //先看这个分类本身是否有模板
      MdmUIInfoVO uiInfoVO = new MdmUIInfoVO();
      uiInfoVO.setTemplateVO(templateVO);
      //我们需要将模板转换为表格相关的显示信息
      uiInfoVO.setTableDefineVO(wrapperTableDefineByTemplate(uiInfoVO.getTemplateVO(), false));
      //需要去看扩展的按钮,只有列表里面本身才添加进去,工具栏上的单独获取
      List<CodeClassifyTemplateButtonVO> buttonVOS = templateButtonService.listButtonByTemplateOid(templateVO.getOid(), true);
      if (!CollectionUtils.isEmpty(buttonVOS)) {
         //我们要分开为按钮,还是在操作列里面
         List<CodeClassifyTemplateButtonVO> tableButtonVOs = buttonVOS.stream().filter(s -> CodeUseButtonPositionTypeEnum.TABLE.getValue().equalsIgnoreCase(s.getButtonUse())).collect(Collectors.toList());
         if (!CollectionUtils.isEmpty(tableButtonVOs)) {
            UITableFieldVO optionFieldVO = new UITableFieldVO();
            optionFieldVO.setField("options");
            optionFieldVO.setTitle("操作");
            optionFieldVO.setFieldType("text");
            optionFieldVO.setOptionField(true);
            List<KeyValue> buttons = new ArrayList<>();
            Map<String, String> optionJsMap = new HashMap<>();
            tableButtonVOs.stream().forEach(buttonVO -> {
               KeyValue kv = new KeyValue();
               kv.setKey(buttonVO.getId());
               kv.setValue(buttonVO.getClassifyButtonOidName());
               kv.setAttributes(VciBaseUtil.objectToMap(buttonVO));
               buttons.add(kv);
               optionJsMap.put(buttonVO.getId(), buttonVO.getButtonVO().getExecuteJs());
            });
            optionFieldVO.setOptionJsMap(optionJsMap);
            uiInfoVO.getTableDefineVO().getCols().get(0).add(optionFieldVO);
         }
      }
      return uiInfoVO;
   }
    /**
     * 使用分类的编号路径,获取表格的相关定义
     *
     * @param codeClassifyIdPath 分类的编号路径,必须是从顶层节点开始,xxx/yy/zz这样的格式
     * @param functionId         功能的编号
     * @return UI相关的信息(仅包含表格)
     */
    @Override
    public MdmUIInfoVO getUIInfoByClassifyIdPath(String codeClassifyIdPath, String functionId) {
        CodeClassifyVO classifyVO = classifyService.getObjectByIdPath(codeClassifyIdPath);
        if (classifyVO != null) {
            return getUIInfoByClassifyOid(classifyVO.getOid(), functionId);
        }
        return null;
    }
   /**
    * 使用分类的编号路径,获取表格的相关定义
    *
    * @param codeClassifyIdPath 分类的编号路径,必须是从顶层节点开始,xxx/yy/zz这样的格式
    * @param functionId         功能的编号
    * @return UI相关的信息(仅包含表格)
    */
   @Override
   public MdmUIInfoVO getUIInfoByClassifyIdPath(String codeClassifyIdPath, String functionId) {
      CodeClassifyVO classifyVO = classifyService.getObjectByIdPath(codeClassifyIdPath);
      if (classifyVO != null) {
         return getUIInfoByClassifyOid(classifyVO.getOid(), functionId);
      }
      return null;
   }
    /**
     * 使用分类主键获取页面的内容,包含按钮
     *
     * @param codeClassifyOid 主题库分类主键
     * @param functionId      功能的编号
     * @return UI相关的内容
     */
    @Override
    public MdmUIInfoVO getUIInfoByClassifyOid(String codeClassifyOid, String functionId) {
        VciBaseUtil.alertNotNull(codeClassifyOid, "主题库分类主键");
   /**
    * 使用分类主键获取页面的内容,包含按钮
    *
    * @param codeClassifyOid 主题库分类主键
    * @param functionId      功能的编号
    * @return UI相关的内容
    */
   @Override
   public MdmUIInfoVO getUIInfoByClassifyOid(String codeClassifyOid, String functionId) {
      VciBaseUtil.alertNotNull(codeClassifyOid, "主题库分类主键");
      MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid));
      uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0);
      if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) {
         // TODO:2024-1-25 18:42模板上的btmtypeid有时候会存在大小写的问题,按理来说这儿直接用functionId就能满足查询菜单按钮了uiInfoVO.getTemplateVO().getBtmTypeId()
         R<List<Menu>> buttonListR = iSysClient.getMenuButtonByType(codeClassifyOid, functionId, "data_auth");
         if(!buttonListR.isSuccess()){
            throw new ServiceException("获取按钮授权列表失败,原因:"+buttonListR.getMsg());
         }
         List<Menu> buttonVOS = buttonListR.getData();
        MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid));
        uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0);
        if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) {
            List<Menu> buttonVOS = iSysClient.getMenuButtonByType(uiInfoVO.getTemplateVO().getBtmTypeId()).getData();
            //         List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId);
            //         if (operationVOS == null) {
            //            operationVOS = new ArrayList<>();
            //         }
            //         //查询扩展按钮
            //         List<CodeButtonVO> buttonVOS = listButtonInToolbarByClassifyOid(codeClassifyOid);
            List<SmOperationVO> operationVOS = new ArrayList<>();
            if (!CollectionUtils.isEmpty(buttonVOS)) {
                for (int i = 0; i < buttonVOS.size(); i++) {
                    Menu buttonVO = buttonVOS.get(i);
                    SmOperationVO operationVO = new SmOperationVO();
                    operationVO.setModuleNo(functionId);
                    operationVO.setUniqueFlag(buttonVO.getCode());
                    operationVO.setName(buttonVO.getName());
                    operationVO.setAlias(buttonVO.getAlias());
                    operationVO.setOrderNo(String.valueOf(buttonVO.getSort()));
         List<SmOperationVO> operationVOS = new ArrayList<>();
         if (!CollectionUtils.isEmpty(buttonVOS)) {
            for (int i = 0; i < buttonVOS.size(); i++) {
               Menu buttonVO = buttonVOS.get(i);
               SmOperationVO operationVO = new SmOperationVO();
               operationVO.setModuleNo(functionId);
               operationVO.setUniqueFlag(buttonVO.getCode());
               operationVO.setName(buttonVO.getName());
               operationVO.setAlias(buttonVO.getAlias());
               operationVO.setOrderNo(String.valueOf(buttonVO.getSort()));
//               operationVO.setExecuteJs(buttonVO.getExecuteJs());
//               operationVO.setIconCls(buttonVO.getIconCls());
                    operationVOS.add(operationVO);
                }
            }
            uiInfoVO.setButtons(operationVOS);
        }
        return uiInfoVO;
    }
               operationVOS.add(operationVO);
            }
         }
         uiInfoVO.setButtons(operationVOS);
      }
      return uiInfoVO;
   }
    @Override
   public MdmUIInfoVO getFlowUIInfoByClassifyOid(String codeClassifyOid, String functionId,String templateId,String taskId,String modelKey){
   @Override
   public MdmUIInfoVO getFlowUIInfoByClassifyOid(String codeClassifyOid, String functionId, String templateId, String taskId, String modelKey) {
//      MdmUIInfoVO uiInfoVO = getTableDefineByClassifyOid_v2(codeClassifyOid,templateId,taskId,modelKey);
      MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid));
      R<List<ProcessStageAttrVO>> r = imdmiFlowAttrClient.ssslist(templateId,modelKey,taskId);
      R<List<ProcessStageAttrVO>> r = imdmiFlowAttrClient.ssslist(templateId, modelKey, taskId);
      List<ProcessStageAttrVO> stageAttrVOS = r.getData();
      Set<String> attrSet = new HashSet<>();
      stageAttrVOS.stream().forEach(attr->{
      stageAttrVOS.stream().forEach(attr -> {
         attrSet.add(attr.getAttrId());
      });
@@ -3788,67 +4024,67 @@
         UITableDefineVO tableDefineVO = uiInfoVO.getTableDefineVO();
         List<List<UITableFieldVO>> tableFieldVOs = tableDefineVO.getCols();
         List<UITableFieldVO> uiTableFieldVOS = tableFieldVOs.get(0);
         uiTableFieldVOS.stream().forEach(ui->{
         uiTableFieldVOS.stream().forEach(ui -> {
//            if(!attrSet.contains(ui.getField())){
//               ui.setEdit(null);
//               ui.setEditConfig(null);
//            }
         });
      }catch (Exception e){
      } catch (Exception e) {
         throw new ServiceException("模板没有定义属性,读取表头失败!");
      }
      return uiInfoVO;
   }
    /**
     * 使用分类主键获取工具栏中的按钮信息
     *
     * @param codeClassifyOid 分类的主键
     * @return 按钮的信息,会按照排序号进行排序
     */
    @Override
    public List<CodeButtonVO> listButtonInToolbarByClassifyOid(String codeClassifyOid) {
        CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
        return listButtonInToolbarByTemplateOid(templateVO.getOid());
    }
   /**
    * 使用分类主键获取工具栏中的按钮信息
    *
    * @param codeClassifyOid 分类的主键
    * @return 按钮的信息,会按照排序号进行排序
    */
   @Override
   public List<CodeButtonVO> listButtonInToolbarByClassifyOid(String codeClassifyOid) {
      CodeClassifyTemplateVO templateVO = getUsedTemplateByClassifyOid(codeClassifyOid);
      return listButtonInToolbarByTemplateOid(templateVO.getOid());
   }
    /**
     * 使用模板主键获取工具栏中的按钮信息
     *
     * @param templateOid 模板的主键
     * @return 按钮的信息,会按照排序号进行排序
     */
    @Override
    public List<CodeButtonVO> listButtonInToolbarByTemplateOid(String templateOid) {
        List<CodeClassifyTemplateButtonVO> buttonVOS = templateButtonService.listButtonByTemplateOid(templateOid, true);
        if (CollectionUtils.isEmpty(buttonVOS)) {
            return new ArrayList<>();
        }
        List<CodeClassifyTemplateButtonVO> toolbarButtons = buttonVOS.stream().filter(s -> CodeUseButtonPositionTypeEnum.TOOLBAR.getValue().equalsIgnoreCase(s.getButtonUse())).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(toolbarButtons)) {
            return new ArrayList<>();
        }
        List<CodeButtonVO> buttonVOList = new ArrayList<>();
        for (int i = 0; i < toolbarButtons.size(); i++) {
            buttonVOList.add(toolbarButtons.get(i).getButtonVO());
        }
        return buttonVOList;
    }
   /**
    * 使用模板主键获取工具栏中的按钮信息
    *
    * @param templateOid 模板的主键
    * @return 按钮的信息,会按照排序号进行排序
    */
   @Override
   public List<CodeButtonVO> listButtonInToolbarByTemplateOid(String templateOid) {
      List<CodeClassifyTemplateButtonVO> buttonVOS = templateButtonService.listButtonByTemplateOid(templateOid, true);
      if (CollectionUtils.isEmpty(buttonVOS)) {
         return new ArrayList<>();
      }
      List<CodeClassifyTemplateButtonVO> toolbarButtons = buttonVOS.stream().filter(s -> CodeUseButtonPositionTypeEnum.TOOLBAR.getValue().equalsIgnoreCase(s.getButtonUse())).collect(Collectors.toList());
      if (CollectionUtils.isEmpty(toolbarButtons)) {
         return new ArrayList<>();
      }
      List<CodeButtonVO> buttonVOList = new ArrayList<>();
      for (int i = 0; i < toolbarButtons.size(); i++) {
         buttonVOList.add(toolbarButtons.get(i).getButtonVO());
      }
      return buttonVOList;
   }
    /**
     * 传入业务类型以及相关数据进行批量插入操作
     *
     * @param btmType    业务类型
     * @param baseModels 处理数据
     * @return 处理成功数据条数
     */
    @Override
    public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
   /**
    * 传入业务类型以及相关数据进行批量插入操作
    *
    * @param btmType    业务类型
    * @param baseModels 处理数据
    * @return 处理成功数据条数
    */
   @Override
   public Integer insertBatchByType(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) {
@@ -3858,36 +4094,37 @@
         return btmTypeAttributeVO.getId().toLowerCase();
      }).collect(Collectors.toSet());
      //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
      List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));
            } catch (Exception e) {
                throw new VciBaseException("类型转换错误:" + e.toString());
            }
        });
      // 是否开启多线程执行插入语句
      if(IS_THREAD_IMPORT){
      baseModels.stream().forEach(model -> {
         try {
            threadBactchExecuteInsert(listR.getData().get(0).getTableName(),maps);
         }catch (Exception e){
            throw new ServiceException("分批执行insert语句报错:"+e.getMessage());
            maps.add(VciBaseUtil.convertBean2Map(model, existFild));
         } catch (Exception e) {
            throw new VciBaseException("类型转换错误:" + e.toString());
         }
      }else {
         bacthExcecuteInsert(listR.getData().get(0).getTableName(),maps);
      });
      // 是否开启多线程执行插入语句
      if (IS_THREAD_IMPORT) {
         try {
            threadBactchExecuteInsert(listR.getData().get(0).getTableName(), maps);
         } catch (Exception e) {
            throw new ServiceException("分批执行insert语句报错:" + e.getMessage());
         }
      } else {
         bacthExcecuteInsert(listR.getData().get(0).getTableName(), maps);
      }
        return maps.size();
    }
      return maps.size();
   }
   /**
    * 多线程方式分批执行insert语句
    *
    * @param tableName
    * @param maps
    * @throws ServiceException
    */
   private void threadBactchExecuteInsert(String tableName, List<Map<String, String>> maps) throws ServiceException{
   private void threadBactchExecuteInsert(String tableName, List<Map<String, String>> maps) throws ServiceException {
      ExecutorService executor = Executors.newFixedThreadPool(THREAD_NUM); // 创建一个固定大小的线程池
      List<Map<String, String>> threadSafeMaps = new CopyOnWriteArrayList<>(maps);
@@ -3900,7 +4137,7 @@
               // 调用插入数据库的方法
               commonsMapper.insertByBaseModel(tableName, threadSafeMaps.get(0), subList);
            });
         }catch (Throwable e){
         } catch (Throwable e) {
            throw new ServiceException(e.getMessage());
         }
      }
@@ -3912,16 +4149,17 @@
         executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
      } catch (InterruptedException e) {
         // 处理异常
         throw new ServiceException("多线程方式执行批量插入时产生错误:"+e.getMessage());
         throw new ServiceException("多线程方式执行批量插入时产生错误:" + e.getMessage());
      }
   }
   /**
    * 单线程方式分批执行
    *
    * @param tableName
    * @param maps
    */
   private void bacthExcecuteInsert(String tableName, List<Map<String, String>> maps){
   private void bacthExcecuteInsert(String tableName, List<Map<String, String>> maps) {
      for (int i = 0; i < maps.size(); i += MAX_IMPORT_NUM) {
         final int startIndex = i;
         final int endIndex = Math.min(i + MAX_IMPORT_NUM, maps.size());
@@ -3935,26 +4173,26 @@
    * 传入业务类型以及ID查询业务表数据是否重复
    *
    * @param btmType 业务类型
    * @param ids      处理数据
    * @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("传入业务类型未查询到相应表单,请检查!");
        }
   @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(",")) +")");
    }
         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
    * @param oid     处理数据oid
    * @return 查询到数据的总数
    */
   @Override
@@ -3968,152 +4206,152 @@
         listR.getData().get(0).getTableName() + " where id ='" + id + "' and oid <> '" + oid + "'");
   }
    /**
     * 传入业务类型以及相oid集合查询数据进行返回
     *
     * @param btmType 业务类型
     * @param oids    需要查询的oid集合 逗号分开
     * @return 查询出的数据
     */
    @Override
    public List<BaseModel> selectByTypeAndOid(String btmType, String oids) {
   /**
    * 传入业务类型以及相oid集合查询数据进行返回
    *
    * @param btmType 业务类型
    * @param oids    需要查询的oid集合 逗号分开
    * @return 查询出的数据
    */
   @Override
   public List<BaseModel> selectByTypeAndOid(String btmType, String oids) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //查询数据
        List<Map> maps = commonsMapper.selectBySql("select * from " + listR.getData().get(0).getTableName() + " where oid in ("
                + VciBaseUtil.toInSql(oids.toString()) + ")");
      //使用传入的业务类型查询表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      //查询数据
      List<Map> maps = commonsMapper.selectBySql("select * from " + listR.getData().get(0).getTableName() + " where oid in ("
         + VciBaseUtil.toInSql(oids.toString()) + ")");
        List<BaseModel> baseModels = new ArrayList<>();
        //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
        try {
            for (Map map : maps) {
                Object obj = BaseModel.class.newInstance();
                BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
                for (PropertyDescriptor property : propertyDescriptors) {
                    Method setter = property.getWriteMethod();
                    if (setter != null) {
                        //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错
                        if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
                            LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
                            ZoneId zoneId = ZoneId.systemDefault();
                            ZonedDateTime zdt = localDateTime.atZone(zoneId);
                            Date date = Date.from(zdt.toInstant());
                            setter.invoke(obj, date);
                            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());
                        } else if (map.containsKey(property.getName().toUpperCase())) {
                     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{
      List<BaseModel> baseModels = new ArrayList<>();
      //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
      try {
         for (Map map : maps) {
            Object obj = BaseModel.class.newInstance();
            BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            for (PropertyDescriptor property : propertyDescriptors) {
               Method setter = property.getWriteMethod();
               if (setter != null) {
                  //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错
                  if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
                     LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
                     ZoneId zoneId = ZoneId.systemDefault();
                     ZonedDateTime zdt = localDateTime.atZone(zoneId);
                     Date date = Date.from(zdt.toInstant());
                     setter.invoke(obj, date);
                     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());
                  } else if (map.containsKey(property.getName().toUpperCase())) {
                     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());
                        }
                    }
                }
                for (Object key : map.keySet()) {
                    map.put(key, map.get(key) == null ? null : String.valueOf(map.get(key)));
                }
                     map.remove(property.getName().toUpperCase());
                  }
               }
            }
            for (Object key : map.keySet()) {
               map.put(key, map.get(key) == null ? null : String.valueOf(map.get(key)));
            }
                ((BaseModel) obj).setData(map);
                baseModels.add((BaseModel) obj);
            }
        } catch (Exception e) {
            throw new VciBaseException("查询失败:" + e.getMessage());
        }
        return baseModels;
    }
            ((BaseModel) obj).setData(map);
            baseModels.add((BaseModel) obj);
         }
      } catch (Exception e) {
         throw new VciBaseException("查询失败:" + e.getMessage());
      }
      return baseModels;
   }
    /**
     * 根据业务类型名称创建业务数据源对象
     *
     * @param boName 业务类型名称
     * @return 业务数据对象
     */
    public BaseModel createBaseModel(String boName) {
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(boName));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
   /**
    * 根据业务类型名称创建业务数据源对象
    *
    * @param boName 业务类型名称
    * @return 业务数据对象
    */
   public BaseModel createBaseModel(String boName) {
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(boName));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
//        String userName = String.valueOf(AuthUtil.getUser().getUserId());
        BaseModel bo = new BaseModel();
      BaseModel bo = new BaseModel();
//      bo.setOid(VciBaseUtil.getPk());
//      bo.setRevisionid(VciBaseUtil.getPk());
//      bo.setNameoid(VciBaseUtil.getPk());
        bo.setBtmname(boName);
        bo.setLastR("1");
        bo.setFirstR("1");
        bo.setFirstV("1");
        bo.setLastV("1");
        bo.setRevisionRule(listR.getData().get(0).getRevisionRuleId());
        bo.setVersionRule("".equals(listR.getData().get(0).getVersionRule())?"0":listR.getData().get(0).getVersionRule());
        if (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId())) {
            R<List<RevisionRuleVO>> revisionRuleVO = revisionRuleClient
                    .selectByIdCollection(Collections.singletonList(listR.getData().get(0).getRevisionRuleId().toLowerCase()));
            if(revisionRuleVO.getData().size() != 0 ){
      bo.setBtmname(boName);
      bo.setLastR("1");
      bo.setFirstR("1");
      bo.setFirstV("1");
      bo.setLastV("1");
      bo.setRevisionRule(listR.getData().get(0).getRevisionRuleId());
      bo.setVersionRule("".equals(listR.getData().get(0).getVersionRule()) ? "1" : listR.getData().get(0).getVersionRule());
      if (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId())) {
         R<List<RevisionRuleVO>> revisionRuleVO = revisionRuleClient
            .selectByIdCollection(Collections.singletonList(listR.getData().get(0).getRevisionRuleId().toLowerCase()));
         if (revisionRuleVO.getData().size() != 0) {
            bo.setRevisionValue(revisionRuleVO.getData().get(0).getStartCode());
         }else{
         } else {
            bo.setRevisionValue("1");
         }
        }
        bo.setRevisionSeq(1);
        bo.setVersionSeq(1);
        bo.setVersionValue(getVersionValue(WebUtil.getInt(listR.getData().get(0).getVersionRule())));
        bo.setLctid(listR.getData().get(0).getLifeCycleId());
      }
      bo.setRevisionSeq(1);
      bo.setVersionSeq(1);
      bo.setVersionValue(getVersionValue(WebUtil.getInt(listR.getData().get(0).getVersionRule())));
      bo.setLctid(listR.getData().get(0).getLifeCycleId());
//      if(StringUtils.isNotBlank(listR.getData().get(0).getLifeCycleId())){
//         OsLifeCycleVO lifeCycleVO = lifeService.getLifeCycleById(listR.getData().get(0).getLifeCycleId());
        bo.setLcStatus("Editing");
      bo.setLcStatus("Editing");
//      }
        bo.setId("");
        bo.setName("");
        bo.setDescription("");
        bo.setOwner("1");
      bo.setId("");
      bo.setName("");
      bo.setDescription("");
      bo.setOwner(AuthUtil.getUser().getUserId().toString());
//      bo.setCheckinby(userName);
        bo.setCopyFromVersion("");
      bo.setCopyFromVersion("");
//      this.initTypeAttributeValue(bo,btmTypeVO);
        return bo;
    }
      return bo;
   }
    /**
     * 获取版次的值
     *
     * @param verRuleName 版次的规则
     * @return 版次的值,没有规则则为空
     */
    private String getVersionValue(int verRuleName) {
        if (verRuleName == 0) {
            return "1";
        } else if (verRuleName == 1) {
            return "a";
        } else if (verRuleName == 2) {
            return "0";
        }
        return "";
    }
   /**
    * 获取版次的值
    *
    * @param verRuleName 版次的规则
    * @return 版次的值,没有规则则为空
    */
   private String getVersionValue(int verRuleName) {
      if (verRuleName == 0) {
         return "1";
      } else if (verRuleName == 1) {
         return "a";
      } else if (verRuleName == 2) {
         return "0";
      }
      return "";
   }
    /**
     * 传入业务类型以及相关数据进行批量更新操作
     *
     * @param btmType    业务类型
     * @param baseModels 处理数据
     * @return 处理状态
     */
    @Override
    public R updateBatchByBaseModel(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
   /**
    * 传入业务类型以及相关数据进行批量更新操作
    *
    * @param btmType    业务类型
    * @param baseModels 处理数据
    * @return 处理状态
    */
   @Override
   public R updateBatchByBaseModel(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) {
@@ -4122,30 +4360,31 @@
      Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
         return btmTypeAttributeVO.getId();
      }).collect(Collectors.toSet());
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
      //将bean转为map,mybatis统一处理
      List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));
            } catch (Exception e) {
                throw new VciBaseException("类型转换错误:" + e.getMessage());
            }
        });
        try {
            //注意此处更新成功是返回的-1
            commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps);
        } catch (Exception e) {
            return R.fail("更新失败!" + e.getMessage());
        }
      baseModels.stream().forEach(model -> {
         try {
            maps.add(VciBaseUtil.convertBean2Map(model, existFild));
         } catch (Exception e) {
            throw new VciBaseException("类型转换错误:" + e.getMessage());
         }
      });
      try {
         //注意此处更新成功是返回的-1
         commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps);
      } catch (Exception e) {
         return R.fail("更新失败!" + e.getMessage());
      }
        return R.success("更新成功!");
    }
      return R.success("更新成功!");
   }
   /**
    * 更新业务数据同时对码值表数据操作接口
    *
    * @param btmType 业务类型
    * @param baseModels      处理数据
    * @param btmType    业务类型
    * @param baseModels 处理数据
    * @return 处理状态
    */
   @Transactional(rollbackFor = VciBaseException.class)
@@ -4165,28 +4404,28 @@
      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());
      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);
         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<>();
         List<CodeAllCode> newCodeAllCodeList = new ArrayList<>();
         //将bean转为map,mybatis统一处理
         List<Map<String, String>> maps = new ArrayList<>();
         try {
            baseModels.stream().forEach(baseModel->{
               String oid=baseModel.getOid();
            baseModels.stream().forEach(baseModel -> {
               String oid = baseModel.getOid();
               try {
                  maps.add(VciBaseUtil.convertBean2Map(baseModel,existFild));
                  maps.add(VciBaseUtil.convertBean2Map(baseModel, existFild));
               } catch (Exception e) {
                  throw new VciBaseException("类型转换错误:" + e.getMessage());
               }
               if(cboMap.containsKey(oid)){
                  CodeAllCode codeAllCode=   cboMap.get(oid);
               if (cboMap.containsKey(oid)) {
                  CodeAllCode codeAllCode = cboMap.get(oid);
                  codeAllCode.setId(baseModel.getId());
                  // codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
                  codeAllCode.setLastModifier(AuthUtil.getUser().getAccount());
                  // 主数据推送形式,是拿不到用户信息的
                  codeAllCode.setLastModifier(Func.isBlank(AuthUtil.getUserAccount()) ? applyCodeUserAccount:AuthUtil.getUserAccount());
                  codeAllCode.setLastModifyTime(new Date());
                  codeAllCode.setLcStatus(baseModel.getLcStatus());
                  newCodeAllCodeList.add(codeAllCode);
@@ -4203,200 +4442,201 @@
   }
   /**
     * 获取参照的信息
     *
     * @param referConfigVO 参照的配置
     * @return 列表数据
     */
    @Override
    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接口调用错误;"+allAttributeByBtmId.getMsg());
        }
        if (Func.isEmpty(allAttributeByBtmId.getData())) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        BtmTypeVO btmTypeVO = allAttributeByBtmId.getData();
        /**
         * 加上查询最新版次
         */
        baseQueryObject.getConditionMap().put("lastr", "1");
        baseQueryObject.getConditionMap().put("lastv", "1");
        if (VciBaseUtil.containsKeyUnCaseForMap(baseQueryObject.getConditionMap(), VciQueryWrapperForDO.LC_STATUS_FIELD) &&
                BtmTypeLcStatusConstant.FRAME_WORK_LIFE_CYCLE_NAME.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
            baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, FrameworkDataLCStatus.ENABLED.getValue());
        }
        if (VciBaseUtil.containsKeyUnCaseForMap(baseQueryObject.getConditionMap(), VciQueryWrapperForDO.LC_STATUS_FIELD) &&
                BtmTypeLcStatusConstant.RELEASE_LIFE_CYCLE.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
            baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, CodeDefaultLC.RELEASED.getValue());
        }
    * 获取参照的信息
    *
    * @param referConfigVO 参照的配置
    * @return 列表数据
    */
   @Override
   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接口调用错误;" + allAttributeByBtmId.getMsg());
      }
      if (Func.isEmpty(allAttributeByBtmId.getData())) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      BtmTypeVO btmTypeVO = allAttributeByBtmId.getData();
      /**
       * 加上查询最新版次
       */
      baseQueryObject.getConditionMap().put("lastr", "1");
      baseQueryObject.getConditionMap().put("lastv", "1");
      if (VciBaseUtil.containsKeyUnCaseForMap(baseQueryObject.getConditionMap(), VciQueryWrapperForDO.LC_STATUS_FIELD) &&
         BtmTypeLcStatusConstant.FRAME_WORK_LIFE_CYCLE_NAME.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
         baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, FrameworkDataLCStatus.ENABLED.getValue());
      }
      if (VciBaseUtil.containsKeyUnCaseForMap(baseQueryObject.getConditionMap(), VciQueryWrapperForDO.LC_STATUS_FIELD) &&
         BtmTypeLcStatusConstant.RELEASE_LIFE_CYCLE.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
         baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, CodeDefaultLC.RELEASED.getValue());
      }
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referConfigVO.getReferType()));
        if (!listR.isSuccess()) {
            throw new ServiceException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg() : "业务类型feign接口调用错误!");
        }
        if (listR.getData().isEmpty()) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referConfigVO.getReferType()));
      if (!listR.isSuccess()) {
         throw new ServiceException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg() : "业务类型feign接口调用错误!");
      }
      if (listR.getData().isEmpty()) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      // TODO:参照配置的模糊查询过滤条件暂未处理
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
            String s = baseQueryObject.getConditionMap().get("name");
            s = "%" + s + "%";
            namesql = "and name like" + VciBaseUtil.toInSql(s);
        }
      /*        String namesql = "";
            if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
               String s = baseQueryObject.getConditionMap().get("name");
               s = "%" + s + "%";
               namesql = "and name like" + VciBaseUtil.toInSql(s);
            }
        String codesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("id"))) {
            String s = baseQueryObject.getConditionMap().get("id");
            s = "%" + s + "%";
            codesql = "and id like" + VciBaseUtil.toInSql(s);
        }
            String codesql = "";
            if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("id"))) {
               String s = baseQueryObject.getConditionMap().get("id");
               s = "%" + s + "%";
               codesql = "and id like" + VciBaseUtil.toInSql(s);
            }
        String lcstatusSql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("lcstatus"))) {
            lcstatusSql = "and lcstatus =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lcstatus"));
        }
//        String where = "";
            String lcstatusSql = "";
            if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("lcstatus"))) {
               lcstatusSql = "and lcstatus =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lcstatus"));
            }*/
      //        String where = "";
//        if (StringUtils.isNotBlank(codesql) || StringUtils.isNotBlank(lcstatusSql) || StringUtils.isNotBlank(namesql)) {
//            where = "where ";
//        }
      //        if (StringUtils.isNotBlank(codesql) || StringUtils.isNotBlank(lcstatusSql) || StringUtils.isNotBlank(namesql)) {
      //            where = "where ";
      //        }
      String whereSqlByMap = UBCSCondition.getWhereSqlByMap(baseQueryObject.getConditionMap());
        String num1 = baseQueryObject.getPage() * baseQueryObject.getLimit() + "";
        String num2 = ((baseQueryObject.getPage()) - 1) * baseQueryObject.getLimit() + 1 + "";
      String num1 = baseQueryObject.getPage() * baseQueryObject.getLimit() + "";
      String num2 = ((baseQueryObject.getPage()) - 1) * baseQueryObject.getLimit() + 1 + "";
        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 "+ (baseQueryObject.getLimit()==-1?")": ("where rownum <=" + num1 + ") where rn >=" + num2)
      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 "
         + (Func.isNotBlank(whereSqlByMap) ? "and " + whereSqlByMap : "") + ") t " + (baseQueryObject.getLimit() == -1 ? ")" : ("where rownum <=" + num1 + ") where rn >=" + num2)
      ));
        List<BaseModel> baseModels = new ArrayList<>();
        //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
        try {
            for (Map map : maps) {
                Object obj = BaseModel.class.newInstance();
                BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
                for (PropertyDescriptor property : propertyDescriptors) {
                    Method setter = property.getWriteMethod();
                    if (setter != null) {
                        //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错
                        if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
                            LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
                            ZoneId zoneId = ZoneId.systemDefault();
                            ZonedDateTime zdt = localDateTime.atZone(zoneId);
                            Date date = Date.from(zdt.toInstant());
                            setter.invoke(obj, date);
                            //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());
                        } 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{
      List<BaseModel> baseModels = new ArrayList<>();
      //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
      try {
         for (Map map : maps) {
            Object obj = BaseModel.class.newInstance();
            BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            for (PropertyDescriptor property : propertyDescriptors) {
               Method setter = property.getWriteMethod();
               if (setter != null) {
                  //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错
                  if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
                     LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
                     ZoneId zoneId = ZoneId.systemDefault();
                     ZonedDateTime zdt = localDateTime.atZone(zoneId);
                     Date date = Date.from(zdt.toInstant());
                     setter.invoke(obj, date);
                     //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());
                  } 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());
                        }
                    }
                }
                for (Object key : map.keySet()) {
                    map.put(key, String.valueOf(map.get(key)));
                }
                     //map.remove(property.getName().toUpperCase());
                  }
               }
            }
            for (Object key : map.keySet()) {
               map.put(key, String.valueOf(map.get(key)));
            }
            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) {
            throw new VciBaseException("查询失败:" + e.getMessage());
        }
        int total = commonsMapper.queryCountBySql("select count(*) 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
        );
        IPage<BaseModelVO> objectDataGrid = new Page<>();
        objectDataGrid.setPages(baseQueryObject.getPage());
        objectDataGrid.setCurrent(baseQueryObject.getPage());
        objectDataGrid.setRecords(BaseMdodelWrapper.build().listVO(baseModels));
        objectDataGrid.setSize(baseQueryObject.getLimit());
        objectDataGrid.setTotal(total);
        return objectDataGrid;
    }
            baseModels.add((BaseModel) obj);
         }
      } catch (Exception e) {
         throw new VciBaseException("查询失败:" + e.getMessage());
      }
      int total = commonsMapper.queryCountBySql("select count(*) 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 "
         + (Func.isNotBlank(whereSqlByMap) ? "and " + whereSqlByMap : "")
      );
      IPage<BaseModelVO> objectDataGrid = new Page<>();
      objectDataGrid.setPages(baseQueryObject.getPage());
      objectDataGrid.setCurrent(baseQueryObject.getPage());
      objectDataGrid.setRecords(BaseMdodelWrapper.build().listVO(baseModels));
      objectDataGrid.setSize(baseQueryObject.getLimit());
      objectDataGrid.setTotal(total);
      return objectDataGrid;
   }
    /**
     * 获取树形的参照
     *
     * @param referConfigVO 参照的配置
     * @return 树形的数据
     */
    @Override
    public List<Tree> referTree(UIFormReferVO referConfigVO, TreeQueryObject queryObject) {
        if (queryObject.getConditionMap() == null) {
            queryObject.setConditionMap(new HashMap<>());
        }
   /**
    * 获取树形的参照
    *
    * @param referConfigVO 参照的配置
    * @return 树形的数据
    */
   @Override
   public List<Tree> referTree(UIFormReferVO referConfigVO, TreeQueryObject queryObject) {
      if (queryObject.getConditionMap() == null) {
         queryObject.setConditionMap(new HashMap<>());
      }
        if (queryObject.getParentOid() == null) {
            LambdaQueryWrapper<CodeClassify> lqw = new LambdaQueryWrapper<>();
            String parentValue = referConfigVO.getParentValue().substring(3);
            lqw.inSql(CodeClassify::getOid, parentValue);
            List<String> codeClassifies = classifyService.select1(lqw);
            String oid = codeClassifies.get(0);
            queryObject.setParentOid(oid);
        }
        String oidFieldName = StringUtils.isNotBlank(referConfigVO.getParentUsedField()) ? referConfigVO.getParentUsedField() : referConfigVO.getValueField();
        if (queryObject.isQueryAllLevel()) {
            String parentOidSql = "";
            if (StringUtils.isNotBlank(referConfigVO.getParentValue())) {
                String temp = referConfigVO.getParentValue();
                if (temp.startsWith(QueryOptionConstant.IN)) {
                    temp = temp.substring((QueryOptionConstant.IN).length()).trim();
                    parentOidSql = " in " + ((temp.startsWith("(") && temp.endsWith(")")) ? temp : "(" + temp + ")");
                } else if (temp.startsWith(QueryOptionConstant.NOTIN)) {
                    parentOidSql = " not in " + ((temp.startsWith("(") && temp.endsWith(")")) ? temp : "(" + temp + ")");
                } else if (temp.startsWith(QueryOptionConstant.NOTEQUAL)) {
                    temp = temp.substring((QueryOptionConstant.NOTEQUAL).length()).trim();
                    parentOidSql = QueryOptionConstant.NOTEQUAL + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                } else if (temp.startsWith(QueryOptionConstant.MORETHAN)) {
                    temp = temp.substring((QueryOptionConstant.MORETHAN).length()).trim();
                    parentOidSql = QueryOptionConstant.MORETHAN + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                } else if (temp.startsWith(QueryOptionConstant.MORE)) {
                    temp = temp.substring((QueryOptionConstant.MORE).length()).trim();
                    parentOidSql = QueryOptionConstant.MORE + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                } else if (temp.startsWith(QueryOptionConstant.LESSTHAN)) {
                    temp = temp.substring((QueryOptionConstant.LESSTHAN).length()).trim();
                    parentOidSql = QueryOptionConstant.LESSTHAN + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                } else if (temp.startsWith(QueryOptionConstant.LESS)) {
                    temp = temp.substring((QueryOptionConstant.LESS).length()).trim();
                    parentOidSql = QueryOptionConstant.LESS + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                } else if (temp.startsWith(QueryOptionConstant.ISNOTNULL)) {
                    parentOidSql = " is not null";
                } else if (temp.startsWith(QueryOptionConstant.ISNULL)) {
                    parentOidSql = " is  null";
                } else if (temp.contains("*")) {
                    parentOidSql = " like " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'").replace("*", "%");
                } else {
                    parentOidSql = " = " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
                }
      if (queryObject.getParentOid() == null) {
         LambdaQueryWrapper<CodeClassify> lqw = new LambdaQueryWrapper<>();
         String parentValue = referConfigVO.getParentValue().substring(3);
         lqw.inSql(CodeClassify::getOid, parentValue);
         List<String> codeClassifies = classifyService.select1(lqw);
         String oid = codeClassifies.get(0);
         queryObject.setParentOid(oid);
      }
      String oidFieldName = StringUtils.isNotBlank(referConfigVO.getParentUsedField()) ? referConfigVO.getParentUsedField() : referConfigVO.getValueField();
      if (queryObject.isQueryAllLevel()) {
         String parentOidSql = "";
         if (StringUtils.isNotBlank(referConfigVO.getParentValue())) {
            String temp = referConfigVO.getParentValue();
            if (temp.startsWith(QueryOptionConstant.IN)) {
               temp = temp.substring((QueryOptionConstant.IN).length()).trim();
               parentOidSql = " in " + ((temp.startsWith("(") && temp.endsWith(")")) ? temp : "(" + temp + ")");
            } else if (temp.startsWith(QueryOptionConstant.NOTIN)) {
               parentOidSql = " not in " + ((temp.startsWith("(") && temp.endsWith(")")) ? temp : "(" + temp + ")");
            } else if (temp.startsWith(QueryOptionConstant.NOTEQUAL)) {
               temp = temp.substring((QueryOptionConstant.NOTEQUAL).length()).trim();
               parentOidSql = QueryOptionConstant.NOTEQUAL + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            } else if (temp.startsWith(QueryOptionConstant.MORETHAN)) {
               temp = temp.substring((QueryOptionConstant.MORETHAN).length()).trim();
               parentOidSql = QueryOptionConstant.MORETHAN + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            } else if (temp.startsWith(QueryOptionConstant.MORE)) {
               temp = temp.substring((QueryOptionConstant.MORE).length()).trim();
               parentOidSql = QueryOptionConstant.MORE + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            } else if (temp.startsWith(QueryOptionConstant.LESSTHAN)) {
               temp = temp.substring((QueryOptionConstant.LESSTHAN).length()).trim();
               parentOidSql = QueryOptionConstant.LESSTHAN + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            } else if (temp.startsWith(QueryOptionConstant.LESS)) {
               temp = temp.substring((QueryOptionConstant.LESS).length()).trim();
               parentOidSql = QueryOptionConstant.LESS + " " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            } else if (temp.startsWith(QueryOptionConstant.ISNOTNULL)) {
               parentOidSql = " is not null";
            } else if (temp.startsWith(QueryOptionConstant.ISNULL)) {
               parentOidSql = " is  null";
            } else if (temp.contains("*")) {
               parentOidSql = " like " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'").replace("*", "%");
            } else {
               parentOidSql = " = " + ((temp.startsWith("'") && temp.endsWith("'")) ? temp : "'" + temp + "'");
            }
            }
            //查询全部的信息
            queryObject.getConditionMap().put("oid", QueryOptionConstant.IN + "(select oid from " +
                    getTableName(referConfigVO.getReferType()) +
                    " START WITH " + referConfigVO.getParentFieldName() + " " +
                    parentOidSql +
                    " CONNECT BY PRIOR " + oidFieldName + " = " + referConfigVO.getParentFieldName() + ")");
        } else {
            if (StringUtils.isNotBlank(referConfigVO.getParentFieldName()) && StringUtils.isNotBlank(queryObject.getParentOid())) {
                queryObject.getConditionMap().put(referConfigVO.getParentFieldName(), queryObject.getParentOid());
         }
         //查询全部的信息
         queryObject.getConditionMap().put("oid", QueryOptionConstant.IN + "(select oid from " +
            getTableName(referConfigVO.getReferType()) +
            " START WITH " + referConfigVO.getParentFieldName() + " " +
            parentOidSql +
            " CONNECT BY PRIOR " + oidFieldName + " = " + referConfigVO.getParentFieldName() + ")");
      } else {
         if (StringUtils.isNotBlank(referConfigVO.getParentFieldName()) && StringUtils.isNotBlank(queryObject.getParentOid())) {
            queryObject.getConditionMap().put(referConfigVO.getParentFieldName(), queryObject.getParentOid());
            //查询全部的信息
            String parentOidSql = "";
            if (StringUtils.isNotBlank(referConfigVO.getParentValue())) {
@@ -4439,101 +4679,108 @@
               parentOidSql +
               " CONNECT BY PRIOR " + oidFieldName + " = " + referConfigVO.getParentFieldName() + ")");
         }
        }
        LambdaQueryWrapper<CodeClassify> lqw = new LambdaQueryWrapper<>();
        String sql = queryObject.getConditionMap().get("oid").substring(3);
        lqw.inSql(CodeClassify::getOid, sql);
        List<CodeClassify> codeClassifies = classifyService.selectByWrapper(lqw);
        TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(referConfigVO.getParentFieldName());
        treeWrapperOptions.setOidFieldName(oidFieldName);
        treeWrapperOptions.setTextFieldName(referConfigVO.getTextField());
        treeWrapperOptions.setMultipleSelect(referConfigVO.isMuti());
        treeWrapperOptions.setParentOid(queryObject.getParentOid());
        return revisionModelUtil.doList2Trees(codeClassifies, treeWrapperOptions, null);
    }
      }
      LambdaQueryWrapper<CodeClassify> lqw = new LambdaQueryWrapper<>();
      String sql = queryObject.getConditionMap().get("oid").substring(3);
      lqw.inSql(CodeClassify::getOid, sql);
      List<CodeClassify> codeClassifies = classifyService.selectByWrapper(lqw);
      TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(referConfigVO.getParentFieldName());
      treeWrapperOptions.setOidFieldName(oidFieldName);
      treeWrapperOptions.setTextFieldName(referConfigVO.getTextField());
      treeWrapperOptions.setMultipleSelect(referConfigVO.isMuti());
      treeWrapperOptions.setParentOid(queryObject.getParentOid());
      return revisionModelUtil.doList2Trees(codeClassifies, treeWrapperOptions, null);
   }
    @Override
    public boolean checkUnAttrUnEdit(String attrName) {
        return (VciQueryWrapperForDO.OID_FIELD.equalsIgnoreCase(attrName)
                || "ts".equalsIgnoreCase(attrName)
                || "lastmodifier".equalsIgnoreCase(attrName)
                || "lastmodifytime".equalsIgnoreCase(attrName)
                || "createtime".equalsIgnoreCase(attrName)
                || "checkintime".equalsIgnoreCase(attrName)
                || "checkouttime".equalsIgnoreCase(attrName));
    }
   @Override
   public boolean checkUnAttrUnEdit(String attrName) {
      return (VciQueryWrapperForDO.OID_FIELD.equalsIgnoreCase(attrName)
         || "ts".equalsIgnoreCase(attrName)
         || "lastmodifier".equalsIgnoreCase(attrName)
         || "lastmodifytime".equalsIgnoreCase(attrName)
         || "createtime".equalsIgnoreCase(attrName)
         || "checkintime".equalsIgnoreCase(attrName)
         || "checkouttime".equalsIgnoreCase(attrName));
   }
    private String getTableName(String refertype) {
        if ("codeclassify".equals(refertype)) {
            return "pl_code_classify";
        }
        if ("table".equals(refertype)) {
            return "pl_code_test_table";
        }
        if ("testBtmType".equals(refertype)) {
            return "PLBT_code_testBtmType";
        }
   private String getTableName(String refertype) {
      if ("codeclassify".equals(refertype)) {
         return "pl_code_classify";
      }
      if ("table".equals(refertype)) {
         return "pl_code_test_table";
      }
      if ("testBtmType".equals(refertype)) {
         return "PLBT_code_testBtmType";
      }
        return "pl_code_" + refertype.trim().toLowerCase();
    }
      return "pl_code_" + refertype.trim().toLowerCase();
   }
    public BaseModel reviseBusinessObject(BaseModel fromBo) {
        BaseModel toBo = new BaseModel();
        toBo.setOid(VciBaseUtil.getPk());
        toBo.setRevisionOid(VciBaseUtil.getPk());
        toBo.setNameOid(fromBo.getNameOid());
        toBo.setBtmname(fromBo.getBtmname());
        toBo.setLastR(String.valueOf(1));
   public BaseModel reviseBusinessObject(BaseModel fromBo) {
      BaseModel toBo = new BaseModel();
      toBo.setOid(VciBaseUtil.getPk());
      toBo.setRevisionOid(VciBaseUtil.getPk());
      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.setFirstR(String.valueOf(0));
      toBo.setFirstV(String.valueOf(1));
      toBo.setLastV(String.valueOf(1));
      // 数据升版不需要重新设置创建人,只对最后修改人做更新就可以了
        //toBo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
        toBo.setCreateTime(fromBo.getCreateTime());
        // toBo.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      //toBo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
      toBo.setCreateTime(fromBo.getCreateTime());
      // 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());
      toBo.setLastModifyTime(new Date());
      toBo.setRevisionRule(fromBo.getRevisionRule());
      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());
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      //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();
      String revisionval = "";
      try{
         revisionval = nextRevision.get("REVISIONVAL").toString();
      }catch (Exception e){
         throw new ServiceException("业务数据版次值获取出错,原因:" + e.getMessage());
      }
      // 未查询到版本规则,默认直接给大版本加一
      if(!revisionRuleVOR.isSuccess() || Func.isEmpty(revisionRuleVOR.getData())){
         revisionval = String.valueOf((Integer.parseInt(revisionval)+1));
      }else {
         revisionval = String.valueOf(Integer.parseInt(revisionval)+revisionRuleVOR.getData().getSerialStep());
      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());
        //toBo.setLcStatus("Editing");
      toBo.setVersionSeq(Integer.valueOf(nextRevision.get("VERSIONSEQ").toString()));
      toBo.setVersionValue(nextRevision.get("VERSIONVAL").toString());
      toBo.setLctid(fromBo.getLctid());
      //toBo.setLcStatus("Editing");
      toBo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
        toBo.setId(fromBo.getId());
        toBo.setName(fromBo.getName());
        toBo.setDescription(fromBo.getDescription());
        toBo.setOwner(String.valueOf(AuthUtil.getUser().getUserId()));
        toBo.setCopyFromVersion(fromBo.getOid());
        toBo.getData().putAll(fromBo.getData());
        toBo.getData().put("CHECKINBY", String.valueOf(AuthUtil.getUser().getUserId()));
        return toBo;
    }
      toBo.setId(fromBo.getId());
      toBo.setName(fromBo.getName());
      toBo.setDescription(fromBo.getDescription());
      toBo.setOwner(String.valueOf(AuthUtil.getUser().getUserId()));
      toBo.setCopyFromVersion(fromBo.getOid());
      toBo.getData().putAll(fromBo.getData());
      toBo.getData().put("CHECKINBY", String.valueOf(AuthUtil.getUser().getUserId()));
      return toBo;
   }
   /**
    * 流程中变更状态值
    *
    * @param flowDTO
    * @return
    */
@@ -4543,7 +4790,7 @@
         BaseModelDTO baseModel = new BaseModelDTO();
         baseModel.setOid(s);
         baseModel.setBtmname(flowDTO.getBtmType());
         baseModel.setLcStatus(String.valueOf(flowDTO.getVariableMap().getOrDefault("statusValue","Auditing")));
         baseModel.setLcStatus(String.valueOf(flowDTO.getVariableMap().getOrDefault("statusValue", "Auditing")));
         changeStatus(baseModel);
      });
      return R.success("成功");