From 264b5ede0e815999c589e411c597ea9fc010f3df Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期五, 30 八月 2024 17:00:51 +0800 Subject: [PATCH] 2024-08-30 朱宝民 根据区划代码获取指定级别的区划 --- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java | 38 ++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java | 30 +++++ pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java | 18 +++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java | 52 ++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java | 27 ++++ pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java | 21 +++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml | 115 +++++++++++++++++++ 7 files changed, 301 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java new file mode 100644 index 0000000..7b03bdf --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/AreaCode2023Mapper.java @@ -0,0 +1,38 @@ +package com.dy.pipIrrGlobal.daoBa; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dy.pipIrrGlobal.pojoBa.AreaCode2023; +import com.dy.pipIrrGlobal.voBa.VoDistrict; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ZhuBaoMin + * @date 2024-08-30 16:09 + * @LastEditTime 2024-08-30 16:09 + * @Description + */ +@Mapper +public interface AreaCode2023Mapper extends BaseMapper<AreaCode2023> { + int deleteByPrimaryKey(Long code); + + int insert(AreaCode2023 record); + + int insertSelective(AreaCode2023 record); + + AreaCode2023 selectByPrimaryKey(Long code); + + int updateByPrimaryKeySelective(AreaCode2023 record); + + int updateByPrimaryKey(AreaCode2023 record); + + /** + * 鏍规嵁鍖哄垝浠g爜鏌ヨ鎸囧畾绾у埆琛屾斂鍖哄垝 + * @param aredCode + * @param level + * @return + */ + List<VoDistrict> getDistrictS(@Param("aredCode") String aredCode, @Param("level") Integer level); +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java new file mode 100644 index 0000000..17e6a4d --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/AreaCode2023.java @@ -0,0 +1,52 @@ +package com.dy.pipIrrGlobal.pojoBa; + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.TableName; +import com.dy.common.po.BaseEntity; +import lombok.*; + +/** + * @author ZhuBaoMin + * @date 2024-08-30 16:09 + * @LastEditTime 2024-08-30 16:09 + * @Description + */ + +@TableName(value="area_code_2023", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class AreaCode2023 implements BaseEntity { + public static final long serialVersionUID = 202408301613001L; + + /** + * 鍖哄垝浠g爜 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + private Long code; + + /** + * 鍚嶇О + */ + private String name; + + /** + * 绾у埆1-5,鐪佸競鍘块晣鏉� + */ + private Boolean level; + + /** + * 鐖剁骇鍖哄垝浠g爜 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + private Long pcode; + + /** + * 鍩庝埂鍒嗙被 + */ + private Integer category; + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java new file mode 100644 index 0000000..1aecf28 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoDistrict.java @@ -0,0 +1,30 @@ +package com.dy.pipIrrGlobal.voBa; + +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-08-30 16:02 + * @LastEditTime 2024-08-30 16:02 + * @Description 鍖哄垝瑙嗗浘瀵硅薄 + */ + +@Data +public class VoDistrict { + private static final long serialVersionUID = 202408301604001L; + + /** + * 鍖哄垝鍚嶇О + */ + private String name; + + /** + * 鍖哄垝浠g爜 + */ + private String code; + + /** + * 绾у埆锛�1-5鐪佸競鍘块晣鏉� + */ + private Integer level; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml new file mode 100644 index 0000000..e482c61 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/AreaCode2023Mapper.xml @@ -0,0 +1,115 @@ +<?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.daoBa.AreaCode2023Mapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.AreaCode2023"> + <!--@mbg.generated--> + <!--@Table area_code_2023--> + <id column="code" jdbcType="BIGINT" property="code" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="level" jdbcType="BOOLEAN" property="level" /> + <result column="pcode" jdbcType="BIGINT" property="pcode" /> + <result column="category" jdbcType="INTEGER" property="category" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + code, `name`, `level`, pcode, category + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from area_code_2023 + where code = #{code,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from area_code_2023 + where code = #{code,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023"> + <!--@mbg.generated--> + insert into area_code_2023 (code, `name`, `level`, + pcode, category) + values (#{code,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=BOOLEAN}, + #{pcode,jdbcType=BIGINT}, #{category,jdbcType=INTEGER}) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023"> + <!--@mbg.generated--> + insert into area_code_2023 + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="code != null"> + code, + </if> + <if test="name != null"> + `name`, + </if> + <if test="level != null"> + `level`, + </if> + <if test="pcode != null"> + pcode, + </if> + <if test="category != null"> + category, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="code != null"> + #{code,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="level != null"> + #{level,jdbcType=BOOLEAN}, + </if> + <if test="pcode != null"> + #{pcode,jdbcType=BIGINT}, + </if> + <if test="category != null"> + #{category,jdbcType=INTEGER}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023"> + <!--@mbg.generated--> + update area_code_2023 + <set> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="level != null"> + `level` = #{level,jdbcType=BOOLEAN}, + </if> + <if test="pcode != null"> + pcode = #{pcode,jdbcType=BIGINT}, + </if> + <if test="category != null"> + category = #{category,jdbcType=INTEGER}, + </if> + </set> + where code = #{code,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.AreaCode2023"> + <!--@mbg.generated--> + update area_code_2023 + set `name` = #{name,jdbcType=VARCHAR}, + `level` = #{level,jdbcType=BOOLEAN}, + pcode = #{pcode,jdbcType=BIGINT}, + category = #{category,jdbcType=INTEGER} + where code = #{code,jdbcType=BIGINT} + </update> + + <!--鏍规嵁鍖哄垝浠g爜鏌ヨ鎸囧畾绾у埆琛屾斂鍖哄垝--> + <select id="getDistrictS" resultType="com.dy.pipIrrGlobal.voBa.VoDistrict"> + SELECT + name, + CASE + WHEN level = 4 THEN SUBSTRING(code,7,3) + WHEN level = 5 THEN SUBSTRING(code,10,3) + END AS code, + level + FROM area_code_2023 + WHERE code LIKE CONCAT('%', #{aredCode}, '%') AND level = #{level} + </select> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java index 033a2f9..f75cd48 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java @@ -9,9 +9,11 @@ import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrBase.district.qo.DistrictQO; import com.dy.pipIrrGlobal.pojoBa.BaClient; import com.dy.pipIrrGlobal.pojoBa.BaDistrict; import com.dy.pipIrrGlobal.util.DistrictLevel; +import com.dy.pipIrrGlobal.voBa.VoDistrict; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -324,4 +326,29 @@ //return BaseResponseUtils.buildSuccess(); } + + /** + * 鏍规嵁鍖哄垝浠g爜鏌ヨ鎸囧畾绾у埆琛屾斂鍖哄垝 + * @param qo + * @return + */ + @GetMapping(path = "/districts") + @SsoAop() + public BaseResponse<List<VoDistrict>> getDistrictS(DistrictQO qo) { + String aredCode = qo.getAredCode(); + Integer level = qo.getLevel(); + + if((aredCode.trim().length() == 6 && level == 4) || (aredCode.trim().length() == 9 && level == 5)) { + try { + return BaseResponseUtils.buildSuccess(sv.getDistrictS(qo)); + } catch (Exception e) { + log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + }else { + return BaseResponseUtils.buildErrorMsg("琛屾斂鍖哄垝浣嶆暟涓庣骇鍒笉鍖归厤"); + } + + + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java index 48e7256..e3fdb4f 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictSv.java @@ -1,8 +1,11 @@ package com.dy.pipIrrBase.district; +import com.dy.pipIrrBase.district.qo.DistrictQO; +import com.dy.pipIrrGlobal.daoBa.AreaCode2023Mapper; import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; import com.dy.pipIrrGlobal.pojoBa.BaDistrict; import com.dy.pipIrrGlobal.util.DistrictLevel; +import com.dy.pipIrrGlobal.voBa.VoDistrict; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,10 +19,16 @@ public class DistrictSv { private BaDistrictMapper dao; + private AreaCode2023Mapper areaCode2023Dao; @Autowired private void setDao(BaDistrictMapper dao){ this.dao = dao; + } + + @Autowired + private void setDao(AreaCode2023Mapper areaCode2023Dao){ + this.areaCode2023Dao = areaCode2023Dao; } /** @@ -117,4 +126,13 @@ public List<Map<String, Object>> getDistrictsBySupperId(Long supperId) { return dao.getDistrictsBySupperId(supperId); } + + /** + * 鏍规嵁鍖哄垝浠g爜鏌ヨ鎸囧畾绾у埆琛屾斂鍖哄垝 + * @param qo + * @return + */ + public List<VoDistrict> getDistrictS(DistrictQO qo) { + return areaCode2023Dao.getDistrictS(qo.getAredCode(), qo.getLevel()); + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java new file mode 100644 index 0000000..25fed02 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/qo/DistrictQO.java @@ -0,0 +1,21 @@ +package com.dy.pipIrrBase.district.qo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author ZhuBaoMin + * @date 2024-08-30 16:28 + * @LastEditTime 2024-08-30 16:28 + * @Description + */ + +@Data +@EqualsAndHashCode(callSuper = false) +public class DistrictQO { + + private String aredCode; + + private Integer level; + +} -- Gitblit v1.8.0