wuzeyu
2024-01-02 d9ced0cba82dfb6931ca65540eed2f55058342db
取水口的 添加 修改 逻辑删除 查询一个 查询全部 分页查询
12个文件已添加
1405 ■■■■■ 已修改文件
pipIrr-platform/.idea/.gitignore 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/.idea/misc.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/.idea/vcs.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 294 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml 197 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/.idea/.gitignore
New file
@@ -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/
pipIrr-platform/.idea/misc.xml
New file
@@ -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>
pipIrr-platform/.idea/vcs.xml
New file
@@ -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>
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
New file
@@ -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);
    /**
     * 根据指定条件获取取水口记录数
     * @param params
     * @return
     */
    Long getRecordCount(Map<?, ?> params);
    /**
     * 根据指定条件获取取水口记录
     * @param params
     * @return
     */
    List<VoIntake> getIntakes(Map<?, ?> params);
    Long getSupperByVillageId(long vaId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrIntake.java
New file
@@ -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;
/**
 * 取水口表
 */
@TableName(value = "pr_intake", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "取水口实体")
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 = "所在片区ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "所在片区不能为空")
    private Long blockId;
    /**
     * 取水口名称
     */
    @Schema(description = "取水口名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "取水口名称不能为空")
    @Length(message = "取水口名称不大于{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;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java
New file
@@ -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 = "取水口视图对象")
public class VoIntake implements BaseEntity {
    private static final long serialVersionUID = 202312261049001L;
    @Schema(title = "ID")
    @ExcelProperty("ID")
    @ColumnWidth(10)
    private Long id;
    @Schema(title = "取水口名称")
    @ExcelProperty("取水口名称")
    @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;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
New file
@@ -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>
  <!--根据指定条件获取取水口记录数-->
  <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>
  <!--根据指定条件获取取水口记录-->
  <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>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/xml/PrIntakeMapper.xml
New file
@@ -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>
pipIrr-platform/pipIrr-global/src/main/resources/mapperxml/PrIntakeMapper.xml
New file
@@ -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>
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
New file
@@ -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 = "取水口管理", description = "取水口操作")
@RestController
@RequestMapping(path="intake")
@RequiredArgsConstructor
public class IntakeCtrl {
    private final IntakeSv intakeSv;
    /**
     * 客户端请求得到所有分水口名字
     * @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 = 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);
            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 = 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 = "返回一页取水口数据(BaseResponse.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("获取取水口记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    @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 @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 保存取水口form表单对象
     * @return 是否成功
     */
    @Operation(summary = "编辑修改取水口", description = "提交取水口数据(form表单),进行修改")
    @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)
    @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);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
    /**
     * 删除取水口
     * @param id 取水口ID
     * @return 是否成功
     */
    @Operation(summary = "删除分水口", description = "提交取水口ID,进行逻辑删除")
    @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))}
            )
    })
    @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);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
    /**
     * 导出取水口列表
     * @param response
     * @param vo
     */
    @SneakyThrows(IOException.class)
    @GetMapping(value = "exportIntakes")
    public void exportIntakes(HttpServletResponse response, QueryVo vo) {
        setExcelRespProp(response, "取水口列表");
        //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("取水口列表")
                .doWrite(memberList);
    }
    /**
     * 导入取水口列表
     * @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");
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
New file
@@ -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 取水口服务类
 */
@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;
    }
    /**
     * 根据指定条件导出取水口列表
     *
     * @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 取水口ID
     * @return 取水口实体
     */
    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) ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java
New file
@@ -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 = "取水口查询条件")
public class QueryVo extends QueryConditionVo {
    @Schema(description = "取水口名称")
    public String intakeName;
    @Schema(description = "所属分水房")
    public String divideName;
    @Schema(description = "所属片区")
    public String blockName;
    @Schema(description = "是否绑定设备")
    public String isBind;
    @Schema(description = "地址")
    public String address;
}