ludc
2023-09-19 8381325223bee254168855b1b697db31fc591b9e
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -16,6 +16,7 @@
import com.vci.ubcs.code.enumpack.*;
import com.vci.ubcs.code.mapper.CommonsMapper;
import com.vci.ubcs.code.service.*;
import com.vci.ubcs.code.util.ClientBusinessObject;
import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO;
import com.vci.ubcs.code.vo.CodeReferConfigVO;
import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
@@ -56,6 +57,7 @@
import com.vci.ubcs.system.user.feign.IUserClient;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import oracle.sql.TIMESTAMP;
import org.aspectj.apache.bcel.classfile.Code;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.cache.utils.CacheUtil;
@@ -466,7 +468,7 @@
                if (!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyInvokeLevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyInvokeLevel())) {
                    //指定了层级的
                    //注意,因为查询上级分类出来的层级是倒序的,即顶层节点是最大的值
                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> -o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
                    int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
                    if (classifyVOS.size() >= level && level > 0) {
                        classifyVO = classifyVOS.get(level - 1);
@@ -753,7 +755,7 @@
    */
   @Override
   public R checkGroupCode(Map<String, String> parameter) {
      List<CodeClassify> codeClassifyList = classifyService.selectAllLevelParents(parameter.get("oid"));
      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--) {
@@ -1387,6 +1389,9 @@
      uiTableConfigVO.setQueryColumns(queryColumns);
      //set给表格配置属性
      uiFormReferVO.setTableConfig(uiTableConfigVO);
      //字段名不一致,需要手动set
      uiFormReferVO.setMuti(Func.toBoolean(codeReferConfig.getIsMuti()));
      uiFormReferVO.setInitSort(new UIFieldSortVO(codeReferConfig.getSortField(),codeReferConfig.getSortType()));
      // 筛选条件
      HashMap<String, String> whereMap = new HashMap<>();
      if(!CollectionUtils.isEmpty(codeReferConfig.getCodeSrchCondConfigVOS())){
@@ -2800,7 +2805,7 @@
            // 日期码段设置默认值
            if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
               try {
                  secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
                  secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
               }catch (Exception e){
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
               }
@@ -2818,7 +2823,7 @@
            // 日期码段设置默认值
            if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
               try {
                  secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
                  secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
               }catch (Exception e){
                  throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
               }
@@ -2840,7 +2845,7 @@
         // 日期码段设置默认值
         if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
            try {
               secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
               secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
            }catch (Exception e){
               throw new ServiceException("日期码段日期格式配置有误,导致转换出错:"+e.getMessage());
            }
@@ -2867,7 +2872,7 @@
        } else {
            if (CollectionUtils.isEmpty(fullInfoBO.getParentClassifyVOs())) {
                //说明已经是最高层级,
                throw new VciBaseException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
            List<CodeClassifyVO> parentClassifyVOList = fullInfoBO.getParentClassifyVOs().stream().sorted((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())).collect(Collectors.toList());
            //从最高的level开始获取
@@ -2879,7 +2884,7 @@
                }
            }
            if (StringUtils.isBlank(codeRuleOid)) {
                throw new VciBaseException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
                throw new ServiceException("当前主题库分类,以及它的所有的上级分类都没有设置编码规则");
            }
        }
        return ruleService.getObjectHasSecByOid(codeRuleOid);
@@ -3684,8 +3689,67 @@
        return R.success("更新成功!");
    }
   /**
    * 更新业务数据同时对码值表数据操作接口
    *
    * @param btmType 业务类型
    * @param baseModels      处理数据
    * @return 处理状态
    */
   @Transactional(rollbackFor = VciBaseException.class)
   @Override
   public R<Integer> updateBatchBtypeDatas(String btmType, List<BaseModel> baseModels) {
    /**
      //使用传入的业务类型查询表
      R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
      if (!listR.isSuccess() || listR.getData().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      //获取当前业务类型所有字段用来做对比
      R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType);
      if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) {
         throw new VciBaseException("传入业务类型未查询到相应字段信息,请检查!");
      }
      Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
         return btmTypeAttributeVO.getId();
      }).collect(Collectors.toSet());
      if(!CollectionUtils.isEmpty(baseModels)){
         List<String> oidList=baseModels.stream().filter(data-> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getOid())).map(BaseModel::getOid).distinct().collect(Collectors.toList());
         LambdaQueryWrapper<CodeAllCode> lqw = new LambdaQueryWrapper<>();
         lqw.in(CodeAllCode::getCreateCodeOid,oidList);
         List<CodeAllCode> codeAllCodeList= codeAllCodeService.selectByWrapper(lqw);
         Map<String, CodeAllCode> cboMap = codeAllCodeList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getCreateCodeOid(), t -> t));
         List<CodeAllCode> newCodeAllCodeList=new ArrayList<>();
         //将bean转为map,mybatis统一处理
         List<Map<String, String>> maps = new ArrayList<>();
         try {
            baseModels.stream().forEach(baseModel->{
               String oid=baseModel.getOid();
               try {
                  maps.add(VciBaseUtil.convertBean2Map(baseModel,existFild));
               } catch (Exception e) {
                  throw new VciBaseException("类型转换错误:" + e.getMessage());
               }
               if(cboMap.containsKey(oid)){
                  CodeAllCode codeAllCode=   cboMap.get(oid);
                  codeAllCode.setId(baseModel.getId());
                  codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
                  codeAllCode.setLastModifyTime(new Date());
                  codeAllCode.setLcStatus(baseModel.getLcStatus());
                  newCodeAllCodeList.add(codeAllCode);
               }
            });
            commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps);
            codeAllCodeService.saveOrUpdateBatch(newCodeAllCodeList);
         } catch (Exception e) {
            throw new VciBaseException("类型转换错误:" + e.getMessage());
         }
      }
      return R.success("更新成功!");
   }
   /**
     * 获取参照的信息
     *
     * @param referConfigVO 参照的配置
@@ -3697,7 +3761,7 @@
        //使用业务类型查询
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
        if (!allAttributeByBtmId.isSuccess()) {
            throw new ServiceException("业务类型feign接口调用错误!");
            throw new ServiceException("业务类型feign接口调用错误;"+allAttributeByBtmId.getMsg());
        }
        if (Func.isEmpty(allAttributeByBtmId.getData())) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
@@ -3724,6 +3788,7 @@
        if (listR.getData().isEmpty()) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
      // TODO:参照配置的模糊查询过滤条件暂未处理
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
            String s = baseQueryObject.getConditionMap().get("name");