Browse Source

Merge remote-tracking branch 'origin/dev_area_code' into dev_temp

master
yinzuomei 4 years ago
parent
commit
52add5bde1
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 3
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java
  3. 22
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/CustomerAgencyDTO.java
  4. 31
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/NextAreaCodeFormDTO.java
  5. 27
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/NextAreaCodeResultDTO.java
  6. 56
      epmet-module/data-aggregator/data-aggregator-server/pom.xml
  7. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  8. 39
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/commonservice/AreaCodeDao.java
  9. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java
  10. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/opercrm/CustomerRelationDao.java
  11. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java
  12. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerDepartmentEntity.java
  13. 23
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/AreaCodeService.java
  14. 75
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/commonservice/impl/AreaCodeServiceImpl.java
  15. 3
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  16. 76
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  17. 13
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/CustomerRelation.java
  18. 30
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/impl/CustomerRelationImpl.java
  19. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml
  20. 57
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/commonservice/AreaCodeDao.xml
  21. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml
  22. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/opercrm/CustomerRelationDao.xml
  23. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java
  24. 27
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AddAreaCodeFormDTO.java
  25. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  26. 12
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  27. 4
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/AreaCodeConstant.java
  28. 14
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java
  29. 4
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java
  30. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java
  31. 70
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
  32. 16
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
  33. 22
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java
  34. 96
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerOrgParameterDTO.java
  35. 86
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java
  36. 14
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java
  37. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java
  38. 6
      epmet-module/gov-org/gov-org-server/pom.xml
  39. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java
  40. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  41. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  42. 43
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerOrgParameterDao.java
  43. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java
  44. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java
  45. 66
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerOrgParameterEntity.java
  46. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  47. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  48. 104
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerOrgParameterService.java
  49. 96
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  50. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  51. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  52. 116
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerOrgParameterServiceImpl.java
  53. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
  54. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml
  55. 10
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  56. 14
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerOrgParameterDao.xml

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -70,6 +70,8 @@ public enum EpmetErrorCode {
NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"),
NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"),
NOT_DEL_AGENCY_GRID(8207, "该机关存在网格,不允许删除"),
AREA_CODE_ALREADY_EXISTS(8208,"组织区划已被占用,请重新选择"),
AGENCY_NAME_ALREADY_EXISTS(8209,"您当前的组织名称已存在,请重新修改"),
REQUIRE_PERMISSION(8301, "您没有足够的操作权限"),
THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"),

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

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

22
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/CustomerAgencyDTO.java

@ -114,17 +114,17 @@ public class CustomerAgencyDTO implements Serializable {
private Integer totalUser;
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province;
private String province;
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city;
private String city;
/**
* 区县
* 域编码字典中的名称
*/
private String district;
@ -132,4 +132,14 @@ public class CustomerAgencyDTO implements Serializable {
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
}

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

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

@ -143,6 +143,20 @@
<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>
<!-- opercrm -->
<datasource.druid.opercrm.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercrm.url>
<datasource.druid.opercrm.username>epmet_oper_crm_user</datasource.druid.opercrm.username>
<datasource.druid.opercrm.password>EpmEt-db-UsEr</datasource.druid.opercrm.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
@ -210,6 +224,20 @@
<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>
<!-- opercrm -->
<datasource.druid.opercrm.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercrm.url>
<datasource.druid.opercrm.username>epmet_oper_crm_user</datasource.druid.opercrm.username>
<datasource.druid.opercrm.password>EpmEt-db-UsEr</datasource.druid.opercrm.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
@ -277,6 +305,20 @@
<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>
<!-- opercrm-->
<datasource.druid.opercrm.url>
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercrm.url>
<datasource.druid.opercrm.username>epmet</datasource.druid.opercrm.username>
<datasource.druid.opercrm.password>elink@833066</datasource.druid.opercrm.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host>
@ -344,6 +386,20 @@
<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>
<!-- opercrm-->
<datasource.druid.opercrm.url>
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_oper_crm?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</datasource.druid.opercrm.url>
<datasource.druid.opercrm.username>epmet_oper_crm_user</datasource.druid.opercrm.username>
<datasource.druid.opercrm.password>EpmEt-db-UsEr</datasource.druid.opercrm.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);
}

16
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/opercrm/CustomerRelationDao.java

@ -0,0 +1,16 @@
package com.epmet.dataaggre.dao.opercrm;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/13 10:43
*/
@Mapper
public interface CustomerRelationDao {
List<String> selectUsedAreaCodeList(String areaCode);
}

16
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java

@ -80,17 +80,17 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
private Integer totalUser;
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province;
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city;
/**
* 区县
* 域编码字典中的名称
*/
private String district;
@ -98,4 +98,14 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerDepartmentEntity.java

@ -60,4 +60,8 @@ public class CustomerDepartmentEntity extends BaseEpmetEntity {
*/
private Integer totalUser;
/**
* 部门所属的行政地区编码:实际就是所属组织的地区编码
*/
private String areaCode;
}

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

76
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,24 @@ 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 com.epmet.dataaggre.service.opercrm.CustomerRelation;
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 +45,10 @@ public class GovOrgServiceImpl implements GovOrgService {
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Autowired
private CustomerGridDao customerGridDao;
@Autowired
private AreaCodeService areaCodeService;
@Autowired
private CustomerRelation customerRelation;
/**
* @param staffId
@ -120,5 +131,68 @@ 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> usedAreaCodeList1 = customerAgencyDao.selectUsedAreaCodeList(formDTO.getAreaCode());
//外部子客户:
List<String> usedAreaCodeList2= customerRelation.selectUsedAreaCodeList(formDTO.getAreaCode());
//已经被使用的移除不显示
Iterator<NextAreaCodeResultDTO> iterator = allList.iterator();
while (iterator.hasNext()) {
NextAreaCodeResultDTO next = iterator.next();
for (String usedAreaCode1 : usedAreaCodeList1) {
if (next.getAreaCode().equals(usedAreaCode1)) {
iterator.remove();
}
}
for (String usedAreaCode2 : usedAreaCodeList2) {
if (next.getAreaCode().contains(usedAreaCode2)) {
iterator.remove();
}
}
}
}
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));
}
}

13
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/CustomerRelation.java

@ -0,0 +1,13 @@
package com.epmet.dataaggre.service.opercrm;
import java.util.List;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/13 10:38
*/
public interface CustomerRelation {
List<String> selectUsedAreaCodeList(String areaCode);
}

30
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/opercrm/impl/CustomerRelationImpl.java

@ -0,0 +1,30 @@
package com.epmet.dataaggre.service.opercrm.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.opercrm.CustomerRelationDao;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/13 10:38
*/
@DataSource(DataSourceConstant.OPER_CRM)
@Slf4j
@Service
public class CustomerRelationImpl implements CustomerRelation {
@Autowired
private CustomerRelationDao customerRelationDao;
@Override
public List<String> selectUsedAreaCodeList(String areaCode) {
return customerRelationDao.selectUsedAreaCodeList(areaCode);
}
}

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

@ -119,7 +119,16 @@ 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@
opercrm:
driver-class-name: com.mysql.cj.jdbc.Driver
url: @datasource.druid.opercrm.url@
username: @datasource.druid.opercrm.username@
password: @datasource.druid.opercrm.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>

16
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/opercrm/CustomerRelationDao.xml

@ -0,0 +1,16 @@
<?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.opercrm.CustomerRelationDao">
<select id="selectUsedAreaCodeList" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
cr.AREA_CODE
FROM
customer_relation cr
WHERE
cr.DEL_FLAG = '0'
AND cr.AREA_CODE LIKE concat(#{areaCode}, '%')
AND cr.AREA_CODE != #{areaCode}
</select>
</mapper>

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java

@ -80,17 +80,17 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
private Integer totalUser;
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province;
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city;
/**
* 区县
* 域编码字典中的名称
*/
private String district;
@ -98,4 +98,14 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
* 当前组织的上级行政地区编码add0204;举例平阴县370124对应的是济南市3701
*/
private String parentAreaCode;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
}

27
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AddAreaCodeFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/13 14:36
*/
@Data
public class AddAreaCodeFormDTO implements Serializable {
@NotBlank(message = "currentAreaLevel不能为空")
private String currentAreaLevel;
@NotBlank(message = "parentAreaCode不能为空")
private String parentAreaCode;
/**
* 新增的街道或者社区名称
*/
@NotBlank(message = "name不能为空")
private String name;
}

10
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -113,4 +113,14 @@ public interface EpmetCommonServiceOpenFeignClient {
**/
@PostMapping(value = "commonservice/areacode/addstreetcommareacode", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<String> addStreetCommAreaCode(@RequestBody AddAreaCodeDictFormDTO formDTO);
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @author yinzuomei
* @description 自定义行政地区编码
* @Date 2021/4/13 14:31
**/
@PostMapping(value = "commonservice/areacode/addareacode", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<String> addAreaCode(AddAreaCodeFormDTO formDTO);
}

12
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -99,4 +99,16 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result<String> addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "addStreetCommAreaCode", formDTO);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @author yinzuomei
* @description 自定义行政地区编码
* @Date 2021/4/13 14:31
**/
@Override
public Result<String> addAreaCode(AddAreaCodeFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "addAreaCode", formDTO);
}
}

4
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/AreaCodeConstant.java

@ -26,4 +26,8 @@ public interface AreaCodeConstant {
String LEVEL_ERROR = "RootAreaLevel填写错误【%s】";
String FIRST_THREE_UD="001_UD";
String FIRST_TOW_UD="01_UD";
String UD="_UD";
}

14
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java

@ -26,6 +26,7 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.service.AreaCodeService;
@ -107,4 +108,17 @@ public class AreaCodeController {
ValidatorUtils.validateEntity(formDTO);
return new Result<String>().ok(areaCodeService.addStreetCommAreaCode(formDTO));
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @author yinzuomei
* @description 自定义行政地区编码-产品自身使用
* @Date 2021/4/13 14:40
**/
@PostMapping(value = "addareacode")
Result<String> addAreaCode(@RequestBody AddAreaCodeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<String>().ok(areaCodeService.addAreaCode(formDTO));
}
}

4
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java

@ -36,4 +36,8 @@ public interface AreaCodeDao extends BaseDao<AreaCodeEntity> {
List<AreaCodeDTO> selectAllArea();
AreaCodeDTO selectByCountyCode(String countyCode);
AreaCodeDTO selectByCityCode(String cityCode);
AreaCodeDTO selectMaxCounty(String cityCode);
}

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.entity.AreaCodeEntity;
@ -113,4 +114,13 @@ public interface AreaCodeService extends BaseService<AreaCodeEntity> {
* @Date 2021/2/5 17:39
**/
String addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO);
/**
* @return java.lang.String
* @param formDTO
* @author yinzuomei
* @description 自定义行政地区编码
* @Date 2021/4/13 14:40
**/
String addAreaCode(AddAreaCodeFormDTO formDTO);
}

70
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

@ -34,6 +34,7 @@ import com.epmet.dao.AreaCodeDao;
import com.epmet.dto.AreaCodeChildDTO;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.entity.AreaCodeEntity;
@ -588,7 +589,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
**/
@Override
public String addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO) {
String originalParentCode = formDTO.getParentAreaCode().replaceAll("_UD", "");
String originalParentCode = formDTO.getParentAreaCode().replaceAll(AreaCodeConstant.UD, "");
if (originalParentCode.length() < NumConstant.SIX) {
throw new RenException("目前只允许添加街道或社区");
}
@ -624,13 +625,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
//如果是增加街道
areaCodeChildDTO.setLevel(NumConstant.FOUR);
} else {
areaCodeChildDTO.setLevel(null != parent && null != parent.getLevel() ? parent.getLevel() + 1 : null);
areaCodeChildDTO.setLevel(null != parent && null != parent.getLevel() ? parent.getLevel() + NumConstant.ONE : null);
}
//获取子级中最大的编码
AreaCodeChildDTO maxChildDto = childDao.selectMaxChild(formDTO.getParentAreaCode().trim());
if (null == maxChildDto) {
//默认添加001
areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat("001_UD"));
areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat(AreaCodeConstant.FIRST_THREE_UD));
} else {
//去掉_UD +1赋值;370124001225_UD 锦源社区
/*String[] codeArr = maxChildDto.getCode().split(StrConstant.UNDER_LINE);
@ -641,14 +642,14 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
long num = Long.parseLong(codeArr[NumConstant.ZERO]) + NumConstant.ONE;
String numStr = String.valueOf(num);
String temp = "";
if (numStr.length() == 2) {
temp = "0".concat(numStr);
} else if (numStr.length() == 1) {
if (numStr.length() == NumConstant.TWO) {
temp = NumConstant.ZERO_STR.concat(numStr);
} else if (numStr.length() == NumConstant.ONE) {
temp = "00".concat(numStr);
} else {
temp = numStr;
}
areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat(temp).concat("_UD"));
areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat(temp).concat(AreaCodeConstant.UD));
/*log.info("最大="+maxChildDto.getCode()+";去初父级("+formDTO.getParentAreaCode()+"):"+subStr);
log.info("数字位+1="+num);
log.info("temp="+temp);*/
@ -657,4 +658,59 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
areaCodeChildService.save(areaCodeChildDTO);
return areaCodeChildDTO.getCode();
}
/**
* @param formDTO
* @return java.lang.String
* @author yinzuomei
* @description 自定义行政地区编码
* @Date 2021/4/13 14:40
**/
@Transactional(rollbackFor = Exception.class)
@Override
public String addAreaCode(AddAreaCodeFormDTO formDTO) {
String areaCode = "";
switch (formDTO.getCurrentAreaLevel()) {
case AreaCodeConstant.DISTRICT:
areaCode = addDistrictAreaCode(formDTO.getParentAreaCode(),formDTO.getName());
break;
case AreaCodeConstant.STREET:
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class));
break;
case AreaCodeConstant.COMMUNITY:
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class));
break;
default:
log.info("currentAreaLevel值为"+formDTO.getCurrentAreaLevel());
}
return areaCode;
}
private String addDistrictAreaCode(String cityCode, String countyName) {
AreaCodeDTO city = baseDao.selectByCityCode(cityCode);
AreaCodeEntity insert = ConvertUtils.sourceToTarget(city, AreaCodeEntity.class);
insert.setCityName(countyName);
AreaCodeDTO maxCountyDTO = baseDao.selectMaxCounty(cityCode);
if (null == maxCountyDTO) {
insert.setCountyCode(cityCode.concat(AreaCodeConstant.FIRST_TOW_UD));
} else {
//山东省37
//济南市3701
//济南高新技术产业开发区370171
//370172_UD
if (NumConstant.SIX == maxCountyDTO.getCountyCode().length()) {
long maxCountyCode = Long.parseLong(maxCountyDTO.getCountyCode());
long newCountyCode = maxCountyCode + NumConstant.ONE;
insert.setCountyCode(String.valueOf(newCountyCode));
} else {
String countyCode = maxCountyDTO.getCountyCode().replace(AreaCodeConstant.FIRST_TOW_UD, StrConstant.EPMETY_STR);
long maxCountyCode = Long.parseLong(countyCode);
long newCountyCode = maxCountyCode + NumConstant.ONE;
insert.setCountyCode(String.valueOf(newCountyCode));
}
}
baseDao.insert(insert);
return insert.getCountyCode();
}
}

16
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml

@ -11,4 +11,20 @@
<select id="selectByCountyCode" resultType="com.epmet.dto.AreaCodeDTO">
select * from area_code m where m.COUNTY_CODE=#{countyCode}
</select>
<select id="selectByCityCode" resultType="com.epmet.dto.AreaCodeDTO" parameterType="java.lang.String">
select distinct ac.PROVINCE_CODE,ac.PROVINCE_NAME,ac.CITY_CODE,ac.CITY_NAME
from area_code ac
where ac.DEL_FLAG='0'
and ac.CITY_CODE=#{cityCode}
</select>
<select id="selectMaxCounty" resultType="com.epmet.dto.AreaCodeDTO" parameterType="java.lang.String">
select *
from area_code ac
where ac.DEL_FLAG='0'
and ac.CITY_CODE=#{cityCode}
order by ac.COUNTY_CODE desc
limit 1
</select>
</mapper>

22
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java

@ -114,17 +114,17 @@ public class CustomerAgencyDTO implements Serializable {
private Integer totalUser;
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province;
private String province;
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city;
private String city;
/**
* 区县
* 域编码字典中的名称
*/
private String district;
@ -132,4 +132,14 @@ public class CustomerAgencyDTO implements Serializable {
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
}

96
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerOrgParameterDTO.java

@ -0,0 +1,96 @@
/**
* 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.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 客户组织相关参数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-04-12
*/
@Data
public class CustomerOrgParameterDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 参数键 eg:area_code_switch
*/
private String parameterKey;
/**
* 参数名 eg:是否开启区域编码
*/
private String parameterName;
/**
* 参数值 eg:开启open关闭closed
*/
private String parameterValue;
/**
* 参数说明 eg:open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
private String description;
/**
* 删除标志 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

86
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java

@ -0,0 +1,86 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 添加组织V2
*
* @author yinzuomei@elink-cn.com
* @date 2021/4/13 11:08
*/
@Data
public class AddAgencyV2FormDTO implements Serializable {
private static final long serialVersionUID = -8951334902226679043L;
public interface AddUserInternalGroup {
}
public interface DefaultUserShowGroup extends CustomerClientShowGroup {
}
public interface AreaCodeGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "上级组织ID不能为空", groups = AddUserInternalGroup.class)
private String parentAgencyId;
/**
* 机构组织名称
*/
@NotBlank(message = "组织名称不能为空", groups = DefaultUserShowGroup.class)
@Length(max = 50, message = "组织名称不能超过50个字", groups = DefaultUserShowGroup.class)
private String agencyName;
/**
* 机关级别社区级community
* 街道:street,
* 区县级: district,
* 市级: city
* 省级:province
*/
@NotBlank(message = "组织级别不能为空;社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province", groups = AddUserInternalGroup.class)
private String level;
/**
* open: 选择地区编码必填closed: 无需选择地区编码;0409新增返参
*/
@NotBlank(message = "areaCodeSwitch不能为空", groups = AddUserInternalGroup.class)
private String areaCodeSwitch;
/**
* 地区编码
*/
@NotBlank(message = "请选择组织区划", groups = AreaCodeGroup.class)
private String areaCode;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 区县
*/
private String district;
/**
* 区域编码字典中的街道名称来源于/data/aggregator/org/nextlevelareacodelist接口里的areaName
*/
private String street;
/**
* 区域编码字典中的社区名称来源于/data/aggregator/org/nextlevelareacodelist接口里的areaName
*/
private String community;
}

14
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java

@ -33,8 +33,18 @@ public class AddAgencyResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
* 新添加的组织Id
*/
private String agencyId = "";
private String agencyId;
/**
* 新添加的组织地区编码
*/
private String areaCode;
/**
* open: 选择地区编码必填closed: 无需选择地区编码;0409新增返参
*/
private String areaCodeSwitch;
}

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java

@ -58,17 +58,17 @@ public class AgencysResultDTO implements Serializable {
private String areaCode = "";
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province = "";
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city = "";
/**
* 区县
* 域编码字典中的名称
*/
private String district = "";
@ -76,4 +76,24 @@ public class AgencysResultDTO implements Serializable {
* 本机关的所有上级机关
*/
private List<ParentListResultDTO> parentList;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
/**
* open: 选择地区编码必填closed: 无需选择地区编码;;0409新增返参
*/
private String areaCodeSwitch;
/**
* 组织区划的名称
*/
private String areaName;
}

6
epmet-module/gov-org/gov-org-server/pom.xml

@ -101,6 +101,12 @@
<artifactId>epmet-commons-rocketmq</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

18
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java

@ -26,6 +26,15 @@ public interface CustomerAgencyConstant {
* 机关级别-市级
*/
String CITY_LEVEL = "city";
// 社区级:community,
String COMMUNITY_LEVEL="community";
// 乡(镇、街道)级:street,
String STREET_LEVEL="street";
// 区县级: district,
String DISTRICT="district";
/**
* 市级名称不能为空
*/
@ -71,4 +80,13 @@ public interface CustomerAgencyConstant {
* 获取工作人员组织信息失败
*/
String SELECT_STAFF_AGENCY_EXCEPTION = "获取工作人员组织信息失败";
/**
* 参数(area_code_switch)值open: 选择地区编码必填closed:
*/
String AREA_CODE_SWITCH="area_code_switch";
String AREA_CODE_SWITCH_CLOSED="closed";
String AREA_CODE_SWITCH_OPEN="open";
}

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -33,6 +33,7 @@ import com.epmet.dto.result.AgencysResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,6 +55,8 @@ public class AgencyController {
@Autowired
private AgencyService agencyService;
@Autowired
private CustomerAgencyService customerAgencyService;
/**
* @param formDTO
@ -81,6 +84,25 @@ public class AgencyController {
return agencyService.addAgency(formDTO);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.AddAgencyResultDTO>
* @author yinzuomei
* @description 添加组织V2
* @Date 2021/4/13 11:09
**/
@PostMapping("addagency-v2")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_SUBAGENCY_CREATE)
public Result<AddAgencyResultDTO> addAgencyV2(@RequestBody AddAgencyV2FormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, AddAgencyV2FormDTO.DefaultUserShowGroup.class, AddAgencyV2FormDTO.AddUserInternalGroup.class);
if (formDTO.getAreaCodeSwitch().equals(CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN)) {
ValidatorUtils.validateEntity(formDTO, AddAgencyV2FormDTO.AreaCodeGroup.class);
}
//组织名称是否存在
customerAgencyService.checkAgencyName(formDTO.getAgencyName());
return new Result<AddAgencyResultDTO>().ok(agencyService.addAgencyV2(formDTO));
}
/**
* 添加根级组织
* @param form

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -224,4 +224,6 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @Date 2020/12/15 10:04
**/
int delByAgencyId(@Param("agencyId") String agencyId, @Param("operateUserId") String operateUserId);
List<String> selectAgencyIdsByAreaCode(String areaCode);
}

43
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerOrgParameterDao.java

@ -0,0 +1,43 @@
/**
* 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.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.CustomerOrgParameterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 客户组织相关参数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-04-12
*/
@Mapper
public interface CustomerOrgParameterDao extends BaseDao<CustomerOrgParameterEntity> {
/**
* @return com.epmet.entity.CustomerOrgParameterEntity
* @param customerId
* @param parameterKey
* @author yinzuomei
* @description 根据customerId查询参数(area_code_switch)
* @Date 2021/4/12 14:26
**/
CustomerOrgParameterEntity selectByCustomerId(@Param("customerId") String customerId, @Param("parameterKey") String parameterKey);
}

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java

@ -80,17 +80,17 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
private Integer totalUser;
/**
* 省份
* 区域编码字典中的省份名称
*/
private String province;
/**
* 城市
* 区域编码字典中的城市名称
*/
private String city;
/**
* 区县
* 域编码字典中的名称
*/
private String district;
@ -98,4 +98,14 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
/**
* 区域编码字典中的街道名称0409
*/
private String street;
/**
* 区域编码字典中的社区名称0409
*/
private String community;
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java

@ -60,4 +60,8 @@ public class CustomerDepartmentEntity extends BaseEpmetEntity {
*/
private Integer totalUser;
/**
* 部门所属的行政地区编码:实际就是所属组织的地区编码
*/
private String areaCode;
}

66
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerOrgParameterEntity.java

@ -0,0 +1,66 @@
/**
* 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.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 客户组织相关参数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-04-12
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("customer_org_parameter")
public class CustomerOrgParameterEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 参数键 eg:area_code_switch
*/
private String parameterKey;
/**
* 参数名 eg:是否开启区域编码
*/
private String parameterName;
/**
* 参数值 eg:开启open关闭closed
*/
private String parameterValue;
/**
* 参数说明 eg:open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
private String description;
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java

@ -108,4 +108,13 @@ public interface AgencyService {
* @Date 2020/7/16 17:13
**/
void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff);
/**
* 添加组织V2
*
* @param formDTO rule id
* @return com.epmet.dto.result.AddAgencyResultDTO
*/
AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO);
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -234,4 +234,6 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @author sun
**/
OrganizeTreeResultDTO organizeTree(String agencyId);
void checkAgencyName(String agencyName);
}

104
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerOrgParameterService.java

@ -0,0 +1,104 @@
/**
* 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.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.CustomerOrgParameterDTO;
import com.epmet.entity.CustomerOrgParameterEntity;
import java.util.List;
import java.util.Map;
/**
* 客户组织相关参数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-04-12
*/
public interface CustomerOrgParameterService extends BaseService<CustomerOrgParameterEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<CustomerOrgParameterDTO>
* @author generator
* @date 2021-04-12
*/
PageData<CustomerOrgParameterDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<CustomerOrgParameterDTO>
* @author generator
* @date 2021-04-12
*/
List<CustomerOrgParameterDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return CustomerOrgParameterDTO
* @author generator
* @date 2021-04-12
*/
CustomerOrgParameterDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-04-12
*/
void save(CustomerOrgParameterDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-04-12
*/
void update(CustomerOrgParameterDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-04-12
*/
void delete(String[] ids);
/**
* @return java.lang.String
* @param customerId
* @author yinzuomei
* @description 根据customerId查询参数(area_code_switch)值open: 选择地区编码必填closed: 无需选择地区编码;;0409新增返参;没配置,返回closed
* @Date 2021/4/12 14:23
**/
String getAreaCodeSwitch(String customerId);
}

96
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -19,6 +19,7 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.user.LoginUserUtil;
@ -33,10 +34,13 @@ import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService;
import com.epmet.service.CustomerOrgParameterService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,7 +49,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* 机关单位信息
@ -70,6 +77,12 @@ public class AgencyServiceImpl implements AgencyService {
private CustomerGridDao customerGridDao;
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private CustomerOrgParameterService customerOrgParameterService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
/**
* @param formDTO
* @return
@ -235,6 +248,29 @@ public class AgencyServiceImpl implements AgencyService {
List<String> listStr = Arrays.asList(entity.getPids().split(":"));
parentList = customerAgencyDao.selectPAgencyById(listStr);
agencysResultDTO.setParentList(parentList);
agencysResultDTO.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(entity.getCustomerId()));
//查询组织区划的名称
if (null != entity && StringUtils.isNotBlank(entity.getAreaCode())) {
switch (entity.getLevel()) {
case CustomerAgencyConstant.PROVINCE_LEVEL:
agencysResultDTO.setAgencyName(entity.getProvince());
break;
case CustomerAgencyConstant.CITY_LEVEL:
agencysResultDTO.setAgencyName(entity.getCity());
break;
case CustomerAgencyConstant.DISTRICT:
agencysResultDTO.setAgencyName(entity.getDistrict());
break;
case CustomerAgencyConstant.STREET_LEVEL:
agencysResultDTO.setAgencyName(entity.getStreet());
break;
case CustomerAgencyConstant.COMMUNITY_LEVEL:
agencysResultDTO.setAgencyName(entity.getCommunity());
break;
default:
agencysResultDTO.setAgencyName(StrConstant.EPMETY_STR);
}
}
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
@ -380,4 +416,62 @@ public class AgencyServiceImpl implements AgencyService {
}
/**
* 添加组织V2
*
* @param formDTO rule id
* @return com.epmet.dto.result.AddAgencyResultDTO
*/
@Transactional(rollbackFor = Exception.class)
@Override
public AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO) {
CustomerAgencyDTO parent = customerAgencyService.get(formDTO.getParentAgencyId());
if (null == parent) {
throw new RenException(String.format("添加组织失败:没有找到跟组织信息,parentAgencyId=%s", formDTO.getParentAgencyId()));
}
AddAgencyResultDTO resultDTO = new AddAgencyResultDTO();
resultDTO.setAreaCodeSwitch(formDTO.getAreaCodeSwitch());
//判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
insertEntity.setOrganizationName(formDTO.getAgencyName());
insertEntity.setTotalUser(NumConstant.ZERO);
insertEntity.setPid(parent.getId());
insertEntity.setCustomerId(parent.getCustomerId());
insertEntity.setParentAreaCode(parent.getAreaCode());
if (StringUtils.isBlank(parent.getPid()) || NumConstant.ZERO_STR.equals(parent.getPid())) {
//如果上级是根级组织
insertEntity.setPids(parent.getId());
insertEntity.setAllParentName(parent.getOrganizationName());
} else {
insertEntity.setPids(parent.getPids().concat(StrConstant.COLON).concat(parent.getId()));
insertEntity.setAllParentName(parent.getAllParentName().concat(StrConstant.HYPHEN).concat(parent.getOrganizationName()));
}
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) {
//校验areaCode是否被使用过
if (!"other".equals(formDTO.getAreaCode())) {
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(insertEntity.getAreaCode());
if (CollectionUtils.isNotEmpty(agencyIds)) {
//已经被占用,提示
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg());
}
}else{
//如果选择的是other,需要自定义一个编码
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO();
addAreaCodeFormDTO.setCurrentAreaLevel(formDTO.getLevel());
addAreaCodeFormDTO.setParentAreaCode(parent.getAreaCode());
addAreaCodeFormDTO.setName(formDTO.getAgencyName());
Result<String> addAreaCodeResult = epmetCommonServiceOpenFeignClient.addAreaCode(addAreaCodeFormDTO);
if (!addAreaCodeResult.success() || StringUtils.isBlank(addAreaCodeResult.getData())) {
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg());
}
insertEntity.setAreaCode(addAreaCodeResult.getData());
}
}
customerAgencyDao.insert(insertEntity);
//3:返回新组织Id
resultDTO.setAgencyId(insertEntity.getId());
resultDTO.setAreaCode(StrConstant.EPMETY_STR);
return resultDTO;
}
}

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -40,6 +41,7 @@ import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import com.epmet.util.ModuleConstant;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -1057,4 +1059,14 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return baseDao.selectorganizeTree(agencyId);
}
@Override
public void checkAgencyName(String agencyName) {
QueryWrapper<CustomerAgencyEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(agencyName), "ORGANIZATION_NAME", agencyName);
List<CustomerAgencyEntity> entityList = baseDao.selectList(wrapper);
if (CollectionUtils.isNotEmpty(entityList)) {
throw new RenException(EpmetErrorCode.AGENCY_NAME_ALREADY_EXISTS.getCode(), EpmetErrorCode.AGENCY_NAME_ALREADY_EXISTS.getMsg());
}
}
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
@ -244,6 +245,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
customerGridEntity.setAreaCode(customerAgencyDTO.getAreaCode());
customerGridEntity.setCustomerId(customerAgencyDTO.getCustomerId());
customerGridEntity.setPid(addGridFormDTO.getAgencyId());
//新增area_code,部门的area_code=所属组织的area_code
customerGridEntity.setAreaCode(null != customerAgencyDTO && StringUtils.isNotBlank(customerAgencyDTO.getAreaCode()) ? customerAgencyDTO.getAreaCode() : StrConstant.EPMETY_STR);
//所有上级机构id,必须包括当前机构id (放在所有上级机构id后)
if(StringUtils.isBlank(customerAgencyDTO.getPids())){
customerGridEntity.setPids(addGridFormDTO.getAgencyId());

116
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerOrgParameterServiceImpl.java

@ -0,0 +1,116 @@
/**
* 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.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dao.CustomerOrgParameterDao;
import com.epmet.dto.CustomerOrgParameterDTO;
import com.epmet.entity.CustomerOrgParameterEntity;
import com.epmet.service.CustomerOrgParameterService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 客户组织相关参数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-04-12
*/
@Service
public class CustomerOrgParameterServiceImpl extends BaseServiceImpl<CustomerOrgParameterDao, CustomerOrgParameterEntity> implements CustomerOrgParameterService {
@Override
public PageData<CustomerOrgParameterDTO> page(Map<String, Object> params) {
IPage<CustomerOrgParameterEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerOrgParameterDTO.class);
}
@Override
public List<CustomerOrgParameterDTO> list(Map<String, Object> params) {
List<CustomerOrgParameterEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerOrgParameterDTO.class);
}
private QueryWrapper<CustomerOrgParameterEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerOrgParameterEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public CustomerOrgParameterDTO get(String id) {
CustomerOrgParameterEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerOrgParameterDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerOrgParameterDTO dto) {
CustomerOrgParameterEntity entity = ConvertUtils.sourceToTarget(dto, CustomerOrgParameterEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerOrgParameterDTO dto) {
CustomerOrgParameterEntity entity = ConvertUtils.sourceToTarget(dto, CustomerOrgParameterEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* @param customerId
* @return java.lang.String
* @author yinzuomei
* @description 根据customerId查询参数(area_code_switch)值open: 选择地区编码必填closed: 无需选择地区编码;;0409新增返参;没配置,返回closed
* @Date 2021/4/12 14:23
**/
@Override
public String getAreaCodeSwitch(String customerId) {
CustomerOrgParameterEntity entity = baseDao.selectByCustomerId(customerId, CustomerAgencyConstant.AREA_CODE_SWITCH);
if (null == entity || StringUtils.isBlank(entity.getParameterValue())) {
return CustomerAgencyConstant.AREA_CODE_SWITCH_CLOSED;
}
return entity.getParameterValue();
}
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java

@ -18,6 +18,7 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -90,6 +91,8 @@ public class DepartmentServiceImpl implements DepartmentService {
//1:查询当前组织机构信息,获取客户Id
CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getAgencyId());
entity.setCustomerId(parentEntity.getCustomerId());
//新增area_code,部门的area_code=所属组织的area_code
entity.setAreaCode(null!=parentEntity&&StringUtils.isNotBlank(parentEntity.getAreaCode())?parentEntity.getAreaCode(): StrConstant.EPMETY_STR);
//2:保存部门信息
if (customerDepartmentDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerDepartmentConstant.SAVE_EXCEPTION);

4
epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml

@ -128,14 +128,14 @@
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文档只记录ERROR级别的 发送钉钉短信 -->
<filter class="com.epmet.commons.tools.filter.LogMsgSendFilter">
<!--<filter class="com.epmet.commons.tools.filter.LogMsgSendFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
<webHook>${webHook}</webHook>
<secret>${secret}</secret>
<appName>${appname}</appName>
</filter>
</filter>-->
</appender>
<!-- 开发、测试环境 -->

10
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -399,4 +399,14 @@
UPDATED_TIME=NOW()
where id=#{agencyId}
</update>
<select id="selectAgencyIdsByAreaCode" resultType="java.lang.String" parameterType="java.lang.String">
SELECT
ca.id
FROM
customer_agency ca
WHERE
ca.DEL_FLAG = '0'
AND ca.AREA_CODE = #{areaCode}
</select>
</mapper>

14
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerOrgParameterDao.xml

@ -0,0 +1,14 @@
<?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.dao.CustomerOrgParameterDao">
<select id="selectByCustomerId" parameterType="map" resultType="com.epmet.entity.CustomerOrgParameterEntity">
select *
from customer_org_parameter p
where p.DEL_FLAG='0'
and p.CUSTOMER_ID=#{customerId}
and p.PARAMETER_KEY=#{parameterKey}
</select>
</mapper>
Loading…
Cancel
Save