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 |  340 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 301 insertions(+), 39 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 7ce4a1d..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
@@ -23,46 +23,58 @@
 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.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.*;
+import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
 import com.vci.ubcs.code.lifecycle.CodeRuleLC;
 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.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.BladeQueryObject;
-import com.vci.ubcs.starter.web.pagemodel.KeyValue;
+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 org.springblade.core.log.exception.ServiceException;
+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;
@@ -97,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;
 
 	/**
 	 * 鍒嗛〉鏌ヨ
@@ -111,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);
@@ -125,15 +156,46 @@
 	 * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
 	 */
 	@Override
-	public boolean addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
+	public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
 		VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
-		//灏咲TO杞崲涓篋O
+		if(checkCodeRuleRepeat(codeRuleDTO)){
+			return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒");
+		}
+		// 灏咲TO杞崲涓篋O
 		CodeRule codeRule = Objects.requireNonNull(BeanUtil.copy(codeRuleDTO, CodeRule.class));
-		String userId = AuthUtil.getUserId().toString();
+		// 濉厖榛樿鍊�
 		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE);
 		codeRule.setLctid(CODE_RULE_LC);
 		codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING);
-		return codeRuleMapper.insert(codeRule)>0;
+		codeRule.setOwnerText(AuthUtil.getUserAccount()+"("+AuthUtil.getNickName()+")");
+		return R.status(codeRuleMapper.insert(codeRule)>0);
+	}
+
+	/**
+	 * 妫�鏌d缂栧彿鏄惁閲嶅
+	 * @param codeRuleDTO 褰撳墠鍒ゆ柇鏄惁閲嶅鐨勫璞�
+	 * @return 杩斿洖false琛ㄧず鏈噸澶�
+	 */
+	@Override
+	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〃鏄慨鏀硅鍒欙紝涓嶆槸灏嗙紪鍙蜂慨鏀逛负宸插瓨鍦ㄧ殑鐨勭紪鍙�
+					return !codeRule.getOid().equals(codeRuleDTO.getOid());
+				}else {
+					return true;
+				}
+			});
+		}
+		return false;
 	}
 
 	/**
@@ -143,7 +205,7 @@
 	 * @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;
 		}
@@ -158,16 +220,28 @@
 	 * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
 	 */
 	@Override
-	public boolean editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{
+	public R editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{
 		VciBaseUtil.alertNotNull(codeRuleDTO, "鏁版嵁瀵硅薄", codeRuleDTO.getOid(), "涓绘暟鎹紪鐮佽鍒欎富閿�");
+		if(checkCodeRuleRepeat(codeRuleDTO)){
+			return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒");
+		}
 		if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) {
 			throw new VciBaseException("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎");
 		}
 		//灏咲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 codeRuleMapper.updateById(codeRule)>0;
+		return R.status(codeRuleMapper.updateById(codeRule)>0);
 	}
 
 	/**
@@ -189,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("缂栫爜瑙勫垯宸茬敓鎴愮紪鐮侊紝涓嶅厑璁稿垹闄�");
@@ -271,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;
@@ -287,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);
 	}
@@ -316,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);
 	}
 
 	/**
@@ -330,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);
 	}
 
 	/**
@@ -340,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);
 				}
@@ -374,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);
@@ -396,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("鏆備笉鏀寔鐨勬搷浣滅被鍨�");
 		}
@@ -415,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())) {
@@ -430,15 +536,44 @@
 			}
 			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);
 	}
-
 
 	/**
 	 * 浣跨敤涓婚敭鑾峰彇缂栫爜瑙勫垯鐨勫唴瀹�
@@ -447,9 +582,135 @@
 	 * @return 瑙勫垯鐨勬樉绀哄璞�
 	 */
 	@Override
-	public CodeRuleVO getObjectHasSecByOid(String oid) {
+	public CodeRuleVO getObjectHasSecByOid(String oid) throws VciBaseException {
 		CodeRule ruleDO = selectByOid(oid);
 		return codeRuleDO2VO(ruleDO, true);
+	}
+
+	/**
+	 * 妫�鏌ョ浉浼肩紪鐮佽鍒欙紝骞惰繑鍥炲搴旂殑缁撴灉
+	 * @param oid 涓婚敭
+	 * @return 鎵ц缁撴灉
+	 */
+	@Override
+	public R checkLikeCodeRule(String oid) throws VciBaseException {
+		// 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);
 	}
 
 	/**
@@ -488,8 +749,9 @@
 			//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
 			vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus()));
 			if (hasSec) {
+				List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid());
 				//鏌ヨ鐮佹
-				vo.setSecVOList(codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()));
+				vo.setSecVOList(codeBasicSecVOS);
 			}
 		}
 		return vo;

--
Gitblit v1.9.3