From 02d965a2ff0cb5d415cedceacd2ae90c7ec1ac39 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期六, 10 五月 2025 09:03:50 +0800 Subject: [PATCH] 解决开关阀记录数据因重绑定或改RTU地址而引起的地址变更问题 --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 108 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java new file mode 100644 index 0000000..f699aac --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/p202404V201/Cd50Ctrl.java @@ -0,0 +1,108 @@ +package com.dy.pipIrrRemote.monitor.p202404V201; + +import com.alibaba.fastjson2.JSONObject; +import com.dy.common.aop.SsoAop; +import com.dy.common.mw.protocol.Command; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.pipIrrRemote.common.dto.DtoBase; +import com.dy.pipIrrRemote.monitor.common.ComCtrl; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.http.MediaType; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: liurunyu + * @Date: 2025/5/9 14:41 + * @Description + */ +@Slf4j +@Tag(name = "杩滅▼閫忎紶鍛戒护", description = "杩滅▼閫忎紶鍛戒护") +@RestController +@RequestMapping(path = "p202404V201") +@RequiredArgsConstructor +@Scope("prototype") //鍥犱负鏈夊璞$被灞炴�э紝鎵�浠ラ噰鐢ㄥ師鍨嬫ā寮忥紝姣忔璇锋眰鏂板缓涓�涓疄渚嬪璞� +public class Cd50Ctrl extends ComCtrl { + + private static final String RtuSuccessMsg = "鎺у埗鍣ㄦ帴鏀跺苟鎵ц鍛戒护鎴愬姛"; + + private static final String ComCode = "50" ; + + @Autowired + private Cd50Sv sv ; + /** + * 鍚戣澶囷紙鎺у埗鍣級鍙戦�侀�忎紶鍛戒护 + * @param dto 鍓嶇鍙戞潵鐨勫�煎璞� + * @param bindingResult 瀵筪to楠岃瘉鐨勭粨鏋� + * @return 杩斿洖鍓嶇 + */ + @PostMapping(path = "cd50", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Object> send(@RequestBody @Valid Cd50Dto dto, BindingResult bindingResult) { + BaseResponse<Object> res ; + //鍙戦�佸懡浠ゅ墠-1锛氶獙璇� + res = super.pre1(sv, ComCode, dto, bindingResult); + if(res == null) { + //鍙戦�佸懡浠ゅ墠-2锛氳幏寰楁暟鎹� + res = super.pre2(sv, ComCode, dto, bindingResult); + if (res == null) { + //鍙戦�佸懡浠ゅ墠-3锛氫繚瀛樺懡浠ゆ棩蹇� + Cd50Param comParam = Cd50Param.builder().commandCode(ComCode).build(); + res = super.pre3(sv, dto.getIntakeId(), dto.getOperator(), ComCode, comParam); + if (res == null) { + //鍙戦�佸懡浠ゅ墠-4锛氬噯澶嘑eature + super.pre4(); + try { + //鍒涘缓澶栭儴鍛戒护锛堝彂缁欐帶鍒跺櫒锛� + Command com = sv.createOuterCommand("" + comId, ComCode); + com.rtuAddr = ctrlPo.getRtuAddr(); + com.rtuResultSendWebUrl = rtuResultSendWebUrl; + //鍙戦�佸懡浠� + res = super.doSend(sv, com); + if (res == null) { + //鍙戦�佸懡浠ゅ悗 + res = super.after(ComCode); + } + } catch (Exception e) { + res = BaseResponseUtils.buildFail("鏈嶅姟绔瀯閫犲苟鍚戦�氫俊涓棿浠跺彂閫佽姹傛椂寮傚父" + (e.getMessage() == null ? "" : e.getMessage())); + } finally { + //鏈�缁� + super.end(); + } + } + } + } + return res ; + } + + @Override + protected String checkDto(DtoBase dto) { + return null; + } + + @Override + protected String createRtnMsg(String code, JSONObject resultData){ + String msg; + if(resultData != null){ + JSONObject codeData = resultData.getJSONObject("data") ; + if(codeData == null){ + return RtuSuccessMsg ; + }else { + Integer minute = codeData.getInteger("minute"); + return "鏌ヨ鎴愬姛锛岃嚜鎶ュ懆鏈燂細" + minute + "鍒嗛挓"; + } + }else{ + msg = RtuSuccessMsg ; + } + return msg; + } +} -- Gitblit v1.8.0