ludc
2023-05-09 1b8120cacac0037fcb1f8ae747c2f54eb735368b
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -20,10 +20,10 @@
import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper;
import com.vci.ubcs.code.mapper.CodeRuleMapper;
import com.vci.ubcs.code.service.*;
import com.vci.ubcs.code.vo.CodeClstempattrVO;
import com.vci.ubcs.code.vo.CodeClstemplateVO;
import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO;
import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO;
import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
import com.vci.ubcs.omd.entity.Dict;
@@ -61,7 +61,6 @@
 */
@Service
public class MdmEngineServiceImpl extends ServiceImpl<CodeAllCodeMapper, CodeAllCode> implements MdmEngineService {
   /**
    * 模板的服务
@@ -106,10 +105,8 @@
    */
   private Logger logger = LoggerFactory.getLogger(getClass());
//   @Autowired
//   private CodeOsbtmtypeMapper codeOsbtmtypeMapper;
   //   @Autowired
   //   private CodeOsbtmtypeMapper codeOsbtmtypeMapper;
   /**
    * 使用分类的主键获取可以使用的模板对象
@@ -142,15 +139,15 @@
    * @return 下拉选项
    */
   @Override
   public List<KeyValue> listComboboxItems(CodeClstempattrVO attrVO) {
   public List<KeyValue> listComboboxItems(CodeClassifyTemplateAttrVO attrVO) {
      List<KeyValue> comboboxKVs = null;
      if (StringUtils.isNotBlank(attrVO.getEnumstring())) {
         comboboxKVs = JSONObject.parseArray(attrVO.getEnumstring(), KeyValue.class);
      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<DictBiz>> list = iDictBizClient.getList(attrVO.getEnumid());
         R<List<DictBiz>> list = iDictBizClient.getList(attrVO.getEnumId());
         if(list.isSuccess()){
            for (DictBiz datum : list.getData()) {
               KeyValue keyValue = new KeyValue();
@@ -257,8 +254,8 @@
    * @param orderDTO           编码申请的信息
    */
   private void switchClassifyLevelOnOrder(CodeClstemplateVO templateVO, CodeClassifyFullInfoBO classifyFullInfoBO, CodeOrderDTO orderDTO) {
      Map<String,CodeClstempattrVO> classifyAttrVOMap = templateVO.getAttributes().stream().filter(
         s -> StringUtils.isNotBlank(s.getClassifyinvokeattr()) && StringUtils.isNotBlank(s.getClassifyinvokelevel())
      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) {
         //需要重新查询一下,因为这个是指定的分类进来的
@@ -269,11 +266,11 @@
            //分类注入的编号或者名称,
            //层级包含指定层和最小层
            CodeClassifyVO classifyVO = null;
            if (!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyinvokelevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyinvokelevel())) {
            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());
               int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
               if (classifyVOS.size() >= level && level > 0) {
                  classifyVO = classifyVOS.get(level - 1);
               }
@@ -283,11 +280,11 @@
            }
            if (classifyVO == null) {
               //说明层级有误
               orderDTO.getData().put(attrId, "分类树上没有层级[" + attrVO.getClassifyinvokelevel() + "]");
               orderDTO.getData().put(attrId, "分类树上没有层级[" + attrVO.getClassifyInvokeLevel() + "]");
               // classifyVO = classifyFullInfoBO.getCurrentClassifyVO();
            } else {
               Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO);
               String value = classifyDataMap.getOrDefault(attrVO.getClassifyinvokeattr(), "");
               String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), "");
               orderDTO.getData().put(attrId, value);
            }
         });
@@ -328,9 +325,9 @@
    * @param orderDTO   编码申请的信息
    */
   private void checkRequiredAttrOnOrder(CodeClstemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClstempattrVO> requiredAttrMap = templateVO.getAttributes().stream().filter(
            s -> VciBaseUtil.getBoolean(s.getRequireflag()) && StringUtils.isBlank(s.getComponentrule())
               && StringUtils.isBlank(s.getClassifyinvokeattr()))
      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) -> {
@@ -369,7 +366,7 @@
    * @param orderDTO   编码申请的信息
    */
   private void switchComponentAttrOnOrder(CodeClstemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClstempattrVO> compAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getComponentrule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      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);
@@ -413,11 +410,11 @@
    * @param orderDTO   编码申请的相关的信息
    */
   private void checkVerifyOnOrder(CodeClstemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClstempattrVO> verifyAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getVerifyrule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      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())) {
            if (StringUtils.isNotBlank(value) && !value.matches(attrVO.getVerifyRule())) {
               //校验正则表达式
               throw new VciBaseException("属性[{0}]的值不符合校验规则的要求", new String[]{attrVO.getName()});
            }
@@ -437,7 +434,7 @@
      CodeKeyattrrepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo);
      //注意的是keyRuleVO可能为空,表示不使用规则控制
      //获取所有的关键属性
      Map<String, CodeClstempattrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyattrflag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      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());
      //全部去空的优先级大于去空
@@ -544,7 +541,7 @@
   private void checkEnumOnOrder(CodeClstemplateVO templateVO, CodeOrderDTO orderDTO) {
      //如果枚举可以修改,则不需要校验是否符合枚举的选项
      Map<String, CodeClstempattrVO> 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));
      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);
@@ -566,7 +563,7 @@
    * @param orderDTO   编码申请的信息
    */
   private void switchDateAttrOnOrder(CodeClstemplateVO templateVO, CodeOrderDTO orderDTO) {
      Map<String, CodeClstempattrVO> dateAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getCodedateformat())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
      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);
@@ -757,7 +754,7 @@
//   public void batchSaveSelectChar(CodeClstemplateVO templateVO, List<ClientBusinessObject> cboList) {
//      if (templateVO != null && !CollectionUtils.isEmpty(cboList)) {
//         //是异步的,所以直接循环
//         List<CodeClstempattrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryidentification())).collect(Collectors.toList());
//         List<CodeClassifyTemplateAttrVO> selectAttrVOs = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getLibraryidentification())).collect(Collectors.toList());
//
//         if (!CollectionUtils.isEmpty(selectAttrVOs)) {
////            SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();