pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateSchedulingMapper.java
New file @@ -0,0 +1,48 @@ package com.dy.pipIrrGlobal.daoIr; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling; import com.dy.pipIrrGlobal.voIr.VoScheduling; import com.dy.pipIrrGlobal.voIr.VoSchedulingOne; import org.apache.ibatis.annotations.Mapper; import java.util.List; import java.util.Map; /** * @author :WuZeYu * @Date :2024/5/27 10:46 * @LastEditTime :2024/5/27 10:46 * @Description */ @Mapper public interface IrIrrigateSchedulingMapper extends BaseMapper<IrIrrigateScheduling> { //增 int insertSelective(IrIrrigateScheduling record); //删 int deleteLogicById(Long id); //改 int updateByPrimaryKeySelective(IrIrrigateScheduling record); //查一个 VoSchedulingOne selectById(Long id); /** * 根据指定条件获取作物灌溉制度数 * * @param params * @return */ Long getRecordCount(Map<?, ?> params); /** * 根据指定条件获取作物灌溉制度记录 * * @param params * @return */ List<VoScheduling> getSchedulings(Map<?, ?> params); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigateScheduling.java
@@ -1,10 +1,98 @@ 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 io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.*; import org.hibernate.validator.constraints.Length; import java.util.Date; /** * @author :WuZeYu * @Date :2024/5/25 9:41 * @LastEditTime :2024/5/25 9:41 * @Description */ public class IrIrrigateScheduling { /** * 灌溉制度表 */ @TableName(value="ir_irrigate_scheduling", autoResultMap = true) @Data @Builder @ToString @NoArgsConstructor @AllArgsConstructor @Schema(name = "项目实体") public class IrIrrigateScheduling implements BaseEntity { public static final long serialVersionUID = 202405270901001L; /** * 主键 */ @JSONField(serializeUsing= ObjectWriterImplToString.class) @TableId(type = IdType.INPUT) @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long id; /** * 作物id */ @Schema(description = "作物id", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "作物id不能为空") private Long cropId; /** * 作物生长期 */ @Schema(description = "作物生长期", requiredMode = Schema.RequiredMode.REQUIRED) @Length(message = "作物生长期不大于{max}字",max = 10) private String growthPeriod; /** * 灌水周期 */ @Schema(description = "灌水周期", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "灌水周期不能为空") private Integer irrigateCycle; /** * 灌水延续时间 */ @Schema(description = "灌水延续时间", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "灌水延续时间不能为空") private Integer duration; /** * 备注 */ @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED) private String remarks; /** * 操作人ID */ @Schema(description = "操作人ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotNull(message = "操作人ID不能为空") private Long operator; /** * 操作时间 */ @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Date operateDt; /** * 逻辑删除标识;0-未删除,1-删除 */ @Schema(description = "删除标识", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Byte deleted; } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoScheduling.java
New file @@ -0,0 +1,31 @@ package com.dy.pipIrrGlobal.voIr; import com.dy.common.po.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** * @author :WuZeYu * @Date :2024/5/27 10:34 * @LastEditTime :2024/5/27 10:34 * @Description */ @Data @Schema(name = "作物灌溉制度视图") public class VoScheduling implements BaseEntity { @Schema(description = "灌溉制度实体id") private String id; @Schema(description = "作物名称") private String cropName; @Schema(description = "作物生长期") private String growthPeriod; @Schema(description = "作物生长期") private int irrigateCycle; @Schema(description = "作物生长期") private int duration; } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoSchedulingOne.java
New file @@ -0,0 +1,48 @@ package com.dy.pipIrrGlobal.voIr; import com.dy.common.po.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.util.Date; /** * @author :WuZeYu * @Date :2024/5/27 13:59 * @LastEditTime :2024/5/27 13:59 * @Description */ @Data @Schema(name = "作物灌溉制度视图") public class VoSchedulingOne implements BaseEntity { @Schema(description = "灌溉制度实体id") private String id; @Schema(description = "作物id") private String cropId; @Schema(description = "作物名称") private String cropName; @Schema(description = "作物生长期") private String growthPeriod; @Schema(description = "作物生长期") private int irrigateCycle; @Schema(description = "作物生长期") private int duration; @Schema(description = "备注") private String remarks; @Schema(description = "操作人ID") private String operator; @Schema(description = "操作人名字") private String operatorName; @Schema(description = "操作时间") private Date operateDt; } pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateSchedulingMapper.xml
New file @@ -0,0 +1,172 @@ <?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.IrIrrigateSchedulingMapper"> <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling"> <!--@mbg.generated--> <!--@Table ir_irrigate_scheduling--> <id column="id" jdbcType="BIGINT" property="id" /> <result column="crop_id" jdbcType="BIGINT" property="cropId" /> <result column="growth_period" jdbcType="VARCHAR" property="growthPeriod" /> <result column="irrigate_cycle" jdbcType="INTEGER" property="irrigateCycle" /> <result column="duration" jdbcType="INTEGER" property="duration" /> <result column="remarks" jdbcType="VARCHAR" property="remarks" /> <result column="operator" jdbcType="BIGINT" property="operator" /> <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" /> <result column="deleted" jdbcType="TINYINT" property="deleted" /> </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> id, crop_id,growth_period,irrigate_cycle,duration, remarks,operator,operate_time, deleted </sql> <!--添加--> <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling"> insert into ir_irrigate_scheduling <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="cropId != null"> crop_id, </if> <if test="growthPeriod != null"> growth_period, </if> <if test="irrigateCycle != null"> irrigate_cycle, </if> <if test="duration != null"> duration, </if> <if test="operator != null"> operator, </if> <if test="operateDt != null"> operate_time, </if> <if test="remarks != null"> remarks, </if> <if test="deleted != null"> deleted, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=BIGINT}, </if> <if test="cropId != null"> #{cropId,jdbcType=BIGINT}, </if> <if test="growthPeriod != null"> #{growthPeriod,jdbcType=VARCHAR}, </if> <if test="irrigateCycle != null"> #{irrigateCycle,jdbcType=INTEGER}, </if> <if test="duration != null"> #{duration,jdbcType=INTEGER}, </if> <if test="operator != null"> #{operator,jdbcType=BIGINT}, </if> <if test="operateDt != null"> #{operateDt,jdbcType=TIMESTAMP}, </if> <if test="remarks != null"> #{remarks,jdbcType=VARCHAR}, </if> <if test="deleted != null"> #{deleted,jdbcType=TINYINT}, </if> </trim> </insert> <!--逻辑删除--> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update ir_irrigate_scheduling set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> <!--修改信息--> <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling"> update ir_irrigate_scheduling <set> <if test="cropId != null"> crop_id = #{cropId,jdbcType=BIGINT}, </if> <if test="growthPeriod != null"> growth_period = #{growthPeriod,jdbcType=VARCHAR}, </if> <if test="irrigateCycle != null"> irrigate_cycle = #{irrigateCycle,jdbcType=INTEGER}, </if> <if test="duration != null"> duration = #{duration,jdbcType=INTEGER}, </if> <if test="operator != null"> operator = #{operator,jdbcType=BIGINT}, </if> <if test="operateDt != null"> operate_time = #{operateDt,jdbcType=TIMESTAMP}, </if> <if test="remarks != null"> remarks = #{remarks,jdbcType=VARCHAR}, </if> <if test="deleted != null"> deleted = #{deleted,jdbcType=TINYINT}, </if> </set> where id = #{id,jdbcType=BIGINT} </update> <select id="getRecordCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount from ir_irrigate_scheduling sch left join ir_crop cro on cro.id = sch.crop_id <where> sch.deleted = 0 <if test="cropName != null and cropName != ''"> AND cro.crop_name LIKE CONCAT('%', #{cropName}, '%') </if> </where> </select> <select id="getSchedulings" resultType="com.dy.pipIrrGlobal.voIr.VoScheduling"> SELECT CAST(sch.id AS char)AS id, cro.crop_name AS cropName, sch.growth_period AS growthPeriod, sch.irrigate_cycle AS irrigateCycle, sch.duration AS duration from ir_irrigate_scheduling sch left join ir_crop cro on cro.id = sch.crop_id <where> sch.deleted = 0 <if test="cropName != null and cropName != ''"> AND cro.crop_name LIKE CONCAT('%', #{cropName}, '%') </if> </where> <if test="pageCurr != null and pageSize != null"> LIMIT ${(pageCurr-1)*pageSize}, ${pageSize} </if> </select> <select id="selectById" resultType="com.dy.pipIrrGlobal.voIr.VoSchedulingOne"> select CAST(sch.id AS char)AS id, CAST(cro.id AS char)AS cropId, cro.crop_name AS cropName, sch.growth_period AS growthPeriod, sch.irrigate_cycle AS irrigateCycle, sch.duration AS duration, sch.remarks AS remarks, CAST(sch.operator AS char)AS operator, cli.name AS operatorName, sch.operate_time AS operateDt from ir_irrigate_scheduling sch left join ir_crop cro on cro.id = sch.crop_id left join se_client cli on cli.id = sch.operator where sch.id = #{id,jdbcType=BIGINT} and sch.deleted = 0 </select> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrIrrigateSchedulingSv.java
New file @@ -0,0 +1,97 @@ package com.dy.pipIrrIrrigate.irrigateScheduling; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoIr.IrIrrigateSchedulingMapper; import com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling; import com.dy.pipIrrGlobal.voIr.VoScheduling; import com.dy.pipIrrGlobal.voIr.VoSchedulingOne; 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.List; import java.util.Map; /** * @author :WuZeYu * @Date :2024/5/27 10:12 * @LastEditTime :2024/5/27 10:12 * @Description */ @Slf4j @Service public class IrIrrigateSchedulingSv { @Autowired private IrIrrigateSchedulingMapper irIrrigateSchedulingMapper; /** * 添加作物灌溉制度 * * @param po * @return */ public Integer addScheduling(IrIrrigateScheduling po) { po.setDeleted((byte) 0); po.setOperateDt(new Date()); int rows = irIrrigateSchedulingMapper.insertSelective(po); if (rows == 0) { return 0; } return 1; } /** * 删除作物灌溉制度 * * @param id */ public Integer deleteScheduling(Long id) { int rows = irIrrigateSchedulingMapper.deleteLogicById(id); if (rows == 0) { return 0; } return 1; } /** * 修改作物灌溉制度 * @param po * @return */ public Integer updateScheduling(IrIrrigateScheduling po){ int rows = irIrrigateSchedulingMapper.updateByPrimaryKeySelective(po); if (rows == 0){ return 0; } return 1; } /** * 分页查询作物灌溉制度 * @param queryVo * @return */ public QueryResultVo<List<VoScheduling>> getSchedulings(QueryVo queryVo){ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); Long itemTotal = irIrrigateSchedulingMapper.getRecordCount(params); QueryResultVo<List<VoScheduling>> rsVo = new QueryResultVo<>(); rsVo.pageSize = queryVo.pageSize; rsVo.pageCurr = queryVo.pageCurr; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = irIrrigateSchedulingMapper.getSchedulings(params); return rsVo; } /** * 获取一个作物灌溉制度数据 * @param id * @return */ public VoSchedulingOne selectById(Long id){ VoSchedulingOne irCrop = irIrrigateSchedulingMapper.selectById(id); return irCrop; } } pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrrigateSchedulingCtrl.java
New file @@ -0,0 +1,198 @@ package com.dy.pipIrrIrrigate.irrigateScheduling; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling; import com.dy.pipIrrGlobal.pojoIr.IrProject; import com.dy.pipIrrGlobal.voIr.VoScheduling; import com.dy.pipIrrGlobal.voIr.VoSchedulingOne; import com.dy.pipIrrGlobal.voSe.VoActiveCard; import com.dy.pipIrrIrrigate.result.IrrigateResultCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; /** * @author :WuZeYu * @Date :2024/5/27 10:12 * @LastEditTime :2024/5/27 10:12 * @Description */ @Slf4j @Tag(name = "作物灌溉制度管理", description = "作物灌溉制度操作") @RestController @RequestMapping(path = "scheduling") @RequiredArgsConstructor public class IrrigateSchedulingCtrl { private final IrIrrigateSchedulingSv irIrrigateSchedulingSv; /** * 添加作物灌溉制度 * * @param po 作物灌溉制度实体对象 * @param bindingResult * @return 添加是否成功 */ @Operation(summary = "添加作物灌溉制度记录", description = "添加作物灌溉制度记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add(@RequestBody @Valid IrIrrigateScheduling po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { Integer rec = Optional.ofNullable(irIrrigateSchedulingSv.addScheduling(po)).orElse(0); if (rec == 0) { return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); } } catch (Exception e) { log.error("添加作物灌溉制度异常", e); return BaseResponseUtils.buildException(e.getMessage()); } return BaseResponseUtils.buildSuccess(true); } /** * 逻辑删除作物灌溉制度 * @param map * @return */ @Operation(summary = "逻辑删除作物灌溉制度", description = "逻辑删除作物灌溉制度") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> delete(@RequestBody Map map) { if (map == null || map.size() <= 0) { BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage()); } Long schedulingId = Long.parseLong(map.get("id").toString()); try { Integer rows = irIrrigateSchedulingSv.deleteScheduling(schedulingId); if (rows == 0) { return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage()); } } catch (Exception e) { log.error("删除作物灌溉制度异常", e); return BaseResponseUtils.buildException(e.getMessage()); } return BaseResponseUtils.buildSuccess(true); } /** * 修改作物灌溉制度 * @param po * @param bindingResult * @return */ @Operation(summary = "修改作物灌溉制度", description = "修改作物灌溉制度") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateScheduling po, BindingResult bindingResult){ if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { Integer rec = Optional.ofNullable(irIrrigateSchedulingSv.updateScheduling(po)).orElse(0); if (rec == 0) { return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage()); } } catch (Exception e) { log.error("修改作物灌溉制度异常", e); return BaseResponseUtils.buildException(e.getMessage()); } return BaseResponseUtils.buildSuccess(true); } /** * 分页查询 * @param vo * @return */ @Operation(summary = "获得一页作物灌溉制度记录", description = "获得一页作物灌溉制度记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "获得一页作物记录(BaseResponse.content:QueryResultVo[{}])", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = VoActiveCard.class))} ) }) @GetMapping(path = "some") @SsoAop() public BaseResponse<QueryResultVo<List<VoScheduling>>> getSchedulings(QueryVo vo) { try { QueryResultVo<List<VoScheduling>> res = irIrrigateSchedulingSv.getSchedulings(vo); return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("获取作物灌溉制度记录异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } /** * 获取一个作物灌溉制度数据 * * @return 获取一个作物灌溉制度数据 */ @Operation(summary = "获取一个作物灌溉制度数据", description = "获取一个作物灌溉制度数据") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "获取一个作物灌溉制度数据(BaseResponse.content:{})", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = IrProject.class))} ) }) @GetMapping(path = "one") @SsoAop() public BaseResponse<VoSchedulingOne> one(@RequestParam Long id) { VoSchedulingOne irScheduling = this.irIrrigateSchedulingSv.selectById(id); return BaseResponseUtils.buildSuccess(irScheduling); } } pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/QueryVo.java
New file @@ -0,0 +1,24 @@ package com.dy.pipIrrIrrigate.irrigateScheduling; import com.dy.common.webUtil.QueryConditionVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; /** * @author :WuZeYu * @Date :2024/5/27 10:29 * @LastEditTime :2024/5/27 10:29 * @Description */ @Data @EqualsAndHashCode(callSuper = false) @ToString(callSuper = true) @NoArgsConstructor @AllArgsConstructor @Builder @Schema(name = "作物灌溉制度查询条件") public class QueryVo extends QueryConditionVo { @Schema(description = "作物名称") public String cropName; }