From 28ca3d9f9e6e7eeeb7a7f2a7f50012350f3934c3 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 13 十一月 2024 18:07:11 +0800
Subject: [PATCH] 优化业务数据的查询接口;修改业务数据保存和编辑接口没有保存基础默认属性问题。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java |   45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
index 31b4c62..b4860b3 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java
@@ -5,6 +5,7 @@
 import com.vci.client.common.datatype.VTLong;
 import com.vci.client.common.datatype.VTString;
 import com.vci.client.mw.ClientSessionUtility;
+import com.vci.common.utility.ObjectUtility;
 import com.vci.corba.common.PLException;
 import com.vci.corba.omd.atm.AttributeDef;
 import com.vci.corba.omd.ltm.LinkType;
@@ -54,6 +55,7 @@
 import java.util.*;
 import java.util.List;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 //import static com.vci.client.omd.attribpool.ui.VTDataTypePanel.*;
 import static com.vci.omd.constants.AttributeConstants.*;
@@ -166,7 +168,7 @@
 	}
 
 	/**
-	 * 澶熺潃灞炴�ф爲鑺傜偣
+	 * 鏋勯�犲睘鎬ф爲鑺傜偣
 	 * @param parentTreeList
 	 * @param refTypeName
 	 * @param refFlag
@@ -341,7 +343,10 @@
 				attributeVO.setLastModifyTime(new Date(attribItem.modifyTime));
 				attributeVO.setTs(VciDateUtil.str2Date(attribItem.ts,VciDateUtil.DateTimeMillFormat));
 			}catch (Throwable e){
-
+				e.printStackTrace();
+				String errorLog = "灞炴�O杞琕O鏃跺嚭閿欙紝鍘熷洜锛�"+VciBaseUtil.getExceptionMessage(e);
+				logger.error(errorLog);
+				throw new VciBaseException(errorLog);
 			}
 			attributeVO.setLastModifier(attribItem.modifier);
 			attributeVO.setName(attribItem.label);
@@ -638,9 +643,10 @@
 		//妫�鏌ラ粯璁ゅ�间笌灞炴�х被鍨嬫槸鍚﹀尮閰�
 		checkDefValue(osAttributeDTO);
 		boolean compatible = isCompatible(osAttributeVO,osAttributeDTO);
-		boolean hasInstance = hasInstance(osAttributeDTO.getName());
-		//浜х敓鏁版嵁, 骞朵笖涓嶅吋瀹�
-		if(hasInstance && !compatible){
+		//boolean hasInstance = hasInstance(osAttributeDTO.getId()); //涓嶅垽鏂槸鍚︿骇鐢熸暟鎹彧瑕佽寮曠敤灏遍渶瑕佽繘涓�姝ュ垽鏂被鍨嬫槸鍚﹀吋瀹�
+		boolean checkAttrIsUse = this.checkAttrIsUse(osAttributeDTO.getId());
+		//TODO锛氭寜鐓т互鍓嶆搷浣滈厤缃枃妗d腑鐨勯�昏緫搴旇鏄細涓嶈鏄惁浜х敓鏁版嵁鍙琚紩鐢ㄥ氨闇�瑕佽鍒ゆ柇绫诲瀷鏄惁鍏煎锛堝VTString涓嶈兘杞负VTIntger鎴朧TLong锛�
+		if(checkAttrIsUse/*hasInstance*/ && !compatible){
 			throw new PLException("500",new String[]{"鏃犳晥鍙樻洿, 涓嶅吋瀹瑰凡浜х敓鐨勬暟鎹紒"});
 		}
 		String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
@@ -790,6 +796,26 @@
 	 */
 	private boolean hasInstance(String abName) throws PLException {
 		return osBtmService.hasInstance(abName) && osLinkTypeServiceI.hasInstance(abName);
+	}
+
+	/**
+	 * 鏌ョ湅灞炴�ф槸鍚﹁寮曠敤
+	 * @param abName
+	 * @return false鏈寮曠敤 true琚紩鐢�
+	 */
+	private boolean checkAttrIsUse(String abName) throws PLException {
+		if(Func.isBlank(abName)){
+			return false;
+		}
+		String[] btNames = platformClientUtil.getBtmService().getBTNamesByAPName(abName);
+		if(Func.isNotEmpty(btNames)){
+			return true;
+		}
+		String[] ltNames = platformClientUtil.getLinkTypeService().getLTNamesByAPName(abName);
+		if(Func.isNotEmpty(ltNames)){
+			return true;
+		}
+		return false;
 	}
 
 	/**
@@ -973,11 +999,14 @@
 			throw new PLException("500",new String[]{"璇烽�夋嫨瑕佹煡璇㈠簲鐢ㄨ寖鍥寸殑灞炴��!"});
 		}
 		String[] btNames = platformClientUtil.getBtmService().getBTNamesByAPName(attributeName);
-		if(Func.isEmpty(btNames)){
+		String[] ltNames = platformClientUtil.getLinkTypeService().getLTNamesByAPName(attributeName);
+		String[] mergedArray = Stream.concat(Stream.of(btNames), Stream.of(ltNames)).toArray(String[]::new);
+
+		if(Func.isEmpty(mergedArray)){
 			return new ArrayList<>();
 		}
 		List<Map<String,String>> btmNameMapList = new ArrayList<>();
-		Arrays.stream(btNames).forEach(btName->{
+		Arrays.stream(mergedArray).forEach(btName->{
 			Map<String, String> itemMap = new HashMap<>();
 			itemMap.put("attributeName",attributeName);
 			itemMap.put("source",btName);
@@ -1197,7 +1226,7 @@
 					}
 					osAttributeDTO.setBtmTypeId(osAttributePO.getEnumId());
 				}
-				osAttributeDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT));
+				osAttributeDTO.setOid(ObjectUtility.getNewObjectID36());
 				osAttributeDTO.setId(osAttributePO.getId());
 				osAttributeDTO.setName(osAttributePO.getName());
 				osAttributeDTO.setDescription(osAttributePO.getDescription());

--
Gitblit v1.9.3