| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | 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; |
| | | 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.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | 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 com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.WebUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Resource |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | @Value("${user-info.tenant-id}") |
| | | private String tenantId; |
| | | @Value("${user-info.id}") |
| | | private String userId; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | |
| | | */ |
| | | @Override |
| | | public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) { |
| | | //如果等于自己配置的管理组租户id和管理组超管账号,就不需要按照规则所有者来进行查询 |
| | | if(!(AuthUtil.getTenantId().equals(this.tenantId) && AuthUtil.getUserId().toString().equals(this.userId))){ |
| | | // 按照规则所有者来查询 |
| | | conidtionMap.put("owner",AuthUtil.getUserId()); |
| | | } |
| | | IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class)); |
| | | //do转vo同时setLcStatusText生命周期值,并包装成分页对象返回 |
| | | return CodeRuleWrapper.build().pageVO(codeRuleIPage); |
| | |
| | | @Override |
| | | public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "需要添加的数据对象"); |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | if(checkCodeRuleRepeat(codeRuleDTO)){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | // 将DTO转换为DO |
| | |
| | | |
| | | /** |
| | | * 检查id编号是否重复 |
| | | * @param id 当前编号 |
| | | * @param codeRuleDTO 当前判断是否重复的对象 |
| | | * @return 返回false表示未重复 |
| | | */ |
| | | @Override |
| | | public boolean checkCodeRuleRepeat(String id){ |
| | | Long count = this.codeRuleMapper.selectCount(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, id)); |
| | | if(count>0){ |
| | | return true; |
| | | public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO){ |
| | | List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, codeRuleDTO.getId())); |
| | | if(!codeRulesList.isEmpty()){ |
| | | return codeRulesList.parallelStream().anyMatch(codeRule -> { |
| | | if(StringUtils.isNotBlank(codeRuleDTO.getOid())){ |
| | | // 代表是修改 |
| | | return !codeRule.getOid().equals(codeRuleDTO.getOid()); |
| | | }else { |
| | | return true; |
| | | } |
| | | }); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | * @return true表示可以编辑或删除,false表示不可以 |
| | | */ |
| | | @Override |
| | | public boolean checkEditDelStatus(String lcStatus) { |
| | | public boolean checkEditDelStatus(String lcStatus) throws VciBaseException { |
| | | if (CodeRuleLC.RELEASED.getValue().equals(lcStatus) || CodeRuleLC.DISABLED.getValue().equals(lcStatus)) { |
| | | return false; |
| | | } |
| | |
| | | @Override |
| | | public R editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "数据对象", codeRuleDTO.getOid(), "主数据编码规则主键"); |
| | | if(checkCodeRuleRepeat(codeRuleDTO.getId())){ |
| | | if(checkCodeRuleRepeat(codeRuleDTO)){ |
| | | return R.fail("规则编号已存在!"); |
| | | } |
| | | if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 检查相似编码规则,并返回对应的结果 |
| | | * @param oid 主键 |
| | | * @return 执行结果 |
| | | */ |
| | | @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 待完善 |
| | | |
| | | |
| | | // 2、在1、的基础上再比对码段类型的顺序一致的编码跪着 |
| | | |
| | | // 3、在2、的基础上比较码段码值长度,对比出长度相同的编码规则 |
| | | |
| | | // 4、在3、的基础上比较码值是否相同 |
| | | |
| | | |
| | | // 最后将结果进行返回 |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * |
| | | * @param codeRules 数据对象列表 |
| | |
| | | //如果有lcstatus的类的话 |
| | | vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus())); |
| | | if (hasSec) { |
| | | List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()); |
| | | Map<String, Object> condtionMap = new HashMap<>(); |
| | | condtionMap.put("pkCodeRule",vo.getOid()); |
| | | List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap); |
| | | //查询码段 |
| | | vo.setSecVOList(codeBasicSecVOS); |
| | | } |