From 1ac814a8d8491e432697f58daf91b73404c93b12 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 14 十二月 2024 11:50:54 +0800
Subject: [PATCH] pipIrr-web-temp增加一些日志信息

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java |   62 ++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
index 3cd4e32..f8cfc6e 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
@@ -53,6 +53,8 @@
 		Set<Class<?>> driverClasses = reflections.getTypesAnnotatedWith(AnnotationDriver.class);
 		if (driverClasses != null && driverClasses.size() > 0) {
 			String protocolName;
+			short protocolVersion;
+			String key ;
 			int priority;
 			int onLineDataMinLength;
 			int headMinLength;
@@ -66,14 +68,18 @@
 				if (ann != null) {
 					if (ann.enable()) {
 						protocolName = ann.name();
-						if (!(protocolName.trim().equals(""))) {
-							if (driverMap.containsKey(protocolName)) {
-								throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�(鍚嶇О)" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒");
-							}
-							driverMap.put(protocolName, new AnnotationDriverVo(clazz));
-						} else {
+						protocolVersion = ann.version() ;
+						if(protocolName == null || protocolName.trim().equals("")){
 							throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆");
 						}
+						if(protocolVersion == -1){
+							throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄧ増鏈彿鏈厤缃�");
+						}
+						key = protocolName + protocolVersion ;
+						if (driverMap.containsKey(key)) {
+							throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�(鍚嶇О+鐗堟湰鍙�)" + key + "鍑虹幇浜嗛噸澶嶆敞瑙o紒");
+						}
+						driverMap.put(key, new AnnotationDriverVo(clazz));
 					}
 				}
 			}
@@ -92,6 +98,11 @@
 							throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆");
 						}
 
+						protocolVersion = ann.protocolVersion();
+						if (protocolVersion == -1) {
+							throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁増鏈彿鏈厤缃�");
+						}
+
 						priority = ann.priority();
 						if (priority == 0) {
 							throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0");
@@ -101,18 +112,19 @@
 						}
 
 						onLineDataMinLength = ann.onLineDataMinLength();
-									/*姘旇薄鍗忚涓�0
-									if(onLineDataMinLength == 0){
-										throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂绾挎暟鎹渶灏忛暱搴︽敞瑙d笉鑳戒负0") ;
-									}
-									*/
+						/*姘旇薄鍗忚涓�0
+						if(onLineDataMinLength == 0){
+							throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂绾挎暟鎹渶灏忛暱搴︽敞瑙d笉鑳戒负0") ;
+						}
+						*/
 						headMinLength = ann.headMinLength();
-									/*姘旇薄鍗忚涓�0
-									if(headMinLength == 0){
-										throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂鎶ユ暟鎹殑澶撮儴鏈�灏忛暱搴︽敞瑙d笉鑳戒负0") ;
-									}
-									*/
-						prefixedDataAvailableMap.put(protocolName, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength));
+						/*姘旇薄鍗忚涓�0
+						if(headMinLength == 0){
+							throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂鎶ユ暟鎹殑澶撮儴鏈�灏忛暱搴︽敞瑙d笉鑳戒负0") ;
+						}
+						*/
+						key = protocolName + protocolVersion ;
+						prefixedDataAvailableMap.put(key, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, protocolVersion, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength));
 					}
 				}
 			}
@@ -131,6 +143,11 @@
 							throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆");
 						}
 
+						protocolVersion = ann.protocolVersion();
+						if (protocolVersion == -1) {
+							throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁増鏈彿鏈厤缃�");
+						}
+
 						priority = ann.priority();
 						if (priority == 0) {
 							throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0");
@@ -139,7 +156,8 @@
 							throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅");
 						}
 
-						onLineMap.put(protocolName, new AnnotationOnLineVo(clazz, protocolName, priority));
+						key = protocolName + protocolVersion ;
+						onLineMap.put(key, new AnnotationOnLineVo(clazz, protocolName, protocolVersion, priority));
 					}
 				}
 			}
@@ -204,8 +222,8 @@
 												   HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
 		Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
 		for(AnnotationPrefixedDataAvailableVo vo : col){
-			if(!driverMap.containsKey(vo.protocolName)){
-				return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
+			if(!driverMap.containsKey(vo.protocolName + vo.protocolVersion)){
+				return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶉┍鍔ㄥ悕绉�(" + (vo.protocolName + vo.protocolVersion) + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
 			}
 		}
 
@@ -240,8 +258,8 @@
 									HashMap<String, AnnotationOnLineVo> onLineMap){
 		Collection<AnnotationOnLineVo> col = onLineMap.values();
 		for(AnnotationOnLineVo vo : col){
-			if(!driverMap.containsKey(vo.protocolName)){
-				return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
+			if(!driverMap.containsKey(vo.protocolName + vo.protocolVersion)){
+				return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶉┍鍔ㄥ悕绉�(" + (vo.protocolName + vo.protocolVersion) + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
 			}
 		}
 

--
Gitblit v1.8.0