From d9ced0cba82dfb6931ca65540eed2f55058342db Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期二, 02 一月 2024 20:23:08 +0800 Subject: [PATCH] 取水口的 添加 修改 逻辑删除 查询一个 查询全部 分页查询 --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java | 263 ++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java | 125 +++++ pipIrr-platform/.idea/misc.xml | 11 pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml | 197 ++++++++ pipIrr-platform/.idea/vcs.xml | 6 pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml | 197 ++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java | 134 +++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java | 61 ++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java | 29 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java | 80 +++ pipIrr-platform/.idea/.gitignore | 8 pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml | 294 ++++++++++++ 12 files changed, 1,405 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/.idea/.gitignore b/pipIrr-platform/.idea/.gitignore new file mode 100644 index 0000000..2dc1dfd --- /dev/null +++ b/pipIrr-platform/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../:\javaWorkspaces\pipIrr\pipIrr-platform\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/pipIrr-platform/.idea/misc.xml b/pipIrr-platform/.idea/misc.xml new file mode 100644 index 0000000..d94cfc2 --- /dev/null +++ b/pipIrr-platform/.idea/misc.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + </component> + <component name="ProjectRootManager" version="2" project-jdk-name="20" project-jdk-type="JavaSDK" /> +</project> \ No newline at end of file diff --git a/pipIrr-platform/.idea/vcs.xml b/pipIrr-platform/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/pipIrr-platform/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java new file mode 100644 index 0000000..c12a4d2 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java @@ -0,0 +1,80 @@ +package com.dy.pipIrrGlobal.daoPr; + + +import com.dy.pipIrrGlobal.pojoPr.PrIntake; +import com.dy.pipIrrGlobal.voPr.VoIntake; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * @author wuzeyu + * @date 2023/12/26 13:56 + * @LastEditTime 2023/12/26 13:56 + * @Description + */ +@Mapper +public interface PrIntakeMapper { + + /** + * select by primary key + * @param id primary key + * @return object by primary key + */ + PrIntake selectByPrimaryKey(Long id); + + /** + * 寰楀埌鍏ㄩ儴瀹炰綋 + * @return 鍏ㄩ儴瀹炰綋 + * */ + List<PrIntake> selectAll(); + + /** + * 閫昏緫鍒犻櫎 + * @param id primaryKey + * @return deleteCount + */ + int deleteLogicById(Long id); + + /** + * 瀹為檯鍒犻櫎 + * @param id primaryKey + * @return deleteCount + */ + int deleteByPrimaryKey(Long id); + + int insert(PrIntake record); + + int insertSelective(PrIntake record); + + /** + * update record + * @param record the updated record + * @return update count + */ + int updateByPrimaryKey(PrIntake record); + + /** + * update record selective + * @param record the updated record + * @return update count + */ + int updateByPrimaryKeySelective(PrIntake record); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰曟暟 + * @param params + * @return + */ + Long getRecordCount(Map<?, ?> params); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰� + * @param params + * @return + */ + List<VoIntake> getIntakes(Map<?, ?> params); + + Long getSupperByVillageId(long vaId); +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java new file mode 100644 index 0000000..92a4428 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java @@ -0,0 +1,125 @@ +package com.dy.pipIrrGlobal.pojoPr; + +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; + +/** + * 鍙栨按鍙h〃 + */ + +@TableName(value = "pr_intake", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "鍙栨按鍙e疄浣�") +public class PrIntake implements BaseEntity { + public static final long serialVersionUID = 202312260931001L; + /** + * 涓婚敭 + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @TableId(type = IdType.INPUT) + @Schema(description = "瀹炰綋id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Long id; + + /** + * 鎵�鍦ㄥ幙 + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄥ幙ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄥ幙涓嶈兘涓虹┖") + private Long countyId; + + /** + * 鎵�鍦ㄩ晣 + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄩ晣ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄩ晣涓嶈兘涓虹┖") + private Long townId; + + /** + * 鎵�鍦ㄦ潙 + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄦ潙ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄦ潙涓嶈兘涓虹┖") + private Long villageId; + + /** + * 鎵�鍦ㄥ垎姘村彛 + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄥ垎姘村彛ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "鎵�鍦ㄥ垎姘村彛涓嶈兘涓虹┖") + private Long divideId; + + /** + * 鎵�鍦ㄧ墖鍖� + */ + @JSONField(serializeUsing = ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄧ墖鍖篒D", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "鎵�鍦ㄧ墖鍖轰笉鑳戒负绌�") + private Long blockId; + + /** + * 鍙栨按鍙e悕绉� + */ + @Schema(description = "鍙栨按鍙e悕绉�", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "鍙栨按鍙e悕绉颁笉鑳戒负绌�") + @Length(message = "鍙栨按鍙e悕绉颁笉澶т簬{max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 1, max = 25) + private String name; + + /** + * 缁忓害 + */ + @Schema(description = "缁忓害", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "缁忓害涓嶈兘涓虹┖") + private Double lng; + + /** + * 绾害 + */ + @Schema(description = "缁忓害", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "缁忓害涓嶈兘涓虹┖") + private Double lat; + + /** + * 澶囨敞淇℃伅 + */ + @Schema(description = "澶囨敞", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Length(message = "澶囨敞涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 1, max = 200) + private String remarks; + + /** + * 鎿嶄綔浜虹紪鍙� + */ + @Schema(description = "鎿嶄綔浜虹紪鍙�", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "鎿嶄綔浜虹紪鍙蜂笉鑳戒负绌�") + 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; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java new file mode 100644 index 0000000..89a2e92 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java @@ -0,0 +1,61 @@ +package com.dy.pipIrrGlobal.voPr; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.dy.common.po.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @author WuZeYu + * @date 2023/12/26 10:40 + * @LastEditTime 2023/12/26 10:40 + * @Description + */ + +@Data +@Schema(title = "鍙栨按鍙h鍥惧璞�") +public class VoIntake implements BaseEntity { + private static final long serialVersionUID = 202312261049001L; + + @Schema(title = "ID") + @ExcelProperty("ID") + @ColumnWidth(10) + private Long id; + + @Schema(title = "鍙栨按鍙e悕绉�") + @ExcelProperty("鍙栨按鍙e悕绉�") + @ColumnWidth(15) + private String intakeName; + + @Schema(title = "鎵�灞炲垎姘存埧") + @ExcelProperty("鎵�灞炲垎姘存埧") + @ColumnWidth(15) + private String divideName; + + @Schema(title = "鎵�灞炵墖鍖�") + @ExcelProperty("鎵�灞炵墖鍖�") + @ColumnWidth(15) + private String blockName; + + @Schema(title = "缁戝畾璁惧") + @ExcelProperty("缁戝畾璁惧") + @ColumnWidth(6) + private String isBind; + + @Schema(title = "鍦板潃") + @ExcelProperty("鍦板潃") + @ColumnWidth(25) + private String address; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @Schema(title = "鎿嶄綔鏃堕棿") + @ExcelIgnore + private Date operateDt; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml new file mode 100644 index 0000000..485f1b5 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml @@ -0,0 +1,294 @@ +<?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.daoPr.PrIntakeMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + <!--@Table pr_intake--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="countyId" jdbcType="BIGINT" property="countyId" /> + <result column="townId" jdbcType="BIGINT" property="townId" /> + <result column="villageId" jdbcType="BIGINT" property="villageId" /> + <result column="divideId" jdbcType="BIGINT" property="divideId" /> + <result column="blockId" jdbcType="BIGINT" property="blockId" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="lng" jdbcType="DOUBLE" property="lng" /> + <result column="lat" jdbcType="DOUBLE" property="lat" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operateDt" jdbcType="TIMESTAMP" property="operateDt" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, countyId, townId, villageId, divideId, blockId, `name`, lng, lat, remarks, `operator`, + operateDt, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from pr_intake + where id = #{id,jdbcType=BIGINT} and deleted = 0 + </select> + + <delete id="deleteLogicById" parameterType="java.lang.Long"> + <!--@mbg.generated--> + update pr_intake + set deleted = 1 + where id = #{id,jdbcType=BIGINT} + </delete> + + <select id="selectAll" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List"/> + from pr_intake + where deleted != 1 + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from pr_intake + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake (id, countyId, townId, + villageId, divideId, blockId, + `name`, lng, lat, remarks, + `operator`, operateDt, deleted + ) + values (#{id,jdbcType=BIGINT}, #{countyId,jdbcType=BIGINT}, #{townId,jdbcType=BIGINT}, + #{villageId,jdbcType=BIGINT}, #{divideId,jdbcType=BIGINT}, #{blockId,jdbcType=BIGINT}, + #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{operateDt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="countyId != null"> + countyId, + </if> + <if test="townId != null"> + townId, + </if> + <if test="villageId != null"> + villageId, + </if> + <if test="divideId != null"> + divideId, + </if> + <if test="blockId != null"> + blockId, + </if> + <if test="name != null"> + `name`, + </if> + <if test="lng != null"> + lng, + </if> + <if test="lat != null"> + lat, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operateDt != null"> + operateDt, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="countyId != null"> + #{countyId,jdbcType=BIGINT}, + </if> + <if test="townId != null"> + #{townId,jdbcType=BIGINT}, + </if> + <if test="villageId != null"> + #{villageId,jdbcType=BIGINT}, + </if> + <if test="divideId != null"> + #{divideId,jdbcType=BIGINT}, + </if> + <if test="blockId != null"> + #{blockId,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operateDt != null"> + #{operateDt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + <set> + <if test="countyId != null"> + countyId = #{countyId,jdbcType=BIGINT}, + </if> + <if test="townId != null"> + townId = #{townId,jdbcType=BIGINT}, + </if> + <if test="villageId != null"> + villageId = #{villageId,jdbcType=BIGINT}, + </if> + <if test="divideId != null"> + divideId = #{divideId,jdbcType=BIGINT}, + </if> + <if test="blockId != null"> + blockId = #{blockId,jdbcType=BIGINT}, + </if> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + lng = #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + lat = #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operateDt != null"> + operateDt = #{operateDt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + set countyId = #{countyId,jdbcType=BIGINT}, + townId = #{townId,jdbcType=BIGINT}, + villageId = #{villageId,jdbcType=BIGINT}, + divideId = #{divideId,jdbcType=BIGINT}, + blockId = #{blockId,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + lng = #{lng,jdbcType=DOUBLE}, + lat = #{lat,jdbcType=DOUBLE}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operateDt = #{operateDt,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰曟暟--> + <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM pr_intake ge + INNER JOIN ba_divide divi ON ge.divideId = divi.id + INNER JOIN ba_block blo ON divi.blockId = blo.id + INNER JOIN ba_district country ON ge.countyId = country.id + INNER JOIN ba_district town ON ge.townId = town.id + INNER JOIN ba_district village ON ge.villageId = village.id + , (SELECT @i:=0) AS itable + <where> + ge.deleted = 0 + AND divi.deleted = 0 + and blo.deleted = 0 + <if test="intakeName != null and intakeName != ''"> + AND ge.name LIKE CONCAT('%', #{intakeName}, '%') + </if> + + <if test="divideName != null and divideName != ''"> + AND divi.name LIKE CONCAT('%', #{divideName}, '%') + </if> + + <if test="blockName != null and blockName != ''"> + AND blo.name = #{blockName} + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰�--> + <select id="getIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoIntake"> + SELECT (@i:=@i+1) AS id, + ge.`name` AS intakeName, + divi.`name` AS divideName, + blo.`name` AS blockName, + ge.operateDt As operateDt, + CONCAT(country.`name`, town.`name`, village.`name`) AS address + FROM pr_intake ge + INNER JOIN pr_divide divi ON ge.divideId = divi.id + INNER JOIN ba_block blo ON divi.blockId = blo.id + INNER JOIN ba_district country ON ge.countyId = country.id + INNER JOIN ba_district town ON ge.townId = town.id + INNER JOIN ba_district village ON ge.villageId = village.id + , (SELECT @i:=0) AS itable + <where> + ge.deleted = 0 + AND divi.deleted = 0 + and blo.deleted = 0 + <if test="intakeName != null and intakeName != ''"> + AND ge.name LIKE CONCAT('%', #{intakeName}, '%') + </if> + <if test="divideName != null and divideName != ''"> + AND divi.name LIKE CONCAT('%', #{divideName}, '%') + </if> + + <if test="blockName != null and blockName != ''"> + AND blo.name = #{blockName} + </if> + </where> + ORDER BY ge.operateDt DESC + <if test="pageCurr != null and pageSize != null"> + LIMIT ${pageCurr}, ${pageSize} + </if> + </select> + + <select id="getSupperByvillageId" parameterType="_long" resultType="java.lang.Long"> + select dis_tow.* + from ba_district dis_vil + inner join + ba_district dis_tow + on dis_vil.supperId = dis_tow.id + where dis_vil.id = #{vaId,jdbcType=BIGINT} + </select> + + <select id="getSupperByVillageId" parameterType="_long" resultType="java.lang.Long"> + select dis_tow.* + from ba_district dis_vil + inner join + ba_district dis_tow + on dis_vil.supperId = dis_tow.id + where dis_vil.id = #{vaId,jdbcType=BIGINT} + </select> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml new file mode 100644 index 0000000..d624641 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml @@ -0,0 +1,197 @@ +<?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.daoPr.PrIntakeMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + <!--@Table pr_intake--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="countyId" jdbcType="BIGINT" property="countyid" /> + <result column="townId" jdbcType="BIGINT" property="townid" /> + <result column="villageId" jdbcType="BIGINT" property="villageid" /> + <result column="divideId" jdbcType="BIGINT" property="divideid" /> + <result column="blockId" jdbcType="BIGINT" property="blockid" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="lng" jdbcType="DOUBLE" property="lng" /> + <result column="lat" jdbcType="DOUBLE" property="lat" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, countyId, townId, villageId, divideId, blockId, `name`, lng, lat, remarks, `operator`, + operateDt, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from pr_intake + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from pr_intake + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake (id, countyId, townId, + villageId, divideId, blockId, + `name`, lng, lat, remarks, + `operator`, operateDt, deleted + ) + values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, + #{villageid,jdbcType=BIGINT}, #{divideid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, + #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="countyid != null"> + countyId, + </if> + <if test="townid != null"> + townId, + </if> + <if test="villageid != null"> + villageId, + </if> + <if test="divideid != null"> + divideId, + </if> + <if test="blockid != null"> + blockId, + </if> + <if test="name != null"> + `name`, + </if> + <if test="lng != null"> + lng, + </if> + <if test="lat != null"> + lat, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operatedt != null"> + operateDt, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="countyid != null"> + #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + #{villageid,jdbcType=BIGINT}, + </if> + <if test="divideid != null"> + #{divideid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + <set> + <if test="countyid != null"> + countyId = #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + townId = #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + villageId = #{villageid,jdbcType=BIGINT}, + </if> + <if test="divideid != null"> + divideId = #{divideid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + blockId = #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + lng = #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + lat = #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + set countyId = #{countyid,jdbcType=BIGINT}, + townId = #{townid,jdbcType=BIGINT}, + villageId = #{villageid,jdbcType=BIGINT}, + divideId = #{divideid,jdbcType=BIGINT}, + blockId = #{blockid,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + lng = #{lng,jdbcType=DOUBLE}, + lat = #{lat,jdbcType=DOUBLE}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml new file mode 100644 index 0000000..d624641 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml @@ -0,0 +1,197 @@ +<?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.daoPr.PrIntakeMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + <!--@Table pr_intake--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="countyId" jdbcType="BIGINT" property="countyid" /> + <result column="townId" jdbcType="BIGINT" property="townid" /> + <result column="villageId" jdbcType="BIGINT" property="villageid" /> + <result column="divideId" jdbcType="BIGINT" property="divideid" /> + <result column="blockId" jdbcType="BIGINT" property="blockid" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="lng" jdbcType="DOUBLE" property="lng" /> + <result column="lat" jdbcType="DOUBLE" property="lat" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, countyId, townId, villageId, divideId, blockId, `name`, lng, lat, remarks, `operator`, + operateDt, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from pr_intake + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from pr_intake + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake (id, countyId, townId, + villageId, divideId, blockId, + `name`, lng, lat, remarks, + `operator`, operateDt, deleted + ) + values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, + #{villageid,jdbcType=BIGINT}, #{divideid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, + #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} + ) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + insert into pr_intake + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="countyid != null"> + countyId, + </if> + <if test="townid != null"> + townId, + </if> + <if test="villageid != null"> + villageId, + </if> + <if test="divideid != null"> + divideId, + </if> + <if test="blockid != null"> + blockId, + </if> + <if test="name != null"> + `name`, + </if> + <if test="lng != null"> + lng, + </if> + <if test="lat != null"> + lat, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operatedt != null"> + operateDt, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="countyid != null"> + #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + #{villageid,jdbcType=BIGINT}, + </if> + <if test="divideid != null"> + #{divideid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + <set> + <if test="countyid != null"> + countyId = #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + townId = #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + villageId = #{villageid,jdbcType=BIGINT}, + </if> + <if test="divideid != null"> + divideId = #{divideid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + blockId = #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + lng = #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + lat = #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrIntake"> + <!--@mbg.generated--> + update pr_intake + set countyId = #{countyid,jdbcType=BIGINT}, + townId = #{townid,jdbcType=BIGINT}, + villageId = #{villageid,jdbcType=BIGINT}, + divideId = #{divideid,jdbcType=BIGINT}, + blockId = #{blockid,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + lng = #{lng,jdbcType=DOUBLE}, + lat = #{lat,jdbcType=DOUBLE}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java new file mode 100644 index 0000000..cdb44cb --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java @@ -0,0 +1,263 @@ +package com.dy.pipIrrProject.intake; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.support.ExcelTypeEnum; +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.pojoPr.PrIntake; +import com.dy.pipIrrGlobal.voPr.VoIntake; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +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.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +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 org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * @author WuZeYu + * @date 2023/12/26 20:11 + * @LastEditTime 2023/12/20 20:11 + * @Description + */ + +@Slf4j +@Tag(name = "鍙栨按鍙g鐞�", description = "鍙栨按鍙f搷浣�") +@RestController +@RequestMapping(path="intake") +@RequiredArgsConstructor +public class IntakeCtrl { + private final IntakeSv intakeSv; + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夊垎姘村彛鍚嶅瓧 + * @return 鎵�鏈夊垎姘村彛鍚嶅瓧 + */ + @Operation(summary = "鑾峰緱鍏ㄩ儴鍙栨按鍙�", description = "杩斿洖鍏ㄩ儴鍙栨按鍙f暟鎹�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖鍏ㄩ儴鍙栨按鍙f暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrIntake.class))} + ) + }) + @GetMapping(path = "all") + @SsoAop() + public BaseResponse<QueryResultVo<List<PrIntake>>> all(){ + try { + QueryResultVo<List<PrIntake>> res = this.intakeSv.selectAll(); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鍙栨按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 寰楀埌涓�涓彇姘村彛鏁版嵁 + * @return 涓�涓彇姘村彛鏁版嵁 + */ + @Operation(summary = "涓�涓彇姘村彛", description = "寰楀埌涓�涓彇姘村彛鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�涓彇姘村彛鏁版嵁锛圔aseResponse.content:{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = PrIntake.class))} + ) + }) + @GetMapping(path = "one/{id}") + @SsoAop() + public BaseResponse<PrIntake> one(@PathVariable("id") Long id){ + return BaseResponseUtils.buildSuccess(this.intakeSv.selectById(id)); + } + + @Operation(summary = "鑾峰緱涓�椤靛彇姘村彛璁板綍", description = "杩斿洖涓�椤靛彇姘村彛鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤靛彇姘村彛鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoActiveCard.class))} + ) + }) + @GetMapping(path = "getIntakes", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<VoIntake>>> getIntakes(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){ + try { + QueryResultVo<List<VoIntake>> res = intakeSv.getIntakes(vo); + if(res == null) { + return BaseResponseUtils.buildFail("鏌ヨ澶辫触"); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鍙栨按鍙h褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + @Operation(summary = "娣诲姞鍙栨按鍙h褰�", description = "娣诲姞鍙栨按鍙h褰�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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 @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult){ + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Date operateTime = new Date(); + po.setOperateDt(operateTime); + Integer rec = Optional.ofNullable(intakeSv.addIntake(po)).orElse(0); + if(rec == 0) { + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�"); + } + return BaseResponseUtils.buildSuccess(true) ; + } + + /** + * 缂栬緫淇敼鍙栨按鍙� + * @param po 淇濆瓨鍙栨按鍙orm琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "缂栬緫淇敼鍙栨按鍙�", description = "鎻愪氦鍙栨按鍙f暟鎹紙form琛ㄥ崟锛夛紝杩涜淇敼") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + int count; + Date operateTime = new Date(); + po.setOperateDt(operateTime); + try { + count = this.intakeSv.update(po); + } catch (Exception e) { + log.error("淇濆瓨鍒嗘按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + /** + * 鍒犻櫎鍙栨按鍙� + * @param id 鍙栨按鍙D + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "鍒犻櫎鍒嗘按鍙�", description = "鎻愪氦鍙栨按鍙D锛岃繘琛岄�昏緫鍒犻櫎") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @GetMapping(path = "delete/{id}") + @SsoAop() + public BaseResponse<Boolean> delete(@PathVariable("id") Long id){ + if(id == null){ + return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + } + int count; + try { + count = this.intakeSv.delete(id); + } catch (Exception e) { + log.error("淇濆瓨鍒嗘按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + /** + * 瀵煎嚭鍙栨按鍙e垪琛� + * @param response + * @param vo + */ + @SneakyThrows(IOException.class) + @GetMapping(value = "exportIntakes") + public void exportIntakes(HttpServletResponse response, QueryVo vo) { + setExcelRespProp(response, "鍙栨按鍙e垪琛�"); + //List<VoDivide> memberList = LocalJsonUtil.getListFromJson("json/members.json", VoDivide.class); + List<VoIntake> memberList = intakeSv.exportIntakes(vo); + + EasyExcel.write(response.getOutputStream()) + .head(VoIntake.class) + .excelType(ExcelTypeEnum.XLSX) + .sheet("鍙栨按鍙e垪琛�") + .doWrite(memberList); + } + + /** + * 瀵煎叆鍙栨按鍙e垪琛� + * @param file + */ + @SneakyThrows + @PostMapping(value = "importIntakes") + @ResponseBody + public BaseResponse<Boolean> importIntakes(@RequestPart("file") MultipartFile file) { + List<VoIntake> memberList = EasyExcel.read(file.getInputStream()) + .head(VoIntake.class) + .sheet() + .doReadSync(); + return BaseResponseUtils.buildSuccess(memberList) ; + } + + /** + * 璁剧疆excel涓嬭浇鍝嶅簲澶村睘鎬� + */ + private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java new file mode 100644 index 0000000..ac5cfe1 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java @@ -0,0 +1,134 @@ +package com.dy.pipIrrProject.intake; + +import com.dy.common.webUtil.QueryResultVo; +import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper; +import com.dy.pipIrrGlobal.pojoPr.PrIntake; +import com.dy.pipIrrGlobal.voPr.VoIntake; +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 org.springframework.transaction.annotation.Transactional; + + +import java.util.List; +import java.util.Map; + +/** + * @author wuzeyu + * @date 2023/12/26 11:12 + * @LastEditTime 2023/12/26 11:12 + * @Description 鍙栨按鍙f湇鍔$被 + */ + +@Slf4j +@Service +public class IntakeSv { + @Autowired + private PrIntakeMapper prIntakeMapper; + + /** + * 娣诲姞鍙栨按鍙� + * + * @param po + * @return + */ + @Transactional + Integer addIntake(PrIntake po) { + if (po.getTownId()==null||po.getTownId()==0) + { + Long townId=getSupperByVillageId(po.getVillageId()); + po.setTownId(townId); + } + if (po.getCountyId()==null||po.getCountyId()==0) + { + Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId())); + po.setCountyId(countyId); + } + return prIntakeMapper.insertSelective(po); + } + public Long getSupperByVillageId(long vaId){ + return prIntakeMapper.getSupperByVillageId(vaId); + } + + + /** + * 淇濆瓨淇敼瀹炰綋 + * @param po 瀹炰綋 + * @return 鏁伴噺 + */ + + public int update(PrIntake po){ + if (po.getTownId()==null||po.getTownId()==0) + { + Long townId=getSupperByVillageId(po.getVillageId()); + po.setTownId(townId); + } + if (po.getCountyId()==null||po.getCountyId()==0) + { + Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId())); + po.setCountyId(countyId); + } + return this.prIntakeMapper.updateByPrimaryKeySelective(po) ; +// return this.prIntakeMapper.updateByPrimaryKey(po); + } + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰� + * + * @param queryVo 鏌ヨ瑙嗗浘 + * @return 鍒嗘按鎴胯褰曞垪琛� + */ + public QueryResultVo<List<VoIntake>> getIntakes(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + Long itemTotal = prIntakeMapper.getRecordCount(params); + + QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>(); + rsVo.pageSize = queryVo.pageSize; + rsVo.pageCurr = queryVo.pageCurr; + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = prIntakeMapper.getIntakes(params); + return rsVo; + } + + /** + * 鏍规嵁鎸囧畾鏉′欢瀵煎嚭鍙栨按鍙e垪琛� + * + * @param queryVo + * @return + */ + public List<VoIntake> exportIntakes(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + List<VoIntake> rsVo = prIntakeMapper.getIntakes(params); + return rsVo; + } + + /** + * 寰楀埌鎵�鏈夊彇姘村彛 + * @return 鎵�鏈夊彇姘村彛闆嗗悎 + */ + public QueryResultVo<List<PrIntake>> selectAll() { + QueryResultVo<List<PrIntake>> rsVo = new QueryResultVo<>() ; + rsVo.obj = this.prIntakeMapper.selectAll() ; + return rsVo ; + } + + /** + * 寰楀埌涓�涓彇姘村彛 + * @param id 鍙栨按鍙D + * @return 鍙栨按鍙e疄浣� + */ + public PrIntake selectById(Long id) { + return this.prIntakeMapper.selectByPrimaryKey(id) ; + } + + /** + * 閫昏緫鍒犻櫎瀹炰綋 + * @param id 瀹炰綋ID + * @return 鏁伴噺 + */ + @Transactional + public int delete(Long id){ + return this.prIntakeMapper.deleteLogicById(id) ; + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java new file mode 100644 index 0000000..4535b06 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java @@ -0,0 +1,29 @@ +package com.dy.pipIrrProject.intake; + +import com.dy.common.webUtil.QueryConditionVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Data +@EqualsAndHashCode(callSuper = false) +@ToString(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Schema(name = "鍙栨按鍙f煡璇㈡潯浠�") +public class QueryVo extends QueryConditionVo { + @Schema(description = "鍙栨按鍙e悕绉�") + public String intakeName; + + @Schema(description = "鎵�灞炲垎姘存埧") + public String divideName; + + @Schema(description = "鎵�灞炵墖鍖�") + public String blockName; + + @Schema(description = "鏄惁缁戝畾璁惧") + public String isBind; + + @Schema(description = "鍦板潃") + public String address; +} -- Gitblit v1.8.0