diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 3d26395c0e..fad4233d80 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -19,6 +19,9 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.enums.OrgLevelEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; @@ -41,6 +44,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -564,4 +568,54 @@ public class CustomerAgencyController { return new Result>().ok(customerAgencyService.getCommunityList(dto)); } + /** + * 返回区县列表 + * @param tokenDto + * @return + */ + @PostMapping("districtList") + public Result> districtList(@LoginUser TokenDto tokenDto){ + Map params=new HashMap<>(); + params.put("CUSTOMER_ID",tokenDto.getCustomerId()); + params.put("LEVEL",OrgLevelEnum.DISTRICT.getCode()); + params.put("PID",null); + return new Result>().ok(customerAgencyService.list(params)); + } + + /** + * 返回街道列表,必传区县 + * @param tokenDto + * @param districtId + * @return + */ + @PostMapping("streetList/{districtId}") + public Result> streetList(@LoginUser TokenDto tokenDto,@PathVariable("districtId")String districtId){ + if(StringUtils.isBlank(districtId)){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"districtId为空","请先选择区县"); + } + Map params=new HashMap<>(); + params.put("CUSTOMER_ID",tokenDto.getCustomerId()); + params.put("LEVEL",OrgLevelEnum.STREET.getCode()); + params.put("PID",districtId); + return new Result>().ok(customerAgencyService.list(params)); + } + + /** + * 返回社区列表,街道必传 + * @param tokenDto + * @param streetId + * @return + */ + @PostMapping("communityList/{streetId}") + public Result> communityList(@LoginUser TokenDto tokenDto,@PathVariable("streetId")String streetId){ + if(StringUtils.isBlank(streetId)){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"streetId为空","请先选择街道"); + } + Map params=new HashMap<>(); + params.put("CUSTOMER_ID",tokenDto.getCustomerId()); + params.put("LEVEL",OrgLevelEnum.COMMUNITY.getCode()); + params.put("PID",streetId); + return new Result>().ok(customerAgencyService.list(params)); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index 4585f7481d..87f0555690 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -18,7 +18,6 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -45,7 +44,6 @@ import com.epmet.constant.CustomerGridConstant; import com.epmet.dao.*; import com.epmet.dto.*; import com.epmet.dto.form.*; -import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerDepartmentEntity; @@ -136,12 +134,16 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl getWrapper(Map params) { - String id = (String) params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - + private LambdaQueryWrapper getWrapper(Map map) { + String id = map.containsKey(FieldConstant.ID_HUMP) ? (String) map.get(FieldConstant.ID_HUMP) : null; + String customerId = map.containsKey("CUSTOMER_ID") ? (String) map.get("CUSTOMER_ID") : null; + String level = map.containsKey("LEVEL") ? (String) map.get("LEVEL") : null; + String pid = map.containsKey("PID") ? (String) map.get("PID") : null; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), CustomerAgencyEntity::getId, id) + .eq(StringUtils.isNotBlank(customerId), CustomerAgencyEntity::getCustomerId, customerId) + .eq(StringUtils.isNotBlank(level), CustomerAgencyEntity::getLevel, level) + .eq(StringUtils.isNotBlank(pid), CustomerAgencyEntity::getPid, pid); return wrapper; } @@ -1244,7 +1246,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl agencyList, List gridList) {