From 3511619ad42e1706b1e798bf846426f1083bc63d Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期一, 01 七月 2024 15:44:32 +0800 Subject: [PATCH] 靳总协议与王工协议开关阀报数据库层面统一在一起。 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java | 105 +++++++++++++++++++++++++++------------------------- 1 files changed, 55 insertions(+), 50 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 2b3aa3a..3eea8c9 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 @@ -75,14 +75,16 @@ if(clazz.isAnnotationPresent(AnnotationDriver.class)){ AnnotationDriver ann = clazz.getAnnotation(AnnotationDriver.class) ; if(ann != null){ - protocolName = ann.name() ; - if(!(protocolName.trim().equals(""))){ - if(driverMap.containsKey(protocolName)){ - throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ; + 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{ + throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆") ; } - driverMap.put(protocolName, new AnnotationDriverVo(clazz)) ; - }else{ - throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆") ; } } } @@ -91,61 +93,64 @@ if(clazz.isAnnotationPresent(AnnotationPrefixedDataAvailable.class)){ AnnotationPrefixedDataAvailable ann = clazz.getAnnotation(AnnotationPrefixedDataAvailable.class) ; if(ann != null){ - protocolName = ann.protocolName() ; - if(!(protocolName.trim().equals(""))){ - if(prefixedDataAvailableMap.containsKey(protocolName)){ - throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ; + if(ann.enable()){ + protocolName = ann.protocolName() ; + if(!(protocolName.trim().equals(""))){ + if(prefixedDataAvailableMap.containsKey(protocolName)){ + throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ; + } + }else{ + throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ; } - }else{ - throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ; - } - priority = ann.priority() ; - if(priority == 0){ - throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ; - } - if(isRepeatPrefixedDataAvailablePriority(priority, prefixedDataAvailableMap)){ - throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ; - } + priority = ann.priority() ; + if(priority == 0){ + throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ; + } + if(isRepeatPrefixedDataAvailablePriority(priority, prefixedDataAvailableMap)){ + throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ; + } - onLineDataMinLength = ann.onLineDataMinLength() ; - /*姘旇薄鍗忚涓�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)) ; + onLineDataMinLength = ann.onLineDataMinLength() ; + /*姘旇薄鍗忚涓�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)) ; + } } } if(clazz.isAnnotationPresent(AnnotationOnLine.class)){ AnnotationOnLine ann = clazz.getAnnotation(AnnotationOnLine.class) ; if(ann != null){ - protocolName = ann.protocolName() ; - if(!(protocolName.trim().equals(""))){ - if(onLineMap.containsKey(protocolName)){ - throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ; + if(ann.enable()){ + protocolName = ann.protocolName() ; + if(!(protocolName.trim().equals(""))){ + if(onLineMap.containsKey(protocolName)){ + throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ; + } + }else{ + throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ; } - }else{ - throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ; - } - priority = ann.priority() ; - if(priority == 0){ - throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ; - } - if(isRepeatOnLinePriority(priority, onLineMap)){ - throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ; - } + priority = ann.priority() ; + if(priority == 0){ + throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ; + } + if(isRepeatOnLinePriority(priority, onLineMap)){ + throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ; + } - onLineMap.put(protocolName, new AnnotationOnLineVo(clazz, protocolName, priority)) ; + onLineMap.put(protocolName, new AnnotationOnLineVo(clazz, protocolName, priority)) ; + } } } } -- Gitblit v1.8.0