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/CodeClassifyValueServiceImpl.java |   90 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 74 insertions(+), 16 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
index 46ce3a2..e0a5d7a 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyValueServiceImpl.java
@@ -5,7 +5,7 @@
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.vci.ubcs.code.constant.MdmBtmTypeConstant;
+
 import com.vci.ubcs.code.dto.CodeClassifyValueDTO;
 import com.vci.ubcs.code.entity.CodeBasicSec;
 import com.vci.ubcs.code.entity.CodeClassifyValue;
@@ -20,11 +20,13 @@
 import com.vci.ubcs.starter.revision.model.TreeWrapperOptions;
 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.web.pagemodel.Tree;
 import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
 import com.vci.ubcs.starter.web.util.VciBaseUtil;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.http.ResponseEntity;
@@ -33,6 +35,7 @@
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import java.rmi.ServerException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -41,7 +44,7 @@
 import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
 
 @Service
-public class CodeClassifyValueServiceImpl  extends ServiceImpl<CodeClassifyValueMapper, CodeClassifyValue> implements ICodeClassifyValueService {
+public class CodeClassifyValueServiceImpl extends ServiceImpl<CodeClassifyValueMapper, CodeClassifyValue> implements ICodeClassifyValueService {
 
 	@Resource
 	private RevisionModelUtil revisionModelUtil;
@@ -59,6 +62,33 @@
 	private static final String PARENT_FIELD_NAME = "parentClassifyValueOid";
 
 	/**
+	 * 鍏嬮殕鍒嗙被鐮佸��
+	 * @param codeClassifyValues
+	 * @return
+	 */
+	@Override
+	public boolean cloneCodeClassifyVaue(List<CodeClassifyValue> codeClassifyValues) {
+		// 鍒涘缓Map瀵硅薄锛岀敤浜庡瓨鍌ㄥ師濮媜id鍜屾柊oid鐨勬槧灏勫叧绯�
+		Map<String, String> oidMap = new HashMap<>();
+		// 閬嶅巻瀵硅薄鏁扮粍锛屼负姣忎釜瀵硅薄鐢熸垚鏂扮殑oid锛屽苟灏嗗師濮媜id鍜屾柊oid鐨勬槧灏勫叧绯诲瓨鍌ㄥ埌Map涓�
+		for (CodeClassifyValue obj : codeClassifyValues) {
+			String originalOid = obj.getOid();
+			String newOid = VciBaseUtil.getPk();
+			oidMap.put(originalOid, newOid);
+		}
+		// 閬嶅巻瀵硅薄鏁扮粍锛屾洿鏂版瘡涓璞$殑oid鍜宑odeClassifySecOid灞炴�у��
+		for (CodeClassifyValue obj : codeClassifyValues) {
+			String originalOid = obj.getOid();
+			String newOid = oidMap.get(originalOid);
+			obj.setOid(newOid);
+			String originalParentClassifyValueOid = obj.getParentClassifyValueOid();
+			String newParentClassifyValueOid = oidMap.get(originalParentClassifyValueOid);
+			obj.setParentClassifyValueOid(newParentClassifyValueOid);
+		}
+		return this.saveBatch(codeClassifyValues);
+	}
+
+	/**
 	 * 鏌ヨ鍒嗙被鐮佹鐨勭爜鍊� 鏍�
 	 * @param treeQueryObject 鏍戞煡璇㈠璞�
 	 * @return 鍒嗙被鐮佹鐨勭爜鍊� 鏄剧ず鏍�
@@ -66,14 +96,13 @@
 	 */
 	@Override
 	public List<Tree> treeCodeClassifyValue(TreeQueryObject treeQueryObject) throws VciBaseException {
-		// List<CodeClassifyValueDO> doList =selectCodeClassifyValueDOByTree(treeQueryObject);
 		List<CodeClassifyValue> doList = selectCodeClassifyValueDO4Tree(treeQueryObject);
 		List<CodeClassifyValueVO> voList = CodeClassifyValueWrapper.build().listVO(doList);
 		TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME);
 		treeWrapperOptions.copyFromTreeQuery(treeQueryObject);
 		return revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyValueVO s) ->{
 			//鍙互鍦ㄨ繖閲屽鐞嗘爲鑺傜偣鐨勬樉绀�
-			return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
+			return (Func.isNotEmpty(s.getId()) ? s.getId():"") + " " + (Func.isNotEmpty(s.getName()) ? s.getName():"") + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
 				.getLcStatus()) ? (" 銆愬仠鐢ㄣ�� ") : "");
 		});
 	}
@@ -101,12 +130,16 @@
 		CodeClassifyValue codeClassifyValueDO = new CodeClassifyValue();
 		BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyValueDTO,codeClassifyValueDO);
 		//濉厖涓�浜涢粯璁ゅ��
-		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyValueDO,MdmBtmTypeConstant.CODE_CLASSIFY_VALUE);
+		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyValueDO, MdmBtmTypeConstant.CODE_CLASSIFY_VALUE);
+		LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
+			.lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifyValueDO.getCodeClassifySecOid());
+		if(Func.isEmpty(codeClassifyValueDO.getParentClassifyValueOid())){
+			wrapper.isNull(CodeClassifyValue::getParentClassifyValueOid);
+		}else{
+			wrapper.eq(CodeClassifyValue::getParentClassifyValueOid, codeClassifyValueDO.getParentClassifyValueOid());
+		}
 		//鏌ヨ
-		List<CodeClassifyValue> existList = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query()
-			.lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifyValueDO.getCodeClassifySecOid())
-			.eq(CodeClassifyValue::getParentClassifyValueOid, codeClassifyValueDO.getParentClassifyValueOid())
-		);
+		List<CodeClassifyValue> existList = codeClassifyValueMapper.selectList(wrapper);
 		codeClassifyValueDO.setOrderNum(existList.size() + 1);
 		boolean resBoolean = codeClassifyValueMapper.insert(codeClassifyValueDO) > 0;
 		return resBoolean;
@@ -216,19 +249,17 @@
 		VciBaseUtil.alertNotNull(codeClassifyValueDTO,"鍒嗙被鐮佹鐨勭爜鍊兼暟鎹璞�",codeClassifyValueDTO.getOid(),"鍒嗙被鐮佹鐨勭爜鍊肩殑涓婚敭");
 		CodeClassifyValue codeClassifyValueDO = selectByOid(codeClassifyValueDTO.getOid());
 		R baseResult = checkIsCanDeleteForDO(codeClassifyValueDTO,codeClassifyValueDO);
-		if(!baseResult.isSuccess()) {
-			//鎵句笅绾х殑锛岃繖涓槸鍙互鍒犻櫎鐨勬椂鍊橰
-			List<String> childrenOids = codeClassifyValueMapper.selectAllLevelChildOid(codeClassifyValueDO.getOid().trim());
+		if(baseResult.isSuccess()) {
+			//鍏堝垹闄や笅绾х爜鍊硷紝鎵句笅绾х殑锛岃繖涓槸鍙互鍒犻櫎鐨勬椂鍊�
+			List<String> childrenOids = codeClassifyValueMapper.selectChildOid(codeClassifyValueDO.getOid().trim());
 			if (!CollectionUtils.isEmpty(childrenOids)) {
 				Collection<Collection<String>> childrenCollections = VciBaseUtil.switchCollectionForOracleIn(childrenOids);
 				for(Collection<String> s : childrenCollections){
-					codeClassifyValueMapper.delete(Wrappers.<CodeClassifyValue>query().lambda().eq(CodeClassifyValue::getOid,s));
+					codeClassifyValueMapper.deleteBatchIds(s);
 				}
 			}
-		}else{
-			return baseResult;
 		}
-		//鎵ц鍒犻櫎鎿嶄綔
+		//鎵ц鍒犻櫎鎿嶄綔锛屽啀鍒犻櫎鐖剁殑鐮佸��
 		boolean resBoolean = codeClassifyValueMapper.deleteById(codeClassifyValueDO.getOid()) > 0;
 		return R.status(resBoolean);
 	}
@@ -394,6 +425,20 @@
 	}
 
 	/**
+	 * 鏍规嵁涓婚敭鑾峰彇鐮佸�煎瓧绗︿覆
+	 * @param oid
+	 * @return
+	 */
+	@Override
+	public String getClassifyValueStr(String oid){
+		if(Func.isEmpty(oid)){
+			return "";
+		}
+		String classifyValueStr = this.codeClassifyValueMapper.getClassifyValueStr(oid);
+		return Func.isEmpty(classifyValueStr) ? "":classifyValueStr;
+	}
+
+	/**
 	 * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
 	 * @param codeClassifyValueDOs 鏁版嵁瀵硅薄鍒楄〃
 	 * @return 鏄剧ず瀵硅薄
@@ -414,6 +459,19 @@
 	}
 
 	/**
+	 * 鏍规嵁codeClassifySecOid鍒犻櫎鐮佸��
+	 * @param codeClassifySecOid
+	 * @return
+	 * @throws ServerException
+	 */
+	@Override
+	public Boolean deleteClassifyValueBySecOid(String codeClassifySecOid) throws ServerException {
+		LambdaQueryWrapper<CodeClassifyValue> wrapper = Wrappers.<CodeClassifyValue>query()
+			.lambda().eq(CodeClassifyValue::getCodeClassifySecOid, codeClassifySecOid);
+		return codeClassifyValueMapper.delete(wrapper) > 0;
+	}
+
+	/**
 	 * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
 	 * @param  codeClassifyValueDO 鏁版嵁瀵硅薄
 	 * @return 鏄剧ず瀵硅薄

--
Gitblit v1.9.3