diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/commonservice/AddAreaCodeDictResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/commonservice/AddAreaCodeDictResultDTO.java new file mode 100644 index 0000000000..d3d0e59442 --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/commonservice/AddAreaCodeDictResultDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.result.commonservice; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 003、新增街道或者社区地区编码 入参 + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/5 17:39 + */ +@Data +public class AddAreaCodeDictResultDTO implements Serializable { + private static final long serialVersionUID = 7505566589581480619L; + private String code; + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java index 53646ee6dc..91672af42b 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java @@ -3,8 +3,10 @@ package com.epmet.datareport.controller.screen; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.datareport.service.evaluationindex.screen.AgencyService; +import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; +import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentByBizTypeFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO; @@ -27,7 +29,6 @@ public class AgencyController { @Autowired private AgencyService agencyService; - /** * @param * @Description 1、组织机构树 只返回 is_display = '1'的 @@ -81,4 +82,16 @@ public class AgencyController { return new Result>().ok(agencyService.areaCodeDictTree(formDTO)); } + /** + * @return com.epmet.commons.tools.utils.Result + * @param + * @author yinzuomei + * @description 003、新增街道或者社区地区编码 + * @Date 2021/2/5 17:39 + **/ + @PostMapping("addstreetcomm") + public Result addStreetCommAreaCode(@RequestBody AddAreaCodeDictFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(agencyService.addStreetCommAreaCode(formDTO)); + } } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java index 144e12fe1a..3812695176 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java @@ -1,7 +1,9 @@ package com.epmet.datareport.service.evaluationindex.screen; +import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; +import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentByBizTypeFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; import com.epmet.evaluationindex.screen.dto.form.TreeByTypeFormDTO; @@ -47,4 +49,5 @@ public interface AgencyService { */ List areaCodeDictTree(AreaCodeDictFormDTO formDTO); + AddAreaCodeDictResultDTO addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java index 5c720eee42..8252b44077 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java @@ -8,8 +8,10 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.datareport.service.evaluationindex.screen.AgencyService; +import com.epmet.dto.form.AddAreaCodeDictFormDTO; import com.epmet.dto.form.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; +import com.epmet.dto.result.commonservice.AddAreaCodeDictResultDTO; import com.epmet.evaluationindex.screen.constant.ScreenConstant; import com.epmet.evaluationindex.screen.dto.form.CompartmentByBizTypeFormDTO; import com.epmet.evaluationindex.screen.dto.form.CompartmentFormDTO; @@ -248,4 +250,15 @@ public class AgencyServiceImpl implements AgencyService { } return new ArrayList<>(); } + + @Override + public AddAreaCodeDictResultDTO addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO) { + Result res = commonServiceOpenFeignClient.addStreetCommAreaCode(formDTO); + if (res.success() && null != res.getData()) { + AddAreaCodeDictResultDTO resultDTO = new AddAreaCodeDictResultDTO(); + resultDTO.setCode(res.getData()); + return resultDTO; + } + throw new RenException(res.getMsg() + res.getInternalMsg()); + } } diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeChildDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeChildDTO.java index d3da19fa21..31f68bc86f 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeChildDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeChildDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -36,7 +37,7 @@ public class AreaCodeChildDTO implements Serializable { /** * 主键 */ - private Integer id; + private String id; /** * 省份code diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AddAreaCodeDictFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AddAreaCodeDictFormDTO.java new file mode 100644 index 0000000000..d97379ec72 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AddAreaCodeDictFormDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 003、新增街道或者社区地区编码 入参 + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/5 17:39 + */ +@Data +public class AddAreaCodeDictFormDTO implements Serializable { + /** + * 街道或者社区所属的上一级areaCode + */ + @NotBlank(message = "parentAreaCode不能为空") + private String parentAreaCode; + + /** + * 新增的街道或者社区名称 + */ + @NotBlank(message = "name不能为空") + private String name; + + /** + * 传入此列时,代表修改名称 + */ + private String code; +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java index 03bae0640b..66a1f46ee7 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java @@ -6,6 +6,7 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -19,7 +20,7 @@ import java.util.Map; * @date 2020/6/4 10:28 */ @FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103") +// @FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103") public interface EpmetCommonServiceOpenFeignClient { /** * @param formDTO @@ -103,4 +104,13 @@ public interface EpmetCommonServiceOpenFeignClient { */ @PostMapping("commonservice/areacode/areacodedicttree") Result> areaCodeDictTree(@RequestBody AreaCodeDictFormDTO formDTO); + + /** + * @param formDTO + * @author yinzuomei + * @description 003、新增街道或者社区地区编码 + * @Date 2021/2/5 17:39 + **/ + @PostMapping(value = "commonservice/areacode/addstreetcommareacode", consumes = MediaType.APPLICATION_JSON_VALUE) + Result addStreetCommAreaCode(@RequestBody AddAreaCodeDictFormDTO formDTO); } diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java index e7a9500143..d9731558cd 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java @@ -84,4 +84,9 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer public Result> areaCodeDictTree(AreaCodeDictFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeDictTree", formDTO); } + + @Override + public Result addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "addStreetCommAreaCode", formDTO); + } } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java index 5dc1747438..af8ecf093f 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java @@ -22,9 +22,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; 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.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.service.AreaCodeService; @@ -95,4 +96,15 @@ public class AreaCodeController { return new Result>().ok(areaCodeService.areaCodeDictTreePlus(formDTO)); } + /** + * @param formDTO + * @author yinzuomei + * @description 003、新增街道或者社区地区编码 + * @Date 2021/2/5 17:39 + **/ + @PostMapping("addstreetcommareacode") + Result addStreetCommAreaCode(@RequestBody AddAreaCodeDictFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(areaCodeService.addStreetCommAreaCode(formDTO)); + } } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeChildDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeChildDao.java index a0b28216b9..24339f6397 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeChildDao.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeChildDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.AreaCodeChildDTO; import com.epmet.entity.AreaCodeChildEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -35,4 +36,9 @@ public interface AreaCodeChildDao extends BaseDao { List selectAllChild(); + AreaCodeChildDTO selectByCode(@Param("code") String code); + + List selectByPCodeAndName(@Param("parentAreaCode") String parentAreaCode, @Param("name") String name); + + AreaCodeChildDTO selectMaxChild(@Param("parentAreaCode") String parentAreaCode); } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java index 45222bbb53..415712de43 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java @@ -20,10 +20,10 @@ package com.epmet.service; 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.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.entity.AreaCodeEntity; -import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; @@ -105,4 +105,12 @@ public interface AreaCodeService extends BaseService { List areaCodeDictTree(AreaCodeDictFormDTO formDTO); List areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO); + + /** + * @param formDTO + * @author yinzuomei + * @description 003、新增街道或者社区地区编码 + * @Date 2021/2/5 17:39 + **/ + String addStreetCommAreaCode(AddAreaCodeDictFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java index 9b67de52a2..051a431ddd 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java @@ -17,12 +17,14 @@ package com.epmet.service.impl; +import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; 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.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; @@ -31,10 +33,12 @@ import com.epmet.dao.AreaCodeChildDao; 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.AreaCodeDictFormDTO; import com.epmet.dto.result.AreaCodeDictResultDTO; import com.epmet.entity.AreaCodeEntity; import com.epmet.redis.AreaCodeRedis; +import com.epmet.service.AreaCodeChildService; import com.epmet.service.AreaCodeService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -58,7 +62,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -554,4 +559,53 @@ public class AreaCodeServiceImpl extends BaseServiceImpl list = childDao.selectByPCodeAndName(formDTO.getParentAreaCode().trim(), formDTO.getName().trim()); + if (CollUtil.isNotEmpty(list)) { + throw new RenException("name已存在"); + } + AreaCodeChildDTO areaCodeChildDTO = new AreaCodeChildDTO(); + areaCodeChildDTO.setName(formDTO.getName().trim()); + areaCodeChildDTO.setPCode(formDTO.getParentAreaCode().trim()); + //4:街道;5:社区或村委会 + areaCodeChildDTO.setLevel(formDTO.getParentAreaCode().length() == NumConstant.SIX ? NumConstant.FOUR : NumConstant.FIVE); + //获取子级中最大的编码 + AreaCodeChildDTO maxChildDto = childDao.selectMaxChild(formDTO.getParentAreaCode().trim()); + if (null == maxChildDto) { + //默认添加001 + areaCodeChildDTO.setCode(formDTO.getParentAreaCode().concat("001_UD")); + } else { + //去掉_UD +1赋值;370124001225_UD 锦源社区 + String[] codeArr = maxChildDto.getCode().split(StrConstant.UNDER_LINE); + long code = Long.parseLong(codeArr[NumConstant.ZERO]) + NumConstant.ONE; + areaCodeChildDTO.setCode(String.valueOf(code).concat("_UD")); + } + //保存到area_code_child表 + areaCodeChildService.save(areaCodeChildDTO); + return areaCodeChildDTO.getCode(); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml index 0dfe0d02f1..422565051c 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml @@ -7,4 +7,40 @@ + + + + + + + + \ No newline at end of file