zhubaomin
2025-02-21 1f19230e00b543b58f03853df1a38ebd8b508e55
发布灌溉计划并生成开阀计划
10个文件已修改
6个文件已添加
516 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateScheduleMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrOpeningScheduleMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrPlanOperateMapper.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrOpeningSchedule.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrPlanOperate.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigateSchedule.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateScheduleMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrOpeningScheduleMapper.xml 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrPlanOperateMapper.xml 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/IrrigatePlan.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/PlanSimple.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/enums/OperateTypeENUM.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java
@@ -24,4 +24,11 @@
    int updateByPrimaryKeySelective(IrIrrigatePlan record);
    int updateByPrimaryKey(IrIrrigatePlan record);
    /**
     * 发布指定的灌溉计划
     * @param planId
     * @return
     */
    int publishIrrigatePlan(Long planId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateScheduleMapper.java
@@ -2,7 +2,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author ZhuBaoMin
@@ -23,4 +26,11 @@
    int updateByPrimaryKeySelective(IrIrrigateSchedule record);
    int updateByPrimaryKey(IrIrrigateSchedule record);
    /**
     * 根据计划ID获取灌溉次序
     * @param planId
     * @return
     */
    List<VoIrrigateSchedule> getIrrigateSchedules(Long planId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrOpeningScheduleMapper.java
@@ -6,10 +6,11 @@
/**
 * @author ZhuBaoMin
 * @date 2025-02-20 15:35
 * @LastEditTime 2025-02-20 15:35
 * @date 2025-02-21 11:08
 * @LastEditTime 2025-02-21 11:08
 * @Description
 */
@Mapper
public interface IrOpeningScheduleMapper extends BaseMapper<IrOpeningSchedule> {
    int deleteByPrimaryKey(Long id);
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrPlanOperateMapper.java
New file
@@ -0,0 +1,27 @@
package com.dy.pipIrrGlobal.daoIr;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
import org.apache.ibatis.annotations.Mapper;
/**
 * @author ZhuBaoMin
 * @date 2025-02-21 11:11
 * @LastEditTime 2025-02-21 11:11
 * @Description
 */
@Mapper
public interface IrPlanOperateMapper extends BaseMapper<IrPlanOperate> {
    int deleteByPrimaryKey(Long id);
    int insert(IrPlanOperate record);
    int insertSelective(IrPlanOperate record);
    IrPlanOperate selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(IrPlanOperate record);
    int updateByPrimaryKey(IrPlanOperate record);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrOpeningSchedule.java
@@ -29,28 +29,34 @@
    public static final long serialVersionUID = 202502201600001L;
    /**
    * 主键
    */
     * 主键
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
    * 灌溉次序ID
    */
     * 灌溉次序ID
     */
    @NotNull(message = "灌溉次序ID不能为空")
    private Long scheduleId;
    /**
    * 开阀时间
    */
     * 取水口ID
     */
    @NotNull(message = "取水口ID不能为空")
    private Long intakeId;
    /**
     * 开阀时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "开阀时间不能为空")
    private Date startTime;
    /**
    * 灌溉时长;分钟
    */
     * 灌溉时长;分钟
     */
    @NotNull(message = "灌溉时长不能为空")
    private Integer duration;
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrPlanOperate.java
New file
@@ -0,0 +1,61 @@
package com.dy.pipIrrGlobal.pojoIr;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import java.util.Date;
/**
 * @author ZhuBaoMin
 * @date 2025-02-21 11:11
 * @LastEditTime 2025-02-21 11:11
 * @Description 灌溉计划操实体类
 */
@TableName(value="ir_plan_operate", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class IrPlanOperate implements BaseEntity {
    public static final long serialVersionUID = 202502201600001L;
    /**
    * 主键
    */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
    * 灌溉计划ID
    */
    @NotNull(message = "灌溉计划ID不能为空")
    private Long planId;
    /**
    * 操作人编号
    */
    @NotNull(message = "操作人编号不能为空")
    private Long operator;
    /**
    * 操作类型;1-创建,2-发布,3-执行,4-暂停,5-终止,6-完成
    */
    private Byte operateType;
    /**
    * 操作时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date operateTime;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigateSchedule.java
New file
@@ -0,0 +1,45 @@
package com.dy.pipIrrGlobal.voIr;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.dy.common.po.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Data;
import java.util.Date;
/**
 * @author ZhuBaoMin
 * @date 2025-02-21 14:21
 * @LastEditTime 2025-02-21 14:21
 * @Description 灌溉次序视图对象
 */
@Data
@JsonPropertyOrder({ "id", "vcNum", "money", "inUse", "isAlarmValue"})
public class VoIrrigateSchedule implements BaseEntity {
    private static final long serialVersionUID = 202502211423001L;
    /**
     * 灌溉次序ID
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    private Long scheduleId;
    /**
     * 灌溉开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    /**
     * 灌溉时长,分钟
     */
    private Integer duration;
    /**
     * 取水口ID,多个用逗号隔开
     */
    private String intakeIds;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -148,4 +148,9 @@
      deleted = #{deleted,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--发布指定的灌溉计划-->
  <update id="publishIrrigatePlan">
    UPDATE ir_irrigate_plan SET plan_state = 2 WHERE id = #{planId}
  </update>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateScheduleMapper.xml
@@ -134,4 +134,15 @@
      current_state = #{currentState,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据计划ID获取灌溉次序-->
  <select id="getIrrigateSchedules" resultType="com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule">
    SELECT
        id AS scheduleId,
        start_time AS startTime,
        TIMESTAMPDIFF(MINUTE, start_time, stop_time) AS duration,
        intake_ids AS intakeIds
    FROM ir_irrigate_schedule
    WHERE plan_id = #{planId}
  </select>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrOpeningScheduleMapper.xml
@@ -6,12 +6,13 @@
    <!--@Table ir_opening_schedule-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="schedule_id" jdbcType="BIGINT" property="scheduleId" />
    <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="duration" jdbcType="INTEGER" property="duration" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, schedule_id, start_time, duration
    id, schedule_id, intake_id, start_time, duration
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -27,10 +28,10 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule">
    <!--@mbg.generated-->
    insert into ir_opening_schedule (id, schedule_id, start_time,
      duration)
    values (#{id,jdbcType=BIGINT}, #{scheduleId,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP},
      #{duration,jdbcType=INTEGER})
    insert into ir_opening_schedule (id, schedule_id, intake_id,
      start_time, duration)
    values (#{id,jdbcType=BIGINT}, #{scheduleId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT},
      #{startTime,jdbcType=TIMESTAMP}, #{duration,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule">
    <!--@mbg.generated-->
@@ -41,6 +42,9 @@
      </if>
      <if test="scheduleId != null">
        schedule_id,
      </if>
      <if test="intakeId != null">
        intake_id,
      </if>
      <if test="startTime != null">
        start_time,
@@ -55,6 +59,9 @@
      </if>
      <if test="scheduleId != null">
        #{scheduleId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
@@ -71,6 +78,9 @@
      <if test="scheduleId != null">
        schedule_id = #{scheduleId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        intake_id = #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
@@ -84,6 +94,7 @@
    <!--@mbg.generated-->
    update ir_opening_schedule
    set schedule_id = #{scheduleId,jdbcType=BIGINT},
      intake_id = #{intakeId,jdbcType=BIGINT},
      start_time = #{startTime,jdbcType=TIMESTAMP},
      duration = #{duration,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrPlanOperateMapper.xml
New file
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dy.pipIrrGlobal.daoIr.IrPlanOperateMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrPlanOperate">
    <!--@mbg.generated-->
    <!--@Table ir_plan_operate-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="plan_id" jdbcType="BIGINT" property="planId" />
    <result column="operator" jdbcType="BIGINT" property="operator" />
    <result column="operate_type" jdbcType="TINYINT" property="operateType" />
    <result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, plan_id, `operator`, operate_type, operate_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from ir_plan_operate
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ir_plan_operate
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrPlanOperate">
    <!--@mbg.generated-->
    insert into ir_plan_operate (id, plan_id, `operator`,
      operate_type, operate_time)
    values (#{id,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, #{operator,jdbcType=BIGINT},
      #{operateType,jdbcType=TINYINT}, #{operateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrPlanOperate">
    <!--@mbg.generated-->
    insert into ir_plan_operate
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="planId != null">
        plan_id,
      </if>
      <if test="operator != null">
        `operator`,
      </if>
      <if test="operateType != null">
        operate_type,
      </if>
      <if test="operateTime != null">
        operate_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="planId != null">
        #{planId,jdbcType=BIGINT},
      </if>
      <if test="operator != null">
        #{operator,jdbcType=BIGINT},
      </if>
      <if test="operateType != null">
        #{operateType,jdbcType=TINYINT},
      </if>
      <if test="operateTime != null">
        #{operateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrPlanOperate">
    <!--@mbg.generated-->
    update ir_plan_operate
    <set>
      <if test="planId != null">
        plan_id = #{planId,jdbcType=BIGINT},
      </if>
      <if test="operator != null">
        `operator` = #{operator,jdbcType=BIGINT},
      </if>
      <if test="operateType != null">
        operate_type = #{operateType,jdbcType=TINYINT},
      </if>
      <if test="operateTime != null">
        operate_time = #{operateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrPlanOperate">
    <!--@mbg.generated-->
    update ir_plan_operate
    set plan_id = #{planId,jdbcType=BIGINT},
      `operator` = #{operator,jdbcType=BIGINT},
      operate_type = #{operateType,jdbcType=TINYINT},
      operate_time = #{operateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
@@ -4,8 +4,13 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigatePlan;
import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigateSchedule;
import com.dy.pipIrrWechat.irrigatePlan.dto.PlanSimple;
import com.dy.pipIrrWechat.irrigatePlan.enums.OperateTypeENUM;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -17,6 +22,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -34,6 +40,15 @@
public class IrrigatePlanCtrl {
    private final IrrigatePlanSv irrigatePlanSv;
    /**
     * 创建灌溉计划
     * 1. 添加灌溉计划
     * 2. 添加灌溉次序
     * 3. 添加灌溉计划操作记录
     * @param planAndSchedule
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    public BaseResponse<Boolean> createPlan(@RequestBody @Valid IrrigatePlan planAndSchedule, BindingResult bindingResult){
@@ -41,6 +56,9 @@
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        Long operatorId = planAndSchedule.getOperatorId();
        // 添加灌溉计划
        IrIrrigatePlan plan = new IrIrrigatePlan();
        plan.setProjectId(planAndSchedule.getProjectId());
        plan.setPlanName(planAndSchedule.getPlanName());
@@ -52,6 +70,11 @@
        plan.setDeleted(0L);
        Long planId = irrigatePlanSv.addIrrigatePlan(plan);
        if(planId == null) {
            return BaseResponseUtils.buildErrorMsg("创建灌溉计划失败");
        }
        // 添加灌溉次序
        if(planId != null){
            for(IrrigateSchedule schedule : planAndSchedule.getSchedules()){
                IrIrrigateSchedule po = new IrIrrigateSchedule();
@@ -77,13 +100,75 @@
                po.setStartTime(schedule.getStartTime());
                po.setStopTime(schedule.getStopTime());
                //po.setIntakeIds(schedule.getIntakeIds());
                po.setCurrentState((byte)1);
                Long scheduleId = irrigatePlanSv.addIrrigateSchedule(po);
            }
        }
        // 添加灌溉计划操作记录
        IrPlanOperate planOperate  = new IrPlanOperate();
        planOperate.setPlanId(planId);
        planOperate.setOperator(operatorId);
        planOperate.setOperateType(OperateTypeENUM.CREATE.getCode());
        planOperate.setOperateTime(new Date());
        if(irrigatePlanSv.addPlanOperate(planOperate) == 0){
            return BaseResponseUtils.buildErrorMsg("添加灌溉计划操作记录失败");
        }
        return BaseResponseUtils.buildSuccess();
    }
    /**
     * 发布灌溉计划
     * 1. 修改灌溉计划状态为发布状态
     * 2. 添加灌溉计划操作记录
     * 3. 生成开阀计划
     * @param planSimple
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "publishPlan", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    public BaseResponse<Boolean> publishPlan(@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();
        // 修改灌溉计划状态为发布状态
        if(irrigatePlanSv.publishIrrigatePlan(planId) == 0){
            return BaseResponseUtils.buildErrorMsg("修改灌溉计划状态失败");
        }
        // 添加灌溉计划操作记录
        IrPlanOperate planOperate  = new IrPlanOperate();
        planOperate.setPlanId(planId);
        planOperate.setOperator(operatorId);
        planOperate.setOperateType(OperateTypeENUM.PUBLISH.getCode());
        planOperate.setOperateTime(new Date());
        if(irrigatePlanSv.addPlanOperate(planOperate) == 0){
            return BaseResponseUtils.buildErrorMsg("添加灌溉计划操作记录失败");
        }
        // 生成开阀计划
        List<VoIrrigateSchedule> schedules = irrigatePlanSv.getIrrigateSchedules(planId);
        if(schedules == null || schedules.size() == 0) {
            return BaseResponseUtils.buildErrorMsg("无取水口,生成开阀计划失败");
        }
        for (VoIrrigateSchedule schedule : schedules) {
            for(String intakeId : schedule.getIntakeIds().split(",")){
                // 添加灌溉计划开启记录
                IrOpeningSchedule openingSchedule = new IrOpeningSchedule();
                openingSchedule.setScheduleId(schedule.getScheduleId());
                openingSchedule.setIntakeId(Long.parseLong(intakeId));
                openingSchedule.setStartTime(schedule.getStartTime());
                openingSchedule.setDuration(schedule.getDuration());
                if(irrigatePlanSv.addOpeningSchedule(openingSchedule) == 0){
                    return BaseResponseUtils.buildErrorMsg("添加开阀计划失败");
                }
            }
        }
        return BaseResponseUtils.buildSuccess();
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
@@ -1,11 +1,11 @@
package com.dy.pipIrrWechat.irrigatePlan;
import com.dy.pipIrrGlobal.daoIr.IrIrrigateGroupMapper;
import com.dy.pipIrrGlobal.daoIr.IrIrrigatePlanMapper;
import com.dy.pipIrrGlobal.daoIr.IrIrrigateScheduleMapper;
import com.dy.pipIrrGlobal.daoIr.IrIrrigateUnitMapper;
import com.dy.pipIrrGlobal.daoIr.*;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -26,7 +26,13 @@
    private IrIrrigatePlanMapper irrigatePlanMapper;
    @Autowired
    private IrPlanOperateMapper irPlanOperateMapper;
    @Autowired
    private IrIrrigateScheduleMapper irIrrigateScheduleMapper;
    @Autowired
    private IrOpeningScheduleMapper irOpeningScheduleMapper;
    @Autowired
    private IrIrrigateGroupMapper irIrrigateGroupMapper;
@@ -35,12 +41,31 @@
    private IrIrrigateUnitMapper irIrrigateUnitMapper;
    /**
     * 添加灌溉计划记录
     * 添加灌溉计划
     * @param po
     * @return
     */
    public Long addIrrigatePlan(IrIrrigatePlan po) {
        irrigatePlanMapper.insert(po);
        return po.getId();
    }
    /**
     * 发布指定的灌溉计划
     * @param planId
     * @return
     */
    public Integer publishIrrigatePlan(Long planId) {
        return irrigatePlanMapper.publishIrrigatePlan(planId);
    }
    /**
     * 添加灌溉计划操作记录
     * @param po
     * @return
     */
    public Long addPlanOperate(IrPlanOperate po) {
        irPlanOperateMapper.insert(po);
        return po.getId();
    }
@@ -55,6 +80,25 @@
    }
    /**
     * 根据计划ID获取灌溉次序
     * @param planId
     * @return
     */
    public List<VoIrrigateSchedule> getIrrigateSchedules(Long planId) {
        return irIrrigateScheduleMapper.getIrrigateSchedules(planId);
    }
    /**
     * 添加开阀计划
     * @param po
     * @return
     */
    public Long addOpeningSchedule(IrOpeningSchedule po) {
        irOpeningScheduleMapper.insert(po);
        return po.getId();
    }
    /**
     * 根据轮灌组ID获取取水口ID列表
     * @param groupId
     * @return
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/IrrigatePlan.java
@@ -57,4 +57,10 @@
     */
    @NotEmpty(message = "巡检轨迹不能为空")
    private List<IrrigateSchedule> schedules;
    /**
     * 操作人ID
     */
    @NotNull(message = "操作人ID不能为空")
    private Long operatorId;
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/PlanSimple.java
New file
@@ -0,0 +1,28 @@
package com.dy.pipIrrWechat.irrigatePlan.dto;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2025-02-21 13:59
 * @LastEditTime 2025-02-21 13:59
 * @Description 灌溉计划简单对象
 */
@Data
public class PlanSimple {
    public static final long serialVersionUID = 202502211400001L;
    /**
     * 灌溉计划
     */
    @NotNull(message = "计划ID不能为空")
    private Long planId;
    /**
     * 操作人ID
     */
    @NotNull(message = "操作人ID不能为空")
    private Long operatorId;
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/enums/OperateTypeENUM.java
New file
@@ -0,0 +1,25 @@
package com.dy.pipIrrWechat.irrigatePlan.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
 * @author ZhuBaoMin
 * @date 2025-02-21 15:32
 * @LastEditTime 2025-02-21 15:32
 * @Description 灌溉计划操作类型枚举
 * @Version 1.0
 */
@Getter
@AllArgsConstructor
public enum OperateTypeENUM {
    CREATE((byte)1, "创建"),
    PUBLISH((byte)2, "发布"),
    EXECUTE((byte)3, "执行"),
    SUSPEND((byte)4, "暂停"),
    TERMINATE((byte)5, "终止");
    private final Byte code;
    private final String message;
}