forked from rongchao/epmet-cloud-rizhao
				
			
				 14 changed files with 384 additions and 2 deletions
			
			
		| @ -0,0 +1,31 @@ | |||
| package com.epmet.dataaggre.dto.govorg.form; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import javax.validation.constraints.NotBlank; | |||
| import java.io.Serializable; | |||
| 
 | |||
| /** | |||
|  * 描述一下 | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2021/4/12 15:55 | |||
|  */ | |||
| @Data | |||
| public class NextAreaCodeFormDTO implements Serializable { | |||
|     private static final long serialVersionUID = -1974456701949979946L; | |||
| 
 | |||
|     @NotBlank(message = "areaCode不能为空") | |||
|     private String areaCode; | |||
| 
 | |||
|     /** | |||
|      * 社区级:community, | |||
|      * 乡(镇、街道)级:street, | |||
|      * 区县级: district, | |||
|      * 市级: city | |||
|      * 省级:province | |||
|      */ | |||
|     @NotBlank(message = "level不能为空") | |||
|     private String level; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,27 @@ | |||
| package com.epmet.dataaggre.dto.govorg.result; | |||
| 
 | |||
| import lombok.Data; | |||
| 
 | |||
| import java.io.Serializable; | |||
| 
 | |||
| /** | |||
|  * 描述一下 | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2021/4/12 15:56 | |||
|  */ | |||
| @Data | |||
| public class NextAreaCodeResultDTO implements Serializable { | |||
|     private static final long serialVersionUID = 9188265480821079966L; | |||
| 
 | |||
|     private String areaCode; | |||
|     private String areaName; | |||
|     /** | |||
|      * 社区级:community, | |||
|      * 乡(镇、街道)级:street, | |||
|      * 区县级: district, | |||
|      * 市级: city | |||
|      * 省级:province | |||
|      */ | |||
|     private String level; | |||
| } | |||
| @ -0,0 +1,39 @@ | |||
| /** | |||
|  * Copyright 2018 人人开源 https://www.renren.io
 | |||
|  * <p> | |||
|  * This program is free software: you can redistribute it and/or modify | |||
|  * it under the terms of the GNU General Public License as published by | |||
|  * the Free Software Foundation, either version 3 of the License, or | |||
|  * (at your option) any later version. | |||
|  * <p> | |||
|  * This program is distributed in the hope that it will be useful, | |||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
|  * GNU General Public License for more details. | |||
|  * <p> | |||
|  * You should have received a copy of the GNU General Public License | |||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |||
|  */ | |||
| 
 | |||
| package com.epmet.dataaggre.dao.commonservice; | |||
| 
 | |||
| import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; | |||
| import org.apache.ibatis.annotations.Mapper; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * @author generator generator@elink-cn.com | |||
|  * @since v1.0.0 2021-01-07 | |||
|  */ | |||
| @Mapper | |||
| public interface AreaCodeDao { | |||
| 
 | |||
|     List<NextAreaCodeResultDTO> selectCityList(String areaCode); | |||
| 
 | |||
|     List<NextAreaCodeResultDTO> selectDistrictList(String areaCode); | |||
| 
 | |||
|     List<NextAreaCodeResultDTO> selectStreetList(String areaCode); | |||
| 
 | |||
|     List<NextAreaCodeResultDTO> selectCommunityList(String areaCode); | |||
| } | |||
| @ -0,0 +1,23 @@ | |||
| package com.epmet.dataaggre.service.commonservice; | |||
| 
 | |||
| import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; | |||
| import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 描述一下 | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2021/4/12 15:45 | |||
|  */ | |||
| public interface AreaCodeService { | |||
|     /** | |||
|      * @return java.util.List<com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO> | |||
|      * @param formDTO | |||
|      * @author yinzuomei | |||
|      * @description 新增组织-查询下一级可选的组织区划 | |||
|      * @Date 2021/4/12 16:02 | |||
|      **/ | |||
|     List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO); | |||
| } | |||
| @ -0,0 +1,75 @@ | |||
| package com.epmet.dataaggre.service.commonservice.impl; | |||
| 
 | |||
| import com.epmet.commons.dynamic.datasource.annotation.DataSource; | |||
| import com.epmet.dataaggre.constant.DataSourceConstant; | |||
| import com.epmet.dataaggre.dao.commonservice.AreaCodeDao; | |||
| import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; | |||
| import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; | |||
| import com.epmet.dataaggre.service.commonservice.AreaCodeService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.collections4.CollectionUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| 
 | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| 
 | |||
| /** | |||
|  * 描述一下 | |||
|  * | |||
|  * @author yinzuomei@elink-cn.com | |||
|  * @date 2021/4/12 15:46 | |||
|  */ | |||
| @DataSource(DataSourceConstant.EPMET_COMMON_SERVICE) | |||
| @Slf4j | |||
| @Service | |||
| public class AreaCodeServiceImpl implements AreaCodeService { | |||
| 
 | |||
|     @Autowired | |||
|     private AreaCodeDao areaCodeDao; | |||
| 
 | |||
|     /** | |||
|      * @param formDTO | |||
|      * @return java.util.List<com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO> | |||
|      * @author yinzuomei | |||
|      * @description 新增组织-查询下一级可选的组织区划 | |||
|      * @Date 2021/4/12 16:02 | |||
|      **/ | |||
|     @Override | |||
|     public List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO) { | |||
|         List<NextAreaCodeResultDTO> list = new ArrayList<>(); | |||
|         NextAreaCodeResultDTO other = new NextAreaCodeResultDTO(); | |||
|         other.setAreaCode("other"); | |||
|         other.setAreaName("其它"); | |||
|         switch (formDTO.getLevel()) { | |||
|             /** | |||
|              * 社区级:community, | |||
|              * 乡(镇、街道)级:street, | |||
|              * 区县级: district, | |||
|              * 市级: city | |||
|              * 省级:province | |||
|              */ | |||
|             case "province": | |||
|                 list = areaCodeDao.selectCityList(formDTO.getAreaCode()); | |||
|                 other.setLevel("city"); | |||
|                 break; | |||
|             case "city": | |||
|                 list = areaCodeDao.selectDistrictList(formDTO.getAreaCode()); | |||
|                 other.setLevel("district"); | |||
|                 break; | |||
|             case "district": | |||
|                 list = areaCodeDao.selectStreetList(formDTO.getAreaCode()); | |||
|                 other.setLevel("street"); | |||
|                 break; | |||
|             case "street": | |||
|                 list = areaCodeDao.selectCommunityList(formDTO.getAreaCode()); | |||
|                 other.setLevel("community"); | |||
|                 break; | |||
|             default: | |||
|         } | |||
|         if (CollectionUtils.isNotEmpty(list)) { | |||
|             list.add(other); | |||
|         } | |||
|         return list; | |||
|     } | |||
| } | |||
| @ -0,0 +1,57 @@ | |||
| <?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.epmet.dataaggre.dao.commonservice.AreaCodeDao"> | |||
| 
 | |||
|     <select id="selectCityList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> | |||
|         SELECT DISTINCT | |||
|             ac.CITY_CODE AS areaCode, | |||
|             ac.CITY_NAME AS areaName, | |||
|             'city' LEVEL | |||
|         FROM | |||
|             area_code ac | |||
|         WHERE | |||
|             ac.DEL_FLAG='0' | |||
|             and  ac.PROVINCE_CODE = #{areaCode} | |||
|         ORDER BY | |||
|             ac.CITY_CODE ASC | |||
|     </select> | |||
| 
 | |||
|     <select id="selectDistrictList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> | |||
|         SELECT DISTINCT | |||
|             ac.COUNTY_CODE AS areaCode, | |||
|             ac.COUNTY_NAME AS areaName, | |||
|             'district' LEVEL | |||
|         FROM | |||
|             area_code ac | |||
|         WHERE ac.DEL_FLAG='0' | |||
|             and ac.CITY_CODE = #{areaCode} | |||
|         ORDER BY | |||
|             ac.COUNTY_CODE ASC | |||
|     </select> | |||
| 
 | |||
|     <select id="selectStreetList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> | |||
|         SELECT DISTINCT CODE AS areaCode, | |||
|             NAME AS areaName, | |||
|             'street' AS LEVEL | |||
|         FROM | |||
|             area_code_child acc | |||
|         WHERE | |||
|             acc.DEL_FLAG = '0' | |||
|             AND acc.P_CODE = #{areaCode} | |||
|             order by acc.CODE ASC | |||
|     </select> | |||
| 
 | |||
|     <select id="selectCommunityList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> | |||
|         SELECT DISTINCT CODE AS areaCode, | |||
|             NAME AS areaName, | |||
|             'community' AS LEVEL | |||
|         FROM | |||
|             area_code_child acc | |||
|         WHERE | |||
|             acc.DEL_FLAG = '0' | |||
|             AND acc.P_CODE = #{areaCode} | |||
|         ORDER BY | |||
|             acc.CODE ASC | |||
|     </select> | |||
| </mapper> | |||
					Loading…
					
					
				
		Reference in new issue