2023-12-26 朱宝民 县镇村获取接口、用水方式获取接口、农户增加虚拟卡号和用水方式
| | |
| | | */ |
| | | Map getDistrictsByVillageId(@Param("villageId") Long villageId); |
| | | |
| | | /** |
| | | * 根据级别获取行政区划列表 |
| | | * @param level 行政区划层级 |
| | | * @return 行政区划列表 |
| | | */ |
| | | List<Map<String, Object>> getDistrictgsByLevel(@Param("level") Integer level); |
| | | |
| | | /** |
| | | * 根据父ID获取行政区划列表 |
| | | * @param supperId 行政区划父级ID |
| | | * @return 行政区划列表 |
| | | */ |
| | | List<Map<String, Object>> getDistrictsBySupperId(@Param("supperId") Long supperId); |
| | | } |
| | |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2023/12/22 9:50 |
| | | * @LastEditTime 2023/12/22 9:50 |
| | | * @date 2023-12-26 10:32 |
| | | * @LastEditTime 2023-12-26 10:32 |
| | | * @Description |
| | | */ |
| | | |
| | |
| | | * @return 村主键 |
| | | */ |
| | | Long getVillageIdById(@Param("id") Long id); |
| | | |
| | | /** |
| | | * 获取虚拟卡号最大值 |
| | | * @return |
| | | */ |
| | | Long getMa1xVirtualId(); |
| | | |
| | | /** |
| | | * 获取用水方式列表 |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> getWaterTypes(); |
| | | } |
| | |
| | | private String name; |
| | | |
| | | /** |
| | | * 虚拟卡号;10位,从1000000000开始 |
| | | */ |
| | | @Schema(description = "虚拟卡号", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "虚拟卡号不能为空") |
| | | private Long virtualid; |
| | | |
| | | /** |
| | | * 农户编号;6位区划 + 4为顺序号 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | |
| | | private Double area; |
| | | |
| | | /** |
| | | * 用水类型ID |
| | | */ |
| | | @Schema(description = "用水类型ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long typeid; |
| | | |
| | | /** |
| | | * 街道及门牌号 |
| | | */ |
| | | @Schema(description = "街道+门牌号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | |
| | | INNER JOIN ba_district pro ON cit.supperId = pro.id |
| | | WHERE vil.id = ${villageId} |
| | | </select> |
| | | |
| | | <!--根据级别获取行政区划列表--> |
| | | <select id="getDistrictgsByLevel" resultType="java.util.Map"> |
| | | SELECT |
| | | id, |
| | | name |
| | | FROM ba_district WHERE `level` = ${level} |
| | | </select> |
| | | |
| | | <!--根据父ID获取行政区划列表--> |
| | | <select id="getDistrictsBySupperId" resultType="java.util.Map"> |
| | | SELECT |
| | | id, |
| | | name |
| | | FROM ba_district WHERE supperId = ${supperId} |
| | | </select> |
| | | </mapper> |
| | |
| | | <result column="blockId" jdbcType="BIGINT" property="blockid" /> |
| | | <result column="divideId" jdbcType="BIGINT" property="divideid" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result column="virtualId" jdbcType="BIGINT" property="virtualid" /> |
| | | <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="typeId" jdbcType="BIGINT" property="typeid" /> |
| | | <result column="address" jdbcType="VARCHAR" property="address" /> |
| | | <result column="remarks" jdbcType="VARCHAR" property="remarks" /> |
| | | <result column="operator" jdbcType="BIGINT" property="operator" /> |
| | |
| | | </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 |
| | | id, countyId, townId, villageId, blockId, divideId, `name`, virtualId, clientNum, |
| | | districtNum, districtTitle, phone, idCard, area, typeId, address, remarks, `operator`, |
| | | operateDt, disabled, deleted |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@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) |
| | | `name`, virtualId, clientNum, |
| | | districtNum, districtTitle, phone, |
| | | idCard, area, typeId, |
| | | 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}) |
| | | #{name,jdbcType=VARCHAR}, #{virtualid,jdbcType=BIGINT}, #{clientnum,jdbcType=VARCHAR}, |
| | | #{districtnum,jdbcType=BIGINT}, #{districttitle,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, |
| | | #{idcard,jdbcType=VARCHAR}, #{area,jdbcType=DOUBLE}, #{typeid,jdbcType=BIGINT}, |
| | | #{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 |
| | |
| | | <if test="name != null"> |
| | | `name`, |
| | | </if> |
| | | <if test="virtualid != null"> |
| | | virtualId, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | clientNum, |
| | | </if> |
| | |
| | | </if> |
| | | <if test="area != null"> |
| | | area, |
| | | </if> |
| | | <if test="typeid != null"> |
| | | typeId, |
| | | </if> |
| | | <if test="address != null"> |
| | | address, |
| | |
| | | <if test="name != null"> |
| | | #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="virtualid != null"> |
| | | #{virtualid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | #{clientnum,jdbcType=VARCHAR}, |
| | | </if> |
| | |
| | | </if> |
| | | <if test="area != null"> |
| | | #{area,jdbcType=DOUBLE}, |
| | | </if> |
| | | <if test="typeid != null"> |
| | | #{typeid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="address != null"> |
| | | #{address,jdbcType=VARCHAR}, |
| | |
| | | <if test="name != null"> |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="virtualid != null"> |
| | | virtualId = #{virtualid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="clientnum != null"> |
| | | clientNum = #{clientnum,jdbcType=VARCHAR}, |
| | | </if> |
| | |
| | | </if> |
| | | <if test="area != null"> |
| | | area = #{area,jdbcType=DOUBLE}, |
| | | </if> |
| | | <if test="typeid != null"> |
| | | typeId = #{typeid,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="address != null"> |
| | | address = #{address,jdbcType=VARCHAR}, |
| | |
| | | blockId = #{blockid,jdbcType=BIGINT}, |
| | | divideId = #{divideid,jdbcType=BIGINT}, |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | <!-- virtualId = #{virtualid,jdbcType=BIGINT},--> |
| | | clientNum = #{clientnum,jdbcType=VARCHAR}, |
| | | districtNum = #{districtnum,jdbcType=BIGINT}, |
| | | districtTitle = #{districttitle,jdbcType=VARCHAR}, |
| | | phone = #{phone,jdbcType=VARCHAR}, |
| | | idCard = #{idcard,jdbcType=VARCHAR}, |
| | | area = #{area,jdbcType=DOUBLE}, |
| | | typeId = #{typeid,jdbcType=BIGINT}, |
| | | address = #{address,jdbcType=VARCHAR}, |
| | | remarks = #{remarks,jdbcType=VARCHAR}, |
| | | `operator` = #{operator,jdbcType=BIGINT}, |
| | | operateDt = #{operatedt,jdbcType=TIMESTAMP} |
| | | <!-- ,--> |
| | | operateDt = #{operatedt,jdbcType=TIMESTAMP}, |
| | | <!-- disabled = #{disabled,jdbcType=TINYINT},--> |
| | | <!-- deleted = #{deleted,jdbcType=TINYINT}--> |
| | | where id = #{id,jdbcType=BIGINT} |
| | |
| | | <!--根据指定条件获取农户记录数--> |
| | | <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | COUNT(*) AS recordCount |
| | | FROM se_client cli |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | |
| | | <!--根据指定条件获取农户数据--> |
| | | <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 |
| | | (@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 |
| | | , (SELECT @i:=0) AS itable |
| | | <where> |
| | | AND disabled = 0 |
| | | AND deleted = 0 |
| | |
| | | <select id="getVillageIdById" parameterType="java.lang.Long" resultType="java.lang.Long"> |
| | | SELECT villageId FROM se_client WHERE id = ${id} |
| | | </select> |
| | | |
| | | <!--获取虚拟卡号最大值--> |
| | | <select id="getMa1xVirtualId" resultType="java.lang.Long"> |
| | | SELECT virtualId FROM se_client ORDER BY id DESC LIMIT 0,1 |
| | | </select> |
| | | |
| | | <!--获取用水方式列表--> |
| | | <select id="getWaterTypes" resultType="java.util.Map"> |
| | | SELECT id, typeName from se_water_type |
| | | </select> |
| | | </mapper> |
| | |
| | | import com.dy.common.mybatis.envm.Deleted; |
| | | 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.pojoBa.BaDistrict; |
| | | import com.dy.pipIrrGlobal.util.DistrictLevel; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Tag(name = "行政区划管理", description = "行政区划增删改查等操作") |
| | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据级别获取行政区划列表 |
| | | * @param id |
| | | * @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "/level/{id}") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictgsByLevel(@PathVariable("id") Integer id){ |
| | | if(id == null || id <= 0){ |
| | | return BaseResponseUtils.buildFail("id不能为空") ; |
| | | } |
| | | |
| | | List<Map<String, Object>> map_Districts = Optional.ofNullable(sv.getDistrictgsByLevel(id)).orElse(new ArrayList<>()); |
| | | if(map_Districts == null || map_Districts.size() == 0) { |
| | | return BaseResponseUtils.buildFail("您输入的层级有误") ; |
| | | } |
| | | return BaseResponseUtils.buildSuccess(map_Districts); |
| | | } |
| | | |
| | | /** |
| | | * 根据父ID获取行政区划列表 |
| | | * @param supperId |
| | | * @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "/supperid/{supperId}") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictsBySupperId(@PathVariable("supperId") Long supperId){ |
| | | if(supperId == null || supperId <= 0){ |
| | | return BaseResponseUtils.buildFail("父ID不能为空") ; |
| | | } |
| | | |
| | | List<Map<String, Object>> map_Districts = Optional.ofNullable(sv.getDistrictsBySupperId(supperId)).orElse(new ArrayList<>()); |
| | | if(map_Districts == null || map_Districts.size() == 0) { |
| | | return BaseResponseUtils.buildFail("您输入的父级ID有误") ; |
| | | } |
| | | return BaseResponseUtils.buildSuccess(map_Districts); |
| | | } |
| | | } |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据级别获取行政区划列表 |
| | | * @param level |
| | | * @return |
| | | */ |
| | | public List<Map<String, Object>> getDistrictgsByLevel(Integer level) { |
| | | return dao.getDistrictgsByLevel(level); |
| | | } |
| | | |
| | | /** |
| | | * 根据父ID获取行政区划列表 |
| | | * @param supperId |
| | | * @return |
| | | */ |
| | | public List<Map<String, Object>> getDistrictsBySupperId(Long supperId) { |
| | | return dao.getDistrictsBySupperId(supperId); |
| | | } |
| | | } |
| | |
| | | Long districtNum = Long.parseLong(provinceNum + cityNum + district8); |
| | | String districtTitle = countryName + townName + villageName; |
| | | |
| | | // 生成虚拟卡号 |
| | | Long virtualId = Optional.ofNullable(clientSv.getMa1xVirtualId()).orElse(0L); |
| | | if(virtualId == 0) { |
| | | virtualId = 1000000000L; |
| | | }else { |
| | | virtualId = virtualId + 1; |
| | | if(virtualId > 10000000000L) { |
| | | return BaseResponseUtils.buildFail("虚拟卡号超限"); |
| | | } |
| | | } |
| | | |
| | | SeClient seClient = DtoClientToSeClient.INSTANCT.po2vo(po); |
| | | seClient.setCountyid(countryId); |
| | | seClient.setTownid(townId); |
| | | seClient.setVirtualid(virtualId); |
| | | seClient.setClientnum(clientNum); |
| | | seClient.setDistrictnum(districtNum); |
| | | seClient.setDistricttitle(districtTitle); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改农户对象 |
| | | * 修改农户对象 虚拟卡号、禁止标志、逻辑删除标识不参与修改 |
| | | * @param po 农户对象 |
| | | * @param bindingResult |
| | | * @return |
| | |
| | | seClient.setDistricttitle(districtTitle); |
| | | Date operateTime = new Date(); |
| | | seClient.setOperatedt(operateTime); |
| | | // |
| | | //seClient.setDisabled((byte)0); |
| | | //seClient.setDeleted((byte)0); |
| | | |
| | | Integer rec = Optional.ofNullable(clientSv.updateByPrimaryKey(seClient)).orElse(0); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail("添加农户失败"); |
| | | return BaseResponseUtils.buildFail("农户修改失败"); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取用水方式列表 |
| | | * @param |
| | | * @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 = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "/watertypes") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getWaterTypes(){ |
| | | List<Map<String, Object>> map_WaterTypes = Optional.ofNullable(clientSv.getWaterTypes()).orElse(new ArrayList<>()); |
| | | if(map_WaterTypes == null || map_WaterTypes.size() == 0) { |
| | | return BaseResponseUtils.buildFail("没有用水方式") ; |
| | | } |
| | | return BaseResponseUtils.buildSuccess(map_WaterTypes); |
| | | } |
| | | } |
| | |
| | | return seClientMapper.getVillageIdById(id); |
| | | } |
| | | |
| | | /** |
| | | * 获取虚拟卡号最大值 |
| | | * @return |
| | | */ |
| | | public Long getMa1xVirtualId() { |
| | | return seClientMapper.getMa1xVirtualId(); |
| | | } |
| | | |
| | | /** |
| | | * 获取用水方式列表 |
| | | * @return |
| | | */ |
| | | public List<Map<String, Object>> getWaterTypes() { |
| | | return seClientMapper.getWaterTypes(); |
| | | } |
| | | } |
| | |
| | | private Double area; |
| | | |
| | | /** |
| | | * 用水方式 |
| | | */ |
| | | @Schema(description = "用水方式", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long typeid; |
| | | |
| | | /** |
| | | * 街道及门牌号 |
| | | */ |
| | | @Schema(description = "街道+门牌号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | |
| | | @Mapping(target = "phone", source = "phone") |
| | | @Mapping(target = "idcard", source = "idcard") |
| | | @Mapping(target = "area", source = "area") |
| | | @Mapping(target = "typeid", source = "typeid") |
| | | @Mapping(target = "address", source = "address") |
| | | @Mapping(target = "remarks", source = "remarks") |
| | | @Mapping(target = "operator", source = "operator") |
| | | |
| | | @Mapping(target = "disabled", ignore=true) |
| | | @Mapping(target = "deleted", ignore=true) |
| | | SeClient po2vo(DtoClient po); |