From b181d08b9c8c4f3f4d8c475a60506ba4d93c8382 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 09 四月 2025 11:38:23 +0800
Subject: [PATCH] 灌溉计划详情页,包含计划信息、轮灌组信息、取水口命令发布员结果信息
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 272 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
new file mode 100644
index 0000000..8bba068
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -0,0 +1,272 @@
+package com.dy.pipIrrRemote.rtuUpgrage;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.dy.common.aop.SsoAop;
+import com.dy.common.softUpgrade.state.UpgradeTaskVo;
+import com.dy.common.springUtil.SpringContextUtil;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram;
+import com.dy.pipIrrGlobal.pojoUg.UgRtuTask;
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
+import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Failure;
+import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Success;
+import com.dy.pipIrrGlobal.voUg.VoWatch;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Base64;
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/11/12 8:33
+ * @Description
+ */
+@Slf4j
+@Tag(name = "rtu杩滅▼鍗囩骇浠诲姟", description = "rtu杩滅▼鍗囩骇浠诲姟鐩稿叧鎿嶄綔")
+@RestController
+@RequestMapping(path = "rtuUpgrade")
+public class RtuUpgradeCtrl extends Web2RtuMw {
+ @Autowired
+ private RtuUpgradeSv sv ;
+
+ @Autowired
+ private RtuUpgradeResSv resSv ;
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ /**
+ * 涓嬪彂rtu杩滅▼鍗囩骇浠诲姟
+ * @param id 浠诲姟id
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Operation(summary = "涓嬪彂rtu杩滅▼鍗囩骇浠诲姟", description = "涓嬪彂rtu杩滅▼鍗囩骇浠诲姟")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖鎿嶄綔鎴愬姛涓庡惁鏁版嵁锛圔aseResponse.content:Boolean锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @GetMapping(path = "/issuedTask")
+ @SsoAop()
+ public BaseResponse<Boolean> issuedTask(String id){
+ if(id == null || id.trim().equals("")){
+ return BaseResponseUtils.buildErrorMsg("浠诲姟id涓嶈兘涓虹┖") ;
+ }
+ UgRtuTask tpo = this.sv.selectTaskById(id) ;
+ if(tpo == null){
+ return BaseResponseUtils.buildErrorMsg("浠诲姟涓嶅瓨鍦�") ;
+ }
+ if(tpo.isExecute == 1){
+ return BaseResponseUtils.buildErrorMsg("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ;
+ }
+ UgRtuProgram ppo = this.sv.selectProgramById(tpo.programId) ;
+ if(ppo == null){
+ return BaseResponseUtils.buildErrorMsg("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ;
+ }
+
+ List<String> taskRtuAddrs = this.sv.selectAllRtuAddrByTask(id) ;
+ if(taskRtuAddrs == null || taskRtuAddrs.size() == 0){
+ return BaseResponseUtils.buildErrorMsg("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ;
+ }
+
+ String ugCallbackUrl_rm = env.getProperty("mw.ugCallbackUrl_rm" );
+ if(ugCallbackUrl_rm == null || ugCallbackUrl_rm.trim().equals("")){
+ return BaseResponseUtils.buildErrorMsg("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ;
+ }
+
+ UpgradeTaskVo vo = new UpgradeTaskVo() ;
+ this.valueFromPo(vo, tpo, ppo) ;
+ vo.rtuAddrList = taskRtuAddrs ;
+ vo.callbackWebUrl = ugCallbackUrl_rm ;
+
+ String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ;
+ BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ;
+ if(res != null){
+ if(res.isSuccess()){
+ this.sv.setUpgradeTaskExecuted(id);
+ return BaseResponseUtils.buildSuccess(true) ;
+ }else{
+ String msg = res.getContent()==null?null:(String)res.getContent() ;
+ if(msg == null){
+ msg = res.getMsg() ;
+ }
+ log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐ワ紝" + msg) ;
+ return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽け璐ワ紝" + msg) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ }
+ }
+ /**
+ * 涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Operation(summary = "涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟", description = "涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖鎿嶄綔鎴愬姛涓庡惁鏁版嵁锛圔aseResponse.content:Boolean锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = String.class))}
+ )
+ })
+ @GetMapping(path = "/forceOver")
+ @SsoAop()
+ public BaseResponse<String> forceOver() {
+ String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ;
+ BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ;
+ if(res != null){
+ if(res.isSuccess()){
+ RtuUpgradeStateReceiverCtrl.afterMwForceOverCurUgTask();
+ String msg = res.getContent()==null?null:(String)res.getContent() ;
+ if(msg == null){
+ msg = res.getMsg() ;
+ }
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, msg, msg) ;
+ }else{
+ String msg = res.getContent()==null?null:(String)res.getContent() ;
+ if(msg == null){
+ msg = res.getMsg() ;
+ }
+ log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝己鍒剁粨鏉熷綋鍓峳tu杩滅▼鍗囩骇浠诲姟澶辫触锛�" + msg) ;
+ return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽己鍒剁粨鏉熷綋鍓峳tu杩滅▼鍗囩骇浠诲姟澶辫触锛�" + msg) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ }
+ }
+
+
+ private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){
+ vo.id = "" + tpo.id ;
+ vo.softFileName = ppo.hexFileName ;
+ vo.softStoreAddr = ppo.storeRamAddr ;
+ vo.softStartAddr = ppo.startRamAddr ;
+ vo.softFileData64 = Base64.getEncoder().encodeToString(ppo.programBytes) ;
+ //vo.softFileData = ppo.programBytes ;
+ vo.softBytesCalculate = ppo.programCalculateBytes ;
+ vo.softByteSrc16 = ppo.programCrc16 ;
+ }
+
+
+ /**
+ * 閲嶇疆杩滅▼鍗囩骇婕旂ず绋嬪簭
+ * @return 鎿嶄綔缁撴灉
+ */
+ @GetMapping(path = "/demoReset")
+ @SsoAop()
+ public BaseResponse<Boolean> demoReset(){
+ if(RtuUpgradeStateReceiverCtrl.cache != null){
+ //return BaseResponseUtils.buildError("褰撳墠娌℃湁鍗囩骇浠诲姟") ;
+ //姝e紡杩愯鏃讹紝涓嬮潰涓よ鍘绘帀锛屼笂闈竴琛屾墦寮�
+ RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class);
+ ctrl.resetDemo();
+ ctrl.demo();
+ }
+ return BaseResponseUtils.buildSuccess(true) ;
+ }
+
+ /**
+ * 鐩戣锛�
+ * 褰撳墠rtu杩滅▼鍗囩骇浠诲姟鎵ц鐘舵��
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Operation(summary = "褰撳墠rtu杩滅▼鍗囩骇浠诲姟鎵ц鐘舵��", description = "褰撳墠rtu杩滅▼鍗囩骇浠诲姟鎵ц鐘舵��")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖鎿嶄綔鎴愬姛涓庡惁鏁版嵁锛圔aseResponse.content:Boolean锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = VoWatch.class))}
+ )
+ })
+ @GetMapping(path = "/curUpgradeState")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<VoWatch> > curUpgradeState(QueryVo qvo){
+ if(qvo == null){
+ qvo = new QueryVo();
+ qvo.pageCurr = 1 ;
+ qvo.pageSize = 49 ;
+ }
+ if(RtuUpgradeStateReceiverCtrl.cache == null){
+ return BaseResponseUtils.buildErrorMsg("褰撳墠娌℃湁鍗囩骇浠诲姟") ;
+ //姝e紡杩愯鏃讹紝涓嬮潰涓よ鍘绘帀锛屼笂闈竴琛屾墦寮�
+ //RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class);
+ //ctrl.demo();
+ }
+ QueryResultVo<VoWatch> rsVo = this.resSv.curUpgradeState(qvo) ;
+ return BaseResponseUtils.buildSuccess(rsVo) ;
+ }
+
+ /**
+ * 瀵煎嚭鍗囩骇澶辫触RTU鍒楄〃
+ * @param response
+ */
+ @RequestMapping(value = "/exportUgFail", method = RequestMethod.GET)
+ public void exportUgFail(HttpServletResponse response) throws Exception {
+ setExcelRespProp(response, "鍗囩骇澶辫触RTU鍒楄〃");
+ List<VoUgRtuResult4Failure> rsList = resSv.exportUgFail();
+ EasyExcel.write(response.getOutputStream())
+ .head(VoUgRtuResult4Failure.class)
+ .excelType(ExcelTypeEnum.XLSX)
+ .sheet("鍗囩骇澶辫触RTU鍒楄〃")
+ .doWrite(rsList);
+ }
+
+
+ /**
+ * 瀵煎嚭闀跨骇鎴愬姛RTU鍒楄〃
+ * @param response
+ */
+ @RequestMapping(value = "/exportUgSuccess", method = RequestMethod.GET)
+ public void exportUgSuccess(HttpServletResponse response) throws Exception {
+ setExcelRespProp(response, "鍗囩骇鎴愬姛RTU鍒楄〃");
+ List<VoUgRtuResult4Success> rsList = resSv.exportUgSuccess();
+ EasyExcel.write(response.getOutputStream())
+ .head(VoUgRtuResult4Success.class)
+ .excelType(ExcelTypeEnum.XLSX)
+ .sheet("鍗囩骇鎴愬姛RTU鍒楄〃")
+ .doWrite(rsList);
+ }
+
+
+ /**
+ * 璁剧疆excel涓嬭浇鍝嶅簲澶村睘鎬�
+ */
+ private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+ }
+
+}
--
Gitblit v1.8.0