From 81636c3be211bdd6c32b60df5b89d2026911f24e Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 22 八月 2024 14:53:52 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java | 253 +++----
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnit.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/说明.txt | 1
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/说明.txt | 1
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java | 9
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java | 14
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java | 979 +++++++++++++++----------------
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java | 132 ++--
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnitConfigVo.java | 4
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/util/OrgListener.java | 7
pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml | 6
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/TreeParse.java | 22
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java | 30
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java | 109 +-
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java | 10
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXmlNoSpringboot.java | 33 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/pom.xml | 8
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml | 8
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/resources/application.yml | 2
/dev/null | 90 --
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml4Springboot.java | 36 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/Server.java | 7
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/Server.java | 12
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-common/pom.xml | 7
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/util/SsoListener.java | 7
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/resources/application.yml | 2
pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/resources/application.yml | 2
34 files changed, 908 insertions(+), 903 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/pom.xml b/pipIrr-platform/pipIrr-common/pom.xml
index 6ec010b..436bf5b 100644
--- a/pipIrr-platform/pipIrr-common/pom.xml
+++ b/pipIrr-platform/pipIrr-common/pom.xml
@@ -148,6 +148,13 @@
<artifactId>jna-platform</artifactId>
<version>5.12.1</version>
</dependency>
+ <!-- 绫诲弽灏� -->
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.10.2</version>
+ </dependency>
+
<!-- Hutool鏄竴涓皬鑰屽叏鐨凧ava宸ュ叿绫诲簱(https://github.com/dromara/hutool) -->
<dependency>
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 3eea8c9..3cd4e32 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
@@ -1,13 +1,13 @@
package com.dy.common.mw.protocol;
-import java.net.URI;
-import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
+import java.util.Set;
-import com.dy.common.util.ClassScan;
import com.dy.common.util.NumUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.reflections.Reflections;
/**
* 鎵弿锛�
@@ -19,14 +19,16 @@
*/
@SuppressWarnings("unused")
public class AnnotationScan {
-
- private static String scanRootPackage = "com.dy.common.mw.protocol." ;
+
+ private static final Logger log = LogManager.getLogger(AnnotationScan.class);
+
+ private static String scanRootPackage = "com.dy.common.mw.protocol" ;
private static AnnotationScan instance ;
-
+
private AnnotationScan(){
}
-
+
/**
* 寰楀埌鍞竴瀹炰緥锛�
* 骞跺湪鐢熸垚鍞竴瀹炰緥鏃讹紝鎵弿娉ㄨВ绫�
@@ -40,148 +42,135 @@
}
return instance ;
}
-
+
/**
* 鎵弿鍑烘敞瑙g殑绫�
* @throws ClassNotFoundException 寮傚父
* @throws Exception 寮傚父
*/
- private void scanEndpointAnnotations() throws Exception{
- ClassLoader load = this.getClass().getClassLoader() ;
-
- if(!scanRootPackage.endsWith(".")){
- scanRootPackage += "." ;
- }
- URL url = AnnotationScan.class.getResource("/" + scanRootPackage.replace('.', '/'));
- if(url != null){
- String urlStr = url.toString() ;
- if(urlStr != null){
- URI uri = new URI(url.toString());
+ private void scanEndpointAnnotations() throws Exception {
+ Reflections reflections = new Reflections(scanRootPackage); // 鎸囧畾鍖呭悕
+ Set<Class<?>> driverClasses = reflections.getTypesAnnotatedWith(AnnotationDriver.class);
+ if (driverClasses != null && driverClasses.size() > 0) {
+ String protocolName;
+ int priority;
+ int onLineDataMinLength;
+ int headMinLength;
- List<String> classNames = new ClassScan().searchClassFromUrl(new URI[]{uri}, scanRootPackage) ;
- if(classNames != null && classNames.size() > 0){
- String protocolName ;
- int priority;
- int onLineDataMinLength;
- int headMinLength ;
+ HashMap<String, AnnotationDriverVo> driverMap = ProtocolCache.getDriverMap();
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap();
+ HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCache.getOnLineMap();
- HashMap<String, AnnotationDriverVo> driverMap = ProtocolCache.getDriverMap() ;
- HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ;
- HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCache.getOnLineMap() ;
-
- for(String cName : classNames){
- String className = cName.substring(0, cName.lastIndexOf('.')) ;
- Class<?> clazz = load.loadClass(className) ;
- if(clazz.isAnnotationPresent(AnnotationDriver.class)){
- AnnotationDriver ann = clazz.getAnnotation(AnnotationDriver.class) ;
- 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{
- throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆") ;
- }
- }
+ for (Class<?> clazz : driverClasses) {
+ AnnotationDriver ann = clazz.getAnnotation(AnnotationDriver.class);
+ 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 {
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆");
+ }
+ }
+ }
+ }
+
+ Set<Class<?>> prefixedClass = reflections.getTypesAnnotatedWith(AnnotationPrefixedDataAvailable.class);
+ for (Class<?> clazz : prefixedClass) {
+ AnnotationPrefixedDataAvailable ann = clazz.getAnnotation(AnnotationPrefixedDataAvailable.class);
+ if (ann != null) {
+ if (ann.enable()) {
+ protocolName = ann.protocolName();
+ if (!(protocolName.trim().equals(""))) {
+ if (prefixedDataAvailableMap.containsKey(protocolName)) {
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒");
+ }
+ } else {
+ throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆");
}
+ priority = ann.priority();
+ if (priority == 0) {
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0");
+ }
+ if (isRepeatPrefixedDataAvailablePriority(priority, prefixedDataAvailableMap)) {
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅");
+ }
- if(clazz.isAnnotationPresent(AnnotationPrefixedDataAvailable.class)){
- AnnotationPrefixedDataAvailable ann = clazz.getAnnotation(AnnotationPrefixedDataAvailable.class) ;
- if(ann != null){
- if(ann.enable()){
- protocolName = ann.protocolName() ;
- if(!(protocolName.trim().equals(""))){
- if(prefixedDataAvailableMap.containsKey(protocolName)){
- throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- }else{
- throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ;
- }
-
- priority = ann.priority() ;
- if(priority == 0){
- throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ;
- }
- if(isRepeatPrefixedDataAvailablePriority(priority, prefixedDataAvailableMap)){
- throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ;
- }
-
- onLineDataMinLength = ann.onLineDataMinLength() ;
+ onLineDataMinLength = ann.onLineDataMinLength();
/*姘旇薄鍗忚涓�0
if(onLineDataMinLength == 0){
throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂绾挎暟鎹渶灏忛暱搴︽敞瑙d笉鑳戒负0") ;
}
*/
- headMinLength = ann.headMinLength() ;
+ 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){
- if(ann.enable()){
- protocolName = ann.protocolName() ;
- if(!(protocolName.trim().equals(""))){
- if(onLineMap.containsKey(protocolName)){
- throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- }else{
- throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ;
- }
-
- 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)) ;
- }
- }
- }
+ prefixedDataAvailableMap.put(protocolName, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength));
}
-
- String error = this.hasErrorInDriver(driverMap) ;
- if(error != null){
- throw new Exception(error) ;
- }else{
- error = this.hasErrorInPrefixedDataAvailable(driverMap, prefixedDataAvailableMap) ;
- if(error != null){
- throw new Exception(error) ;
- }else{
- error = this.hasErrorInOnLine(driverMap, onLineMap) ;
- if(error != null){
- throw new Exception(error) ;
- }
- }
- }
- }else{
- throw new Exception("涓ラ噸閿欒锛� 鎵弿鍗忚鐩稿叧娉ㄨВ鎵�寰楀埌绫诲瀷闆嗗悎涓虹┖锛屾壂鎻忔牴璺緞鏄�" + scanRootPackage) ;
}
}
+
+ Set<Class<?>> onLineClass = reflections.getTypesAnnotatedWith(AnnotationOnLine.class);
+ for (Class<?> clazz : onLineClass) {
+ AnnotationOnLine ann = clazz.getAnnotation(AnnotationOnLine.class);
+ if (ann != null) {
+ if (ann.enable()) {
+ protocolName = ann.protocolName();
+ if (!(protocolName.trim().equals(""))) {
+ if (onLineMap.containsKey(protocolName)) {
+ throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒");
+ }
+ } else {
+ throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆");
+ }
+
+ 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));
+ }
+ }
+ }
+
+ //杩涜楠岃瘉
+ String error = this.hasErrorInDriver(driverMap);
+ if (error != null) {
+ throw new Exception(error);
+ } else {
+ error = this.hasErrorInPrefixedDataAvailable(driverMap, prefixedDataAvailableMap);
+ if (error != null) {
+ throw new Exception(error);
+ } else {
+ error = this.hasErrorInOnLine(driverMap, onLineMap);
+ if (error != null) {
+ throw new Exception(error);
+ }
+ }
+ }
+ } else {
+ throw new Exception("涓ラ噸閿欒锛� 鎵弿鍗忚鐩稿叧娉ㄨВ鎵�寰楀埌绫诲瀷闆嗗悎涓虹┖锛屾壂鎻忔牴璺緞鏄�" + scanRootPackage);
}
}
+
/**
* 妫�鏌ヤ紭鍏堢骇閲嶅
* @param priority 浼樺厛绾�
* @return 缁撴灉
*/
private boolean isRepeatPrefixedDataAvailablePriority(int priority, HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
- Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
+ Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
for(AnnotationPrefixedDataAvailableVo vo : col){
if(vo.priority == priority){
return true ;
@@ -195,7 +184,7 @@
* @return 缁撴灉
*/
private boolean isRepeatOnLinePriority(int priority, HashMap<String, AnnotationOnLineVo> onLineMap){
- Collection<AnnotationOnLineVo> col = onLineMap.values();
+ Collection<AnnotationOnLineVo> col = onLineMap.values();
for(AnnotationOnLineVo vo : col){
if(vo.priority == priority){
return true ;
@@ -203,7 +192,7 @@
}
return false ;
}
-
+
private String hasErrorInDriver(HashMap<String, AnnotationDriverVo> driverMap){
if(driverMap.size() == 0){
return "涓ラ噸閿欒锛屾湭娉ㄨВ浠讳綍鍗忚椹卞姩" ;
@@ -211,23 +200,23 @@
return null ;
}
- private String hasErrorInPrefixedDataAvailable(HashMap<String, AnnotationDriverVo> driverMap,
- HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
- Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
+ private String hasErrorInPrefixedDataAvailable(HashMap<String, AnnotationDriverVo> driverMap,
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
+ Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
for(AnnotationPrefixedDataAvailableVo vo : col){
if(!driverMap.containsKey(vo.protocolName)){
return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
}
}
-
+
int[] prioritys = new int[prefixedDataAvailableMap.size()] ;
int count = 0 ;
- col = prefixedDataAvailableMap.values();
+ col = prefixedDataAvailableMap.values();
for(AnnotationPrefixedDataAvailableVo vo : col){
prioritys[count++] = vo.priority ;
}
NumUtil.sort(prioritys, true) ;
-
+
int firstPriority = prioritys[0] ;
if(ProtocolConstant.firstPriority != firstPriority){
return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶄紭鍏堢骇蹇呴』浠� " + ProtocolConstant.firstPriority + " 寮�濮�" ;
@@ -246,24 +235,24 @@
}
return null ;
}
-
+
private String hasErrorInOnLine(HashMap<String, AnnotationDriverVo> driverMap,
- HashMap<String, AnnotationOnLineVo> onLineMap){
- Collection<AnnotationOnLineVo> col = onLineMap.values();
+ HashMap<String, AnnotationOnLineVo> onLineMap){
+ Collection<AnnotationOnLineVo> col = onLineMap.values();
for(AnnotationOnLineVo vo : col){
if(!driverMap.containsKey(vo.protocolName)){
return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
}
}
-
+
int[] prioritys = new int[onLineMap.size()] ;
int count = 0 ;
- col = onLineMap.values();
+ col = onLineMap.values();
for(AnnotationOnLineVo vo : col){
prioritys[count++] = vo.priority ;
}
NumUtil.sort(prioritys, true) ;
-
+
int firstPriority = prioritys[0] ;
if(ProtocolConstant.firstPriority != firstPriority){
return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶄紭鍏堢骇蹇呴』浠� " + ProtocolConstant.firstPriority + " 寮�濮�" ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
index a541bc8..6071100 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
@@ -1,10 +1,9 @@
package com.dy.common.mw.protocol;
-import java.net.URI;
import java.util.HashMap;
-import java.util.List;
+import java.util.Set;
-import com.dy.common.util.ClassScan;
+import org.reflections.Reflections;
public abstract class Driver {
@@ -21,7 +20,6 @@
* @throws Exception 寮傚父
*/
public abstract void scanAnnotationCode() throws Exception ;
-
/**
* 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
* @param driver 椹卞姩
@@ -31,72 +29,73 @@
* @throws Exception 寮傚父
*/
@SuppressWarnings("unchecked")
- protected void doScanAnnotationCode(Driver driver, String protocolName, URI uri, String scanRootPackage) throws Exception{
- ClassLoader load = driver.getClass().getClassLoader() ;
- List<String> classNames = new ClassScan().searchClassFromUrl(new URI[]{uri}, scanRootPackage) ;
- if(classNames != null && classNames.size() > 0){
- String code ;
- String[] codes ;
- for(String cName : classNames){
- String className = cName.substring(0, cName.lastIndexOf('.')) ;
- Class<?> clazz = load.loadClass(className) ;
- Class<CodeParse> codeParseClazz ;
- if(clazz.isAnnotationPresent(AnnotationCodeUp.class)){
- AnnotationCodeUp ann = clazz.getAnnotation(AnnotationCodeUp.class) ;
- if(ann != null){
- codeParseClazz = (Class<CodeParse>)clazz ;
- codes = ann.ifAny() ;
- if(codes.length > 0){
- for(String cd: codes){
- cd = cd.trim() ;
- if(!(cd.trim().equals(""))){
- if(driver.upCode2Classes.containsKey(cd)){
- throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- driver.upCode2Classes.put(cd, codeParseClazz) ;
+ protected void doScanAnnotationCode(Driver driver, String protocolName, String scanRootPackage) throws Exception{
+ Reflections reflections = new Reflections(scanRootPackage); // 鎸囧畾鍖呭悕
+ String code ;
+ String[] codes ;
+ Class<CodeParse> codeParseClazz ;
+
+ Set<Class<?>> codeUpClasses = reflections.getTypesAnnotatedWith(AnnotationCodeUp.class);
+ if (codeUpClasses != null && codeUpClasses.size() > 0) {
+ for (Class<?> clazz : codeUpClasses) {
+ AnnotationCodeUp ann = clazz.getAnnotation(AnnotationCodeUp.class) ;
+ if(ann != null){
+ codeParseClazz = (Class<CodeParse>)clazz ;
+ codes = ann.ifAny() ;
+ if(codes.length > 0){
+ for(String cd: codes){
+ cd = cd.trim() ;
+ if(!(cd.trim().equals(""))){
+ if(driver.upCode2Classes.containsKey(cd)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
}
+ driver.upCode2Classes.put(cd, codeParseClazz) ;
}
- }else{
- code = ann.value().trim() ;
- if(!(code.equals(""))){
- if(driver.upCode2Classes.containsKey(code)){
- throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- driver.upCode2Classes.put(code, codeParseClazz) ;
+ }
+ }else{
+ code = ann.value().trim() ;
+ if(!(code.equals(""))){
+ if(driver.upCode2Classes.containsKey(code)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
}
+ driver.upCode2Classes.put(code, codeParseClazz) ;
}
}
}
-
- if(clazz.isAnnotationPresent(AnnotationCodeDown.class)){
- AnnotationCodeDown ann = clazz.getAnnotation(AnnotationCodeDown.class) ;
- if(ann != null){
- codeParseClazz = (Class<CodeParse>)clazz ;
- codes = ann.ifAny() ;
- if(codes.length > 0){
- for(String cd: codes){
- cd = cd.trim() ;
- if(!(cd.trim().equals(""))){
- if(driver.downCode2Class.containsKey(cd)){
- throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- driver.downCode2Class.put(cd, codeParseClazz) ;
+ }
+ }
+
+ Set<Class<?>> codeDownClasses = reflections.getTypesAnnotatedWith(AnnotationCodeDown.class);
+ if (codeDownClasses != null && codeDownClasses.size() > 0) {
+ for (Class<?> clazz : codeDownClasses) {
+ AnnotationCodeDown ann = clazz.getAnnotation(AnnotationCodeDown.class) ;
+ if(ann != null){
+ codeParseClazz = (Class<CodeParse>)clazz ;
+ codes = ann.ifAny() ;
+ if(codes.length > 0){
+ for(String cd: codes){
+ cd = cd.trim() ;
+ if(!(cd.trim().equals(""))){
+ if(driver.downCode2Class.containsKey(cd)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
}
+ driver.downCode2Class.put(cd, codeParseClazz) ;
}
- }else{
- code = ann.value() ;
- if(!(code.trim().equals(""))){
- if(driver.downCode2Class.containsKey(code)){
- throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
- }
- driver.downCode2Class.put(code, codeParseClazz) ;
+ }
+ }else{
+ code = ann.value() ;
+ if(!(code.trim().equals(""))){
+ if(driver.downCode2Class.containsKey(code)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
}
+ driver.downCode2Class.put(code, codeParseClazz) ;
}
}
}
}
}
}
+
/**
* 鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
* 寰楀埌涓婅鏁版嵁鍔熻兘鐮佸鐞嗙被CodeParse瀵硅薄
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
index 9061179..97fe99c 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
@@ -9,7 +9,7 @@
@AnnotationDriver(enable = true, name= ProtocolConstantV206V1_0_0.protocolName)
public class DriverV1_0_1 extends Driver {
- private static String scanRootPackage = "com.dy.common.mw.protocol.p206V1_0_0." ;
+ private static String scanRootPackage = "com.dy.common.mw.protocol.p206V1_0_0" ;
//鍦―river涓槸鍗曚緥锛岄殢Driver鐨勫崟渚嬪璞″湪鍗曠嚎绋嬩腑杩愯
private ParseParamsForUpV1_0_1 upCpParams ;
@@ -29,12 +29,7 @@
*/
@Override
public void scanAnnotationCode() throws Exception{
- if(!scanRootPackage.endsWith(".")){
- scanRootPackage += "." ;
- }
- URL url = this.getClass().getResource("/" + scanRootPackage.replace('.', '/'));
- URI uri = new URI(url.toString());
- super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.protocolName, uri, scanRootPackage) ;
+ super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.protocolName, scanRootPackage) ;
}
/**
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
index 08c5eb2..26d0a6c 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
@@ -1,6 +1,7 @@
package com.dy.common.mw.protocol.p206V202404;
import com.dy.common.mw.protocol.*;
+import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0;
import com.dy.common.util.DateTime;
import java.net.URI;
@@ -9,7 +10,7 @@
@AnnotationDriver(name= ProtocolConstantV206V202404.protocolName)
public class DriverV202404 extends Driver {
- private static String scanRootPackage = "com.dy.common.mw.protocol.p206V202404." ;
+ private static String scanRootPackage = "com.dy.common.mw.protocol.p206V202404" ;
//鍦―river涓槸鍗曚緥锛岄殢Driver鐨勫崟渚嬪璞″湪鍗曠嚎绋嬩腑杩愯
private ParseParamsForUpV202404 upCpParams ;
@@ -29,12 +30,7 @@
*/
@Override
public void scanAnnotationCode() throws Exception{
- if(!scanRootPackage.endsWith(".")){
- scanRootPackage += "." ;
- }
- URL url = this.getClass().getResource("/" + scanRootPackage.replace('.', '/'));
- URI uri = new URI(url.toString());
- super.doScanAnnotationCode(this, ProtocolConstantV206V202404.protocolName, uri, scanRootPackage) ;
+ super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.protocolName, scanRootPackage) ;
}
/**
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java
deleted file mode 100644
index 5b37f19..0000000
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.dy.common.util;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.logging.Logger;
-
-@SuppressWarnings("unused")
-public class ClassScan {
-
- private static final Logger logger = Logger.getLogger(ClassScan.class.getName());
-
-
- /**
- * 鍦ㄦ寚瀹氱殑URL璺緞涓悳绱lass
- *
- * @param uris 瑕佹悳绱㈢殑java鏂囦欢URI,涓嶈兘鐢║RL绫诲瀷锛屽洜涓篣RL璺緞涓湁涓枃灏嗗け璐�
- * @param rootPackage 瑕佹悳绱㈢殑java鏂囦欢鐨勫寘璺緞
- */
- public List<String> searchClassFromUrl(URI[] uris, String rootPackage){
- List<String> classNames = new ArrayList<>() ;
- for (URI uri : uris) {
- try {
- File file = new File(uri.getPath());
- if (!file.exists()){
- throw new FileNotFoundException();
- }
- this.doSearchClass(file, rootPackage ,classNames);
- } catch (Exception ex) {
- logger.throwing(ClassScan.class.getName(), "searchClassFromUrl", ex);
- }
- }
- return classNames ;
- }
-
- /**
- * 鍦ㄦ寚瀹氱殑jar鏂囦欢涓悳绱lass
- * @param file 瑕佹悳绱㈢殑jar鏂囦欢
- */
- public List<String> searchClassFromArchive(JarFile file) {
- List<String> classNames = new ArrayList<>() ;
- for (Enumeration<JarEntry> enumeration = file.entries(); enumeration.hasMoreElements();) {
- JarEntry entry = enumeration.nextElement();
- if (entry.getName().endsWith(".class")) {
- classNames.add(file.getName()) ;
- }
- }
- return classNames ;
- }
-
- /**
- * 鎼滅储鎸囧畾鏂囦欢澶逛笅灞傜骇閲岀殑class
- * @param dir 鏂囦欢澶�
- * @param rootPackage 鏍瑰寘
- * @param classNames 绫诲悕绉伴泦鍚�
- */
- private void doSearchClass(File dir, String rootPackage, List<String> classNames) {
- String path ;
- if (dir.isDirectory()) {
- File[] fs = dir.listFiles() ;
- if(fs != null && fs.length > 0){
- for (File f : fs){
- //鍙悳褰撳墠鏂囦欢澶逛腑鏂囦欢
- this.doSearchClass(f, rootPackage, classNames);
- }
- }
- return;
- }
- if (dir.getName().endsWith(".class")) {
- path = dir.getAbsolutePath() ;
- path = path.replace('/', '.') ;
- path = path.replace('\\', '.') ;
- path = path.substring(path.indexOf(rootPackage)) ;
- classNames.add(path) ;
- } else if (dir.getName().endsWith(".zip") || dir.getName().endsWith(".jar")) {
- try {
- this.searchClassFromArchive(new JarFile(dir));
- } catch (IOException ex) {
- logger.throwing(ClassScan.class.getName(), "doSearchClass", ex);
- }
- }
- }
-
-}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java
index 1b7f619..9bffe3c 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml.java
@@ -1,516 +1,495 @@
package com.dy.common.util;
-import java.io.FileWriter;
-import java.net.URL;
-import java.util.List;
-
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
-@SuppressWarnings("unused")
+import java.io.FileWriter;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/8/21 15:27
+ * @Description
+ */
public class ConfigXml {
-
- /**
- * 鍒涘缓Document瀵硅薄
- * @param clazz 鍙傝�冪被
- * @param filePath 閰嶇疆鏂囦欢璺緞
- * @return 杩斿洖缁撴灉 杩斿洖缁撴灉杩斿洖 doc瀵硅薄
- * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
- */
- public Document createDom(Class<?> clazz, String filePath) throws Exception {
- if(clazz == null){
- throw new Exception("class瀵硅薄涓虹┖!");
- }
- if(filePath == null || filePath.equals("")){
- throw new Exception("閰嶇疆鏂囦欢璺緞鍚嶇О涓虹┖!");
- }
- if(!filePath.startsWith("/")){
- filePath = "/" + filePath ;
- }
- URL configFileURL = clazz.getResource(filePath);
- if (configFileURL == null) {
- throw new Exception("娌℃湁寰楀埌" + filePath + "閰嶇疆!");
- }
- return this.createDom(configFileURL) ;
- }
-
- /**
- * 鍒涘缓Document瀵硅薄
- * @param configFileURL 閰嶇疆鏂囦欢璺緞
- * @return 杩斿洖缁撴灉 杩斿洖缁撴灉杩斿洖 doc瀵硅薄
- * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
- */
- public Document createDom(URL configFileURL) throws Exception {
- if (configFileURL == null) {
- throw new Exception("娌℃湁寰楀埌閰嶇疆鏂囦欢!", null);
- }
- Document doc;
- try {
- SAXBuilder sb = new SAXBuilder();
- doc = sb.build(configFileURL);
- if (doc == null) {
- throw new Exception("娌℃湁鐢熸垚閰嶇疆鏂囦欢鐨凞OM瀵硅薄!", null);
- }
- } catch (Exception e) {
- throw new Exception("鐢熸垚閰嶇疆鏂囦欢鐨凞OM瀵硅薄澶辫触!", e);
- }
- return doc;
- }
-
-
- /**
- * 淇濆瓨xml鏂囦欢
- * @param clazz 鍙傝�冪被
- * @param doc doc瀵硅薄 doc瀵硅薄
- * @param filePath 閰嶇疆鏂囦欢璺緞
- * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
- */
- public void saveXML(Class<?> clazz, Document doc, String filePath) throws Exception {
- if(doc == null){
- throw new Exception("Document瀵硅薄涓虹┖!");
- }
- if(filePath == null || filePath.equals("")){
- throw new Exception("閰嶇疆鏂囦欢璺緞鍚嶇О涓虹┖!");
- }
- if(!filePath.startsWith("/")){
- filePath = "/" + filePath ;
- }
- // 灏哾oc瀵硅薄杈撳嚭鍒版枃浠�
- FileWriter writer = null ;
- try {
- // 鍒涘缓xml鏂囦欢杈撳嚭娴�
- XMLOutputter xmlopt = new XMLOutputter();
- // 鍒涘缓鏂囦欢杈撳嚭娴�
- URL configFileURL = clazz.getResource(filePath);
- if (configFileURL == null) {
- throw new Exception("娌℃湁寰楀埌" + filePath + "閰嶇疆!");
- }
- writer = new FileWriter(configFileURL.getPath());
- // 鎸囧畾鏂囨。鏍煎紡
- Format fm = Format.getPrettyFormat();
- fm.setEncoding("UTF-8");
- xmlopt.setFormat(fm);
- // 灏哾oc鍐欏叆鍒版寚瀹氱殑鏂囦欢涓�
- xmlopt.output(doc, writer);
- } catch (Exception e) {
- throw new Exception("淇濆瓨xml鏂囦欢澶辫触!", e);
- } finally {
- if(writer != null){
- writer.close();
- }
- }
- }
-
- /**
- * 妫�鏌ュ厓绱犳槸鍚﹀瓨鍦�
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @return 杩斿洖缁撴灉 杩斿洖缁撴灉
- */
- public Element getElement(Document doc, String elementName){
- if(doc == null){
- return null ;
- }
- if(elementName == null){
- return null ;
- }
- elementName = elementName.trim() ;
- if(elementName.equals("")){
- return null ;
- }
- return this.get_element(doc, elementName) ;
- }
-
- /**
- * 妫�鏌ュ厓绱犳槸鍚﹀瓨鍦�
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @return 杩斿洖缁撴灉 杩斿洖缁撴灉
- */
- public boolean existElement(Document doc, String elementName){
- if(doc == null){
- return false ;
- }
- if(elementName == null){
- return false ;
- }
- elementName = elementName.trim() ;
- if(elementName.equals("")){
- return false ;
- }
- Element e = this.get_element(doc, elementName) ;
- return e != null;
- }
+ /**
+ * 鍒涘缓Document瀵硅薄
+ * @param configFileURL 閰嶇疆鏂囦欢璺緞
+ * @return 杩斿洖缁撴灉 杩斿洖缁撴灉杩斿洖 doc瀵硅薄
+ * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
+ */
+ protected Document doCreateDom(URL configFileURL) throws Exception {
+ if (configFileURL == null) {
+ throw new Exception("娌℃湁寰楀埌閰嶇疆鏂囦欢!", null);
+ }
+ Document doc;
+ try {
+ SAXBuilder sb = new SAXBuilder();
+ doc = sb.build(configFileURL);
+ if (doc == null) {
+ throw new Exception("娌℃湁鐢熸垚閰嶇疆鏂囦欢鐨凞OM瀵硅薄!", null);
+ }
+ } catch (Exception e) {
+ throw new Exception("鐢熸垚閰嶇疆鏂囦欢鐨凞OM瀵硅薄澶辫触!", e);
+ }
+ return doc;
+ }
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑甯冨皵鍊�
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public boolean getSetAttrBoolean(Document doc, String elementName, String attrName, String attPropertyNameFix, String setValue) throws Exception{
- String txt = this.getSetAttrTxt(doc, elementName, attrName, attPropertyNameFix, false, setValue) ;
- return txt.equalsIgnoreCase("true");
- }
+ /**
+ * 淇濆瓨xml鏂囦欢
+ * @param clazz 鍙傝�冪被
+ * @param doc doc瀵硅薄 doc瀵硅薄
+ * @param filePath 閰嶇疆鏂囦欢璺緞
+ * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
+ */
+ public void saveXML(Class<?> clazz, Document doc, String filePath) throws Exception {
+ if(doc == null){
+ throw new Exception("Document瀵硅薄涓虹┖!");
+ }
+ if(filePath == null || filePath.equals("")){
+ throw new Exception("閰嶇疆鏂囦欢璺緞鍚嶇О涓虹┖!");
+ }
+ if(!filePath.startsWith("/")){
+ filePath = "/" + filePath ;
+ }
+ // 灏哾oc瀵硅薄杈撳嚭鍒版枃浠�
+ FileWriter writer = null ;
+ try {
+ // 鍒涘缓xml鏂囦欢杈撳嚭娴�
+ XMLOutputter xmlopt = new XMLOutputter();
+ // 鍒涘缓鏂囦欢杈撳嚭娴�
+ URL configFileURL = clazz.getResource(filePath);
+ if (configFileURL == null) {
+ throw new Exception("娌℃湁寰楀埌" + filePath + "閰嶇疆!");
+ }
+ writer = new FileWriter(configFileURL.getPath());
+ // 鎸囧畾鏂囨。鏍煎紡
+ Format fm = Format.getPrettyFormat();
+ fm.setEncoding("UTF-8");
+ xmlopt.setFormat(fm);
+ // 灏哾oc鍐欏叆鍒版寚瀹氱殑鏂囦欢涓�
+ xmlopt.output(doc, writer);
+ } catch (Exception e) {
+ throw new Exception("淇濆瓨xml鏂囦欢澶辫触!", e);
+ } finally {
+ if(writer != null){
+ writer.close();
+ }
+ }
+ }
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑甯冨皵鍊�
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public boolean getSetAttrBoolean(Element e, String attrName, String attPropertyNameFix, String setValue) throws Exception{
- String txt = this.getSetAttrTxt(e, attrName, attPropertyNameFix, false, setValue) ;
- return txt.equalsIgnoreCase("true");
- }
+ /**
+ * 妫�鏌ュ厓绱犳槸鍚﹀瓨鍦�
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @return 杩斿洖缁撴灉 杩斿洖缁撴灉
+ */
+ public Element getElement(Document doc, String elementName){
+ if(doc == null){
+ return null ;
+ }
+ if(elementName == null){
+ return null ;
+ }
+ elementName = elementName.trim() ;
+ if(elementName.equals("")){
+ return null ;
+ }
+ return this.get_element(doc, elementName) ;
+ }
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑瀛楃涓插��
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param canBlank 鏄惁鍙负绌�
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public String getSetAttrTxt(Document doc, String elementName, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{
- Element e = this.check_and_get_element(doc, elementName);
- return this.getSetAttrTxt(e, attrName, attPropertyNameFix, canBlank, setValue) ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑瀛楃涓插��
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param canBlank 鏄惁鍙负绌�
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public String getSetAttrTxt(Element e, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{
- String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
- if(!canBlank){
- if(txt.trim().equals("")){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间负绌哄瓧绗︿覆!");
- }
- }
- return txt.trim() ;
- }
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f暣鏁板��
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Integer getSetAttrPlusInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
- Element e = this.check_and_get_element(doc, elementName);
- return this.getSetAttrPlusInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
- }
+ /**
+ * 妫�鏌ュ厓绱犳槸鍚﹀瓨鍦�
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @return 杩斿洖缁撴灉 杩斿洖缁撴灉
+ */
+ public boolean existElement(Document doc, String elementName){
+ if(doc == null){
+ return false ;
+ }
+ if(elementName == null){
+ return false ;
+ }
+ elementName = elementName.trim() ;
+ if(elementName.equals("")){
+ return false ;
+ }
+ Element e = this.get_element(doc, elementName) ;
+ return e != null;
+ }
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f暣鏁板��
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Integer getSetAttrPlusInt(Element e, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
- int v ;
- String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
- if(!NumUtil.isPlusIntNumber(txt)){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄鏁存暟!");
- }
- v = Integer.parseInt(txt);
- if(min != null && v < min){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
- }
- if(max != null && v > max){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
- }
- return v ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑鏁存暟鍊�
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Integer getSetAttrInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
- Element e = this.check_and_get_element(doc, elementName);
- return this.getSetAttrInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑鏁存暟鍊�
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Integer getSetAttrInt(Element e, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
- int v ;
- String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
- if(!NumUtil.isIntNumber(txt)){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄鏁存暟!");
- }
- v = Integer.parseInt(txt) ;
- if(min != null && v < min){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
- }
- if(max != null && v > max){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
- }
- return v ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Double getSetAttrPlusDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
- Element e = this.check_and_get_element(doc, elementName);
- return this.getSetAttrPlusDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f诞鐐规暟鍊�
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Double getSetAttrPlusDouble(Element e, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
- double v ;
- String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
- if(!NumUtil.isPlusDoubleNumber(txt)){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄娴偣鏁�!");
- }
- v = Double.parseDouble(txt) ;
- if(min != null && v < min){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
- }
- if(max != null && v > max){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
- }
- return v ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Double getSetAttrDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
- Element e = this.check_and_get_element(doc, elementName);
- return this.getSetAttrDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
- }
-
- /**
- * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
- * @param e 鍏冪礌瀵硅薄
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param min 鏈�灏忓��
- * @param max 鏈�澶у��
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- public Double getSetAttrDouble(Element e, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
- double v ;
- String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
- if(!NumUtil.isDoubleNumber(txt)){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄娴偣鏁�!");
- }
- v = Double.parseDouble(txt) ;
- if(min != null && v < min){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
- }
- if(max != null && v > max){
- throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
- }
- return v ;
- }
- /**
- * 寰楀埌鍏冪礌
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О 鍏冪礌鍚嶏紝褰㈠"config.base.test"
- * @return 杩斿洖缁撴灉
- */
- private Element get_element(Document doc, String elementName){
- Element e = null ;
- Element root ;
- String nm ;
- String[] eNames = elementName.split("\\.") ;
- if(eNames.length > 0){
- root = doc.getRootElement() ;
- nm = root.getName() ;
- if(nm.equals(eNames[0].trim())){
- if(eNames.length == 1){
- e = root ;
- }else{
- e = this.get_next_element(root, eNames, 1) ;
- }
- }
- }
- return e ;
- }
-
- /**
- * 寰楀埌瀛愬厓绱�
- * @param base 涓婄骇鍏冪礌瀵硅薄
- * @param eNames 鍏冪礌鍚嶇О
- * @param index 鏁扮粍涓嬫爣
- * @return 杩斿洖缁撴灉
- */
- private Element get_next_element(Element base, String[] eNames, int index){
- Element e = null ;
- String nm ;
- List<Element> list = base.getChildren() ;
- if(list != null && list.size() >0){
- for(Element el: list){
- nm = el.getName() ;
- if(nm.equals(eNames[index].trim())){
- if(eNames.length == index + 1){
- e = el ;
- }else{
- e = this.get_next_element(el, eNames, index + 1) ;
- }
- break ;
- }
- }
- }
- return e ;
- }
- /**
- * 妫�鏌ュ苟鑾峰厓绱�
- * @param doc doc瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- private Element check_and_get_element(Document doc, String elementName)throws Exception{
- if(doc == null){
- throw new Exception("閰嶇疆鏂囦欢鐨凞OM瀵硅薄涓虹┖!");
- }
- if(elementName == null){
- throw new Exception("鍏冪礌鍚嶄负绌�!");
- }
- elementName = elementName.trim() ;
- if(elementName.equals("")){
- throw new Exception("鍏冪礌鍚嶄负绌�!");
- }
- Element e = this.get_element(doc, elementName) ;
- if(e == null){
- throw new Exception("鏈緱鍒板悕绉颁负" + elementName + "鐨勫厓绱�!");
- }
- return e ;
- }
-
- /**
- * 妫�鏌ュ苟鑾峰緱骞惰缃睘鎬у��
- * @param e 鍏冪礌瀵硅薄
- * @param elementName 鍏冪礌鍚嶇О
- * @param attrName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @return 杩斿洖缁撴灉
- * @throws Exception 鎶涘嚭寮傚父
- */
- private String check_get_set_Attribute(Element e, String elementName, String attrName, String attPropertyNameFix, String setValue)throws Exception{
- if(attrName == null){
- throw new Exception("灞炴�у悕涓虹┖!");
- }
- attrName = attrName.trim() ;
- if(attrName.equals("")){
- throw new Exception("灞炴�у悕涓虹┖!");
- }
- String txt = this.get_set_AttributTxt(e, attrName, attPropertyNameFix, setValue) ;
- if(txt == null){
- throw new Exception("鏈緱鍒板厓绱�" + elementName + "鐨勫睘鎬�" + attrName + "鐨勫��!");
- }
- return txt ;
- }
- /**
- * 寰楀埌骞惰缃睘鎬ч厤缃��
- * @param e 鍏冪礌瀵硅薄
- * @param attName 灞炴�у悕绉�
- * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
- * @param setValue 鍚屾椂璁剧疆鍊�
- * @return 杩斿洖缁撴灉
- */
- private String get_set_AttributTxt(Element e, String attName, String attPropertyNameFix, String setValue){
- String txt = null ;
- if(e != null && attName != null){
- attName = attName.trim() ;
- if(!attName.equals("")){
- txt = e.getAttributeValue(attName) ;
- if(setValue != null){
- e.setAttribute(attName, setValue) ;
- }
- }
- }
- if(txt != null && txt.startsWith("${") && txt.endsWith("}")){
- txt = txt.substring(2, txt.length() - 1) ;
- if(attPropertyNameFix != null){
- txt = txt + attPropertyNameFix ;
- }
- txt = ConfigProperties.getConfig(txt) ;
- }
- return txt ;
- }
-
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑甯冨皵鍊�
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public boolean getSetAttrBoolean(Document doc, String elementName, String attrName, String attPropertyNameFix, String setValue) throws Exception{
+ String txt = this.getSetAttrTxt(doc, elementName, attrName, attPropertyNameFix, false, setValue) ;
+ return txt.equalsIgnoreCase("true");
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑甯冨皵鍊�
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public boolean getSetAttrBoolean(Element e, String attrName, String attPropertyNameFix, String setValue) throws Exception{
+ String txt = this.getSetAttrTxt(e, attrName, attPropertyNameFix, false, setValue) ;
+ return txt.equalsIgnoreCase("true");
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑瀛楃涓插��
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param canBlank 鏄惁鍙负绌�
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public String getSetAttrTxt(Document doc, String elementName, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{
+ Element e = this.check_and_get_element(doc, elementName);
+ return this.getSetAttrTxt(e, attrName, attPropertyNameFix, canBlank, setValue) ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑瀛楃涓插��
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param canBlank 鏄惁鍙负绌�
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public String getSetAttrTxt(Element e, String attrName, String attPropertyNameFix, Boolean canBlank, String setValue) throws Exception{
+ String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
+ if(!canBlank){
+ if(txt.trim().equals("")){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间负绌哄瓧绗︿覆!");
+ }
+ }
+ return txt.trim() ;
+ }
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f暣鏁板��
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Integer getSetAttrPlusInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
+ Element e = this.check_and_get_element(doc, elementName);
+ return this.getSetAttrPlusInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f暣鏁板��
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Integer getSetAttrPlusInt(Element e, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
+ int v ;
+ String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
+ if(!NumUtil.isPlusIntNumber(txt)){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄鏁存暟!");
+ }
+ v = Integer.parseInt(txt);
+ if(min != null && v < min){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
+ }
+ if(max != null && v > max){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
+ }
+ return v ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑鏁存暟鍊�
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Integer getSetAttrInt(Document doc, String elementName, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
+ Element e = this.check_and_get_element(doc, elementName);
+ return this.getSetAttrInt(e, attrName, attPropertyNameFix, min, max, setValue) ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑鏁存暟鍊�
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Integer getSetAttrInt(Element e, String attrName, String attPropertyNameFix, Integer min, Integer max, String setValue) throws Exception{
+ int v ;
+ String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
+ if(!NumUtil.isIntNumber(txt)){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄鏁存暟!");
+ }
+ v = Integer.parseInt(txt) ;
+ if(min != null && v < min){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
+ }
+ if(max != null && v > max){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
+ }
+ return v ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Double getSetAttrPlusDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
+ Element e = this.check_and_get_element(doc, elementName);
+ return this.getSetAttrPlusDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑姝f诞鐐规暟鍊�
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Double getSetAttrPlusDouble(Element e, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
+ double v ;
+ String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
+ if(!NumUtil.isPlusDoubleNumber(txt)){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄娴偣鏁�!");
+ }
+ v = Double.parseDouble(txt) ;
+ if(min != null && v < min){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
+ }
+ if(max != null && v > max){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
+ }
+ return v ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Double getSetAttrDouble(Document doc, String elementName, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
+ Element e = this.check_and_get_element(doc, elementName);
+ return this.getSetAttrDouble(e, attrName, attPropertyNameFix, min, max, setValue) ;
+ }
+
+ /**
+ * 寰楀埌骞惰缃厓绱犵殑灞炴�х殑娴偣鏁板��
+ * @param e 鍏冪礌瀵硅薄
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param min 鏈�灏忓��
+ * @param max 鏈�澶у��
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ public Double getSetAttrDouble(Element e, String attrName, String attPropertyNameFix, Double min, Double max, String setValue) throws Exception{
+ double v ;
+ String txt = this.check_get_set_Attribute(e, e.getName(), attrName, attPropertyNameFix, setValue) ;
+ if(!NumUtil.isDoubleNumber(txt)){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�间笉鏄娴偣鏁�!");
+ }
+ v = Double.parseDouble(txt) ;
+ if(min != null && v < min){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎皬浜�" + min + "!");
+ }
+ if(max != null && v > max){
+ throw new Exception("鍏冪礌" + e.getName() + "鐨勫睘鎬�" + attrName + "鐨勫�煎ぇ浜�" + max + "!");
+ }
+ return v ;
+ }
+ /**
+ * 寰楀埌鍏冪礌
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О 鍏冪礌鍚嶏紝褰㈠"config.base.test"
+ * @return 杩斿洖缁撴灉
+ */
+ private Element get_element(Document doc, String elementName){
+ Element e = null ;
+ Element root ;
+ String nm ;
+ String[] eNames = elementName.split("\\.") ;
+ if(eNames.length > 0){
+ root = doc.getRootElement() ;
+ nm = root.getName() ;
+ if(nm.equals(eNames[0].trim())){
+ if(eNames.length == 1){
+ e = root ;
+ }else{
+ e = this.get_next_element(root, eNames, 1) ;
+ }
+ }
+ }
+ return e ;
+ }
+
+ /**
+ * 寰楀埌瀛愬厓绱�
+ * @param base 涓婄骇鍏冪礌瀵硅薄
+ * @param eNames 鍏冪礌鍚嶇О
+ * @param index 鏁扮粍涓嬫爣
+ * @return 杩斿洖缁撴灉
+ */
+ private Element get_next_element(Element base, String[] eNames, int index){
+ Element e = null ;
+ String nm ;
+ List<Element> list = base.getChildren() ;
+ if(list != null && list.size() >0){
+ for(Element el: list){
+ nm = el.getName() ;
+ if(nm.equals(eNames[index].trim())){
+ if(eNames.length == index + 1){
+ e = el ;
+ }else{
+ e = this.get_next_element(el, eNames, index + 1) ;
+ }
+ break ;
+ }
+ }
+ }
+ return e ;
+ }
+ /**
+ * 妫�鏌ュ苟鑾峰厓绱�
+ * @param doc doc瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ private Element check_and_get_element(Document doc, String elementName)throws Exception{
+ if(doc == null){
+ throw new Exception("閰嶇疆鏂囦欢鐨凞OM瀵硅薄涓虹┖!");
+ }
+ if(elementName == null){
+ throw new Exception("鍏冪礌鍚嶄负绌�!");
+ }
+ elementName = elementName.trim() ;
+ if(elementName.equals("")){
+ throw new Exception("鍏冪礌鍚嶄负绌�!");
+ }
+ Element e = this.get_element(doc, elementName) ;
+ if(e == null){
+ throw new Exception("鏈緱鍒板悕绉颁负" + elementName + "鐨勫厓绱�!");
+ }
+ return e ;
+ }
+
+ /**
+ * 妫�鏌ュ苟鑾峰緱骞惰缃睘鎬у��
+ * @param e 鍏冪礌瀵硅薄
+ * @param elementName 鍏冪礌鍚嶇О
+ * @param attrName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @return 杩斿洖缁撴灉
+ * @throws Exception 鎶涘嚭寮傚父
+ */
+ private String check_get_set_Attribute(Element e, String elementName, String attrName, String attPropertyNameFix, String setValue)throws Exception{
+ if(attrName == null){
+ throw new Exception("灞炴�у悕涓虹┖!");
+ }
+ attrName = attrName.trim() ;
+ if(attrName.equals("")){
+ throw new Exception("灞炴�у悕涓虹┖!");
+ }
+ String txt = this.get_set_AttributTxt(e, attrName, attPropertyNameFix, setValue) ;
+ if(txt == null){
+ throw new Exception("鏈緱鍒板厓绱�" + elementName + "鐨勫睘鎬�" + attrName + "鐨勫��!");
+ }
+ return txt ;
+ }
+ /**
+ * 寰楀埌骞惰缃睘鎬ч厤缃��
+ * @param e 鍏冪礌瀵硅薄
+ * @param attName 灞炴�у悕绉�
+ * @param attPropertyNameFix 灞炴�у悕绉板墠缂�
+ * @param setValue 鍚屾椂璁剧疆鍊�
+ * @return 杩斿洖缁撴灉
+ */
+ private String get_set_AttributTxt(Element e, String attName, String attPropertyNameFix, String setValue){
+ String txt = null ;
+ if(e != null && attName != null){
+ attName = attName.trim() ;
+ if(!attName.equals("")){
+ txt = e.getAttributeValue(attName) ;
+ if(setValue != null){
+ e.setAttribute(attName, setValue) ;
+ }
+ }
+ }
+ if(txt != null && txt.startsWith("${") && txt.endsWith("}")){
+ txt = txt.substring(2, txt.length() - 1) ;
+ if(attPropertyNameFix != null){
+ txt = txt + attPropertyNameFix ;
+ }
+ txt = ConfigProperties.getConfig(txt) ;
+ }
+ return txt ;
+ }
+
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml4Springboot.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml4Springboot.java
new file mode 100644
index 0000000..fc4ef32
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXml4Springboot.java
@@ -0,0 +1,36 @@
+package com.dy.common.util;
+
+import java.net.URL;
+import org.jdom2.Document;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+
+@SuppressWarnings("unused")
+public class ConfigXml4Springboot extends ConfigXml {
+
+ /**
+ * 鍦⊿pringBoot鐜涓簲鐢�
+ * @param resourceLoader
+ * @param fileName
+ * @return
+ * @throws Exception
+ */
+ public Document createDom(ResourceLoader resourceLoader, String fileName) throws Exception {
+ if(resourceLoader == null){
+ throw new Exception("resourceLoader瀵硅薄涓虹┖!");
+ }
+ if(fileName == null || fileName.equals("")){
+ throw new Exception("閰嶇疆鏂囦欢璺緞鍚嶇О涓虹┖!");
+ }
+ while(fileName.startsWith("/") || fileName.startsWith("\\")){
+ fileName = fileName.substring(1) ;
+ }
+ Resource resource = resourceLoader.getResource("classpath:" + fileName);
+ URL configFileURL = resource.getURL() ;
+ if (configFileURL == null) {
+ throw new Exception("娌℃湁寰楀埌" + fileName + "閰嶇疆!");
+ }
+ return super.doCreateDom(configFileURL) ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXmlNoSpringboot.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXmlNoSpringboot.java
new file mode 100644
index 0000000..63a8978
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ConfigXmlNoSpringboot.java
@@ -0,0 +1,33 @@
+package com.dy.common.util;
+
+import java.net.URL;
+import org.jdom2.Document;
+
+@SuppressWarnings("unused")
+public class ConfigXmlNoSpringboot extends ConfigXml {
+ /**
+ * 鍦ㄩ潪SpringBoot鐜涓簲鐢�
+ * 鍒涘缓Document瀵硅薄
+ * @param clazz 鍙傝�冪被
+ * @param filePath 閰嶇疆鏂囦欢璺緞
+ * @return 杩斿洖缁撴灉 杩斿洖缁撴灉杩斿洖 doc瀵硅薄
+ * @throws Exception 鎶涘嚭寮傚父 鎶涘嚭寮傚父
+ */
+ public Document createDom(Class<?> clazz, String filePath) throws Exception {
+ if(clazz == null){
+ throw new Exception("class瀵硅薄涓虹┖!");
+ }
+ if(filePath == null || filePath.equals("")){
+ throw new Exception("閰嶇疆鏂囦欢璺緞鍚嶇О涓虹┖!");
+ }
+ if(!filePath.startsWith("/")){
+ filePath = "/" + filePath ;
+ }
+ URL configFileURL = clazz.getResource(filePath);
+ if (configFileURL == null) {
+ throw new Exception("娌℃湁寰楀埌" + filePath + "閰嶇疆!");
+ }
+ return super.doCreateDom(configFileURL) ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
index 2e1fdfc..10b769a 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
@@ -1,10 +1,8 @@
package com.dy.pipIrrGlobal.util;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXml4Springboot;
import org.jdom2.Document;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-
-import java.net.URL;
+import org.springframework.core.io.ResourceLoader;
/**
* @Author: liurunyu
@@ -17,18 +15,17 @@
* 瀹炲鍖�
*/
@SuppressWarnings("unused ")
- protected void init() {
- this.init(null);
+ protected void init(ResourceLoader resourceLoader) {
+ this.doInit(resourceLoader);
}
/**
* 瀹炲鍖�
*/
@SuppressWarnings("unused ")
- protected void init(ApplicationReadyEvent event) {
+ protected void doInit(ResourceLoader resourceLoader) {
try {
- URL configFileURL = OrgListenerSupport.class.getResource("/init-config.xml");
- ConfigXml configXml = new ConfigXml();
- Document doc = configXml.createDom(configFileURL);
+ ConfigXml4Springboot configXml = new ConfigXml4Springboot() ;
+ Document doc = configXml.createDom(resourceLoader, "init-config.xml") ;
this.doInit(configXml, doc);
} catch (Exception e) {
System.out.println("绯荤粺鍚姩鏃讹紝鍒濆鍖栭厤缃嚭閿� !");
@@ -36,16 +33,19 @@
e.printStackTrace();
}
}
- private void doInit(ConfigXml configXml, Document doc) throws Exception {
+ private void doInit(ConfigXml4Springboot configXml, Document doc) throws Exception {
if (configXml != null && doc != null) {
for (int num = 1; num <= 10000; num++) {
if (configXml.existElement(doc, "config.orgs.org" + num)) {
String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "tag", null, false, null);
String orgName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "name", null, false, null);
- Org.OrgVo vo = new Org().new OrgVo() ;
- vo.tag = orgTag ;
- vo.name = orgName ;
- Org.OrgList.add(vo) ;
+ Boolean enable = configXml.getSetAttrBoolean(doc, "config.orgs.org" + num, "enable", null, null);
+ if(enable != null && enable.booleanValue()){
+ Org.OrgVo vo = new Org().new OrgVo() ;
+ vo.tag = orgTag ;
+ vo.name = orgName ;
+ Org.OrgList.add(vo) ;
+ }
}else{
break ;
}
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml b/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
index 2b749e8..5b007fd 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/init-config.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<orgs>
- <!-- 澶氫釜缁勭粐锛岀敤缂栧彿鍖哄垎锛岀紪鍙蜂粠1寮�濮� -->
- <org1 tag="ym" name="鍏冭皨">
+ <!-- 澶氫釜缁勭粐锛岀敤缂栧彿鍖哄垎锛岀紪鍙蜂粠1寮�濮嬶紝enable琛ㄧず鏄惁鍚敤 -->
+ <org1 tag="ym" name="鍏冭皨" enable="true">
<districts>
<province name="浜戝崡鐪�" num="53" level="0">
<city name="妤氶泟褰濇棌鑷不宸�" num="23" level="1">
@@ -29,7 +29,7 @@
<item5 typeName="缁垮寲鐢ㄦ按"/>
</waterTypes>
</org1>
- <org2 tag="pj" name="鐗囪">
+ <org2 tag="pj" name="鐗囪" enable="false">
<districts>
<province name="浜戝崡鐪�" num="53" level="0">
<city name="涓芥睙甯�" num="23" level="1">
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/pom.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/pom.xml
index 1597595..c06d736 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/pom.xml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/pom.xml
@@ -159,6 +159,14 @@
<artifactId>jna-platform</artifactId>
<version>5.12.1</version>
</dependency>
+ <!-- 绫诲弽灏� -->
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.10.2</version>
+ </dependency>
+
+
<!-- 娴嬭瘯 -->
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
index 18b3460..c8ea024 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
@@ -22,17 +22,19 @@
import com.dy.rtuMw.resource.ResourceUnit;
import com.dy.rtuMw.resource.ResourceUnitConfigVo;
import com.dy.common.springUtil.SpringContextUtil;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXml4Springboot;
import com.dy.common.util.IDLongGenerator;
import org.jdom2.Document;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
@Component
public class Server {
- private ConfigXml conf = null ;
+ private ConfigXml4Springboot conf = null ;
private Document doc = null ;
private boolean showStartInfo = false ;
@@ -42,6 +44,9 @@
private String HttpSvPort ;
@Value("${server.servlet.context-path}")
private String HttpSvPath ;
+
+ @Autowired
+ protected ResourceLoader resourceLoader ;
private List<UnitInterface> units = new ArrayList<UnitInterface>() ;
@@ -78,8 +83,8 @@
try {
//ConfigProperties.init(this.getClass().getResourceAsStream("/config/config.properties"), false);
- this.conf = new ConfigXml() ;
- this.doc = this.conf.createDom(this.getClass(), "config.xml") ;
+ this.conf = new ConfigXml4Springboot() ;
+ this.doc = this.conf.createDom(this.resourceLoader, "config.xml") ;
////////////////
//鏈嶅姟 閰嶇疆
this.showStartInfo = this.conf.getSetAttrBoolean(this.doc, "config.server", "showStartInfo", null, null) ;
@@ -325,6 +330,7 @@
/////////////////
//RTU涓婅鏁版嵁澶勭悊妯″潡
RtuDataUnitConfigVo rducVo = new RtuDataUnitConfigVo();
+ rducVo.resourceLoader = this.resourceLoader ;
AdapterImp_RtuDataUnit rducAdap = new AdapterImp_RtuDataUnit();
rducAdap.setConfig(rducVo);
RtuDataUnit rducUnit = RtuDataUnit.getInstance();
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnit.java
index 068f35d..c77c198 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnit.java
@@ -34,7 +34,7 @@
*/
@Override
public void start(UnitStartedCallbackInterface callback) throws Exception {
- TaskPool.setTaskTreeCofig(new TreeParse().parseConfig());
+ TaskPool.setTaskTreeCofig(new TreeParse().parseConfig(confVo.resourceLoader));
callback.call(null) ;
System.out.println("RTU鏁版嵁澶勭悊妯″潡鎴愬姛鍚姩");
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnitConfigVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnitConfigVo.java
index d015070..3e3f00e 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnitConfigVo.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/RtuDataUnitConfigVo.java
@@ -1,5 +1,7 @@
package com.dy.rtuMw.server.rtuData;
-public class RtuDataUnitConfigVo {
+import org.springframework.core.io.ResourceLoader;
+public class RtuDataUnitConfigVo {
+ public ResourceLoader resourceLoader ;
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/TreeParse.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/TreeParse.java
index 22017a8..1e0afa7 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/TreeParse.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/TreeParse.java
@@ -7,7 +7,8 @@
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
-
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
public class TreeParse {
public List<String> ids ;
@@ -26,7 +27,6 @@
/**
* 瑙f瀽澶勭悊鍣ㄩ厤缃�
* @return
- */
protected TreeConfig parseConfig() {
try {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
@@ -39,6 +39,24 @@
return null;
}
}
+ */
+
+ /**
+ * 瑙f瀽澶勭悊鍣ㄩ厤缃�
+ * @return
+ */
+ protected TreeConfig parseConfig(ResourceLoader resourceLoader) {
+ try {
+ Resource resource = resourceLoader.getResource("classpath:RtuDataDealTree.xml");
+ URL configFileURL = resource.getURL() ;
+ return this.parse(this.createDom(configFileURL)) ;
+ } catch (Exception e) {
+ System.out.println("绯荤粺鍚姩鏃讹紝鍒濆涓婅鏁版嵁澶勭悊浠诲姟閰嶇疆鍑洪敊 !");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ }
/**
*
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml
index 8eabad2..11aab7c 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml
@@ -9,7 +9,7 @@
onlyOneProtocol锛氬湪鏀寔澶氶�氫俊鍗忚鏃讹紝鍙湁RTU涓婄嚎浜嗭紝鎵嶈兘璇嗗埆鍑鸿RTU瀹為檯鐢ㄧ殑閫氫俊鍗忚锛岃繘鑰岀敤姝ゅ崗璁В鏋愪笂琛屾暟鎹強鏋勯�犱笅琛屽懡浠ゃ��
濡傛灉RTU鏈浘涓婄嚎锛堥�氫俊涓棿浠跺惎鍔ㄥ悗璇TU鏈浘涓婄嚎锛夛紝閭d箞鍦ㄥ悜瀹冨彂閫佷笅琛屽懡浠ゆ椂锛屼笉鑳藉垽鏂嚭鍏堕噰鐢ㄧ殑鍗忚锛屼篃涓嶈兘鏋勯�犲懡浠わ紝灏ゅ叾鏄綆鍔熻�楁儏鍐典笅锛屼笉涓婄嚎鏄甯哥幇璞°��
褰撳彧鏈変竴涓崗璁儏鍐典笅锛屽湪RTU鏈浘涓婄嚎鏃讹紝涔熻兘鐢ㄦ鍗忚鏋勯�犲懡浠ゅ苟缂撳瓨涓嬫潵锛屽挨鍏堕�傚悎浣庡姛鑰楁儏鍐点��
- onlyOneProtocol=true: 閫氫俊涓棿浠跺綋鍓嶅彧鏈変竴涓崗璁�
+ onlyOneProtocol=true: 閫氫俊涓棿浠跺綋鍓嶅彧鏈変竴涓崗璁�
downComandMaxResendTimes: 涓嬭鍛戒护鍏佽鍙戦�佺殑鏈�澶ф鏁癤锛屽嵆鍏佽閲嶅彂X-1
commandSendInterval: 閽堝涓�涓猂TU锛屼笅鍙戝懡浠ょ殑鏃堕棿闂撮殧(绉�)
cachWaitResultTimeout: 鍛戒护宸茬粡鍙戦�佽揪鏈�澶ф鏁帮紝浠嶆湭鏀跺埌鍛戒护缁撴灉锛岄渶瑕佸湪缂撳瓨缁х画绛夊緟锛屽叾绛夊緟鏈�澶ф椂闀�(绉�)锛屾湰绯荤粺RTU锛屽浜庡紑鍏虫车鍛戒护锛屽叾鍏堟墽琛屽紑鍏虫车鎶ワ紝鐒跺悗鍐嶈繘琛屽懡浠ゅ簲绛旓紝鎵�浠ユ鍊� 瑕佸ぇ涓�浜�
@@ -40,7 +40,8 @@
sendDingDingAlarmMsInterval="60"
/>
- <!--
+ <!--
+ 2024-08-22 鏆傛椂涓嶇敤
centerAddr: 涓績鍦板潃锛屽綋鍓嶏紝centerAddr鏈敤鍒�
synchroRtuClock: 鏄惁瀵筊TU鏍℃椂
synchroRtuClockTimepieces锛氬綋RTU涓庢湇鍔″櫒鏃堕挓鐩稿樊涓�瀹氭绉掞紙閰嶇疆鏂囦欢鏄閽燂級鍚庯紝杩涜鏍℃椂
@@ -107,7 +108,8 @@
/>
- <!--
+ <!--
+ 2024-08-22 鏆傛椂涓嶇敤
port锛歳mi鏈嶅姟绔彛鍙�
context锛歳mi鏈嶅姟涓婁笅鏂�
-->
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/Server.java
index ef09342..84796b2 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/Server.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/Server.java
@@ -11,10 +11,11 @@
import com.dy.common.mw.UnitInterface;
import com.dy.common.mw.support.SupportUnit;
import com.dy.common.mw.support.SupportUnitConfigVo;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXmlNoSpringboot;
+
public class Server {
- private ConfigXml conf = null ;
+ private ConfigXmlNoSpringboot conf = null ;
private Document doc = null ;
private boolean showStartInfo = false ;
@@ -27,7 +28,7 @@
Server sv = new Server();
Long start = System.currentTimeMillis() ;
try {
- sv.conf = new ConfigXml() ;
+ sv.conf = new ConfigXmlNoSpringboot() ;
sv.doc = sv.conf.createDom(sv.getClass(), "/config.xml") ;
////////////////
//鏈嶅姟 閰嶇疆
diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/\350\257\264\346\230\216.txt"
new file mode 100644
index 0000000..1dac049
--- /dev/null
+++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/\350\257\264\346\230\216.txt"
@@ -0,0 +1 @@
+鏈ā鍧楁槸鎵归噺鍘嬪姏娴嬭瘯鐨勫鎴风锛屾ā鎷熷涓祴鎺у櫒涓婃姤鏁版嵁锛屽彈鏈嶅姟绔紙pipIrr-mwTest-server锛夋帶鍒躲��
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
index e77a63c..823f420 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
@@ -12,12 +12,12 @@
import com.dy.common.mw.UnitStartedCallbackInterface;
import com.dy.common.mw.channel.rmi.RmiConfigVo;
import com.dy.common.mw.channel.rmi.RmiUnit;
-import com.dy.common.util.ConfigXml;
import com.dy.common.util.NumUtil;
+import com.dy.common.util.ConfigXmlNoSpringboot;
public class Server{
- private ConfigXml conf = null ;
+ private ConfigXmlNoSpringboot conf = null ;
private Document doc = null ;
private boolean showStartInfo = false ;
@@ -39,7 +39,7 @@
Server sv = new Server();
long start = System.currentTimeMillis() ;
try {
- sv.conf = new ConfigXml() ;
+ sv.conf = new ConfigXmlNoSpringboot() ;
sv.doc = sv.conf.createDom(sv.getClass(), "config.xml") ;
////////////////
//鏈嶅姟 閰嶇疆
diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/\350\257\264\346\230\216.txt"
new file mode 100644
index 0000000..710b2a2
--- /dev/null
+++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/\350\257\264\346\230\216.txt"
@@ -0,0 +1 @@
+鏈ā鍧楁槸鎵归噺鍘嬪姏娴嬭瘯鐨勬湇鍔$锛屼负瀹㈡埛绔紙pipIrr-mwTest-client锛夊垎閰嶆祴鎺у櫒锛圧TU锛夋暟閲忓強娴嬫帶鍣紙RTU锛夊湴鍧�锛屽苟鎺у埗瀹㈡埛鍚姩锛屾帴鏀跺鎴风鏁版嵁銆�
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/Server.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/Server.java
index 6dd6f12..cc02dfc 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/Server.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/Server.java
@@ -1,10 +1,12 @@
package com.dy.pipIrrMwTestRtu;
import com.dy.common.mw.UnitInterface;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXml4Springboot;
import com.dy.pipIrrMwTestRtu.tcpClient.TcpClUnit;
import com.dy.pipIrrMwTestRtu.tcpClient.TcpClUnitConfigVo;
import org.jdom2.Document;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@@ -18,8 +20,10 @@
@Component
public class Server {
+ @Autowired
+ protected ResourceLoader resourceLoader ;
- private ConfigXml conf = null ;
+ private ConfigXml4Springboot conf = null ;
private Document doc = null ;
private boolean showStartInfo = false ;
@@ -41,8 +45,8 @@
try {
//ConfigProperties.init(this.getClass().getResourceAsStream("/config/config.properties"), false);
- this.conf = new ConfigXml() ;
- this.doc = this.conf.createDom(this.getClass(), "config.xml") ;
+ this.conf = new ConfigXml4Springboot() ;
+ this.doc = this.conf.createDom(resourceLoader, "config.xml") ;
////////////////
//鏈嶅姟 閰嶇疆
this.showStartInfo = this.conf.getSetAttrBoolean(this.doc, "config.server", "showStartInfo", null, null) ;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/resources/application.yml
index cbdce6c..f3f6e15 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
index f48d62e..11c4f8a 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/util/InitListener.java
@@ -3,7 +3,7 @@
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.mybatis.envm.Deleted;
import com.dy.common.mybatis.envm.Disabled;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXml4Springboot;
import com.dy.common.util.MD5;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
@@ -20,10 +20,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
-
-import java.net.URL;
/**
* 鐩戝惉鍣紝瀹炵幇鍔熻兘锛氬湪绯荤粺鍚姩鏃跺垵濮嬪寲锛屽悜鏁版嵁搴撲腑鎻掑叆鏁版嵁
@@ -34,11 +33,18 @@
@Component
public class InitListener implements ApplicationListener<ApplicationReadyEvent> {
+ protected ResourceLoader resourceLoader ;
+
private BaDistrictMapper distriDao ;
private BaUserMapper userDao ;
private SePaymentMethodMapper paymentMethodDao ;
private BaSettingsMapper settingsDao ;
private SeWaterTypeMapper waterTypeDao ;
+
+ @Autowired
+ public void setResourceLoader(ResourceLoader resourceLoader){
+ this.resourceLoader = resourceLoader ;
+ }
@Autowired
public void setDistriDao(BaDistrictMapper distriDao){
@@ -88,9 +94,8 @@
@SuppressWarnings("unused ")
private void init(ApplicationReadyEvent event){
try {
- URL configFileURL = InitListener.class.getResource("/init-config.xml" );
- ConfigXml configXml = new ConfigXml() ;
- Document doc = configXml.createDom(configFileURL) ;
+ ConfigXml4Springboot configXml = new ConfigXml4Springboot() ;
+ Document doc = configXml.createDom(this.resourceLoader, "init-config.xml") ;
this.doInit(configXml, doc);
} catch (Exception e) {
System.out.println("绯荤粺鍚姩鏃讹紝鍒濆鍖栭厤缃嚭閿� !");
@@ -98,76 +103,79 @@
e.printStackTrace();
}
}
- private void doInit(ConfigXml configXml, Document doc) throws Exception{
+ private void doInit(ConfigXml4Springboot configXml, Document doc) throws Exception{
if(configXml != null && doc != null){
for(int num = 1; num <= 10000; num++){
if(configXml.existElement(doc, "config.orgs.org" + num)){
String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num,"tag", null, false, null) ;
- //璁剧疆鏁版嵁婧�
- DataSourceContext.set(orgTag);
- if(!this.existDistricts()){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".districts.province")){
- String distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province","name", null, false, null) ;
- String distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province","num", null, false, null) ;
- Integer distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province","level", null, 0, 99,null) ;
- Long supperId = this.saveDistrict(null, distriName, distriNum, distriLevel);
- if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.province.city")){
- distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city","name", null, false, null) ;
- distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city","num", null, false, null) ;
- distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province.city","level", null, 1, 99,null) ;
- supperId = this.saveDistrict(supperId, distriName, distriNum, distriLevel);
- if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.province.city.country")) {
- distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city.country", "name", null, false, null);
- distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city.country", "num", null, false, null);
- distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province.city.country", "level", null, 1, 99, null);
- this.saveDistrict(supperId, distriName, distriNum, distriLevel);
+ Boolean enable = configXml.getSetAttrBoolean(doc, "config.orgs.org" + num, "enable", null, null);
+ if(enable != null && enable.booleanValue()){
+ //璁剧疆鏁版嵁婧�
+ DataSourceContext.set(orgTag);
+ if(!this.existDistricts()){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".districts.province")){
+ String distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province","name", null, false, null) ;
+ String distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province","num", null, false, null) ;
+ Integer distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province","level", null, 0, 99,null) ;
+ Long supperId = this.saveDistrict(null, distriName, distriNum, distriLevel);
+ if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.province.city")){
+ distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city","name", null, false, null) ;
+ distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city","num", null, false, null) ;
+ distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province.city","level", null, 1, 99,null) ;
+ supperId = this.saveDistrict(supperId, distriName, distriNum, distriLevel);
+ if(supperId != null && configXml.existElement(doc, "config.orgs.org" + num + ".districts.province.city.country")) {
+ distriName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city.country", "name", null, false, null);
+ distriNum = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".districts.province.city.country", "num", null, false, null);
+ distriLevel = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".districts.province.city.country", "level", null, 1, 99, null);
+ this.saveDistrict(supperId, distriName, distriNum, distriLevel);
+ }
}
}
}
- }
- if(!this.existUsers()){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".user")){
- String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","name", null, false, null) ;
- String phone = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","phone", null, false, null) ;
- String password = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","password", null, false, null) ;
- Integer supperAdmin = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".user","supperAdmin", null, 0, 1,null) ;
- this.saveUser(orgTag, name, phone, password, supperAdmin);
+ if(!this.existUsers()){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".user")){
+ String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","name", null, false, null) ;
+ String phone = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","phone", null, false, null) ;
+ String password = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".user","password", null, false, null) ;
+ Integer supperAdmin = configXml.getSetAttrPlusInt(doc, "config.orgs.org" + num + ".user","supperAdmin", null, 0, 1,null) ;
+ this.saveUser(orgTag, name, phone, password, supperAdmin);
+ }
}
- }
- if(!this.existPayments()){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".payments")){
- for(int i = 1 ; i < 10000; i++){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".payments.item" + i)){
- String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".payments.item" + i,"name", null, false, null) ;
- this.savePayment(orgTag, name);
- }else{
- break ;
+ if(!this.existPayments()){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".payments")){
+ for(int i = 1 ; i < 10000; i++){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".payments.item" + i)){
+ String name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".payments.item" + i,"name", null, false, null) ;
+ this.savePayment(orgTag, name);
+ }else{
+ break ;
+ }
}
}
}
- }
- if(!this.existSettings()){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".settings")){
- for(int i = 1 ; i < 10000; i++){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".settings.item" + i)){
- String item_name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"item_name", null, false, null) ;
- String item_value = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"item_value", null, false, null) ;
- String remarks = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"remarks", null, false, null) ;
- this.saveSettings(orgTag, item_name, item_value, remarks);
- }else{
- break ;
+ if(!this.existSettings()){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".settings")){
+ for(int i = 1 ; i < 10000; i++){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".settings.item" + i)){
+ String item_name = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"item_name", null, false, null) ;
+ String item_value = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"item_value", null, false, null) ;
+ String remarks = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".settings.item" + i,"remarks", null, false, null) ;
+ this.saveSettings(orgTag, item_name, item_value, remarks);
+ }else{
+ break ;
+ }
}
}
}
- }
- if(!this.existWaterTypes()){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){
- for(int i = 1 ; i < 10000; i++){
- if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes.item" + i)){
- String typeName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".waterTypes.item" + i,"typeName", null, false, null) ;
- this.saveWaterType(orgTag, typeName);
- }else{
- break ;
+ if(!this.existWaterTypes()){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes")){
+ for(int i = 1 ; i < 10000; i++){
+ if(configXml.existElement(doc, "config.orgs.org" + num + ".waterTypes.item" + i)){
+ String typeName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num + ".waterTypes.item" + i,"typeName", null, false, null) ;
+ this.saveWaterType(orgTag, typeName);
+ }else{
+ break ;
+ }
}
}
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/resources/application.yml
index bb3c263..fb79576 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/resources/application.yml
index 3294b13..eb766c7 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-operation/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/resources/application.yml
index efaf3ed..5dea5be 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/resources/application.yml
index a5977d1..ab59316 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml
index a69e2e6..97fc494 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/util/SsoListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/util/SsoListener.java
index a785e69..7a24c20 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/util/SsoListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/util/SsoListener.java
@@ -1,12 +1,17 @@
package com.dy.sso.util;
import com.dy.pipIrrGlobal.util.OrgListenerSupport;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
@Component
public class SsoListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> {
+
+ @Autowired
+ protected ResourceLoader resourceLoader ;
@Override
@@ -18,7 +23,7 @@
e.printStackTrace();
} finally {
//鍒濆鍖栨満鏋�
- super.init();
+ super.init(resourceLoader);
}
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/resources/application.yml
index 7b19f19..1cb57e0 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/util/OrgListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/util/OrgListener.java
index 3aa1ae5..a37f7c6 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/util/OrgListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/util/OrgListener.java
@@ -1,12 +1,17 @@
package com.dy.pipIrrStatistics.util;
import com.dy.pipIrrGlobal.util.OrgListenerSupport;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
@Component
public class OrgListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> {
+
+ @Autowired
+ protected ResourceLoader resourceLoader ;
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
@@ -16,7 +21,7 @@
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
- super.init();
+ super.init(resourceLoader);
}
}
}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/resources/application.yml
index 3586b0f..4b6f2e7 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
index d36ec30..a2178fa 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- include: global, database, database-ym, database-pj, database-sp
+ include: global, database, database-ym, database-pj
#actutor鐨剋eb绔彛
management:
--
Gitblit v1.8.0