Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | rmCommandHistory.setResult((byte) 0); |
| | | rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); |
| | | |
| | | if(openType == 1 ) { |
| | | if(openType != null && openType == 1 ) { |
| | | irIntakeOperateMapper.updateByCommandId(comId, (byte)2, "开阀失败"); |
| | | } |
| | | |
| | |
| | | rmCommandHistory.setResult((byte) 1); |
| | | rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); |
| | | |
| | | if(openType == 1) { |
| | | if(openType != null && openType == 1) { |
| | | irIntakeOperateMapper.updateByCommandId(comId, (byte)1, null); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | List<Long> getIntakeIdsByGroupId(Long groupId); |
| | | |
| | | /** |
| | | * 根据组ID删除取水口关联 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | Integer deleteByGroupId(Long groupId); |
| | | } |
| | |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2025-03-25 20:41 |
| | | * @LastEditTime 2025-03-25 20:41 |
| | | * @date 2025-04-02 10:54 |
| | | * @LastEditTime 2025-04-02 10:54 |
| | | * @Description |
| | | */ |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupDetail; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupOne; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | * @return |
| | | */ |
| | | List<VoGroupSimple> getSimpleGroups(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据轮灌组ID获取轮灌组详情 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | VoGroupDetail getGroupDetail(Long groupId); |
| | | } |
| | |
| | | */ |
| | | Integer updateScheduleStartTime(@Param("scheduleId") Long scheduleId, @Param("startTime") Date startTime); |
| | | |
| | | /** |
| | | * 根据计划ID终止灌溉次序,将灌溉次序的当前状态改为已终止 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | Integer terminateSchedule(Long planId); |
| | | |
| | | } |
| | |
| | | private Long id; |
| | | |
| | | /** |
| | | * 计划ID |
| | | */ |
| | | private Long planId; |
| | | |
| | | /** |
| | | * 操作类型;1-发布(计划开阀),2-终止(远程关阀) |
| | | */ |
| | | private Byte operateType; |
| | | |
| | | /** |
| | | * 命令ID |
| | | */ |
| | | @NotNull(message = "命令ID不能为空") |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voIr; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2025-03-31 17:10 |
| | | * @LastEditTime 2025-03-31 17:10 |
| | | * @Description 轮灌组详情视图对象 |
| | | */ |
| | | |
| | | @Data |
| | | @JsonPropertyOrder({"groupCode", "defaultDuration", "intakes"}) |
| | | public class VoGroupDetail { |
| | | public static final long serialVersionUID = 202503311711001L; |
| | | |
| | | /** |
| | | * 轮灌组编码 |
| | | */ |
| | | private String groupCode; |
| | | |
| | | /** |
| | | * 默认灌溉时长 |
| | | */ |
| | | private Integer defaultDuration; |
| | | |
| | | /** |
| | | * 取水口列表 |
| | | */ |
| | | private String intakes; |
| | | } |
| | |
| | | private Long groupId; |
| | | |
| | | /** |
| | | * 轮灌组编码 |
| | | * 轮灌组名称 |
| | | */ |
| | | private String groupCode; |
| | | |
| | | /** |
| | | * 灌溉单元数量 |
| | | * 取水口数量 |
| | | */ |
| | | private Integer intakeCount; |
| | | |
| | |
| | | FROM ir_group_intake |
| | | WHERE group_id = #{groupId} |
| | | </select> |
| | | |
| | | <!--根据组ID删除取水口关联--> |
| | | <delete id="deleteByGroupId"> |
| | | DELETE FROM ir_group_intake WHERE group_id = #{groupId} |
| | | </delete> |
| | | </mapper> |
| | |
| | | <!--@mbg.generated--> |
| | | <!--@Table ir_intake_operate--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="plan_id" jdbcType="BIGINT" property="planId" /> |
| | | <result column="operate_type" jdbcType="TINYINT" property="operateType" /> |
| | | <result column="command_id" jdbcType="BIGINT" property="commandId" /> |
| | | <result column="intake_id" jdbcType="BIGINT" property="intakeId" /> |
| | | <result column="start_time" jdbcType="TIMESTAMP" property="startTime" /> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, command_id, intake_id, start_time, duration, command_result, failure_factors |
| | | id, plan_id, operate_type, command_id, intake_id, start_time, duration, command_result, |
| | | failure_factors |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate"> |
| | | <!--@mbg.generated--> |
| | | insert into ir_intake_operate (id, command_id, intake_id, |
| | | start_time, duration, command_result, |
| | | failure_factors) |
| | | values (#{id,jdbcType=BIGINT}, #{commandId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, |
| | | #{startTime,jdbcType=TIMESTAMP}, #{duration,jdbcType=INTEGER}, #{commandResult,jdbcType=TINYINT}, |
| | | #{failureFactors,jdbcType=VARCHAR}) |
| | | insert into ir_intake_operate (id, plan_id, operate_type, |
| | | command_id, intake_id, start_time, |
| | | duration, command_result, failure_factors |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, #{operateType,jdbcType=TINYINT}, |
| | | #{commandId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP}, |
| | | #{duration,jdbcType=INTEGER}, #{commandResult,jdbcType=TINYINT}, #{failureFactors,jdbcType=VARCHAR} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate"> |
| | | <!--@mbg.generated--> |
| | |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="planId != null"> |
| | | plan_id, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | operate_type, |
| | | </if> |
| | | <if test="commandId != null"> |
| | | command_id, |
| | |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="planId != null"> |
| | | #{planId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | #{operateType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="commandId != null"> |
| | | #{commandId,jdbcType=BIGINT}, |
| | |
| | | <!--@mbg.generated--> |
| | | update ir_intake_operate |
| | | <set> |
| | | <if test="planId != null"> |
| | | plan_id = #{planId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="operateType != null"> |
| | | operate_type = #{operateType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="commandId != null"> |
| | | command_id = #{commandId,jdbcType=BIGINT}, |
| | | </if> |
| | |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate"> |
| | | <!--@mbg.generated--> |
| | | update ir_intake_operate |
| | | set command_id = #{commandId,jdbcType=BIGINT}, |
| | | set plan_id = #{planId,jdbcType=BIGINT}, |
| | | operate_type = #{operateType,jdbcType=TINYINT}, |
| | | command_id = #{commandId,jdbcType=BIGINT}, |
| | | intake_id = #{intakeId,jdbcType=BIGINT}, |
| | | start_time = #{startTime,jdbcType=TIMESTAMP}, |
| | | duration = #{duration,jdbcType=INTEGER}, |
| | |
| | | <!--根据指定条件获取轮灌组记录数--> |
| | | <select id="getSimpleGroupCount" resultType="java.lang.Long"> |
| | | SELECT COUNT(*) AS recordCount |
| | | <!-- FROM ir_irrigate_group grp--> |
| | | <!-- INNER JOIN ir_project_group pg ON pg.group_id = grp.id--> |
| | | <!-- INNER JOIN ir_project pro ON pg.project_id = pro.id--> |
| | | <!-- <where>--> |
| | | <!-- AND grp.deleted = 0--> |
| | | |
| | | <!-- <if test="projectId != null and projectId != ''">--> |
| | | <!-- AND pro.id = #{projectId}--> |
| | | <!-- </if>--> |
| | | |
| | | <!-- <if test="groupCode != null and groupCode != ''">--> |
| | | <!-- AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- </where>--> |
| | | FROM ir_irrigate_group grp |
| | | INNER JOIN ir_project_group pg ON pg.group_id = grp.id |
| | | INNER JOIN ir_project pro ON pg.project_id = pro.id |
| | | <where> |
| | | AND grp.deleted = 0 |
| | | |
| | | <if test="projectId != null and projectId != ''"> |
| | | AND pro.id = #{projectId} |
| | | </if> |
| | | |
| | | <if test="groupCode != null and groupCode != ''"> |
| | | AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%') |
| | | </if> |
| | |
| | | |
| | | <!--根据指定条件获取轮灌组列表--> |
| | | <select id="getSimpleGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple"> |
| | | <!-- SELECT--> |
| | | <!-- grp.id AS groupId,--> |
| | | <!-- grp.group_code AS groupCode,--> |
| | | <!-- (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount,--> |
| | | <!-- grp.default_duration AS defaultDuration,--> |
| | | <!-- pg.sort--> |
| | | <!-- FROM ir_irrigate_group grp--> |
| | | <!-- INNER JOIN ir_project_group pg ON pg.group_id = grp.id--> |
| | | <!-- INNER JOIN ir_project pro ON pg.project_id = pro.id--> |
| | | <!-- <where>--> |
| | | <!-- AND grp.deleted = 0--> |
| | | |
| | | <!-- <if test="projectId != null and projectId != ''">--> |
| | | <!-- AND pro.id = #{projectId}--> |
| | | <!-- </if>--> |
| | | |
| | | <!-- <if test="groupCode != null and groupCode != ''">--> |
| | | <!-- AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- </where>--> |
| | | <!-- ORDER BY pg.sort--> |
| | | SELECT |
| | | grp.id AS groupId, |
| | | grp.group_code AS groupCode, |
| | | (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount, |
| | | grp.default_duration AS defaultDuration, |
| | | pg.sort |
| | | 0 as sort |
| | | FROM ir_irrigate_group grp |
| | | INNER JOIN ir_project_group pg ON pg.group_id = grp.id |
| | | INNER JOIN ir_project pro ON pg.project_id = pro.id |
| | | <where> |
| | | AND grp.deleted = 0 |
| | | |
| | | <if test="projectId != null and projectId != ''"> |
| | | AND pro.id = #{projectId} |
| | | </if> |
| | | |
| | | <if test="groupCode != null and groupCode != ''"> |
| | | AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%') |
| | | </if> |
| | | </where> |
| | | ORDER BY pg.sort |
| | | ORDER BY grp.operate_time DESC |
| | | <trim prefix="limit "> |
| | | <if test="start != null and count != null"> |
| | | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | <select id="getGroupDetail" resultType="com.dy.pipIrrGlobal.voIr.VoGroupDetail"> |
| | | SELECT |
| | | groupCode, |
| | | defaultDuration, |
| | | GROUP_CONCAT(intakeId) AS intakes |
| | | FROM |
| | | ( |
| | | SELECT |
| | | grp.group_code AS groupCode, |
| | | grp.default_duration AS defaultDuration, |
| | | inta.id AS intakeId |
| | | FROM ir_irrigate_group grp |
| | | INNER JOIN ir_group_intake gi ON gi.group_id = grp.id |
| | | INNER JOIN pr_intake inta ON inta.id = gi.intake_id |
| | | WHERE grp.deleted = 0 AND grp.id = #{groupId} |
| | | ) irrigateGroup |
| | | GROUP BY groupCode,defaultDuration |
| | | </select> |
| | | </mapper> |
| | |
| | | WHERE id = #{scheduleId} |
| | | </update> |
| | | |
| | | <!--根据计划ID终止灌溉次序,将灌溉次序的当前状态改为已终止--> |
| | | <update id="terminateSchedule"> |
| | | UPDATE ir_irrigate_schedule sch |
| | | INNER JOIN ir_plan_schedule ps ON ps.schedule_id = sch.id |
| | | INNER JOIN ir_irrigate_plan plan ON ps.plan_id = plan.id |
| | | SET sch.current_state = 2 |
| | | WHERE plan.id = #{planId} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | FROM ir_project pro |
| | | INNER JOIN ir_project_group pg ON pg.project_id = pro.id |
| | | INNER JOIN ir_irrigate_group grp ON grp.id = pg.group_id |
| | | WHERE pro.id = #{projectId} |
| | | WHERE pro.deleted = 0 AND pro.id = #{projectId} |
| | | ) project |
| | | GROUP BY projectName |
| | | </select> |
| | |
| | | import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupDetail; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupOne; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import com.dy.pipIrrGlobal.voSe.VoActiveCard; |
| | | import com.dy.pipIrrIrrigate.irrigateGroup.dto.GroupClient; |
| | | import com.dy.pipIrrIrrigate.irrigateGroup.dto.IrrigateGroup; |
| | | import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup; |
| | | import com.dy.pipIrrIrrigate.result.IrrigateResultCode; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.media.Content; |
| | |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | /** |
| | | * 新增轮灌组,新代码 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "addIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> addIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = irrigateGroupSv.addIrrigateGroup(po); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 删除轮灌组,新代码 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "deleteIrrigateGroup") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> deleteIrrigateGroup(@RequestParam(required = false) Long groupId) { |
| | | if(groupId == null) { |
| | | return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空"); |
| | | } |
| | | |
| | | Map map_result = irrigateGroupSv.deleteGroup(groupId); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 修改轮灌组,新代码 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "updateIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> updateIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult){ |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | if(po.getGroupId() == null) { |
| | | return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空"); |
| | | } |
| | | |
| | | Map map_result = irrigateGroupSv.updateIrrigateGroup(po); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 获取轮灌组列表,新代码 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getSimpleGroups") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoGroupSimple>>> getSimpleGroups(QoGroup qo) { |
| | | try { |
| | | QueryResultVo<List<VoGroupSimple>> res = irrigateGroupSv.getSimpleGroups(qo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取项目记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取全部轮灌组,新代码 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getAllGroups") |
| | | @SsoAop() |
| | | public BaseResponse<List<VoGroupSimple>> getAllGroups() { |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(irrigateGroupSv.getAllGroups()); |
| | | } catch (Exception e) { |
| | | log.error("获取项目记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取轮灌组详情,新代码 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "getGroupDetail") |
| | | @SsoAop() |
| | | public BaseResponse<VoGroupDetail> getGroupDetail(@RequestParam Long groupId) { |
| | | if(groupId == null) { |
| | | return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空"); |
| | | } |
| | | |
| | | Map map_result = irrigateGroupSv.getGroupDetail(groupId); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoIr.IrGroupClientMapper; |
| | | import com.dy.pipIrrGlobal.daoIr.IrGroupIntakeMapper; |
| | | import com.dy.pipIrrGlobal.daoIr.IrGroupUnitMapper; |
| | | import com.dy.pipIrrGlobal.daoIr.IrIrrigateGroupMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrGroupClient; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrGroupIntake; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroup; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupDetail; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupOne; |
| | | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; |
| | | import com.dy.pipIrrIrrigate.irrigateGroup.dto.IrrigateGroup; |
| | | import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | public class IrrigateGroupSv { |
| | | @Autowired |
| | | private IrIrrigateGroupMapper irIrrigateGroupMapper; |
| | | |
| | | @Autowired |
| | | private IrGroupUnitMapper irGroupUnitMapper; |
| | | |
| | | @Autowired |
| | | private IrGroupClientMapper irGroupClientMapper; |
| | | |
| | | @Autowired |
| | | private IrGroupIntakeMapper irGroupIntakeMapper; |
| | | |
| | | /** |
| | | * 创建轮灌组 |
| | |
| | | public Integer deleteGroupClient (Long id) { |
| | | return irGroupClientMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | /** |
| | | * 创建轮灌组 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Map addIrrigateGroup(IrrigateGroup po) { |
| | | IrIrrigateGroup irrigateGroup = new IrIrrigateGroup(); |
| | | irrigateGroup.setGroupCode(po.getGroupCode()); |
| | | irrigateGroup.setDefaultDuration(po.getDefaultDuration()); |
| | | irrigateGroup.setOperator(po.getOperator()); |
| | | irrigateGroup.setOperateTime(new Date()); |
| | | irrigateGroup.setDeleted((byte) 0); |
| | | irIrrigateGroupMapper.insertSelective(irrigateGroup); |
| | | Long groupId = irrigateGroup.getId(); |
| | | if(groupId == null) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "创建轮灌组失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | String[] intakeArr = po.getIntakes().split(","); |
| | | Integer sort = 1; |
| | | for(String intekeId : intakeArr) { |
| | | String trimmed = intekeId.trim(); |
| | | if(trimmed.isEmpty()) { |
| | | continue; |
| | | } |
| | | try { |
| | | Long intakeIdLong = Long.parseLong(trimmed); |
| | | IrGroupIntake irGroupIntake = new IrGroupIntake(); |
| | | irGroupIntake.setGroupId(groupId); |
| | | irGroupIntake.setIntakeId(intakeIdLong); |
| | | irGroupIntakeMapper.insert(irGroupIntake); |
| | | } catch (NumberFormatException e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "取水口ID格式错误"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "添加轮灌组成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 根据组ID删除取水口关联 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | public Map deleteGroup(Long groupId) { |
| | | try { |
| | | irGroupIntakeMapper.deleteByGroupId(groupId); |
| | | irIrrigateGroupMapper.deleteByPrimaryKey(groupId); |
| | | |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "灌溉项目删除成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } catch (Exception e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "轮灌组删除失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改轮灌组 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Map updateIrrigateGroup(IrrigateGroup po) { |
| | | Long groupId = po.getGroupId(); |
| | | Map map_deleteGroup = deleteGroup(groupId); |
| | | if(map_deleteGroup.get("success").equals(false)) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", map_deleteGroup.get("msg").toString()); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | Map map_addGroup = addIrrigateGroup(po); |
| | | if(map_addGroup.get("success").equals(false)) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", map_addGroup.get("msg").toString()); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "修改轮灌组成功"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 查询轮灌组列表 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoGroupSimple>> getSimpleGroups(QoGroup queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params); |
| | | |
| | | QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 查询全部轮灌组 |
| | | * @return |
| | | */ |
| | | public List<VoGroupSimple> getAllGroups() { |
| | | //Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | //Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params); |
| | | |
| | | //QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>(); |
| | | //rsVo.pageSize = queryVo.pageSize; |
| | | //rsVo.pageCurr = queryVo.pageCurr; |
| | | //rsVo.calculateAndSet(itemTotal, params); |
| | | //rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(null); |
| | | //return rsVo; |
| | | |
| | | return irIrrigateGroupMapper.getSimpleGroups(null); |
| | | } |
| | | |
| | | /** |
| | | * 获取轮灌组详情 |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | | public Map getGroupDetail(Long groupId) { |
| | | try { |
| | | VoGroupDetail voGroupDetail = irIrrigateGroupMapper.getGroupDetail(groupId); |
| | | Map map = new HashMap<>(); |
| | | map.put("success", true); |
| | | map.put("msg", "获取轮灌组详情成功"); |
| | | map.put("content", voGroupDetail); |
| | | return map; |
| | | } catch (Exception e) { |
| | | Map map = new HashMap<>(); |
| | | map.put("success", false); |
| | | map.put("msg", "获取轮灌组详情失败"); |
| | | map.put("content", null); |
| | | return map; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrIrrigate.irrigateGroup.dto; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2025-03-28 20:26 |
| | | * @LastEditTime 2025-03-28 20:26 |
| | | * @Description 轮灌组实体类,添加及修改轮灌组使用 |
| | | */ |
| | | |
| | | @Data |
| | | public class IrrigateGroup { |
| | | public static final long serialVersionUID = 202503282027001L; |
| | | |
| | | /** |
| | | * 轮灌组ID,修改轮灌组信息需要传入 |
| | | */ |
| | | private Long groupId; |
| | | |
| | | /** |
| | | * 轮灌组名 |
| | | */ |
| | | @NotBlank(message = "轮灌组名不能为空") |
| | | private String groupCode; |
| | | |
| | | /** |
| | | * 轮灌组默认时长 |
| | | */ |
| | | @NotNull(message = "轮灌组默认时长不能为空") |
| | | private Integer defaultDuration; |
| | | |
| | | /** |
| | | * 轮灌组关联的 intakeId,以逗号分隔 |
| | | */ |
| | | @NotBlank(message = "轮灌组关联的 intakeId 不能为空") |
| | | private String intakes; |
| | | |
| | | /** |
| | | * 操作员ID |
| | | */ |
| | | @NotNull(message = "操作员ID不能为空") |
| | | private Long operator; |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrIrrigate.irrigateGroup.qo; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2025-03-31 16:02 |
| | | * @LastEditTime 2025-03-31 16:02 |
| | | * @Description 轮灌组查询对象 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class QoGroup extends QueryConditionVo { |
| | | /** |
| | | * 轮灌组编码 |
| | | */ |
| | | private String groupCode; |
| | | } |
| | |
| | | public Map addIrrigateProject(IrrigateProject po) { |
| | | String projectName = po.getProjectName(); |
| | | String irrigateGroups = po.getIrrigateGroups(); |
| | | Long operatorId = po.getOperatorId(); |
| | | Long operatorId = po.getOperator(); |
| | | |
| | | IrProject irProject = new IrProject(); |
| | | irProject.setProjectName(projectName); |
| | |
| | | * @author ZhuBaoMin |
| | | * @date 2025-03-27 15:09 |
| | | * @LastEditTime 2025-03-27 15:09 |
| | | * @Description 灌溉项目实体类,添加项目使用 |
| | | * @Description 灌溉项目实体类,添加及修改项目使用 |
| | | */ |
| | | |
| | | @Data |
| | |
| | | * 操作员ID |
| | | */ |
| | | @NotNull(message = "操作员ID不能为空") |
| | | private Long operatorId; |
| | | private Long operator; |
| | | } |
| | |
| | | * @param automaticClose |
| | | * @return |
| | | */ |
| | | public Map planedOpenTimedClose(AutomaticClose automaticClose, Date startTime, Integer duration) { |
| | | public Map planedOpenTimedClose(AutomaticClose automaticClose, Long planId, Date startTime, Integer duration) { |
| | | Long intakeId = automaticClose.getIntakeId(); |
| | | Long vcId = automaticClose.getVcId(); |
| | | Date plannedOpenTime = automaticClose.getPlannedOpenTime(); |
| | |
| | | Byte openType = automaticClose.getOpenType(); |
| | | Long comId = new IDLongGenerator().generate(); |
| | | |
| | | if(openType == 1) { |
| | | if(openType != null && openType == 1) { |
| | | IrIntakeOperate irIntakeOperate = new IrIntakeOperate(); |
| | | irIntakeOperate.setPlanId(planId); |
| | | irIntakeOperate.setOperateType((byte)1); |
| | | irIntakeOperate.setCommandId(comId); |
| | | irIntakeOperate.setIntakeId(intakeId); |
| | | irIntakeOperate.setStartTime(startTime); |
| | |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = commandSv.planedOpenTimedClose(automaticClose, null,null); |
| | | Map map_result = commandSv.planedOpenTimedClose(automaticClose, null, null,null); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | |
| | | automaticClose.setOperator(operatorId); |
| | | automaticClose.setOpenType(Byte.valueOf("1")); |
| | | |
| | | commandSv.planedOpenTimedClose(automaticClose, schedule.getStartTime(), schedule.getDuration()); |
| | | commandSv.planedOpenTimedClose(automaticClose, planId, schedule.getStartTime(), schedule.getDuration()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取灌溉计划列表 |
| | | * @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("终止计划状态失败"); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | //} |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改灌溉计划 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer updatePlan(IrIrrigatePlan po) { |
| | | return irrigatePlanMapper.updateByPrimaryKeySelective(po); |
| | | } |
| | | |
| | | /** |
| | | * 获取未完成的计划列表,小程序计划列表页使用 |
| | | * @return |
| | | */ |