From 44a78bc47ab66d6492bc0579f58f24dc1921b5d5 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 03 四月 2025 15:44:30 +0800
Subject: [PATCH] 1、webSocket相关代码进行了注解优化; 2、通信中间件把阀控器上报的阀门状态进行消息推送,前端、小程序可能用到(webSocket推送)。

---
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java |   53 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
index 2e03d8f..59708ae 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
@@ -60,6 +60,7 @@
             return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
 
+        Long projectId = planAndSchedule.getProjectId();
         Long operatorId = planAndSchedule.getOperatorId();
         Byte startupMode = planAndSchedule.getStartupMode();
         Date planStartTime = planAndSchedule.getPlanStartTime();;
@@ -68,6 +69,20 @@
         Integer duration = 0;
         for(IrrigateSchedule schedule : planAndSchedule.getSchedules()){
             duration = duration + schedule.getDuration();
+        }
+
+        if(startupMode == 2){
+            if(planStartTime == null) {
+                return BaseResponseUtils.buildErrorMsg("鑷姩鍚姩妯″紡蹇呴』鎸囧畾璁″垝鍚姩鏃堕棿");
+            }
+
+            LocalDateTime startTime = planStartTime.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();
+            LocalDateTime currentTime = LocalDateTime.now();
+            currentTime = currentTime.plusHours(8);
+
+            if(!startTime.isAfter(currentTime)) {
+                return BaseResponseUtils.buildErrorMsg("鍚姩鏃堕棿涓嶈兘鍦�8灏忔椂涔嬪唴");
+            }
         }
 
         //if(startupMode == 1){
@@ -80,6 +95,7 @@
         //planStopTime = Date.from(stopTime.atZone(ZoneId.systemDefault()).toInstant());
 
         IrIrrigatePlan plan = new IrIrrigatePlan();
+        plan.setProjectId(projectId);
         plan.setPlanName(planAndSchedule.getPlanName());
         plan.setStartupMode(startupMode);
         plan.setPlanStartTime(planStartTime);
@@ -208,7 +224,9 @@
             planStartTime = new Date();
         }
         LocalDateTime startTime = planStartTime.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();
-        startTime = startTime.plusMinutes(5);
+        if(startupMode == 1){
+            startTime = startTime.plusMinutes(5);
+        }
         planStartTime = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant());
         LocalDateTime stopTime = startTime.plusMinutes(duration);
         planStopTime = Date.from(stopTime.atZone(ZoneId.systemDefault()).toInstant());
@@ -255,7 +273,7 @@
                 automaticClose.setOperator(operatorId);
                 automaticClose.setOpenType(Byte.valueOf("1"));
 
-                commandSv.planedOpenTimedClose(automaticClose, schedule.getStartTime(), schedule.getDuration());
+                commandSv.planedOpenTimedClose(automaticClose, planId, schedule.getStartTime(), schedule.getDuration());
             }
         }
 
@@ -263,18 +281,29 @@
     }
 
     /**
-     * 鑾峰彇鐏屾簤璁″垝鍒楄〃
-     * @param vo
+     * 缁堟鐏屾簤璁″垝
+     * @param planSimple
+     * @param bindingResult
      * @return
      */
-    //@GetMapping(path = "/getIrrigatePlans")
-    //public BaseResponse<QueryResultVo<List<VoIrrigatePlan>>> getIrrigatePlans(QoIrrigatePlan vo) {
-    //    try {
-    //        QueryResultVo<List<VoIrrigatePlan>> res = irrigatePlanSv.getIrrigatePlans(vo);
-    //        return BaseResponseUtils.buildSuccess(res);
-    //    } catch (Exception e) {
-    //        log.error("鑾峰彇杞亴缁勮褰曞紓甯�", e);
-    //        return BaseResponseUtils.buildException(e.getMessage());
+    //@PostMapping(path = "terminatePlan", consumes = MediaType.APPLICATION_JSON_VALUE)
+    //@Transactional(rollbackFor = Exception.class)
+    //public BaseResponse<Boolean> terminatePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){
+    //    if(bindingResult != null && bindingResult.hasErrors()){
+    //        return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
     //    }
+    //
+    //    Long planId = planSimple.getPlanId();
+    //    Long operatorId = planSimple.getOperatorId();
+    //
+    //    IrIrrigatePlan iIrrigatePlan = new IrIrrigatePlan();
+    //    iIrrigatePlan.setId(planId);
+    //    iIrrigatePlan.setExecutingState((byte)3);
+    //    if(irrigatePlanSv.updatePlan(iIrrigatePlan) == 0){
+    //        return BaseResponseUtils.buildErrorMsg("缁堟璁″垝鐘舵�佸け璐�");
+    //    }
+    //
+    //
+    //
     //}
 }

--
Gitblit v1.8.0