From 66282f3fbc0877c663a8bcecd9a48b483e7efe6b Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 13 五月 2025 15:48:29 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java | 46 +++++++++++++++++++++++++++++++--------------- 1 files changed, 31 insertions(+), 15 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java index 5db3988..a0bd00b 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java @@ -16,7 +16,6 @@ import com.dy.pipIrrWechat.irrigatePlan.enums.OperateTypeENUM; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -217,28 +216,27 @@ startTime = startTime.plusMinutes(irrPlanDelay); } planStartTime = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()); - LocalDateTime stopTime = startTime.plusMinutes(duration); - planStopTime = Date.from(stopTime.atZone(ZoneId.systemDefault()).toInstant()); - - // 鏍规嵁璁″垝ID鏇存柊璁″垝淇℃伅锛堣捣姝㈡椂闂淬�佽鍒掔姸鎬侊級 - if (this.updatePlanTimes(planStartTime, planStopTime, planId) == 0) { - Map map = new HashMap<>(); - map.put("success", false); - map.put("msg", "璁″垝淇℃伅鏇存柊澶辫触"); - map.put("content", null); - return map; - } - - // 鏇存柊姣忎釜鐏屾簤娆″簭鐨勫紑濮嬫椂闂� + + // 鏇存柊姣忎釜鐏屾簤娆″簭鐨勫紑濮嬫椂闂村苟璁$畻鏈�鍚庝竴缁勫叧闃�鏃堕棿 List<VoIrrigateSchedule> schedules = getSchedulesByPlanId(planId); Date scheduleStartTime = null; + LocalDateTime lastScheduleEndTime = null; Integer sort = 0; + + // 绗竴娆¢亶鍘嗭細鏇存柊姣忎釜鐏屾簤娆″簭鐨勫紑濮嬫椂闂� for (VoIrrigateSchedule schedule : schedules) { if (scheduleStartTime == null) { scheduleStartTime = planStartTime; } this.updateScheduleStartTime(schedule.getScheduleId(), scheduleStartTime); - + + // 璁$畻褰撳墠娆″簭鐨勭粨鏉熸椂闂� + LocalDateTime currentScheduleStartTime = scheduleStartTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + LocalDateTime currentScheduleEndTime = currentScheduleStartTime.plusMinutes(schedule.getDuration()); + + // 鏇存柊鏈�鍚庝竴缁勭殑缁撴潫鏃堕棿 + lastScheduleEndTime = currentScheduleEndTime; + // 璁$畻涓嬩竴缁勭殑寮�濮嬫椂闂� LocalDateTime LocalscheduleStartTime = scheduleStartTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); LocalscheduleStartTime = LocalscheduleStartTime.plusMinutes(schedule.getDuration()); @@ -250,6 +248,24 @@ scheduleStartTime = planStartTime; } } + + // 鏍规嵁鏈�鍚庝竴缁勫叧闃�鏃堕棿璁剧疆璁″垝缁撴潫鏃堕棿 + if (lastScheduleEndTime != null) { + planStopTime = Date.from(lastScheduleEndTime.atZone(ZoneId.systemDefault()).toInstant()); + } else { + // 濡傛灉娌℃湁鐏屾簤娆″簭锛屽垯浣跨敤鍘熸潵鐨勮绠楁柟寮� + LocalDateTime stopTime = startTime.plusMinutes(duration); + planStopTime = Date.from(stopTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + // 鏍规嵁璁″垝ID鏇存柊璁″垝淇℃伅锛堣捣姝㈡椂闂淬�佽鍒掔姸鎬侊級 + if (this.updatePlanTimes(planStartTime, planStopTime, planId) == 0) { + Map map = new HashMap<>(); + map.put("success", false); + map.put("msg", "璁″垝淇℃伅鏇存柊澶辫触"); + map.put("content", null); + return map; + } // 娣诲姞鐏屾簤璁″垝鎿嶄綔璁板綍 IrPlanOperate planOperate = new IrPlanOperate(); -- Gitblit v1.8.0