Browse Source

组织区划下拉框接口V1

dev_shibei_match
yinzuomei 4 years ago
parent
commit
588add80cc
  1. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java
  2. 31
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/NextAreaCodeFormDTO.java
  3. 27
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/NextAreaCodeResultDTO.java
  4. 28
      epmet-module/data-aggregator/data-aggregator-server/pom.xml
  5. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  6. 39
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/commonservice/AreaCodeDao.java
  7. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java
  8. 23
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/AreaCodeService.java
  9. 75
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/impl/AreaCodeServiceImpl.java
  10. 3
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  11. 67
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  12. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml
  13. 57
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/commonservice/AreaCodeDao.xml
  14. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java

@ -23,4 +23,6 @@ public interface DataSourceConstant {
*/
String EPMET_USER = "epmetuser";
String EPMET_COMMON_SERVICE="commonservice";
}

31
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/NextAreaCodeFormDTO.java

@ -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;
}

27
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/NextAreaCodeResultDTO.java

@ -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;
}

28
epmet-module/data-aggregator/data-aggregator-server/pom.xml

@ -143,6 +143,13 @@
<datasource.druid.epmetuser.username>epmet_user_user</datasource.druid.epmetuser.username>
<datasource.druid.epmetuser.password>EpmEt-db-UsEr</datasource.druid.epmetuser.password>
<!-- epmet_common_service -->
<datasource.druid.commonservice.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_common_service?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.commonservice.url>
<datasource.druid.commonservice.username>epmet_common_service_user</datasource.druid.commonservice.username>
<datasource.druid.commonservice.password>EpmEt-db-UsEr</datasource.druid.commonservice.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
@ -210,6 +217,13 @@
<datasource.druid.epmetuser.username>epmet_user_user</datasource.druid.epmetuser.username>
<datasource.druid.epmetuser.password>EpmEt-db-UsEr</datasource.druid.epmetuser.password>
<!-- epmet_common_service -->
<datasource.druid.commonservice.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_common_service?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.commonservice.url>
<datasource.druid.commonservice.username>epmet_common_service_user</datasource.druid.commonservice.username>
<datasource.druid.commonservice.password>EpmEt-db-UsEr</datasource.druid.commonservice.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
@ -277,6 +291,13 @@
<datasource.druid.epmetuser.username>epmet</datasource.druid.epmetuser.username>
<datasource.druid.epmetuser.password>elink@833066</datasource.druid.epmetuser.password>
<!-- epmet_common_service -->
<datasource.druid.commonservice.url>
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_common_service?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.commonservice.url>
<datasource.druid.commonservice.username>epmet</datasource.druid.commonservice.username>
<datasource.druid.commonservice.password>elink@833066</datasource.druid.commonservice.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host>
@ -344,6 +365,13 @@
<datasource.druid.epmetuser.username>epmet_user_user</datasource.druid.epmetuser.username>
<datasource.druid.epmetuser.password>EpmEt-db-UsEr</datasource.druid.epmetuser.password>
<!-- epmet_common_service-->
<datasource.druid.commonservice.url>
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_common_service?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.commonservice.url>
<datasource.druid.commonservice.username>epmet_common_service_user</datasource.druid.commonservice.username>
<datasource.druid.commonservice.password>EpmEt-db-UsEr</datasource.druid.commonservice.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com</spring.redis.host>

17
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java

@ -3,13 +3,19 @@ package com.epmet.dataaggre.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/12/25 上午9:45
@ -34,4 +40,15 @@ public class GovOrgController {
return new Result<AgencyGridListResultDTO>().ok(agencyGridList);
}
/**
* @param formDTO
* @author yinzuomei
* @description 新增组织-查询下一级可选的组织区划
* @Date 2021/4/12 16:01
**/
@PostMapping("nextlevelareacodelist")
public Result<List<NextAreaCodeResultDTO>> queryNextLevelAreaCodeList(@RequestBody NextAreaCodeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<NextAreaCodeResultDTO>>().ok(govOrgService.queryNextLevelAreaCodeList(formDTO));
}
}

39
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/commonservice/AreaCodeDao.java

@ -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);
}

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java

@ -47,4 +47,6 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @date 2020/12/25 下午4:55
*/
String getAgencyIdByUserId(@Param("userId") String userId);
List<String> selectUsedAreaCodeList(@Param("parentAreaCode") String parentAreaCode);
}

23
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/AreaCodeService.java

@ -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);
}

75
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/impl/AreaCodeServiceImpl.java

@ -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;
}
}

3
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -1,8 +1,10 @@
package com.epmet.dataaggre.service.govorg;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import java.util.List;
@ -42,4 +44,5 @@ public interface GovOrgService {
*/
String getAgencyIdByUserId(String userId);
List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO);
}

67
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.dataaggre.service.govorg.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
@ -8,17 +9,23 @@ import com.epmet.dataaggre.dao.govorg.CustomerAgencyDao;
import com.epmet.dataaggre.dao.govorg.CustomerGridDao;
import com.epmet.dataaggre.dao.govorg.CustomerStaffAgencyDao;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.service.commonservice.AreaCodeService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -37,7 +44,8 @@ public class GovOrgServiceImpl implements GovOrgService {
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Autowired
private CustomerGridDao customerGridDao;
@Autowired
private AreaCodeService areaCodeService;
/**
* @param staffId
@ -120,5 +128,62 @@ public class GovOrgServiceImpl implements GovOrgService {
return customerAgencyDao.getAgencyIdByUserId(userId);
}
@Override
public List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO) {
//全部下级
List<NextAreaCodeResultDTO> allList = areaCodeService.queryNextLevelAreaCodeList(formDTO);
if (CollectionUtils.isNotEmpty(allList)) {
//已经被使用过的areaCode
List<String> usedAreaCodeList = customerAgencyDao.selectUsedAreaCodeList(formDTO.getAreaCode());
//已经被使用的移除不显示
Iterator<NextAreaCodeResultDTO> iterator = allList.iterator();
while (iterator.hasNext()) {
NextAreaCodeResultDTO next = iterator.next();
for (String usedAreaCode : usedAreaCodeList) {
if (next.getAreaCode().equals(usedAreaCode)) {
iterator.remove();
}
}
//todo 移除掉 子客户下使用的
}
}
return allList;
}
public static void main(String[] args) {
List<NextAreaCodeResultDTO> allList = new ArrayList<>();
NextAreaCodeResultDTO m1 = new NextAreaCodeResultDTO();
m1.setAreaCode("1");
m1.setAreaName("a");
allList.add(m1);
NextAreaCodeResultDTO m2 = new NextAreaCodeResultDTO();
m2.setAreaCode("2");
m2.setAreaName("b");
allList.add(m2);
NextAreaCodeResultDTO m3 = new NextAreaCodeResultDTO();
m3.setAreaCode("3");
m3.setAreaName("c");
allList.add(m3);
List<String> stringList = new ArrayList<>();
stringList.add("1");
stringList.add("2");
Iterator<NextAreaCodeResultDTO> iterator = allList.iterator();
while (iterator.hasNext()) {
NextAreaCodeResultDTO next = iterator.next();
for (String usedAreaCode : stringList) {
if (next.getAreaCode().equals(usedAreaCode)) {
iterator.remove();
}
}
}
System.out.println(JSON.toJSONString(allList, true));
}
}

6
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml

@ -119,7 +119,11 @@ dynamic:
url: @datasource.druid.epmetuser.url@
username: @datasource.druid.epmetuser.username@
password: @datasource.druid.epmetuser.password@
commonservice:
driver-class-name: com.mysql.cj.jdbc.Driver
url: @datasource.druid.commonservice.url@
username: @datasource.druid.commonservice.username@
password: @datasource.druid.commonservice.password@
feign:
hystrix:
enabled: true

57
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/commonservice/AreaCodeDao.xml

@ -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>

9
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

@ -22,4 +22,13 @@
SELECT AGENCY_ID FROM customer_staff_agency WHERE DEL_FLAG = 0 AND USER_ID = #{userId}
</select>
<select id="selectUsedAreaCodeList" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
ca.AREA_CODE
FROM
customer_agency ca
WHERE
ca.DEL_FLAG = '0'
AND ca.PARENT_AREA_CODE = #{parentAreaCode}
</select>
</mapper>
Loading…
Cancel
Save