From 3534b13391b2a6152d0f91b72fda343b13a947cb Mon Sep 17 00:00:00 2001 From: ludc <ludc@vci-tech.com> Date: 星期三, 22 一月 2025 15:55:27 +0800 Subject: [PATCH] 分类码段码值管理查询去除null的情况,分类码段生成编码时去除码值为null的情况 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 312 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 260 insertions(+), 52 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java index 83fafcf..6381134 100644 --- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java @@ -17,11 +17,15 @@ package com.vci.ubcs.code.service.impl; import com.alibaba.cloud.commons.lang.StringUtils; +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.vci.ubcs.code.constant.MdmBtmTypeConstant; +import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; +import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant; + import com.vci.ubcs.code.dto.CodeBasicSecDTO; import com.vci.ubcs.code.dto.CodeRuleDTO; import com.vci.ubcs.code.entity.*; @@ -30,36 +34,47 @@ import com.vci.ubcs.code.mapper.CodeRuleMapper; import com.vci.ubcs.code.mapper.CodeSerialValueMapper; import com.vci.ubcs.code.mapper.CommonsMapper; -import com.vci.ubcs.code.service.ICodeAllCodeService; -import com.vci.ubcs.code.service.ICodeBasicSecService; -import com.vci.ubcs.code.service.ICodeClassifyService; -import com.vci.ubcs.code.service.ICodeRuleService; -import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO; -import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; -import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; +import com.vci.ubcs.code.service.*; +import com.vci.ubcs.code.vo.pagemodel.*; 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.model.TreeQueryObject; import com.vci.ubcs.starter.revision.service.RevisionModelUtil; import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; +import com.vci.ubcs.starter.util.MdmBtmTypeConstant; import com.vci.ubcs.starter.util.UBCSCondition; import com.vci.ubcs.starter.web.pagemodel.*; 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 com.vci.ubcs.system.cache.NacosConfigCache; +import com.vci.ubcs.system.entity.Strategy; +import com.vci.ubcs.system.feign.ISysClient; +import com.vci.ubcs.system.user.entity.User; +import com.vci.ubcs.system.user.feign.IUserClient; 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.IResultCode; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +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; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.rmi.ServerException; 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; @@ -94,12 +109,23 @@ private ICodeAllCodeService codeAllcodeService; @Resource private ICodeBasicSecService codeBasicSecService; + @Resource + private ICodeClassifyValueService iCodeClassifyValueService; /** * 瀵硅薄鐨勬搷浣� */ @Resource private RevisionModelUtil revisionModelUtil; + + @Resource + private ICodeFixedValueService codeFixedValueService; + + /** + * 绯荤粺鏈嶅姟 + */ + @Resource + private IUserClient userClient; /** * 鍒嗛〉鏌ヨ @@ -108,7 +134,15 @@ * @return */ @Override - public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) { + public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) throws VciBaseException { + //int i = 1 / 0; + //濡傛灉绛変簬鑷繁閰嶇疆鐨勭鐞嗙粍绉熸埛id鍜岀鐞嗙粍瓒呯璐﹀彿锛屽氨涓嶉渶瑕佹寜鐓ц鍒欐墍鏈夎�呮潵杩涜鏌ヨ + /*if(!(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId()) + && AuthUtil.getUserId().toString().equals(NacosConfigCache.getAdminUserInfo().getUserId().toString())) + ){ + // 鎸夌収瑙勫垯鎵�鏈夎�呮潵鏌ヨ + conidtionMap.put("owner",AuthUtil.getUserId().toString()); + }*/ IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class)); //do杞瑅o鍚屾椂setLcStatusText鐢熷懡鍛ㄦ湡鍊硷紝骞跺寘瑁呮垚鍒嗛〉瀵硅薄杩斿洖 return CodeRuleWrapper.build().pageVO(codeRuleIPage); @@ -133,6 +167,7 @@ DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE); codeRule.setLctid(CODE_RULE_LC); codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING); + codeRule.setOwnerText(AuthUtil.getUserAccount()+"("+AuthUtil.getNickName()+")"); return R.status(codeRuleMapper.insert(codeRule)>0); } @@ -142,12 +177,18 @@ * @return 杩斿洖false琛ㄧず鏈噸澶� */ @Override - public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO){ - List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, codeRuleDTO.getId())); + public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO)throws VciBaseException { + LambdaQueryWrapper<CodeRule> wrapper = Wrappers.<CodeRule>query() + .lambda().eq(CodeRule::getId, codeRuleDTO.getId()); + if(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())){ + wrapper.eq(CodeRule::getTenantId,AuthUtil.getTenantId()); + } + // 鏍规嵁瑙勫垯id鏌ヨ缂栧彿 + List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(wrapper); if(!codeRulesList.isEmpty()){ return codeRulesList.parallelStream().anyMatch(codeRule -> { if(StringUtils.isNotBlank(codeRuleDTO.getOid())){ - // 浠h〃鏄慨鏀� + // 浠h〃鏄慨鏀硅鍒欙紝涓嶆槸灏嗙紪鍙蜂慨鏀逛负宸插瓨鍦ㄧ殑鐨勭紪鍙� return !codeRule.getOid().equals(codeRuleDTO.getOid()); }else { return true; @@ -190,6 +231,15 @@ //灏咲TO杞崲涓篋O CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); + if(!codeRule.getOwner().equals(codeRuleDTO.getOwner())){ + codeRule.setOwner(codeRuleDTO.getOwner()); + R<User> userR = userClient.userInfoById(Func.toLong(codeRuleDTO.getOwner())); + if(!userR.isSuccess() || Func.isEmpty(userR.getData())){ + codeRule.setOwnerText(codeRuleDTO.getOwner()); + }else{ + codeRule.setOwnerText(userR.getData().getAccount()+"("+userR.getData().getRealName()+")"); + } + } DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); return R.status(codeRuleMapper.updateById(codeRule)>0); } @@ -213,7 +263,6 @@ return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄わ紒"); } } - List<CodeAllCode> codeDOList = codeAllcodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCodeRuleOid, codeRuleDTO.getOid())); if (!CollectionUtils.isEmpty(codeDOList)) { return R.fail("缂栫爜瑙勫垯宸茬敓鎴愮紪鐮侊紝涓嶅厑璁稿垹闄�"); @@ -295,7 +344,7 @@ * @return true琛ㄧず宸茬粡浣跨敤锛宖alse琛ㄧず鏈浣跨敤 */ @Override - public boolean isAlreadyInUse(String oid) { + public boolean isAlreadyInUse(String oid) throws VciBaseException { Collection<CodeClassifyVO> codeClassifyVOS = listUseRangeInCodeClassify(oid); if (codeClassifyVOS.size() > 0) { return true; @@ -311,7 +360,7 @@ * @return 涓婚搴撳垎绫讳娇鐢ㄥ埌璇ョ紪鐮佽鍒欑殑鎵�鏈夐泦鍚� */ @Override - public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) { + public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) throws VciBaseException { List<CodeClassify> codeClassifies = codeClassifyServcie.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getCodeRuleOid, oid)); return CodeClassifyWrapper.build().listVO(codeClassifies); } @@ -340,7 +389,7 @@ public Collection<CodeRuleVO> listCodeRuleByOids(Collection<String> oidCollections) throws VciBaseException { VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎"); List<CodeRule> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections); - return CodeRuleWrapper.build().listVO(codeRuleDOList); + return codeRuleDO2VOs(codeRuleDOList,true); } /** @@ -354,8 +403,8 @@ @Override public Collection<CodeRuleVO> listCodeRuleByIds(Collection<String> oidCollections, boolean hasSec) throws VciBaseException { VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎"); - List<CodeRule> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections); - return codeRuleDO2VOs(codeRuleDOList, true); + List<CodeRule> codeRuleDOList = listCodeRuleDOByIdCollections(oidCollections); + return codeRuleDO2VOs(codeRuleDOList, hasSec); } /** @@ -364,12 +413,35 @@ * @param oidCollections 涓婚敭鐨勯泦鍚� * @return 鏁版嵁瀵硅薄鍒楄〃 */ - private List<CodeRule> listCodeRuleDOByOidCollections(Collection<String> oidCollections) { + private List<CodeRule> listCodeRuleDOByOidCollections(Collection<String> oidCollections) throws VciBaseException { List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>(); if (!CollectionUtils.isEmpty(oidCollections)) { Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); for (Collection<String> oids : oidCollectionsList) { List<CodeRule> tempDOList = codeRuleMapper.selectBatchIds(oids); + if (!CollectionUtils.isEmpty(tempDOList)) { + codeRuleDOList.addAll(tempDOList); + } + } + } + return codeRuleDOList; + } + + /** + * 浣跨敤瑙勫垯id闆嗗悎鏌ヨ鏁版嵁瀵硅薄 + * + * @param idCollections id鐨勯泦鍚� + * @return 鏁版嵁瀵硅薄鍒楄〃 + */ + private List<CodeRule> listCodeRuleDOByIdCollections(Collection<String> idCollections) throws VciBaseException { + List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>(); + if (!CollectionUtils.isEmpty(idCollections)) { + Collection<Collection<String>> idCollectionsList = VciBaseUtil.switchCollectionForOracleIn(idCollections); + for (Collection<String> ids : idCollectionsList) { + List<CodeRule> tempDOList = codeRuleMapper.selectList( + Wrappers.<CodeRule>query() + .lambda().in(CodeRule::getId,ids) + ); if (!CollectionUtils.isEmpty(tempDOList)) { codeRuleDOList.addAll(tempDOList); } @@ -398,7 +470,7 @@ * @return 鎵ц缁撴灉 */ @Override - public R updateStatus(String oid, String update) { + public R updateStatus(String oid, String update) throws VciBaseException { int count = 0; //鍏堟煡璇㈠璞� CodeRule codeRuleDO = selectByOid(oid); @@ -420,7 +492,9 @@ if (!CodeRuleLC.EDITING.getValue().equals(codeRuleDO.getLcStatus())) { return R.fail("闈炵紪杈戠姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍙戝竷"); } - count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue())); + // 鍙戝竷鏃跺皢鐮佹绫诲瀷鎸夌収瀛楃涓插垎闅旂殑褰㈠紡鎷兼帴骞跺瓨鍌� + String secTypeStr = codeBasicSecService.listCodeBasicSecByRuleOid(codeRuleDO.getOid()).stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); + count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue()).set(CodeRule::getBasicSecTypes,secTypeStr)); } else { return R.fail("鏆備笉鏀寔鐨勬搷浣滅被鍨�"); } @@ -439,14 +513,22 @@ */ @Override @Transactional(rollbackFor = Exception.class) - public R cloneCodeRule(CodeRuleDTO codeRuleDTO) { + public R cloneCodeRule(CodeRuleDTO codeRuleDTO) throws ServerException { + if(checkCodeRuleRepeat(codeRuleDTO)){ + return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒"); + } VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); CodeRule codeRuleDO = new CodeRule(); BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDTO, codeRuleDO); - boolean exFlag = codeRuleMapper.insert(codeRuleDO)>0; + DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleDO,MdmBtmTypeConstant.CODE_RULE); + boolean exFlag = SqlHelper.retBool(codeRuleMapper.insert(codeRuleDO)); + List<CodeBasicSecDTO> secList = codeRuleDTO.getElements(); List<CodeBasicSec> codeBasicSecs = new ArrayList<>(); - secList.forEach(codeBasicSecDTO -> { + List<CodeBasicSec> codeClassifySec = new ArrayList<>(); + // 鍥哄畾鐮佸�兼槧灏勫叧绯� + Map<String,List<CodeFixedValue>> codeFixedValueMaps = new HashMap<>(); + for (CodeBasicSecDTO codeBasicSecDTO : secList) { codeBasicSecDTO.setPkCodeRule(codeRuleDO.getOid()); KeyValue attrKv = codeBasicSecService.checkAttrNullableBySecType(codeBasicSecDTO); if (!"success".equals(attrKv.getKey())) { @@ -454,13 +536,43 @@ } CodeBasicSec codeBasicSecDO = new CodeBasicSec(); BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO); - codeBasicSecDO.setOid(""); - codeBasicSecDO.setRevisionOid(""); - codeBasicSecDO.setNameOid(""); + String oldBasicOid = codeBasicSecDO.getOid(); //琚厠闅嗙殑鐮佹鐨刼id + // 鍒ゆ柇鏄惁鏄垎绫荤爜娈� + if(codeBasicSecDO.getSecType().equals(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue())){ + // 瀛樺偍鏃х殑鐮佹oid鍜屾柊鐨勭爜娈电殑oid鐨勫叧鑱斿叧绯� + codeClassifySec.add(codeBasicSecDO); + continue; + } + // 鏇存敼鍒涘缓鏃堕棿锛屼慨鏀规椂闂寸瓑榛樿鍊� + DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC); + // 鍥哄畾鐮佹 + if(codeBasicSecDO.getSecType().equals(CodeSecTypeEnum.CODE_FIXED_SEC.getValue())){ + // 鍥哄畾鐮佹瀛樺偍濂給id鍜岀爜鍊肩殑鍏宠仈鍏崇郴 + codeFixedValueMaps.put(codeBasicSecDO.getOid(),codeFixedValueService.list(Wrappers.<CodeFixedValue>query() + .lambda().eq(CodeFixedValue::getCodeFixedSecOid, oldBasicOid) + )); + } codeBasicSecs.add(codeBasicSecDO); - }); + } + // 澶勭悊鍒嗙被鐮佹鐨刼id锛屽洜涓簅id鍏宠仈parentClassifyOid锛屼笌鐮佸�糲odeClassifyOid锛岀爜鍊煎張闇�瑕侀�氳繃鏃х殑鐮佹oid鏉ユ煡璇紝鎵�浠ヤ笉鑳界洿鎺ユ敼鍙榦id + boolean resChangeAssn = codeBasicSecService.changeParentOidAssnOid(codeClassifySec); + // 灏嗗鐞嗚繃鐨勫垎绫荤爜娈典篃娣诲姞杩涜鍋氭柊澧炲鐞嗙殑鐮佹闆嗗悎涓� + codeBasicSecs.addAll(codeClassifySec); + // 鏂板鐮佹 boolean exFlag1 = this.codeBasicSecService.saveBatch(codeBasicSecs); - return R.data(exFlag&&exFlag1); + // 鏈�缁堣瀛樺叆鐮佸�艰〃涓殑锛岀爜鍊煎璞� + List<CodeFixedValue> codeFixedDOValues = new ArrayList<>(); + // 鏋勯�犵爜鍊煎璞★紝涓庣爜娈典富閿叧鑱斿叧绯伙紝浠ュ強鏀瑰彉鐮佸�肩殑oid + codeFixedValueMaps.forEach((key, value) -> { + value.stream().forEach(item -> { + item.setOid(""); + item.setCodeFixedSecOid(key); + DefaultAttrAssimtUtil.updateDefaultAttrAssimt(item); + codeFixedDOValues.add(item); + }); + }); + boolean exFlag2 = codeFixedValueService.saveBatch(codeFixedDOValues) && resChangeAssn; + return R.data(exFlag&&exFlag1&&exFlag2); } /** @@ -470,7 +582,7 @@ * @return 瑙勫垯鐨勬樉绀哄璞� */ @Override - public CodeRuleVO getObjectHasSecByOid(String oid) { + public CodeRuleVO getObjectHasSecByOid(String oid) throws VciBaseException { CodeRule ruleDO = selectByOid(oid); return codeRuleDO2VO(ruleDO, true); } @@ -482,25 +594,123 @@ */ @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; + // 1銆佹煡璇㈠嚭褰撳墠瑕佸彂甯冪殑瑙勫垯 + CodeRuleVO releaseCodeRule = getObjectHasSecByOid(oid); + // 褰撳墠鍙戝竷鐨勮鍒欎笉瀛樺湪鐮佹淇℃伅锛岀洿鎺ョ┖淇℃伅杩斿洖 + if(Func.isEmpty(releaseCodeRule.getSecVOList())){ + return R.fail("瑙勫垯淇℃伅涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�"); + } + // 2銆佹壘鍑轰笌褰撳墠鍙戝竷鐨勮鍒欑爜娈甸『搴忎竴鑷寸殑瑙勫垯 + String secTypes = releaseCodeRule.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); + // 鏌ヨ鍑烘墍鏈夊凡鍙戝竷鐨勭紪鐮佽鍒欎腑鐮佹绫诲瀷椤哄簭涓庡綋鍓嶈鍙戝竷鐨勮鍒欓『搴忎竴鑷寸殑缂栫爜瑙勫垯锛屾鏃跺凡杩戣繃婊ゆ帀澶ч儴鍒嗚鍒欙紝杩愮畻閲忓噺灏� + List<CodeRule> codeRuleList = codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda() + .eq(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue()) + .eq(CodeRule::getBasicSecTypes,secTypes) + ); + // 涓虹┖锛岃瘉鏄庝笉瀛樺湪绫诲悓鐨勭紪鐮佽鍒欑洿鎺ヨ繑鍥� + if(Func.isEmpty(codeRuleList)){ + return R.data(new ResultDataVO(true)); + } + // 鏌ヨ鍑哄熀纭�鐮佹鍒楄〃锛堟寜鐓rderNum鍗囧簭鎺掑簭锛� + List<CodeRuleVO> codeRuleVOS = codeRuleDO2VOs(codeRuleList, true); + // 3銆佸悇绫荤爜娈靛垎鍒繘琛屾瘮瀵� + List<CodeRuleVO> lastCodeRule = new ArrayList<>(); + codeRuleVOS.stream().forEach(item->{ + List<CodeBasicSecVO> secVOList = item.getSecVOList(); + boolean flag = true; + for (int index = 0; index < secVOList.size(); index++) { + // 褰撳墠瑕佸彂甯冪殑瑙勫垯鍖呭惈鐨勭爜娈典俊鎭� + CodeBasicSecVO releaseBasicSec = releaseCodeRule.getSecVOList().get(index); + // 宸插彂甯冪殑瑙勫垯鍖呭惈鐨勭爜娈典俊鎭� + CodeBasicSecVO releasedBasicSec = secVOList.get(index); + // 鍥犱负鐮佹椤哄簭閮芥槸鎸夌収OrderNum鎺掑簭鐨勶紝鎵�浠ョ洿鎺ユ寜鐓т笅鏍囦袱涓ゆ瘮杈冨氨鍙互浜� + switch (releasedBasicSec.getSecType()){ + // 灞炴�х爜娈碉紝姣斿灞炴�у拰灞炴�ф墍鍦ㄥ垎绫�(referCodeClassifyOid) + case "codeattrsec": + if(!releasedBasicSec.getReferCodeClassifyOid().equals(releaseBasicSec.getReferCodeClassifyOid())){ + flag = false; + } + break; + // 鍙彉鐮佹锛屾瘮瀵圭爜娈甸暱搴︼紝缂栫爜琛ヤ綅鏂瑰紡鍜岃ˉ浣嶆椂鐨勫瓧绗� + case "codevariablesec": + if(!(releasedBasicSec.getCodeSecLength().equals(releaseBasicSec.getCodeSecLength()) + && releasedBasicSec.getCodeFillType().equals(releaseBasicSec.getCodeFillType()) + && releasedBasicSec.getCodeFillSeparator().equals(releaseBasicSec.getCodeFillSeparator()))){ + flag = false; + } + break; + // 鍥哄畾鐮佹姣斿鎸夊崌搴忔帓搴忕殑鐮佸�硷紝 + case "codefixedsec": + if(Func.isNotEmpty(releasedBasicSec.getFixedValueVOList()) && Func.isNotEmpty(releaseBasicSec.getFixedValueVOList())){ + // 灏唂ixedValue鎸夌収閫楀彿鍒嗛殧鎷兼帴璧锋潵锛屼互渚挎瘮杈冿紝鐢变簬鏌ヨ鏃跺凡鎸夌収orderNum鎺掕繃搴忎簡锛屾墍浠ヤ笉闇�瑕佸啀娆℃帓搴� + String reledFixedValues = releasedBasicSec.getFixedValueVOList().stream().map(CodeFixedValueVO::getId).collect(Collectors.joining(",")); + String releFixedValues = releaseBasicSec.getFixedValueVOList().stream().map(CodeFixedValueVO::getId).collect(Collectors.joining(",")); + if(reledFixedValues.equals(releFixedValues)){ + flag = false; + } + } + break; + // 鍒嗙被鐮佹姣斿鎸夊崌搴忔帓搴忕爜鍊� + case "codeclassifysec": + String classifyValueStr = this.iCodeClassifyValueService.getClassifyValueStr(releasedBasicSec.getOid()); + String classifyValueStr1 = this.iCodeClassifyValueService.getClassifyValueStr(releaseBasicSec.getOid()); + if(classifyValueStr.equals(classifyValueStr1)){ + flag = false; + } + break; + // 鏃ユ湡鐮佹姣斿鏃ユ湡鏍煎紡 + case "codedatesec": + if(!releasedBasicSec.getCodeDateFormatStr().equals(releaseBasicSec.getCodeDateFormatStr())){ + flag = false; + } + break; + // 寮曠敤鐮佹锛屾瘮瀵瑰弬鐓у紩鐢ㄧ殑涓氬姟绫诲瀷 + case "coderefersec": + if(!releasedBasicSec.getReferBtmId().equals(releaseBasicSec.getReferBtmId())){ + flag = false; + } + break; + // 灞傜骇鐮佹锛屾瘮瀵瑰眰绾х被鍨嬨�佸眰绾х殑鍊笺�佸瓧绗︽埅鍙栫被鍨嬨�佸彇鍊肩被鍨� + case "codelevelsec": + if(!(releasedBasicSec.getCodeLevelType().equals(releaseBasicSec.getCodeLevelType()) + /*鍏堝仛闈炵┖鍒ゆ柇锛屽洜涓烘敼灞炴�т笉鏄繀濉睘鎬�*/ + && (Func.isNotEmpty(releasedBasicSec.getCodeLevelValue()) && Func.isNotEmpty(releaseBasicSec.getCodeLevelValue())) + && releasedBasicSec.getCodeLevelValue().equals(releaseBasicSec.getCodeLevelValue()) + && releasedBasicSec.getValueCutType().equals(releaseBasicSec.getValueCutType()) + && releasedBasicSec.getCodeGetValueType().equals(releaseBasicSec.getCodeGetValueType()))){ + flag = false; + } + break; + // 娴佹按鐮佹姣斿鐮佹鐨勯暱搴� + case "codeserialsec": + if(!releasedBasicSec.getCodeFillLength().equals(releaseBasicSec.getCodeFillLength())){ + flag = false; + } + break; + } + if (!flag) { + break; + } + } + // 婊¤冻鎵�鏈夌爜娈电被鍨嬫瘮瀵规潯浠剁殑瑙勫垯 + if (flag) { + lastCodeRule.add(item); + } + }); + // 涓虹┖鏃惰鏄庢楠�3娌℃瘮瀵瑰嚭绫讳技鐨勭紪鐮佽鍒� + if(lastCodeRule.isEmpty()){ + return R.data(new ResultDataVO(true)); + } + StringBuffer resMsg = new StringBuffer(); + resMsg.append("瀛樺湪濡備笅鐩镐技瑙勫垯锛屾槸鍚︾户缁彂甯冿紵\n"); + // 鏈�鍚庡皢缁撴灉杩涜澶勭悊骞惰繑鍥� + lastCodeRule.stream().forEach(item->{ + resMsg.append(item.getName()); + resMsg.append(item.getId()); + resMsg.append("缂栫爜瑙勫垯;\n"); + }); + ResultDataVO resultDataVO = new ResultDataVO(false,resMsg.toString()); + return R.data(resultDataVO); } /** @@ -539,9 +749,7 @@ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus())); if (hasSec) { - Map<String, Object> condtionMap = new HashMap<>(); - condtionMap.put("pkCodeRule_equal",vo.getOid()); - List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap); + List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()); //鏌ヨ鐮佹 vo.setSecVOList(codeBasicSecVOS); } -- Gitblit v1.9.3