liurunyu
1 天以前 66282f3fbc0877c663a8bcecd9a48b483e7efe6b
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
1个文件已修改
46 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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();