| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant; |
| | | import com.vci.ubcs.code.constant.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.code.dto.CodeBasicSecDTO; |
| | | import com.vci.ubcs.code.dto.CodeRuleDTO; |
| | |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.code.wrapper.CodeClassifyWrapper; |
| | | import com.vci.ubcs.code.wrapper.CodeRuleWrapper; |
| | | import com.vci.ubcs.omd.cache.EnumCache; |
| | | import com.vci.ubcs.omd.enums.EnumEnum; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_EDITING; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | |
| | | //将DTO转换为DO |
| | | CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); |
| | | if(!codeRule.getOwner().equals(codeRuleDTO.getOwner())){ |
| | | codeRule.setOwner(codeRuleDTO.getOwner()); |
| | | } |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); |
| | | return R.status(codeRuleMapper.updateById(codeRule)>0); |
| | | } |
| | |
| | | if (!CodeRuleLC.EDITING.getValue().equals(codeRuleDO.getLcStatus())) { |
| | | return R.fail("非编辑状态的编码规则无法发布"); |
| | | } |
| | | // 发布时将码段类型按照字符串分隔的形式拼接并存储 |
| | | String secTypeStr = codeBasicSecService.listCodeBasicSecByRuleOid(codeRuleDO.getOid()).stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); |
| | | codeRuleDO.setBasicSecTypes(secTypeStr); |
| | | count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue())); |
| | | } else { |
| | | return R.fail("暂不支持的操作类型"); |
| | |
| | | */ |
| | | @Override |
| | | public R checkLikeCodeRule(String oid) throws VciBaseException { |
| | | CodeRuleVO codeRuleVO = getObjectByOid(oid); |
| | | // 1、去掉流水码段,计算出其他码段值长度,在已发布的规则中比对出长度一致的编码规则 |
| | | HashMap<String, Object> condtionMap = new HashMap<>(); |
| | | condtionMap.put("pkCodeRule_equal",codeRuleVO.getOid()); |
| | | condtionMap.put("secType_notequal", CodeSecTypeEnum.CODE_SERIAL_SEC); |
| | | codeRuleVO.setSecVOList(codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap)); |
| | | // TODO 待完善 |
| | | // 1、查询出当前要发布的规则 |
| | | CodeRuleVO codeRuleVO = getObjectHasSecByOid(oid); |
| | | // 当前发布的规则不存在码段信息 |
| | | if(Func.isEmpty(codeRuleVO.getSecVOList())){ |
| | | return R.data(null); |
| | | } |
| | | // 2、找出与当前发布的规则码段顺序一致的规则 |
| | | String secTypes = codeRuleVO.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); |
| | | //先查询出所有已发布的编码规则 |
| | | List<CodeRule> codeRuleList = codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getLcStatus, FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_RELEASED)); |
| | | List<CodeRuleVO> codeRuleVOS = codeRuleDO2VOs(codeRuleList, true); |
| | | // 满足码段类型顺序一致的要求的编码规则,可以进入下一步比较规则 |
| | | List<CodeRuleVO> codeRuleVOStream = codeRuleVOS.parallelStream().filter(item -> { |
| | | // 对BasicSec使用orderNum排序(查询的时候其实已经排过一次序了),并将secType用逗号分隔拼接成一个字符串 |
| | | String itemSecTypes = item.getSecVOList().parallelStream().sorted(Comparator.comparing(CodeBasicSecVO::getOrderNum)).map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); |
| | | if (secTypes.equals(itemSecTypes)) { |
| | | return true; |
| | | } |
| | | return false; |
| | | }).collect(Collectors.toList()); |
| | | // 3、各类码段分别进行比对 |
| | | codeRuleVOStream.parallelStream().filter(item->{ |
| | | item.getSecVOList().stream().filter(basicSec->{ |
| | | switch (basicSec.getSecType()){ |
| | | // 属性码段,比对属性和属性所在分类(referCodeClassifyOid) |
| | | case "codeattrsec": |
| | | List<CodeBasicSecVO> codeattrsec = this.getBasicSecBySecType("codeattrsec", codeRuleVO); |
| | | |
| | | break; |
| | | // 可变码段,比对码段长度,编码补位方式和补位时的字符 |
| | | case "codevariablesec": |
| | | break; |
| | | // 固定码段比对按升序排序的码值, |
| | | case "codefixedsec": |
| | | break; |
| | | // 分类码段比对按升序排序码值 |
| | | case "codeclassifysec": |
| | | break; |
| | | // 日期码段比对日期格式 |
| | | case "codedatesec": |
| | | break; |
| | | // 引用码段,比对参照应用的业务类型 |
| | | case "coderefersec": |
| | | break; |
| | | // 层级码段,比对层级类型、层级的值、字符截取类型、取值类型 |
| | | case "codelevelsec": |
| | | break; |
| | | case "codeserialsec": |
| | | // 流水码段比对码段的长度 |
| | | |
| | | // 2、在1、的基础上再比对码段类型的顺序一致的编码跪着 |
| | | |
| | | // 3、在2、的基础上比较码段码值长度,对比出长度相同的编码规则 |
| | | |
| | | // 4、在3、的基础上比较码值是否相同 |
| | | |
| | | |
| | | break; |
| | | default: |
| | | return false; |
| | | } |
| | | return false; |
| | | }); |
| | | return false; |
| | | }); |
| | | // 最后将结果进行返回 |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private List<CodeBasicSecVO> getBasicSecBySecType(String secType,CodeRuleVO codeRuleVO){ |
| | | List<CodeBasicSecVO> codeBasicSecVOList = codeRuleVO.getSecVOList().parallelStream().filter(item -> { |
| | | if (item.getSecType().equals(secType)) { |
| | | return true; |
| | | } |
| | | return false; |
| | | }).collect(Collectors.toList()); |
| | | return codeBasicSecVOList; |
| | | } |
| | | |
| | | /** |
| | |
| | | //如果有lcstatus的类的话 |
| | | vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus())); |
| | | if (hasSec) { |
| | | Map<String, Object> condtionMap = new HashMap<>(); |
| | | condtionMap.put("pkCodeRule",vo.getOid()); |
| | | List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap); |
| | | List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()); |
| | | //查询码段 |
| | | vo.setSecVOList(codeBasicSecVOS); |
| | | } |