Browse Source

通讯录树

feature/teamB_zz_wgh
HAHA 3 years ago
parent
commit
a5a30794ea
  1. 45
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NodeTree.java
  2. 31
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NodeTreeUtils.java
  3. 39
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAddressBookTreeResultDTO.java
  4. 92
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  5. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  6. 25
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  7. 180
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  8. 55
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

45
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NodeTree.java

@ -0,0 +1,45 @@
package com.epmet.commons.tools.utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class NodeTree<T> implements Serializable {
private static final long serialVersionUID = 8020505121785861117L;
/**
* 主键
*/
private String id;
/**
* 上级ID
*/
private String pid;
/**
* 子节点列表
*/
private List<T> children = new ArrayList<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public List<T> getChildren() {
return children;
}
public void setChildren(List<T> children) {
this.children = children;
}
}

31
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/NodeTreeUtils.java

@ -0,0 +1,31 @@
package com.epmet.commons.tools.utils;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class NodeTreeUtils {
public static <T extends NodeTree> List<T> build(List<T> treeNodes) {
List<T> result = new ArrayList<>();
//list转map
Map<String, T> nodeMap = new LinkedHashMap<>(treeNodes.size());
for(T treeNode : treeNodes){
nodeMap.put(treeNode.getId(), treeNode);
}
for(T node : nodeMap.values()) {
T parent = nodeMap.get(node.getPid());
if(parent != null && !(node.getId().equals(parent.getId()))){
parent.getChildren().add(node);
continue;
}
result.add(node);
}
return result;
}
}

39
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAddressBookTreeResultDTO.java

@ -0,0 +1,39 @@
package com.epmet.dto.result;
import com.epmet.commons.tools.utils.NodeTree;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AgencyAddressBookTreeResultDTO extends NodeTree implements Serializable {
private static final long serialVersionUID = -1993037593855768962L;
/**
* 父id
*/
private String pid;
/**
* 名字
*/
private String name;
/**
* 级别
*/
private String level;
/**
* 创建时间
*/
private Date createTime;
}

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

@ -94,15 +94,15 @@ public class AgencyController {
public Result<AddAgencyResultDTO> addAgency(@LoginUser TokenDto tokenDTO, @RequestBody AddAgencyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
//机构级别是市级以上则市、区县名称可不传值,是区县级以上则区县名称可不传值
if(!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel())&&!CustomerAgencyConstant.CITY_LEVEL.equals(formDTO.getLevel())){
if(StringUtils.isBlank(formDTO.getCity())){
if (!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel()) && !CustomerAgencyConstant.CITY_LEVEL.equals(formDTO.getLevel())) {
if (StringUtils.isBlank(formDTO.getCity())) {
throw new RenException(CustomerAgencyConstant.CITY_EXCEPTION);
}
if(StringUtils.isBlank(formDTO.getDistrict())){
if (StringUtils.isBlank(formDTO.getDistrict())) {
throw new RenException(CustomerAgencyConstant.DISTRICT_EXCEPTION);
}
}else if(!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel())){
if(StringUtils.isBlank(formDTO.getCity())){
} else if (!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel())) {
if (StringUtils.isBlank(formDTO.getCity())) {
throw new RenException(CustomerAgencyConstant.CITY_EXCEPTION);
}
}
@ -118,13 +118,13 @@ public class AgencyController {
**/
@PostMapping("addagency-v2")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_SUBAGENCY_CREATE)
public Result<AddAgencyResultDTO> addAgencyV2(@LoginUser TokenDto tokenDTO,@RequestBody AddAgencyV2FormDTO formDTO) {
public Result<AddAgencyResultDTO> addAgencyV2(@LoginUser TokenDto tokenDTO, @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(),tokenDTO.getCustomerId(),null,formDTO.getParentAgencyId());
customerAgencyService.checkAgencyName(formDTO.getAgencyName(), tokenDTO.getCustomerId(), null, formDTO.getParentAgencyId());
AddAgencyResultDTO resultDTO = agencyService.addAgencyV2(formDTO);
//2021-11-30 推送mq,数据同步到中介库 start
@ -141,6 +141,7 @@ public class AgencyController {
/**
* 添加根级组织
*
* @param form
* @return
*/
@ -175,7 +176,7 @@ public class AgencyController {
formDTO.setUserId(tokenDTO.getUserId());
formDTO.setCustomerId(tokenDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO, EditAgencyFormDTO.DefaultUserShowGroup.class, EditAgencyFormDTO.AddUserInternalGroup.class);
Result result = agencyService.editAgency(formDTO);
Result result = agencyService.editAgency(formDTO);
//2021-10-18 推送mq,数据同步到中介库 start【中介库只放了组织的名称、级别,所以涉及批量修改pname的操作不涉及同步中间库】
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
@ -245,6 +246,7 @@ public class AgencyController {
/**
* 根据Id查询agency
*
* @param agencyId
* @return
*/
@ -259,6 +261,7 @@ public class AgencyController {
/**
* 根据staffId查询
*
* @param staffId
* @return
*/
@ -275,6 +278,7 @@ public class AgencyController {
/**
* 查询客户根级组织
*
* @param customerId
* @return
*/
@ -286,6 +290,7 @@ public class AgencyController {
/**
* 批量查询客户根级组织
*
* @param customerIds
* @return
*/
@ -324,100 +329,101 @@ public class AgencyController {
}
/**
* @Description 地图配置删除
* @param formDTO
* @Description 地图配置删除
* @author zxc
* @date 2021/10/25 9:30 上午
*/
@PostMapping("mapdelarea")
public Result mapDelArea(@RequestBody MapDelAreaFormDTO formDTO){
public Result mapDelArea(@RequestBody MapDelAreaFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, MapDelAreaFormDTO.MapDelAreaForm.class);
agencyService.mapDelArea(formDTO);
return new Result();
}
/**
* @Description 地图配置新增
* @param formDTO
* @Description 地图配置新增
* @author zxc
* @date 2021/10/25 9:58 上午
*/
@PostMapping("mapaddarea")
public Result mapAddArea(@RequestBody MapAddAreaFormDTO formDTO){
public Result mapAddArea(@RequestBody MapAddAreaFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, MapAddAreaFormDTO.MapAddAreaForm.class);
agencyService.mapAddArea(formDTO);
return new Result();
}
/**
* @Description 地图配置组织查询
* @param formDTO
* @param tokenDto
* @Description 地图配置组织查询
* @author zxc
* @date 2021/10/25 10:50 上午
*/
@PostMapping("maporg")
public Result<MapOrgResultDTO> mapOrg(@RequestBody MapOrgFormDTO formDTO, @LoginUser TokenDto tokenDto){
return new Result<MapOrgResultDTO>().ok(agencyService.mapOrg(formDTO,tokenDto));
public Result<MapOrgResultDTO> mapOrg(@RequestBody MapOrgFormDTO formDTO, @LoginUser TokenDto tokenDto) {
return new Result<MapOrgResultDTO>().ok(agencyService.mapOrg(formDTO, tokenDto));
}
/**
* @Description 查询楼栋信息
* @param formDTO
* @Description 查询楼栋信息
* @author zxc
* @date 2021/11/2 9:18 上午
*/
@PostMapping("baseinfofamilybuilding")
public Result<List<BaseInfoFamilyBuildingResultDTO>> baseInfoFamilyBuilding(@RequestBody BaseInfoFamilyBuildingFormDTO formDTO){
public Result<List<BaseInfoFamilyBuildingResultDTO>> baseInfoFamilyBuilding(@RequestBody BaseInfoFamilyBuildingFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, BaseInfoFamilyBuildingFormDTO.BaseInfoFamilyBuildingForm.class);
return new Result<List<BaseInfoFamilyBuildingResultDTO>>().ok(agencyService.baseInfoFamilyBuilding(formDTO));
}
/**
* @Description 查询下级agencyId
* @param orgId
* @Description 查询下级agencyId
* @author zxc
* @date 2021/12/9 4:42 下午
*/
@PostMapping("getsonagencyid")
public Result<List<SonOrgResultDTO>> getSonAgencyId(@RequestParam("orgId")String orgId,@RequestParam("type")String type){
return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type));
public Result<List<SonOrgResultDTO>> getSonAgencyId(@RequestParam("orgId") String orgId, @RequestParam("type") String type) {
return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId, type));
}
/**
* Desc: 生成某类型下的二维码
*
* @param formDTO
* @author zxc
* @date 2022/3/2 10:32 上午
*/
@PostMapping("create-qrcode")
public void createQrCode(@LoginUser TokenDto tokenDto, @RequestBody CreateQrCodeFormDTO formDTO, HttpServletResponse response){
public void createQrCode(@LoginUser TokenDto tokenDto, @RequestBody CreateQrCodeFormDTO formDTO, HttpServletResponse response) {
ValidatorUtils.validateEntity(formDTO, CreateQrCodeFormDTO.CreateQrCodeForm.class);
String id = formDTO.getId();
String type = formDTO.getType();
String name = "";
try {
if (type.equals(OrgInfoConstant.COMMUNITY)){
if (type.equals(OrgInfoConstant.COMMUNITY)) {
CustomerAgencyDTO customerAgencyDTO = customerAgencyService.get(id);
if (customerAgencyDTO == null){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"组织信息不存在");
if (customerAgencyDTO == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组织信息不存在");
}
name = customerAgencyDTO.getOrganizationName();
}else if (type.equals(OrgInfoConstant.NEIGHBOR_HOOD)){
} else if (type.equals(OrgInfoConstant.NEIGHBOR_HOOD)) {
IcNeighborHoodDTO icNeighborHoodDTO = neighborHoodService.get(id);
if (icNeighborHoodDTO == null){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在");
if (icNeighborHoodDTO == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "小区信息不存在");
}
name = icNeighborHoodDTO.getNeighborHoodName();
}
//url组成:数字社区地址?小区id&用户id
//String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id;
String url = EnvEnum.getCurrentEnv().getUrl()
.replace("cloud","open")
.replace("cloud", "open")
.replace("api/", StrConstant.EPMETY_STR)
.concat("epmet-oper-gov/#/caiji/")
.concat(id).concat("?")
.concat("name=").concat(URLEncoder.encode(name,StrConstant.UTF_8)).concat(StrConstant.AND_MARK)
.concat("name=").concat(URLEncoder.encode(name, StrConstant.UTF_8)).concat(StrConstant.AND_MARK)
.concat("customerId=").concat(tokenDto.getCustomerId()).concat(StrConstant.AND_MARK)
.concat("type=").concat(type).concat(StrConstant.AND_MARK)
.concat("userId=").concat(tokenDto.getUserId())
@ -429,18 +435,18 @@ public class AgencyController {
ImageIO.write(image, "png", imageOutput);
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
long length = imageOutput.length();
String fileName = name+".png";
String fileName = name + ".png";
response.setContentType("application/octet-stream");
response.setContentLength((int)length);
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName, StrConstant.UTF_8));
response.setContentLength((int) length);
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StrConstant.UTF_8));
//输出流
byte[] bytes = new byte[1024];
OutputStream outputStream = response.getOutputStream();
long count = 0;
while(count < length){
while (count < length) {
int len = inputStream.read(bytes, 0, 1024);
count +=len;
count += len;
outputStream.write(bytes, 0, len);
}
outputStream.flush();
@ -451,12 +457,28 @@ public class AgencyController {
/**
* Desc: 查询工作人员所属组织下的所有社区
*
* @param tokenDto
* @author zxc
* @date 2022/3/21 15:13
*/
@PostMapping("community-list")
public Result<List<CommunityListResultDTO>> getCommunityList(@LoginUser TokenDto tokenDto){
public Result<List<CommunityListResultDTO>> getCommunityList(@LoginUser TokenDto tokenDto) {
return new Result<List<CommunityListResultDTO>>().ok(agencyService.getCommunityList(tokenDto));
}
/**
* 通讯录树状结构
*
* @param name
* @param tokenDto
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.AgencyAddressBookTreeResultDTO>>
* @author LZN
* @date 2022/5/16 10:42
*/
@GetMapping("/orgtree/{name}/{customerId}")
public Result<List<AgencyAddressBookTreeResultDTO>> getAddressTree(@PathVariable String name, @PathVariable String customerId) {
List<AgencyAddressBookTreeResultDTO> dto = agencyService.getAddressTree(name, customerId);
return new Result<List<AgencyAddressBookTreeResultDTO>>().ok(dto);
}
}

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

@ -295,26 +295,40 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
/**
* desc:获取组织和网格的数据 树形sql
*
* @param agencyId
* @return
*/
ExtStaffPermissionResultDTO selectAgencyAndGridById(@Param("agencyId") String agencyId);
/**
* @Description 事件社区服务热线
* @author sun
**/
OrgMobileResultDTO getAgencyMobile(@Param("gridId") String gridId);
int updateSubAgencyAreaCodeById(@Param("customerId")String customerId, @Param("agencyId")String agencyId, @Param("operateUserId") String operateUserId);
int updateSubAgencyAreaCodeById(@Param("customerId") String customerId, @Param("agencyId") String agencyId, @Param("operateUserId") String operateUserId);
/**
* Desc: 查询组织下的社区
*
* @param customerId
* @param agencyId
* @author zxc
* @date 2022/3/21 15:23
*/
List<CommunityListResultDTO> getCommunityList(@Param("customerId")String customerId, @Param("agencyId")String agencyId);
List<CommunityListResultDTO> getCommunityList(@Param("customerId") String customerId, @Param("agencyId") String agencyId);
/**
* 通讯录树
*
* @param name
* @param customerId
* @return java.util.List<com.epmet.dto.result.AgencyAddressBookTreeResultDTO>
* @author LZN
* @date 2022/5/16 10:44
*/
List<AgencyAddressBookTreeResultDTO> getAddressTree(@Param("name") String name,
@Param("customerId") String customerId);
}

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

@ -66,6 +66,7 @@ public interface AgencyService {
/**
* 根据Id查询
*
* @param agencyId
* @return
*/
@ -75,6 +76,7 @@ public interface AgencyService {
/**
* 查询客户根级组织
*
* @param customerId
*/
CustomerAgencyDTO getCustomerRootAgency(String customerId);
@ -99,52 +101,63 @@ public interface AgencyService {
AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO);
/**
* @Description 地图配置删除
* @param formDTO
* @Description 地图配置删除
* @author zxc
* @date 2021/10/25 9:30 上午
*/
void mapDelArea(MapDelAreaFormDTO formDTO);
/**
* @Description 地图配置新增
* @param formDTO
* @Description 地图配置新增
* @author zxc
* @date 2021/10/25 9:58 上午
*/
void mapAddArea(MapAddAreaFormDTO formDTO);
/**
* @Description 地图配置组织查询
* @param formDTO
* @param tokenDto
* @Description 地图配置组织查询
* @author zxc
* @date 2021/10/25 10:50 上午
*/
MapOrgResultDTO mapOrg(MapOrgFormDTO formDTO, TokenDto tokenDto);
/**
* @Description 查询楼栋信息
* @param formDTO
* @Description 查询楼栋信息
* @author zxc
* @date 2021/11/2 9:18 上午
*/
List<BaseInfoFamilyBuildingResultDTO> baseInfoFamilyBuilding(BaseInfoFamilyBuildingFormDTO formDTO);
/**
* @Description 查询下级agencyId
* @param orgId
* @Description 查询下级agencyId
* @author zxc
* @date 2021/12/9 4:42 下午
*/
List<SonOrgResultDTO> getSonAgencyId(String orgId,String type);
List<SonOrgResultDTO> getSonAgencyId(String orgId, String type);
/**
* Desc: 查询工作人员所属组织下的所有社区
*
* @param tokenDto
* @author zxc
* @date 2022/3/21 15:13
*/
List<CommunityListResultDTO> getCommunityList(TokenDto tokenDto);
/**
* 通讯录树状结构
*
* @param name
* @param customerId
* @return java.util.List<com.epmet.dto.result.AgencyAddressBookTreeResultDTO>
* @author LZN
* @date 2022/5/16 10:43
*/
List<AgencyAddressBookTreeResultDTO> getAddressTree(String name, String customerId);
}

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

@ -33,6 +33,7 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.NodeTreeUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.constant.OrgInfoConstant;
@ -156,15 +157,15 @@ public class AgencyServiceImpl implements AgencyService {
Result result = new Result();
CustomerAgencyEntity originalEntity = customerAgencyDao.selectById(formDTO.getAgencyId());
//当前客户下,同级组织中,组织名称不允许重复
customerAgencyService.checkAgencyName(formDTO.getAgencyName(),originalEntity.getCustomerId(),originalEntity.getId(),originalEntity.getPid());
customerAgencyService.checkAgencyName(formDTO.getAgencyName(), originalEntity.getCustomerId(), originalEntity.getId(), originalEntity.getPid());
originalEntity.setOrganizationName(formDTO.getAgencyName());
originalEntity.setCode(formDTO.getCode());
originalEntity.setContacts(formDTO.getContacts());
originalEntity.setMobile(formDTO.getMobile());
if(StringUtils.isNotBlank(formDTO.getLatitude())){
if (StringUtils.isNotBlank(formDTO.getLatitude())) {
originalEntity.setLatitude(formDTO.getLatitude());
}
if(StringUtils.isNotBlank(formDTO.getLongitude())){
if (StringUtils.isNotBlank(formDTO.getLongitude())) {
originalEntity.setLongitude(formDTO.getLongitude());
}
originalEntity.setCenterAddress(formDTO.getCenterAddress());
@ -207,20 +208,20 @@ public class AgencyServiceImpl implements AgencyService {
}
//3:循环组织列表,查询每一个组织的所有上级组织重新拼接所有上级名称(allParentName)字段值
List<CustomerAgencyEntity> editList = new ArrayList<>();
agencyList.forEach(agency->{
agencyList.forEach(agency -> {
//3-1:查询当前组织的所有上级组织
List<String> listStr = Arrays.asList(agency.getPids().split(":"));
List<ParentListResultDTO> parentList = customerAgencyDao.selectPAgencyById(listStr);
//3-2:重新拼接当前组织的所有上级名称字段值,将组织Id和拼好的值存入集合
StringBuffer allParentName = new StringBuffer();
parentList.forEach(parents->{
if(StringUtils.isBlank(allParentName)){
parentList.forEach(parents -> {
if (StringUtils.isBlank(allParentName)) {
allParentName.append(parents.getName());
}else {
} else {
allParentName.append("-").append(parents.getName());
}
});
CustomerAgencyEntity customerAgencyEntity = ConvertUtils.sourceToTarget(agency,CustomerAgencyEntity.class);
CustomerAgencyEntity customerAgencyEntity = ConvertUtils.sourceToTarget(agency, CustomerAgencyEntity.class);
customerAgencyEntity.setAllParentName(allParentName.toString());
customerAgencyEntity.setUpdatedBy(formDTO.getUserId());
editList.add(customerAgencyEntity);
@ -240,11 +241,12 @@ public class AgencyServiceImpl implements AgencyService {
/**
* 所有下家组织网格部门的area_codeparent_area_code置为空
* 直属组织parent_area_code直属网格+直属部门的area_code更新为最新值
*
* @param customerId
* @param formDTO
* @param originalAreaCode
*/
private void updateSubOrg(String customerId, EditAgencyFormDTO formDTO,String originalAreaCode) {
private void updateSubOrg(String customerId, EditAgencyFormDTO formDTO, String originalAreaCode) {
//如果原来这个组织有area_code再去更新,没有其实应该按照pids去更新。
customerAgencyDao.updateSubAgencyAreaCodeById(customerId, formDTO.getAgencyId(), formDTO.getUserId());
//网格的
@ -254,40 +256,39 @@ public class AgencyServiceImpl implements AgencyService {
//1、更新直属网格的areaCode
LambdaUpdateWrapper<CustomerGridEntity> updateGridWrapper = new LambdaUpdateWrapper<>();
updateGridWrapper.eq(CustomerGridEntity::getPid,formDTO.getAgencyId())
updateGridWrapper.eq(CustomerGridEntity::getPid, formDTO.getAgencyId())
.set(CustomerGridEntity::getAreaCode, formDTO.getAreaCode())
.set(CustomerGridEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerGridEntity::getUpdatedTime,new Date());
int subGridRows=customerGridDao.update(null,updateGridWrapper);
log.info(String.format("更新了%s个直属网格的area_code",subGridRows));
.set(CustomerGridEntity::getUpdatedBy, formDTO.getUserId())
.set(CustomerGridEntity::getUpdatedTime, new Date());
int subGridRows = customerGridDao.update(null, updateGridWrapper);
log.info(String.format("更新了%s个直属网格的area_code", subGridRows));
// 2、更新直属部门的area_code
LambdaUpdateWrapper<CustomerDepartmentEntity> updateDeptWrapper = new LambdaUpdateWrapper<>();
updateDeptWrapper.eq(CustomerDepartmentEntity::getAgencyId,formDTO.getAgencyId())
updateDeptWrapper.eq(CustomerDepartmentEntity::getAgencyId, formDTO.getAgencyId())
.set(CustomerDepartmentEntity::getAreaCode, formDTO.getAreaCode())
.set(CustomerDepartmentEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerDepartmentEntity::getUpdatedTime,new Date());
int gridRows=customerDepartmentDao.update(null,updateDeptWrapper);
log.info(String.format("更新了%s个直属部门的area_code",gridRows));
.set(CustomerDepartmentEntity::getUpdatedBy, formDTO.getUserId())
.set(CustomerDepartmentEntity::getUpdatedTime, new Date());
int gridRows = customerDepartmentDao.update(null, updateDeptWrapper);
log.info(String.format("更新了%s个直属部门的area_code", gridRows));
// 3、更新下级组织的parent_area_code
LambdaUpdateWrapper<CustomerAgencyEntity> updateAgencyWrapper = new LambdaUpdateWrapper<>();
updateAgencyWrapper.eq(CustomerAgencyEntity::getPid,formDTO.getAgencyId())
updateAgencyWrapper.eq(CustomerAgencyEntity::getPid, formDTO.getAgencyId())
.set(CustomerAgencyEntity::getParentAreaCode, formDTO.getAreaCode())
.set(CustomerAgencyEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerAgencyEntity::getUpdatedTime,new Date());
.set(CustomerAgencyEntity::getUpdatedBy, formDTO.getUserId())
.set(CustomerAgencyEntity::getUpdatedTime, new Date());
Integer rows = customerAgencyDao.update(null, updateAgencyWrapper);
log.info(String.format("更新了%s个下级组织的parent_area_code",rows));
log.info(String.format("更新了%s个下级组织的parent_area_code", rows));
}
/**
*
* @param formDTO 编辑组织入参
* @param parent 当前编辑组织的上级组织
* @param parent 当前编辑组织的上级组织
* @return 返回组织区划编码
*/
private String getAgencyNewAreaCode(EditAgencyFormDTO formDTO, CustomerAgencyEntity parent) {
String newAreaCode="";
String newAreaCode = "";
if (!"other".equals(formDTO.getAreaCode())) {
//校验除了当前组织外,areaCode是否被使用过
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(formDTO.getAreaCode(), formDTO.getAgencyId());
@ -295,7 +296,7 @@ public class AgencyServiceImpl implements AgencyService {
//已经被占用,提示
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg());
}
newAreaCode=formDTO.getAreaCode();
newAreaCode = formDTO.getAreaCode();
} else {
//如果选择的是other,需要自定义一个编码
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO();
@ -310,16 +311,17 @@ public class AgencyServiceImpl implements AgencyService {
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg());
}
}
newAreaCode=addAreaCodeResult.getData();
newAreaCode = addAreaCodeResult.getData();
}
return newAreaCode;
}
/**
* 如果当前客户开启了areaCode校验参数逼单
*
* @param formDTO
*/
private void checkEditAgencyFormDTO(EditAgencyFormDTO formDTO,CustomerAgencyEntity originalEntity) {
private void checkEditAgencyFormDTO(EditAgencyFormDTO formDTO, CustomerAgencyEntity originalEntity) {
//根组织不允许修改
if (StringUtils.isNotBlank(originalEntity.getPid()) && !NumConstant.ZERO_STR.equals(originalEntity.getPid())) {
//03.23:平阴线上版本与产品主线版本差距太大,平阴的修改组织只能修改组织名称。
@ -364,14 +366,14 @@ public class AgencyServiceImpl implements AgencyService {
return result;
}
//3:组织下有网格,不允许删除
int gridCount = customerGridDao.selectGridCountByAgencyId(formDTO.getAgencyId());
int gridCount = customerGridDao.selectGridCountByAgencyId(formDTO.getAgencyId());
if (gridCount > NumConstant.ZERO) {
result.setCode(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getCode());
result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getMsg());
return result;
}
//4:删除当前机关组织(逻辑删)
if (customerAgencyDao.delByAgencyId(formDTO.getAgencyId(),loginUserUtil.getLoginUserId()) < NumConstant.ONE) {
if (customerAgencyDao.delByAgencyId(formDTO.getAgencyId(), loginUserUtil.getLoginUserId()) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.DEL_EXCEPTION);
throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION);
}
@ -403,24 +405,24 @@ public class AgencyServiceImpl implements AgencyService {
agencysResultDTO.setMobile(entity.getMobile());
agencysResultDTO.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(entity.getCustomerId()));
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR);
agencysResultDTO.setAreaCode(StringUtils.isNotBlank(entity.getAreaCode())?entity.getAreaCode():StrConstant.EPMETY_STR);
agencysResultDTO.setAreaCode(StringUtils.isNotBlank(entity.getAreaCode()) ? entity.getAreaCode() : StrConstant.EPMETY_STR);
//查询组织区划的名称
if (null != entity && StringUtils.isNotBlank(entity.getAreaCode())) {
switch (entity.getLevel()) {
case CustomerAgencyConstant.PROVINCE_LEVEL:
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getProvince()) ? entity.getProvince():entity.getOrganizationName());
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getProvince()) ? entity.getProvince() : entity.getOrganizationName());
break;
case CustomerAgencyConstant.CITY_LEVEL:
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCity()) ? entity.getCity():entity.getOrganizationName());
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCity()) ? entity.getCity() : entity.getOrganizationName());
break;
case CustomerAgencyConstant.DISTRICT:
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getDistrict()) ? entity.getDistrict():entity.getOrganizationName());
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getDistrict()) ? entity.getDistrict() : entity.getOrganizationName());
break;
case CustomerAgencyConstant.STREET_LEVEL:
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getStreet()) ? entity.getStreet():entity.getOrganizationName());
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getStreet()) ? entity.getStreet() : entity.getOrganizationName());
break;
case CustomerAgencyConstant.COMMUNITY_LEVEL:
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCommunity()) ? entity.getCommunity():entity.getOrganizationName());
agencysResultDTO.setAreaName(StringUtils.isNotBlank(entity.getCommunity()) ? entity.getCommunity() : entity.getOrganizationName());
break;
default:
agencysResultDTO.setAreaName(StrConstant.EPMETY_STR);
@ -504,7 +506,7 @@ public class AgencyServiceImpl implements AgencyService {
}
customerAgencyRedis.set(agencyId, agencyInfoCache);
}
CustomerAgencyDTO customerAgencyDTO=ConvertUtils.sourceToTarget(agencyInfoCache,CustomerAgencyDTO.class);
CustomerAgencyDTO customerAgencyDTO = ConvertUtils.sourceToTarget(agencyInfoCache, CustomerAgencyDTO.class);
return customerAgencyDTO;
}
@ -547,7 +549,7 @@ public class AgencyServiceImpl implements AgencyService {
@Override
public CustomerAgencyDTO getCustomerRootAgency(String customerId) {
CustomerAgencyDTO root=customerAgencyDao.getCustomerRootAgency(customerId);
CustomerAgencyDTO root = customerAgencyDao.getCustomerRootAgency(customerId);
if (null != root) {
root.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(customerId));
}
@ -652,17 +654,17 @@ public class AgencyServiceImpl implements AgencyService {
}
AddAgencyResultDTO resultDTO = new AddAgencyResultDTO();
resultDTO.setAreaCodeSwitch(formDTO.getAreaCodeSwitch());
CustomerAgencyEntity insertEntity=this.constructInsertEntity(formDTO,parent);
CustomerAgencyEntity insertEntity = this.constructInsertEntity(formDTO, parent);
//判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) {
//校验areaCode是否被使用过
if (!"other".equals(formDTO.getAreaCode())) {
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(insertEntity.getAreaCode(),null);
List<String> agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(insertEntity.getAreaCode(), null);
if (CollectionUtils.isNotEmpty(agencyIds)) {
//已经被占用,提示
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg());
}
}else{
} else {
//如果选择的是other,需要自定义一个编码
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO();
addAreaCodeFormDTO.setCurrentAreaLevel(formDTO.getLevel());
@ -688,19 +690,19 @@ public class AgencyServiceImpl implements AgencyService {
}
/**
* @Description 地图配置删除
* @param formDTO
* @Description 地图配置删除
* @author zxc
* @date 2021/10/25 9:30 上午
*/
@Override
public void mapDelArea(MapDelAreaFormDTO formDTO) {
customerAgencyDao.delMapArea(formDTO.getOrgId(),formDTO.getLevel());
customerAgencyDao.delMapArea(formDTO.getOrgId(), formDTO.getLevel());
}
/**
* @Description 地图配置新增
* @param formDTO
* @Description 地图配置新增
* @author zxc
* @date 2021/10/25 9:58 上午
*/
@ -710,14 +712,14 @@ public class AgencyServiceImpl implements AgencyService {
}
/**
* @param formDTO
* @param tokenDto
* @Description 地图配置组织查询
* 根据level查询去查询不同的表类型组织agency网格grid小区neighborHood
* 组织类型去查 customer_agency看本级是不是 community下级组织就是网格查询customer_grid不是继续查customer_agency
* 网格类型去查 查询customer_grid下级去查 ic_neighbor_hood
* 当前组织没有经纬度的话直接赋值根组织的经纬度
* 下级组织经纬度为空的话直接赋值上级的经纬度
* @param formDTO
* @param tokenDto
* @author zxc
* @date 2021/10/25 10:50 上午
*/
@ -725,38 +727,38 @@ public class AgencyServiceImpl implements AgencyService {
public MapOrgResultDTO mapOrg(MapOrgFormDTO formDTO, TokenDto tokenDto) {
MapOrgResultDTO result = new MapOrgResultDTO();
LambdaQueryWrapper<CustomerAgencyEntity> qw = new LambdaQueryWrapper();
qw.eq(CustomerAgencyEntity::getPid, NumConstant.ZERO_STR).eq(CustomerAgencyEntity::getDelFlag, NumConstant.ZERO_STR).eq(CustomerAgencyEntity::getCustomerId,tokenDto.getCustomerId());
qw.eq(CustomerAgencyEntity::getPid, NumConstant.ZERO_STR).eq(CustomerAgencyEntity::getDelFlag, NumConstant.ZERO_STR).eq(CustomerAgencyEntity::getCustomerId, tokenDto.getCustomerId());
CustomerAgencyEntity customerAgencyEntity = customerAgencyDao.selectOne(qw);
if (StringUtils.isBlank(formDTO.getOrgId())){
if (StringUtils.isBlank(formDTO.getOrgId())) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == staffInfo){
if (null == staffInfo) {
return result;
}
formDTO.setOrgId(staffInfo.getAgencyId());
formDTO.setLevel(OrgInfoConstant.AGENCY);
}
if (StringUtils.isNotBlank(customerAgencyEntity.getLatitude())){
if (StringUtils.isNotBlank(customerAgencyEntity.getLatitude())) {
result.setLatitude(new BigDecimal(customerAgencyEntity.getLatitude()));
}
if (StringUtils.isNotBlank(customerAgencyEntity.getLongitude())){
if (StringUtils.isNotBlank(customerAgencyEntity.getLongitude())) {
result.setLongitude(new BigDecimal(customerAgencyEntity.getLongitude()));
}
if (formDTO.getLevel().equals(OrgInfoConstant.AGENCY)){
if (formDTO.getLevel().equals(OrgInfoConstant.AGENCY)) {
CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getOrgId());
result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class);
result = ConvertUtils.sourceToTarget(entity, MapOrgResultDTO.class);
result.setName(entity.getOrganizationName());
result.setLevel(formDTO.getLevel());
result.setAgencyLevel(entity.getLevel());
//经纬度 如果本级没有则取根级组织的 根级没有就空着
if (StringUtils.isNotBlank(entity.getLatitude())){
if (StringUtils.isNotBlank(entity.getLatitude())) {
result.setLatitude(new BigDecimal(entity.getLatitude()));
}
if (StringUtils.isNotBlank(entity.getLongitude())){
if (StringUtils.isNotBlank(entity.getLongitude())) {
result.setLongitude(new BigDecimal(entity.getLongitude()));
}
if (entity.getLevel().equals(OrgInfoConstant.COMMUNITY)){
if (entity.getLevel().equals(OrgInfoConstant.COMMUNITY)) {
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID);
if (CollectionUtils.isNotEmpty(son)){
if (CollectionUtils.isNotEmpty(son)) {
MapOrgResultDTO finalResult = result;
son.forEach(s -> {
s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? finalResult.getLatitude() : new BigDecimal(s.getLatitudeOrigin()));
@ -764,15 +766,15 @@ public class AgencyServiceImpl implements AgencyService {
});
}
result.setChildren(CollectionUtils.isEmpty(son) ? new ArrayList<>() : son);
}else {
} else {
List<MapSonOrgResultDTO> dtoList = new ArrayList<>();
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.AGENCY);
if (CollectionUtils.isNotEmpty(son)){
if (CollectionUtils.isNotEmpty(son)) {
dtoList.addAll(son);
}
// 直属网格
List<MapSonOrgResultDTO> directlySub = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID);
if (CollectionUtils.isNotEmpty(directlySub)){
if (CollectionUtils.isNotEmpty(directlySub)) {
dtoList.addAll(directlySub);
}
for (MapSonOrgResultDTO d : dtoList) {
@ -781,21 +783,21 @@ public class AgencyServiceImpl implements AgencyService {
}
result.setChildren(dtoList);
}
}else if (formDTO.getLevel().equals(OrgInfoConstant.GRID)){
} else if (formDTO.getLevel().equals(OrgInfoConstant.GRID)) {
CustomerGridEntity entity = customerGridDao.selectById(formDTO.getOrgId());
result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class);
result = ConvertUtils.sourceToTarget(entity, MapOrgResultDTO.class);
result.setName(entity.getGridName());
result.setLevel(formDTO.getLevel());
result.setAgencyLevel(OrgInfoConstant.GRID);
//经纬度 如果本级没有则取根级组织的 根级没有就空着
if (StringUtils.isNotBlank(entity.getLatitude())){
if (StringUtils.isNotBlank(entity.getLatitude())) {
result.setLatitude(new BigDecimal(entity.getLatitude()));
}
if (StringUtils.isNotBlank(entity.getLongitude())){
if (StringUtils.isNotBlank(entity.getLongitude())) {
result.setLongitude(new BigDecimal(entity.getLongitude()));
}
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.NEIGHBOR_HOOD);
if (CollectionUtils.isNotEmpty(son)){
if (CollectionUtils.isNotEmpty(son)) {
for (MapSonOrgResultDTO s : son) {
s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? result.getLatitude() : new BigDecimal(s.getLatitudeOrigin()));
s.setLongitude(StringUtils.isBlank(s.getLongitudeOrigin()) ? result.getLongitude() : new BigDecimal(s.getLongitudeOrigin()));
@ -807,35 +809,35 @@ public class AgencyServiceImpl implements AgencyService {
}
/**
* @Description 查询楼栋信息
* @param formDTO
* @Description 查询楼栋信息
* @author zxc
* @date 2021/11/2 9:18 上午
*/
@Override
public List<BaseInfoFamilyBuildingResultDTO> baseInfoFamilyBuilding(BaseInfoFamilyBuildingFormDTO formDTO) {
List<BaseInfoFamilyBuildingResultDTO> result = icBuildingDao.baseInfoFamilyBuilding(formDTO.getNeighborHoodId());
if (CollectionUtils.isEmpty(result)){
if (CollectionUtils.isEmpty(result)) {
return new ArrayList<>();
}
return result;
}
/**
* @Description 查询下级agencyId
* @param orgId
* @Description 查询下级agencyId
* @author zxc
* @date 2021/12/9 4:42 下午
*/
@Override
public List<SonOrgResultDTO> getSonAgencyId(String orgId,String type) {
public List<SonOrgResultDTO> getSonAgencyId(String orgId, String type) {
List<SonOrgResultDTO> result = new ArrayList<>();
if (type.equals("community")){
if (type.equals("community")) {
result = customerAgencyDao.getSonGridId(orgId);
}else {
} else {
result = customerAgencyDao.getSonAgencyId(orgId);
}
if (CollectionUtils.isNotEmpty(result)){
if (CollectionUtils.isNotEmpty(result)) {
return result;
}
return new ArrayList<>();
@ -843,6 +845,7 @@ public class AgencyServiceImpl implements AgencyService {
/**
* Desc: 查询工作人员所属组织下的所有社区
*
* @param tokenDto
* @author zxc
* @date 2022/3/21 15:13
@ -850,20 +853,36 @@ public class AgencyServiceImpl implements AgencyService {
@Override
public List<CommunityListResultDTO> getCommunityList(TokenDto tokenDto) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == staffInfo){
throw new EpmetException("未查询到工作人员信息"+staffInfo.getStaffId());
if (null == staffInfo) {
throw new EpmetException("未查询到工作人员信息" + staffInfo.getStaffId());
}
String agencyId = staffInfo.getAgencyId();
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId);
if (null == agencyInfo){
throw new EpmetException("查询组织信息失败"+agencyInfo);
if (null == agencyInfo) {
throw new EpmetException("查询组织信息失败" + agencyInfo);
}
if (agencyInfo.getLevel().equals(CustomerAgencyConstant.COMMUNITY_LEVEL)){
if (agencyInfo.getLevel().equals(CustomerAgencyConstant.COMMUNITY_LEVEL)) {
return new ArrayList<>();
}
return customerAgencyDao.getCommunityList(tokenDto.getCustomerId(), agencyId);
}
/**
* 通讯录树
*
* @param name
* @param customerId
* @return java.util.List<com.epmet.dto.result.AgencyAddressBookTreeResultDTO>
* @author LZN
* @date 2022/5/16 10:45
*/
@Override
public List<AgencyAddressBookTreeResultDTO> getAddressTree(String name, String customerId) {
List<AgencyAddressBookTreeResultDTO> list = customerAgencyDao.getAddressTree(name, customerId);
System.out.println(list);
return NodeTreeUtils.build(list);
}
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) {
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
insertEntity.setOrganizationName(formDTO.getAgencyName());
@ -879,8 +898,7 @@ public class AgencyServiceImpl implements AgencyService {
insertEntity.setPids(parent.getPids().concat(StrConstant.COLON).concat(parent.getId()));
insertEntity.setAllParentName(parent.getAllParentName().concat(StrConstant.HYPHEN).concat(parent.getOrganizationName()));
}
switch(parent.getLevel())
{
switch (parent.getLevel()) {
case CustomerAgencyConstant.PROVINCE_LEVEL:
insertEntity.setLevel(CustomerAgencyConstant.CITY_LEVEL);
insertEntity.setProvince(parent.getProvince());
@ -908,7 +926,7 @@ public class AgencyServiceImpl implements AgencyService {
insertEntity.setCommunity(formDTO.getAreaName());
break;
default:
log.info("parent.getLevel()="+parent.getLevel());
log.info("parent.getLevel()=" + parent.getLevel());
break;
}
return insertEntity;

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

@ -744,6 +744,61 @@
AND CUSTOMER_ID = #{customerId}
AND CONCAT(PIDS,':',ID) LIKE CONCAT('%',#{agencyId},'%')
</select>
<select id="getAddressTree" resultType="com.epmet.dto.result.AgencyAddressBookTreeResultDTO">
SELECT
a.id,
a.pid,
a.ORGANIZATION_NAME AS NAME,
a.CREATED_TIME,
a.LEVEL
FROM
customer_agency a
<where>
a.DEL_FLAG = '0'
<if test="customerId != null and customerId != ''">
AND a.CUSTOMER_ID = #{customerId}
</if>
<if test="name != null and name != ''">
AND a.ORGANIZATION_NAME LIKE '%${name}%'
</if>
</where>
UNION ALL
SELECT
d.id,
d.AGENCY_ID AS pid,
d.DEPARTMENT_NAME AS NAME,
d.CREATED_TIME,
0 AS LEVEL
FROM
customer_department d
<where>
d.DEL_FLAG = '0'
<if test="customerId != null and customerId != ''">
AND d.CUSTOMER_ID = #{customerId}
</if>
<if test="name != null and name != ''">
AND d.DEPARTMENT_NAME LIKE '%${name}%'
</if>
</where>
UNION ALL
SELECT
g.id,
g.pid,
g.GRID_NAME AS NAME,
g.CREATED_TIME,
0 AS LEVEL
FROM
customer_grid g
<where>
g.DEL_FLAG = '0'
<if test="customerId != null and customerId != ''">
AND g.CUSTOMER_ID = #{customerId}
</if>
<if test="name != null and name != ''">
AND g.GRID_NAME LIKE '%${name}%'
</if>
</where>
</select>
<update id="updateSubAgencyAreaCodeById" parameterType="map">
UPDATE customer_agency

Loading…
Cancel
Save