From a021f91265139a52c7515942b4332e03ce994351 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 11 六月 2025 16:34:31 +0800 Subject: [PATCH] 1、通信中间件本地命令处理逻辑修改; 2、参数设置软件增量开发,以处理MQTT相关配置; 3、《打包发布配置修改》文档修改。 --- pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamKey.java | 2 + pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.properties | 4 +- pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 53 +++++++++++++++++++------- pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/resources/application-params.yml | 20 ++++++++++ pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamSetMw.java | 10 +++++ pipIrr-platform/文档/打包发布/打包发布配置修改.docx | 0 6 files changed, 73 insertions(+), 16 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java index 5c13be1..a53defb 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java @@ -58,7 +58,21 @@ */ @GetMapping("/rtuLogFile") public void rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){ - File logFile = ResourceUnit.getInstance().getLogFile(rtuAddr + ".log") ; + logFile(rtuAddr, req, rep) ; + } + + /** + * 涓嬭浇鎺у埗鍣紙RTU锛変笂涓嬭鏁版嵁鐨刲og鏃ュ織鏂囦欢 + * @param devId + * @param req + * @param rep + */ + @GetMapping("/mqttDevLogFile") + public void mqttDevLogFile(String devId, HttpServletRequest req, HttpServletResponse rep){ + logFile(devId, req, rep) ; + } + private void logFile(String fileName, HttpServletRequest req, HttpServletResponse rep){ + File logFile = ResourceUnit.getInstance().getLogFile(fileName + ".log") ; if(logFile != null && logFile.exists()){ //鍦⊿pring Boot涓紝application/octet-stream;charset=UTF-8閫氬父琛ㄧず鍝嶅簲鐨勫唴瀹规槸瀛楄妭娴侊紝 //骞朵笖瀛楃闆嗘槸UTF-8銆傚浜庤繖绉嶇被鍨嬬殑鍝嶅簲锛孲pring Boot榛樿浣跨敤ByteArrayHttpMessageConverter鏉ュ鐞嗭紝 @@ -67,7 +81,7 @@ //瀛楃闆嗛�氬父鐢ㄤ簬鏂囨湰鍐呭锛岃�宎pplication/octet-stream閫氬父鐢ㄤ簬浜岃繘鍒跺唴瀹癸紝鍥犳鍦ㄨ繖绉嶆儏鍐典笅鎸囧畾瀛楃闆嗗彲鑳芥槸涓嶅悎閫傜殑銆� //涓嶈繃锛屽鏋滀綘纭疄闇�瑕佸鐞嗗甫鏈夌壒瀹氬瓧绗﹂泦鐨刟pplication/octet-stream鍝嶅簲锛屼綘鍙兘闇�瑕佽嚜瀹氫箟HttpMessageConverter銆� rep.addHeader("content-type", "application/octet-stream;charset=UTF-8"); - rep.addHeader("Content-Disposition", "attachment;fileName=" + (rtuAddr + ".log")) ; + rep.addHeader("Content-Disposition", "attachment;fileName=" + (fileName + ".log")) ; ServletOutputStream out = null; FileInputStream in = null ; try { @@ -112,27 +126,38 @@ */ @GetMapping("/rtuLogText") public BaseResponse<List<String>> rtuLogText(String rtuAddr){ + return logText(rtuAddr, true) ; + } + /** + * 涓嬭浇鎺у埗鍣紙RTU锛変笂涓嬭鏁版嵁鐨刲og鏃ュ織鏂囦欢 + * @param devId + */ + @GetMapping("/mqttDevLogText") + public BaseResponse<List<String>> mqttDevLogText(String devId){ + return logText(devId, false) ; + } + /** + * 涓嬭浇鎺у埗鍣紙RTU锛変笂涓嬭鏁版嵁鐨刲og鏃ュ織鏂囦欢 + * @param fileName + * @param reverseOrder + */ + private BaseResponse<List<String>> logText(String fileName, boolean reverseOrder){ List<String> list ; - File logFile = ResourceUnit.getInstance().getLogFile(rtuAddr + ".log") ; + File logFile = ResourceUnit.getInstance().getLogFile(fileName + ".log") ; if(logFile != null && logFile.exists()){ BufferedReader reader = null ; try { reader = new BufferedReader(new FileReader(logFile)) ; - //鏂扮殑瀹炵幇鏂规硶 Stream<String> linesStream = reader.lines() ; - //list = linesStream.toList() ; //鎸夊師鏉ラ『搴� - list = linesStream.sorted(Comparator.reverseOrder()).collect(Collectors.toList()) ;//鍊掑簭 - /* 鍘熸潵鐨勫疄鐜版柟娉� - list = new ArrayList() ; - String line ; - while((line = reader.readLine()) != null){ - list.add(line) ; + if(reverseOrder){ + list = linesStream.sorted(Comparator.reverseOrder()).collect(Collectors.toList()) ;//鍊掑簭 + }else{ + list = linesStream.toList() ; //鎸夊師鏉ラ『搴� } - */ return BaseResponseUtils.buildSuccess(list); } catch (Exception e) { list = new ArrayList() ; - list.add("璇诲彇鎺у埗鍣紙" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢寮傚父锛�" + (e.getMessage() == null?"":("锛�" + e.getMessage()))) ; + list.add("璇诲彇鎺у埗鍣紙" + fileName + "锛夌殑鏃ュ織鏂囦欢寮傚父锛�" + (e.getMessage() == null?"":("锛�" + e.getMessage()))) ; return BaseResponseUtils.buildSuccess(list); }finally{ if(reader != null){ @@ -144,7 +169,7 @@ } }else{ list = new ArrayList() ; - list.add("鏈緱鍒版帶鍒跺櫒锛�" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢") ; + list.add("鏈緱鍒版帶鍒跺櫒锛�" + fileName + "锛夌殑鏃ュ織鏂囦欢") ; return BaseResponseUtils.buildSuccess(list); } } diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.properties b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.properties index b692e83..6eaec36 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.properties +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.properties @@ -10,7 +10,7 @@ # 鐢樺窞锛� gz # 鍑夊窞锛� lz # 閲戝窛锛� jc -base.orgTag=mq +base.orgTag=ym # 233鏈嶅姟鍣細 # 鍏冭皨锛� 60000 @@ -45,7 +45,7 @@ # 鐢樺窞锛� mqtt.enable=false mqtt.protocolAndDeviceIds= mqtt.topicAndQos= # 鍑夊窞锛� mqtt.enable=false mqtt.protocolAndDeviceIds= mqtt.topicAndQos= # 閲戝窛锛� mqtt.enable=true mqtt.protocolAndDeviceIds=? mqtt.topicAndQos=weather,1;soil,1;manure,1;state,1 -mqtt.enable=true +mqtt.enable=false mqtt.protocolAndDeviceIds=sd1/338220031439,sd1/338220031440 mqtt.subTopicAndQos=weather,1;soil,1;manure,1;state,1 #MQtt璁惧鍦ㄤ竴瀹氭椂闂达紙鍒嗛挓锛夊悗鏈彂甯冩秷鎭紝璁や负璁惧绂荤嚎 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamKey.java b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamKey.java index ee7504b..4f87723 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamKey.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamKey.java @@ -31,6 +31,8 @@ public static final String TcpPort = "tcpPort" ; public static final String UpDataMinInterval = "upDataMinInterval" ; public static final String WebPort = "webPort" ; + public static final String MqttEnable = "mqttEnable" ; + public static final String MqttNoSubThenOff = "noSubThenOff" ; public static final String ActutorPort = "actutorPort" ; public static final String DbName = "dbName" ; } diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamSetMw.java b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamSetMw.java index 806467e..b5234a5 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamSetMw.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/java/com/dy/pipIrrParamSet/paramSet/ParamSetMw.java @@ -121,6 +121,10 @@ newLine = "tcp.port=" + paramMap.get(ParamKey.TcpPort); }else if(newLine != null && newLine.trim().startsWith("base.upData.min.interval=")){ newLine = "base.upData.min.interval=" + paramMap.get(ParamKey.UpDataMinInterval); + }else if(newLine != null && newLine.trim().startsWith("mqtt.enable=")){ + newLine = "mqtt.enable=" + paramMap.get(ParamKey.MqttEnable); + }else if(newLine != null && newLine.trim().startsWith("mqtt.noSubThenOff=")){ + newLine = "mqtt.noSubThenOff=" + paramMap.get(ParamKey.MqttNoSubThenOff); } newLines.add(newLine); } @@ -150,6 +154,12 @@ key = ParamKey.WebPort; this.getConfig(env, map, paramNamePre + key, key); + key = ParamKey.MqttEnable; + this.getConfig(env, map, paramNamePre + key, key); + + key = ParamKey.MqttNoSubThenOff; + this.getConfig(env, map, paramNamePre + key, key); + key = ParamKey.ActutorPort; this.getConfig(env, map, paramNamePre + key, key); diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/resources/application-params.yml b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/resources/application-params.yml index 24a9806..de19a1c 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/resources/application-params.yml +++ b/pipIrr-platform/pipIrr-mw/pipIrr-param-set/src/main/resources/application-params.yml @@ -4,6 +4,8 @@ orgTag: ym tcpPort: 60000 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8070 actutorPort: 9070 dbName: pipIrr_ym @@ -11,6 +13,8 @@ orgTag: sp tcpPort: 62000 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8073 actutorPort: 9073 dbName: pipIrr_sp @@ -18,6 +22,8 @@ orgTag: test tcpPort: 65000 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8072 actutorPort: 9072 dbName: pipIrr_test @@ -25,6 +31,8 @@ orgTag: mj tcpPort: 61000 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8071 actutorPort: 9071 dbName: pipIrr_mj @@ -33,6 +41,8 @@ orgTag: mq tcpPort: 60100 upDataMinInterval: 6 + mqttEnable: true + noSubThenOff: 10 webPort: 8100 actutorPort: 9100 dbName: pipIrr_mq @@ -40,6 +50,8 @@ orgTag: yq tcpPort: 60101 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8101 actutorPort: 9101 dbName: pipIrr_yq @@ -47,6 +59,8 @@ orgTag: hlj tcpPort: 60102 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8102 actutorPort: 9102 dbName: pipIrr_hlj @@ -54,6 +68,8 @@ orgTag: gz tcpPort: 60103 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8103 actutorPort: 9103 dbName: pipIrr_gz @@ -61,6 +77,8 @@ orgTag: lz tcpPort: 60104 upDataMinInterval: 6 + mqttEnable: false + noSubThenOff: 10 webPort: 8104 actutorPort: 9104 dbName: pipIrr_lz @@ -68,6 +86,8 @@ orgTag: jc tcpPort: 60105 upDataMinInterval: 6 + mqttEnable: true + noSubThenOff: 10 webPort: 8105 actutorPort: 9105 dbName: pipIrr_jc diff --git "a/pipIrr-platform/\346\226\207\346\241\243/\346\211\223\345\214\205\345\217\221\345\270\203/\346\211\223\345\214\205\345\217\221\345\270\203\351\205\215\347\275\256\344\277\256\346\224\271.docx" "b/pipIrr-platform/\346\226\207\346\241\243/\346\211\223\345\214\205\345\217\221\345\270\203/\346\211\223\345\214\205\345\217\221\345\270\203\351\205\215\347\275\256\344\277\256\346\224\271.docx" index b568832..6a380ca 100644 --- "a/pipIrr-platform/\346\226\207\346\241\243/\346\211\223\345\214\205\345\217\221\345\270\203/\346\211\223\345\214\205\345\217\221\345\270\203\351\205\215\347\275\256\344\277\256\346\224\271.docx" +++ "b/pipIrr-platform/\346\226\207\346\241\243/\346\211\223\345\214\205\345\217\221\345\270\203/\346\211\223\345\214\205\345\217\221\345\270\203\351\205\215\347\275\256\344\277\256\346\224\271.docx" Binary files differ -- Gitblit v1.8.0