| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface BaDistrictMapper extends BaseMapper<BaDistrict> { |
| | |
| | | */ |
| | | int deleteLogicById(Long id); |
| | | |
| | | /** |
| | | * 根据村编号获取5级区划信息 |
| | | * @param villageId 村编号(主键) |
| | | * @return 5级行政区划信息 |
| | | */ |
| | | Map getDistrictsByVillageId(@Param("villageId") Long villageId); |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoSe; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import com.dy.pipIrrGlobal.voSe.VoClient; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/22 9:50 |
| | | * @LastEditTime 2023/12/22 9:50 |
| | | * @Description |
| | | */ |
| | | public interface SeClientMapper { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(SeClient record); |
| | | |
| | | int insertSelective(SeClient record); |
| | | |
| | | SeClient selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(SeClient record); |
| | | |
| | | int updateByPrimaryKey(SeClient record); |
| | | |
| | | /** |
| | | * 根据6位区划串模糊查询农户编号 |
| | | * @param district8 |
| | | * @return |
| | | */ |
| | | String getClientNumOfMax(@Param("district8") String district8); |
| | | |
| | | /** |
| | | * 根据指定条件获取农户记录数 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getRecordCount(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据指定条件获取农户数据 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoClient> getClients(Map<?, ?> params); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.pojoSe; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/21 19:08 |
| | | * @LastEditTime 2023/12/21 19:08 |
| | | * @Description |
| | | */ |
| | | |
| | | 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.*; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 农户表 |
| | | */ |
| | | |
| | | @TableName(value="se_client", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Schema(name = "农户实体") |
| | | public class SeClient implements BaseEntity { |
| | | public static final long serialVersionUID = 202311141539001L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 县ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "所在县ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在县不能为空") |
| | | private Long countyid; |
| | | |
| | | /** |
| | | * 镇ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "所在镇ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在镇不能为空") //不能为空也不能为null |
| | | private Long townid; |
| | | |
| | | /** |
| | | * 村ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "所在村ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在村不能为空") //不能为空也不能为null |
| | | private Long villageid; |
| | | |
| | | /** |
| | | * 片区ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "所在片区ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在片区不能为空") //不能为空也不能为null |
| | | private Long blockid; |
| | | |
| | | /** |
| | | * 分水房ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "所在分水房ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在分水房不能为空") //不能为空也不能为null |
| | | private Long divideid; |
| | | |
| | | /** |
| | | * 农户姓名 |
| | | */ |
| | | @Schema(description = "农户姓名", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "农户姓名不能为空") //不能为空也不能为null |
| | | @Length(message = "农户姓名不大于{max}字,不小于{min}字", min = 1, max = 25) |
| | | private String name; |
| | | |
| | | /** |
| | | * 农户编号;6位区划 + 4为顺序号 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "农户编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | //@NotBlank(message = "农户编号不能为空") |
| | | private String clientnum; |
| | | |
| | | /** |
| | | * 区划编码串;省区划+市区划+县区划+镇区划+村区划 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @Schema(description = "区划编码串", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | //@NotNull(message = "区划编码串不能为空") |
| | | private Long districtnum; |
| | | |
| | | /** |
| | | * 区划名称串;县名+镇名+村名,用于归属地 |
| | | */ |
| | | @Schema(description = "区划名称串", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | //@NotBlank(message = "区划名称串") |
| | | private String districttitle; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @Schema(description = "农户手机号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotEmpty(message = "农户手机号不能为空") //不能为空也不能为null |
| | | @Length(message = "农户手机号必须{max}位数据", min = 11, max = 11) |
| | | private String phone; |
| | | |
| | | /** |
| | | * 身份证号 |
| | | */ |
| | | @Schema(description = "农户身份证号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "农户身份证号不能为空") //不能为空也不能为null |
| | | @Length(message = "农户身份证号必须{max}位数据", min = 18, max = 18) |
| | | private String idcard; |
| | | |
| | | /** |
| | | * 种植面积 |
| | | */ |
| | | @Schema(description = "农户种植面积", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Double area; |
| | | |
| | | /** |
| | | * 街道及门牌号 |
| | | */ |
| | | @Schema(description = "街道+门牌号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Length(message = "地址不大于{max}字,不小于{min}字", min = 1, max = 50) |
| | | private String address; |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | @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) |
| | | @Max(message = "是否禁用只能0或1", value = 1) |
| | | @Min(message = "是否禁用只能0或1",value = 0) |
| | | private Byte disabled; |
| | | |
| | | /** |
| | | * 逻辑删除标识;0-未删除,1-删除 |
| | | */ |
| | | @Schema(description = "删除标识,form表单中不存在,只在查询显示中有效", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Byte deleted; |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voSe; |
| | | |
| | | 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 ZhuBaoMin |
| | | * @date 2023/12/22 11:43 |
| | | * @LastEditTime 2023/12/22 11:43 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @Schema(title = "农户视图对象") |
| | | public class VoClient implements BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(title = "ID") |
| | | private Long id; |
| | | |
| | | @Schema(title = "农户姓名") |
| | | private String name; |
| | | |
| | | @Schema(title = "农户编号") |
| | | private String clientNum; |
| | | |
| | | @Schema(title = "手机号") |
| | | private String phone; |
| | | |
| | | @Schema(title = "身份证号") |
| | | private String idCard; |
| | | |
| | | @Schema(title = "卡片数量") |
| | | private Integer cardCount; |
| | | |
| | | @Schema(title = "地址") |
| | | private String address; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @Schema(title = "注册时间") |
| | | private Date operateDt; |
| | | |
| | | |
| | | } |
| | |
| | | update ba_district set deleted = 1 |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | |
| | | <!--根据村编号获取5级区划信息--> |
| | | <select id="getDistrictsByVillageId" resultType="java.util.Map"> |
| | | SELECT |
| | | pro.id AS provinceId, |
| | | pro.num AS provinceNum, |
| | | pro.name AS provinceName, |
| | | cit.id AS cityId, |
| | | cit.num AS cityNum, |
| | | cit.name AS cityName, |
| | | con.id AS countryId, |
| | | con.num AS countyNum, |
| | | con.name AS countryName, |
| | | tow.id AS townId, |
| | | tow.num AS townNum, |
| | | tow.name AS townName, |
| | | vil.id AS villageId, |
| | | vil.num AS villageNum, |
| | | vil.name AS villageName |
| | | FROM ba_district vil |
| | | INNER JOIN ba_district tow ON vil.supperId = tow.id |
| | | INNER JOIN ba_district con ON tow.supperId = con.id |
| | | INNER JOIN ba_district cit ON con.supperId = cit.id |
| | | INNER JOIN ba_district pro ON cit.supperId = pro.id |
| | | WHERE vil.id = ${villageId} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?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.daoSe.SeClientMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeClient"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table se_client--> |
| | | <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="blockId" jdbcType="BIGINT" property="blockid" /> |
| | | <result column="divideId" jdbcType="BIGINT" property="divideid" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="clientNum" jdbcType="VARCHAR" property="clientnum" /> |
| | | <result column="districtNum" jdbcType="BIGINT" property="districtnum" /> |
| | | <result column="districtTitle" jdbcType="VARCHAR" property="districttitle" /> |
| | | <result column="phone" jdbcType="VARCHAR" property="phone" /> |
| | | <result column="idCard" jdbcType="VARCHAR" property="idcard" /> |
| | | <result column="area" jdbcType="DOUBLE" property="area" /> |
| | | <result column="address" jdbcType="VARCHAR" property="address" /> |
| | | <result column="remarks" jdbcType="VARCHAR" property="remarks" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | | <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> |
| | | <result column="disabled" jdbcType="TINYINT" property="disabled" /> |
| | | <result column="deleted" jdbcType="TINYINT" property="deleted" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, countyId, townId, villageId, blockId, divideId, `name`, clientNum, districtNum, |
| | | districtTitle, phone, idCard, area, address, remarks, `operator`, operateDt, disabled, |
| | | deleted |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from se_client |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from se_client |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClient"> |
| | | <!--@mbg.generated--> |
| | | insert into se_client (id, countyId, townId, |
| | | villageId, blockId, divideId, |
| | | `name`, clientNum, districtNum, |
| | | districtTitle, phone, idCard, |
| | | area, address, remarks, |
| | | `operator`, operateDt, disabled, |
| | | deleted) |
| | | values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, |
| | | #{villageid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, #{divideid,jdbcType=BIGINT}, |
| | | #{name,jdbcType=VARCHAR}, #{clientnum,jdbcType=VARCHAR}, #{districtnum,jdbcType=BIGINT}, |
| | | #{districttitle,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{idcard,jdbcType=VARCHAR}, |
| | | #{area,jdbcType=DOUBLE}, #{address,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, |
| | | #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{disabled,jdbcType=TINYINT}, |
| | | #{deleted,jdbcType=TINYINT}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClient"> |
| | | <!--@mbg.generated--> |
| | | insert into se_client |
| | | <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="blockid != null"> |
| | | blockId, |
| | | </if> |
| | | <if test="divideid != null"> |
| | | divideId, |
| | | </if> |
| | | <if test="name != null"> |
| | | `name`, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | clientNum, |
| | | </if> |
| | | <if test="districtnum != null"> |
| | | districtNum, |
| | | </if> |
| | | <if test="districttitle != null"> |
| | | districtTitle, |
| | | </if> |
| | | <if test="phone != null"> |
| | | phone, |
| | | </if> |
| | | <if test="idcard != null"> |
| | | idCard, |
| | | </if> |
| | | <if test="area != null"> |
| | | area, |
| | | </if> |
| | | <if test="address != null"> |
| | | address, |
| | | </if> |
| | | <if test="remarks != null"> |
| | | remarks, |
| | | </if> |
| | | <if test="operator != null"> |
| | | `operator`, |
| | | </if> |
| | | <if test="operatedt != null"> |
| | | operateDt, |
| | | </if> |
| | | <if test="disabled != null"> |
| | | disabled, |
| | | </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="blockid != null"> |
| | | #{blockid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="divideid != null"> |
| | | #{divideid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="name != null"> |
| | | #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | #{clientnum,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="districtnum != null"> |
| | | #{districtnum,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="districttitle != null"> |
| | | #{districttitle,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="phone != null"> |
| | | #{phone,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="idcard != null"> |
| | | #{idcard,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="area != null"> |
| | | #{area,jdbcType=DOUBLE}, |
| | | </if> |
| | | <if test="address != null"> |
| | | #{address,jdbcType=VARCHAR}, |
| | | </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="disabled != null"> |
| | | #{disabled,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="deleted != null"> |
| | | #{deleted,jdbcType=TINYINT}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClient"> |
| | | <!--@mbg.generated--> |
| | | update se_client |
| | | <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="blockid != null"> |
| | | blockId = #{blockid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="divideid != null"> |
| | | divideId = #{divideid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="name != null"> |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | clientNum = #{clientnum,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="districtnum != null"> |
| | | districtNum = #{districtnum,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="districttitle != null"> |
| | | districtTitle = #{districttitle,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="phone != null"> |
| | | phone = #{phone,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="idcard != null"> |
| | | idCard = #{idcard,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="area != null"> |
| | | area = #{area,jdbcType=DOUBLE}, |
| | | </if> |
| | | <if test="address != null"> |
| | | address = #{address,jdbcType=VARCHAR}, |
| | | </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="disabled != null"> |
| | | disabled = #{disabled,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="deleted != null"> |
| | | deleted = #{deleted,jdbcType=TINYINT}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeClient"> |
| | | <!--@mbg.generated--> |
| | | update se_client |
| | | set countyId = #{countyid,jdbcType=BIGINT}, |
| | | townId = #{townid,jdbcType=BIGINT}, |
| | | villageId = #{villageid,jdbcType=BIGINT}, |
| | | blockId = #{blockid,jdbcType=BIGINT}, |
| | | divideId = #{divideid,jdbcType=BIGINT}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | clientNum = #{clientnum,jdbcType=VARCHAR}, |
| | | districtNum = #{districtnum,jdbcType=BIGINT}, |
| | | districtTitle = #{districttitle,jdbcType=VARCHAR}, |
| | | phone = #{phone,jdbcType=VARCHAR}, |
| | | idCard = #{idcard,jdbcType=VARCHAR}, |
| | | area = #{area,jdbcType=DOUBLE}, |
| | | address = #{address,jdbcType=VARCHAR}, |
| | | remarks = #{remarks,jdbcType=VARCHAR}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | operateDt = #{operatedt,jdbcType=TIMESTAMP}, |
| | | disabled = #{disabled,jdbcType=TINYINT}, |
| | | deleted = #{deleted,jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据6位区划串模糊查询农户编号--> |
| | | <select id="getClientNumOfMax" resultType="java.lang.String"> |
| | | SELECT clientNum |
| | | FROM se_client |
| | | WHERE clientNum LIKE CONCAT('%',#{district8},'%') |
| | | ORDER BY clientNum desc |
| | | LIMIT 0,1 |
| | | </select> |
| | | |
| | | <!--根据指定条件获取农户记录数--> |
| | | <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | FROM se_client cli |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | | AND disabled = 0 |
| | | AND deleted = 0 |
| | | <if test = "name != null and name !=''"> |
| | | AND name like CONCAT('%',#{name},'%') |
| | | </if> |
| | | |
| | | <if test = "num != null and num !=''"> |
| | | AND clientNum like CONCAT('%',#{num},'%') |
| | | </if> |
| | | |
| | | <if test = "phone != null and phone !=''"> |
| | | AND phone like CONCAT('%',#{phone},'%') |
| | | </if> |
| | | </where> |
| | | |
| | | </select> |
| | | |
| | | |
| | | <!--根据指定条件获取农户数据--> |
| | | <select id="getClients" resultType="com.dy.pipIrrGlobal.voSe.VoClient"> |
| | | SELECT |
| | | (@i:=@i+1) AS id, |
| | | name, |
| | | clientNum, |
| | | phone, |
| | | idCard, |
| | | (SELECT COUNT(*) FROM se_client_card WHERE clientNum = cli.clientNum) AS cardCount, |
| | | address, |
| | | operateDt |
| | | FROM se_client cli |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | | AND disabled = 0 |
| | | AND deleted = 0 |
| | | <if test = "name != null and name !=''"> |
| | | AND name like CONCAT('%',#{name},'%') |
| | | </if> |
| | | |
| | | <if test = "clientNum != null and clientNum !=''"> |
| | | AND clientNum like CONCAT('%',#{clientNum},'%') |
| | | </if> |
| | | |
| | | <if test = "phone != null and phone !=''"> |
| | | AND phone like CONCAT('%',#{phone},'%') |
| | | </if> |
| | | |
| | | <if test = "address != null and address !=''"> |
| | | AND address like CONCAT('%',#{address},'%') |
| | | </if> |
| | | </where> |
| | | ORDER BY operateDt DESC |
| | | <if test="pageCurr != null and pageSize != null"> |
| | | LIMIT ${pageCurr}, ${pageSize} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | }) |
| | | @GetMapping("info/{id}/") |
| | | //http://127.0.0.1:8000/demo/demo/info/123234234/?name=张三 |
| | | @SsoAop(power="123456", ifAllPower = {"123", "456"}) |
| | | @SsoAop() |
| | | public BaseResponse<String> info(@PathVariable String id, @RequestParam String name) throws GlException{ |
| | | if(name == null || name.trim().equals("")){ |
| | | return BaseResponseUtils.buildFail(ResultCodeMsg.RsMsg.ERROR_PARAM); |
| | |
| | | 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; |
| | |
| | | }) |
| | | @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop()//@SsoAop(power = "-1") |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid PrDivide po, @Parameter(hidden = true) BindingResult bindingResult){ |
| | | DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出分水房列表 |
| | | * @param response |
| | | * @param vo |
| | | */ |
| | | @SneakyThrows(IOException.class) |
| | | @RequestMapping(value = "/exportDivides", method = RequestMethod.GET) |
| | | public void exportDivides(HttpServletResponse response, QueryVo vo) { |
| | |
| | | .doWrite(memberList); |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @RequestMapping(value = "/importDivides", method = RequestMethod.POST) |
| | | @ResponseBody |
| | | public BaseResponse<Boolean> importDivides(@RequestPart("file") MultipartFile file) { |
| | | List<VoDivide> memberList = EasyExcel.read(file.getInputStream()) |
| | | .head(VoDivide.class) |
| | | .sheet() |
| | | .doReadSync(); |
| | | return BaseResponseUtils.buildSuccess(memberList) ; |
| | | } |
| | | |
| | | /** |
| | | * 设置excel下载响应头属性 |
| | | */ |
New file |
| | |
| | | package com.dy.pipIrrSell.client; |
| | | |
| | | 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.pojoBa.BaClient; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import com.dy.pipIrrGlobal.voSe.VoClient; |
| | | 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.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/21 19:17 |
| | | * @LastEditTime 2023/12/21 19:17 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Tag(name = "农户管理", description = "农户操作") |
| | | @RestController |
| | | @RequestMapping(path="client") |
| | | @RequiredArgsConstructor |
| | | public class ClientCtrl { |
| | | private final ClientSv clientSv; |
| | | |
| | | @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "get") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoClient>>> get(QueryVo vo){ |
| | | try { |
| | | QueryResultVo<List<VoClient>> res = clientSv.getClients(vo); |
| | | 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 DtoClient po, @Parameter(hidden = true) BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | // 接收村编号(主键) |
| | | Long villageId = po.getVillageid(); |
| | | |
| | | /** |
| | | * 获取5级行政区划信息 |
| | | */ |
| | | Map map_districts = Optional.ofNullable(clientSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); |
| | | if(map_districts.size() <= 0) { |
| | | return BaseResponseUtils.buildFail("区划信息有误"); |
| | | } |
| | | |
| | | String provinceNum = map_districts.get("provinceNum").toString(); |
| | | String cityNum = map_districts.get("cityNum").toString(); |
| | | Long countryId = Long.parseLong(map_districts.get("countryId").toString()); |
| | | String countyNum = map_districts.get("countyNum").toString(); |
| | | String countryName = map_districts.get("countryName").toString(); |
| | | Long townId = Long.parseLong(map_districts.get("townId").toString()); |
| | | String townNum = map_districts.get("townNum").toString(); |
| | | String townName = map_districts.get("townName").toString(); |
| | | String villageNum = map_districts.get("villageNum").toString(); |
| | | String villageName = map_districts.get("villageName").toString(); |
| | | |
| | | // 生成8位行政区划编码,生成农户编号用 |
| | | String district8 = countyNum + townNum + villageNum; |
| | | // 生成农户编号 |
| | | String clientNum = generateClientNum(district8); |
| | | // 生成12位5级行政区划编码串及名称串 |
| | | Long districtNum = Long.parseLong(provinceNum + cityNum + district8); |
| | | String districtTitle = countryName + townName + villageName; |
| | | |
| | | SeClient seClient = DtoClientToSeClient.INSTANCT.po2vo(po); |
| | | seClient.setCountyid(countryId); |
| | | seClient.setTownid(townId); |
| | | seClient.setClientnum(clientNum); |
| | | seClient.setDistrictnum(districtNum); |
| | | seClient.setDistricttitle(districtTitle); |
| | | Date operateTime = new Date(); |
| | | seClient.setOperatedt(operateTime); |
| | | |
| | | seClient.setDisabled((byte)0); |
| | | seClient.setDeleted((byte)0); |
| | | Integer rec = Optional.ofNullable(clientSv.addClient(seClient)).orElse(0); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail("添加农户失败"); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | |
| | | /** |
| | | * 生成10为农户编号 |
| | | * 1. 到农户表中查询6位区划串开头的最大的农户编号 |
| | | * 2. 是否取到记录 |
| | | * 2.1 取到 |
| | | * 2.1.1 取出后4位顺序号并转成整形 |
| | | * 2.1.2. 整形格式的顺序号加1并判断是否大于9999 |
| | | * 2.1.2.1 如果大于则提示用户编号已满 |
| | | * 2.1.2.2 如果不大 6位区划加上格式化后的顺序号 |
| | | * 2.2 未取到 6位区划加上0001 |
| | | * 3. 返回农户编号 |
| | | */ |
| | | private String generateClientNum(String district8) { |
| | | String clientNum = Optional.ofNullable(clientSv.getClientNumOfMax(district8)).orElse(""); |
| | | if(clientNum != null && clientNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(clientNum.substring(8)); |
| | | number = number + 1; |
| | | if(number > 9999) { |
| | | return "农户编号超限"; |
| | | } |
| | | clientNum = clientNum.substring(0, 8) + String.format("%04d", number); |
| | | } else { |
| | | clientNum = district8 + "0001"; |
| | | } |
| | | return clientNum; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrSell.client; |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientMapper; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import com.dy.pipIrrGlobal.voSe.VoClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/21 19:17 |
| | | * @LastEditTime 2023/12/21 19:17 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class ClientSv { |
| | | @Autowired |
| | | private SeClientMapper seClientMapper; |
| | | |
| | | @Autowired |
| | | private BaDistrictMapper baDistrictMapper; |
| | | |
| | | /** |
| | | * 根据指定条件获取农户数据 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoClient>> getClients(QueryVo vo){ |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ; |
| | | Long itemTotal = seClientMapper.getRecordCount(params); |
| | | |
| | | QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = vo.pageSize ; |
| | | rsVo.pageCurr = vo.pageCurr ; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = seClientMapper.getClients(params); |
| | | |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 增开农户 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer addClient(SeClient po) { |
| | | return seClientMapper.insert(po); |
| | | } |
| | | |
| | | /** |
| | | * 根据6位区划串模糊查询农户编号 |
| | | * @param district6 |
| | | * @return |
| | | */ |
| | | public String getClientNumOfMax(String district6) { |
| | | return seClientMapper.getClientNumOfMax(district6); |
| | | } |
| | | |
| | | /** |
| | | * 根据村编号获取5级区划信息 |
| | | * @param villageId 村编号(主键) |
| | | * @return 5级行政区划信息 |
| | | */ |
| | | public Map getDistrictsByVillageId(Long villageId) { |
| | | return baDistrictMapper.getDistrictsByVillageId(villageId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrSell.client; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/22 8:41 |
| | | * @LastEditTime 2023/12/22 8:41 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Schema(name = "创建农户传入对象") |
| | | public class DtoClient { |
| | | public static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 村ID |
| | | */ |
| | | @Schema(description = "所在村ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在村不能为空") |
| | | private Long villageid; |
| | | |
| | | /** |
| | | * 片区ID |
| | | */ |
| | | @Schema(description = "所在片区ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在片区不能为空") |
| | | private Long blockid; |
| | | |
| | | /** |
| | | * 分水房ID |
| | | */ |
| | | @Schema(description = "所在分水房ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "所在分水房不能为空") |
| | | private Long divideid; |
| | | |
| | | /** |
| | | * 农户姓名 |
| | | */ |
| | | @Schema(description = "农户姓名", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "农户姓名不能为空") //不能为空也不能为null |
| | | @Length(message = "农户姓名不大于{max}字,不小于{min}字", min = 1, max = 25) |
| | | private String name; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @Schema(description = "农户手机号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotEmpty(message = "农户手机号不能为空") //不能为空也不能为null |
| | | @Length(message = "农户手机号必须{max}位数据", min = 11, max = 11) |
| | | private String phone; |
| | | |
| | | /** |
| | | * 身份证号 |
| | | */ |
| | | @Schema(description = "农户身份证号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "农户身份证号不能为空") //不能为空也不能为null |
| | | @Length(message = "农户身份证号必须{max}位数据", min = 18, max = 18) |
| | | private String idcard; |
| | | |
| | | /** |
| | | * 种植面积 |
| | | */ |
| | | @Schema(description = "农户种植面积", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Double area; |
| | | |
| | | /** |
| | | * 街道及门牌号 |
| | | */ |
| | | @Schema(description = "街道+门牌号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Length(message = "地址不大于{max}字,不小于{min}字", min = 1, max = 50) |
| | | private String address; |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | @Schema(description = "备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @Length(message = "备注不大于{max}字,不小于{min}字", min = 1, max = 200) |
| | | private String remarks; |
| | | |
| | | /** |
| | | * 操作人编号 |
| | | */ |
| | | @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "操作人编号不能为空") |
| | | private Long operator; |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrSell.client; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/22 9:23 |
| | | * @LastEditTime 2023/12/22 9:23 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface DtoClientToSeClient { |
| | | DtoClientToSeClient INSTANCT = Mappers.getMapper(DtoClientToSeClient.class); |
| | | |
| | | @Mapping(target = "villageid", source = "villageid") |
| | | @Mapping(target = "blockid", source = "blockid") |
| | | @Mapping(target = "divideid", source = "divideid") |
| | | @Mapping(target = "name", source = "name") |
| | | @Mapping(target = "phone", source = "phone") |
| | | @Mapping(target = "idcard", source = "idcard") |
| | | @Mapping(target = "area", source = "area") |
| | | @Mapping(target = "address", source = "address") |
| | | @Mapping(target = "remarks", source = "remarks") |
| | | @Mapping(target = "operator", source = "operator") |
| | | SeClient po2vo(DtoClient po); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrSell.client; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/21 19:18 |
| | | * @LastEditTime 2023/12/21 19:18 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "农户查询条件") |
| | | public class QueryVo extends QueryConditionVo { |
| | | |
| | | //@Schema(description = "县ID") |
| | | //public Long countyId ; |
| | | // |
| | | //@Schema(description = "镇ID") |
| | | //public Long townId ; |
| | | // |
| | | //@Schema(description = "村ID") |
| | | //public Long villageId ; |
| | | // |
| | | //@Schema(description = "片区ID") |
| | | //public Long blockId ; |
| | | |
| | | @Schema(description = "农户姓名") |
| | | public String name; |
| | | |
| | | @Schema(description = "农户编号") |
| | | public String clientNum; |
| | | |
| | | @Schema(description = "农户电话") |
| | | public String phone; |
| | | |
| | | @Schema(description = "地址") |
| | | public String address; |
| | | } |