zhubaomin
2025-03-03 b375247a32664d3d1a37d735180f25ca8f5aedf7
灌溉模块功能升级
10个文件已修改
295 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateScheduleMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigateSchedule.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateScheduleMapper.xml 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/IrrigatePlan.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/IrrigateSchedule.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java
@@ -30,6 +30,20 @@
    int updateByPrimaryKey(IrIrrigatePlan record);
    /**
     * 根据指定的计划ID获取启动模式
     * @param planId
     * @return
     */
    Byte getStartupMode(Long planId);
    /**
     * 根据指定的计划ID获取已发布的灌溉计划数量
     * @param planId
     * @return
     */
    Integer getPublishedCount(Long planId);
    /**
     * 发布指定的灌溉计划
     * @param planId
     * @return
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateScheduleMapper.java
@@ -4,15 +4,17 @@
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * @author ZhuBaoMin
 * @date 2025-02-20 15:35
 * @LastEditTime 2025-02-20 15:35
 * @date 2025-02-27 10:02
 * @LastEditTime 2025-02-27 10:02
 * @Description
 */
@Mapper
public interface IrIrrigateScheduleMapper extends BaseMapper<IrIrrigateSchedule> {
    int deleteByPrimaryKey(Long id);
@@ -32,5 +34,5 @@
     * @param planId
     * @return
     */
    List<VoIrrigateSchedule> getIrrigateSchedules(Long planId);
    List<VoIrrigateSchedule> getIrrigateSchedules(@Param("startupMode") Byte startupMode, @Param("planId") Long planId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigateSchedule.java
@@ -29,50 +29,49 @@
    public static final long serialVersionUID = 202502201601001L;
    /**
    * 主键
    */
     * 主键
     */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
    * 灌溉计划ID
    */
     * 灌溉计划ID
     */
    @NotNull(message = "灌溉计划ID不能为空")
    private Long planId;
    /**
    * 轮灌组ID
    */
     * 轮灌组ID
     */
    @NotNull(message = "轮灌组ID不能为空")
    private Long groupId;
    /**
    * 灌溉单元ID
    */
    private Long unitId;
    /**
    * 灌溉开始时间
    */
     * 灌溉开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "灌溉开始时间不能为空")
    private Date startTime;
    /**
    * 灌溉结束时间
    */
     * 灌溉结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message ="灌溉结束时间不能为空")
    private Date stopTime;
    /**
    * 取水口ID列表
    */
     * 灌溉时长;分钟
     */
    private Integer duration;
    /**
     * 取水口ID列表
     */
    private String intakeIds;
    /**
    * 当前状态;1-正常,2-暂停,3-终止
    */
     * 当前状态;1-正常,2-暂停,3-终止
     */
    private Byte currentState;
}
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -83,7 +83,7 @@
pipIrr:
    global:
        dev: true  #是否开发阶段,true或false
        dev: false  #是否开发阶段,true或false
        dsName: ym  #开发阶段,设置临时的数据库名称
    nginx:
        root: E:/apps/pipIrr/nginx-1.27.0
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -160,6 +160,23 @@
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据指定的计划ID获取启动模式-->
  <select id="getStartupMode" resultType="java.lang.Byte">
    SELECT
        startup_mode AS startupMode
    FROM ir_irrigate_plan
    WHERE id = #{planId}
  </select>
  <!--根据指定的计划ID获取已发布的灌溉计划数量-->
  <select id="getPublishedCount" resultType="java.lang.Integer">
    SELECT COUNT(*)
    FROM ir_irrigate_plan plan
    WHERE plan.id = #{planId}
      AND plan.plan_state = 2
      AND plan.deleted = 0
  </select>
  <!--发布指定的灌溉计划-->
  <update id="publishIrrigatePlan">
    UPDATE ir_irrigate_plan SET plan_state = 2 WHERE id = #{planId}
@@ -198,30 +215,31 @@
  <!--根据指定的条件获取计划列表-->
  <select id="getIrrigatePlans" resultType="com.dy.pipIrrGlobal.voIr.VoIrrigatePlan">
    SELECT
    plan.id AS planId,
    pro.project_name AS projectName,
    plan.plan_name AS planName,
    CASE plan.startup_mode
    WHEN 1 THEN '手动启动'
    WHEN 2 THEN '自动启动'
    END AS startupMode,
    plan.plan_start_time AS startTime,
    plan.plan_stop_time AS stopTime,
    CASE plan.plan_state
    WHEN 1 THEN '草稿'
    WHEN 2 THEN '已发布'
    END AS planState,
        plan.id AS planId,
        pro.project_name AS projectName,
        plan.plan_name AS planName,
        CASE plan.startup_mode
            WHEN 1 THEN '手动启动'
            WHEN 2 THEN '自动启动'
        END AS startupMode,
        plan.plan_start_time AS startTime,
        plan.plan_stop_time AS stopTime,
        plan.duration AS duration,
        CASE plan.plan_state
            WHEN 1 THEN '草稿'
            WHEN 2 THEN '已发布'
        END AS planState,
    CASE plan.executing_state
    WHEN 1 THEN
    '未执行'
    WHEN 2 THEN
    '执行中'
    WHEN 3 THEN
    '已暂停'
    WHEN 4 THEN
    '已终止'
    END AS executingState
        CASE plan.executing_state
            WHEN 1 THEN
            '未执行'
            WHEN 2 THEN
            '执行中'
            WHEN 3 THEN
            '已暂停'
            WHEN 4 THEN
            '已终止'
        END AS executingState
    FROM ir_irrigate_plan plan
    INNER JOIN ir_project pro ON pro.id = plan.project_id
    <where>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateScheduleMapper.xml
@@ -7,15 +7,15 @@
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="plan_id" jdbcType="BIGINT" property="planId" />
    <result column="group_id" jdbcType="BIGINT" property="groupId" />
    <result column="unit_id" jdbcType="BIGINT" property="unitId" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="stop_time" jdbcType="TIMESTAMP" property="stopTime" />
    <result column="intake_ids" jdbcType="VARCHAR" property="intakeIds" />
    <result column="duration" jdbcType="INTEGER" property="duration" />
    <result column="intake_ids" jdbcType="LONGVARCHAR" property="intakeIds" />
    <result column="current_state" jdbcType="TINYINT" property="currentState" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, plan_id, group_id, unit_id, start_time, stop_time, intake_ids, current_state
    id, plan_id, group_id, start_time, stop_time, duration, intake_ids, current_state
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -32,11 +32,11 @@
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule">
    <!--@mbg.generated-->
    insert into ir_irrigate_schedule (id, plan_id, group_id, 
      unit_id, start_time, stop_time,
      start_time, stop_time, duration,
      intake_ids, current_state)
    values (#{id,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, #{groupId,jdbcType=BIGINT}, 
      #{unitId,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP}, #{stopTime,jdbcType=TIMESTAMP},
      #{intakeIds,jdbcType=VARCHAR}, #{currentState,jdbcType=TINYINT})
      #{startTime,jdbcType=TIMESTAMP}, #{stopTime,jdbcType=TIMESTAMP}, #{duration,jdbcType=INTEGER},
      #{intakeIds,jdbcType=LONGVARCHAR}, #{currentState,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule">
    <!--@mbg.generated-->
@@ -51,14 +51,14 @@
      <if test="groupId != null">
        group_id,
      </if>
      <if test="unitId != null">
        unit_id,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="stopTime != null">
        stop_time,
      </if>
      <if test="duration != null">
        duration,
      </if>
      <if test="intakeIds != null">
        intake_ids,
@@ -77,17 +77,17 @@
      <if test="groupId != null">
        #{groupId,jdbcType=BIGINT},
      </if>
      <if test="unitId != null">
        #{unitId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="stopTime != null">
        #{stopTime,jdbcType=TIMESTAMP},
      </if>
      <if test="duration != null">
        #{duration,jdbcType=INTEGER},
      </if>
      <if test="intakeIds != null">
        #{intakeIds,jdbcType=VARCHAR},
        #{intakeIds,jdbcType=LONGVARCHAR},
      </if>
      <if test="currentState != null">
        #{currentState,jdbcType=TINYINT},
@@ -104,17 +104,17 @@
      <if test="groupId != null">
        group_id = #{groupId,jdbcType=BIGINT},
      </if>
      <if test="unitId != null">
        unit_id = #{unitId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="stopTime != null">
        stop_time = #{stopTime,jdbcType=TIMESTAMP},
      </if>
      <if test="duration != null">
        duration = #{duration,jdbcType=INTEGER},
      </if>
      <if test="intakeIds != null">
        intake_ids = #{intakeIds,jdbcType=VARCHAR},
        intake_ids = #{intakeIds,jdbcType=LONGVARCHAR},
      </if>
      <if test="currentState != null">
        current_state = #{currentState,jdbcType=TINYINT},
@@ -127,20 +127,26 @@
    update ir_irrigate_schedule
    set plan_id = #{planId,jdbcType=BIGINT},
      group_id = #{groupId,jdbcType=BIGINT},
      unit_id = #{unitId,jdbcType=BIGINT},
      start_time = #{startTime,jdbcType=TIMESTAMP},
      stop_time = #{stopTime,jdbcType=TIMESTAMP},
      intake_ids = #{intakeIds,jdbcType=VARCHAR},
      duration = #{duration,jdbcType=INTEGER},
      intake_ids = #{intakeIds,jdbcType=LONGVARCHAR},
      current_state = #{currentState,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据计划ID获取灌溉次序-->
  <!--根据计划ID获取灌溉次序_模式2-->
  <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,
        <if test="startupMode == 1">
            null AS startTime,
            duration,
        </if>
        <if test="startupMode == 2">
          start_time AS startTime,
          TIMESTAMPDIFF(MINUTE, start_time, stop_time) AS duration,
        </if>
        intake_ids AS intakeIds
    FROM ir_irrigate_schedule
    WHERE plan_id = #{planId}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
@@ -62,9 +62,14 @@
        IrIrrigatePlan plan = new IrIrrigatePlan();
        plan.setProjectId(planAndSchedule.getProjectId());
        plan.setPlanName(planAndSchedule.getPlanName());
        plan.setStartupMode(planAndSchedule.getStartupMode());
        plan.setPlanStartTime(planAndSchedule.getPlanStartTime());
        plan.setPlanStopTime(planAndSchedule.getPlanStopTime());
        Byte startupMode = planAndSchedule.getStartupMode();
        plan.setStartupMode(startupMode);
        if(startupMode == 1){
            plan.setDuration(planAndSchedule.getDuration());
        }else if(startupMode == 2){
            plan.setPlanStartTime(planAndSchedule.getPlanStartTime());
            plan.setPlanStopTime(planAndSchedule.getPlanStopTime());
        }
        plan.setPlanState((byte)1);
        plan.setExecutingState((byte)1);
        plan.setDeleted(0L);
@@ -79,29 +84,26 @@
            for(IrrigateSchedule schedule : planAndSchedule.getSchedules()){
                IrIrrigateSchedule po = new IrIrrigateSchedule();
                po.setPlanId(planId);
                if(planAndSchedule.getIrrigateType() == 1) {
                    po.setGroupId(schedule.getIrrigateId());
                    List<Long> intakesData = irrigatePlanSv.getIntakesByGroupId(schedule.getIrrigateId());
                    if(intakesData != null && intakesData.size() > 0){
                        String intakeIds = "";
                        for(Long intakeId : intakesData){
                            intakeIds += intakeId + ",";
                        }
                        po.setIntakeIds(intakeIds.substring(0, intakeIds.length() - 1));
                    }
                }else {
                    po.setUnitId(schedule.getIrrigateId());
                    Long intakeId = irrigatePlanSv.getIntakeIdByUnitId(schedule.getIrrigateId());
                    if(intakeId != null){
                        po.setIntakeIds(intakeId.toString());
                    }
                po.setGroupId(schedule.getGroupId());
                if(startupMode == 1){
                    po.setDuration(schedule.getDuration());
                }else if(startupMode == 2){
                    po.setStartTime(schedule.getStartTime());
                    po.setStopTime(schedule.getStopTime());
                }
                po.setStartTime(schedule.getStartTime());
                po.setStopTime(schedule.getStopTime());
                po.setCurrentState((byte)1);
                List<Long> intakesData = irrigatePlanSv.getIntakesByGroupId(schedule.getGroupId());
                if(intakesData != null && intakesData.size() > 0){
                    String intakeIds = "";
                    for(Long intakeId : intakesData){
                        intakeIds += intakeId + ",";
                    }
                    po.setIntakeIds(intakeIds.substring(0, intakeIds.length() - 1));
                }
                Long scheduleId = irrigatePlanSv.addIrrigateSchedule(po);
                if(scheduleId == null) {
                    return BaseResponseUtils.buildErrorMsg("创建灌溉计划失败");
                }
            }
        }
@@ -136,6 +138,10 @@
        Long planId = planSimple.getPlanId();
        Long operatorId = planSimple.getOperatorId();
        if(irrigatePlanSv.getPublishedCount(planId) > 0){
            return BaseResponseUtils.buildErrorMsg("该灌溉计划已发布");
        }
        // 修改灌溉计划状态为发布状态
        if(irrigatePlanSv.publishIrrigatePlan(planId) == 0){
            return BaseResponseUtils.buildErrorMsg("修改灌溉计划状态失败");
@@ -151,11 +157,17 @@
            return BaseResponseUtils.buildErrorMsg("添加灌溉计划操作记录失败");
        }
        // 生成开阀计划
        List<VoIrrigateSchedule> schedules = irrigatePlanSv.getIrrigateSchedules(planId);
        /**
         * 生成开阀计划
         *     货期计划启动模式
         */
        // 获取灌溉计划启动模式
        Byte startupMode = irrigatePlanSv.getStartupMode(planId);
        List<VoIrrigateSchedule> schedules = irrigatePlanSv.getIrrigateSchedules(startupMode, planId);
        if(schedules == null || schedules.size() == 0) {
            return BaseResponseUtils.buildErrorMsg("无取水口,生成开阀计划失败");
        }
        for (VoIrrigateSchedule schedule : schedules) {
            for(String intakeId : schedule.getIntakeIds().split(",")){
                // 添加灌溉计划开启记录
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
@@ -56,6 +56,15 @@
    }
    /**
     * 根据指定的计划ID获取启动模式
     * @param planId
     * @return
     */
    public Byte getStartupMode(Long planId) {
        return irrigatePlanMapper.getStartupMode(planId);
    }
    /**
     * 根据指定的条件获取计划列表
     * @param queryVo
     * @return
@@ -72,6 +81,15 @@
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = irrigatePlanMapper.getIrrigatePlans(params);
        return rsVo;
    }
    /**
     * 根据指定的计划ID获取已发布的灌溉计划数量
     * @param planId
     * @return
     */
    public Integer getPublishedCount(Long planId) {
        return irrigatePlanMapper.getPublishedCount(planId);
    }
    /**
@@ -108,8 +126,8 @@
     * @param planId
     * @return
     */
    public List<VoIrrigateSchedule> getIrrigateSchedules(Long planId) {
        return irIrrigateScheduleMapper.getIrrigateSchedules(planId);
    public List<VoIrrigateSchedule> getIrrigateSchedules(Byte startupMode, Long planId) {
        return irIrrigateScheduleMapper.getIrrigateSchedules(startupMode, planId);
    }
    /**
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/dto/IrrigatePlan.java
@@ -47,10 +47,15 @@
    private Date planStopTime;
    /**
     * 灌溉类型;1-轮灌组,2-灌溉单元
     * 计划持续时间
     */
    @NotNull(message = "灌溉类型不能为空")
    private Byte irrigateType;
    private Integer duration;
    /**
     * 操作人ID
     */
    @NotNull(message = "操作人ID不能为空")
    private Long operatorId;
    /**
     * 灌溉次序
@@ -58,9 +63,4 @@
    @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/IrrigateSchedule.java
@@ -15,10 +15,24 @@
public class IrrigateSchedule {
    public static final long serialVersionUID = 202502201519001L;
    private Long irrigateId;
    /**
     * 轮灌组ID
     */
    private Long groupId;
    /**
     * 该轮灌组开始灌溉时间
     */
    private Date startTime;
    /**
     * 该轮灌组结束灌溉时间
     */
    private Date stopTime;
    /**
     * 该轮灌组灌溉时长
     */
    private Integer duration;
}