From 0f973b472d69bb29d01bb55d95b0d452b30b64c0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 22 Dec 2021 10:15:33 +0800 Subject: [PATCH 01/44] =?UTF-8?q?=E5=A4=9A=E4=B8=80=E4=B8=AA=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=20=E6=80=95=E5=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/feign/EpmetAdminOpenFeignClient.java | 11 +++++++++++ .../fallback/EpmetAdminOpenFeignClientFallback.java | 6 ++++++ .../commons/tools/dto/result/DictTreeResultDTO.java | 2 -- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java index 6d7e1124dd..9068180318 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.form.DictListFormDTO; import com.epmet.commons.tools.dto.result.DictListResultDTO; +import com.epmet.commons.tools.dto.result.DictTreeResultDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.CorsConfigResultDTO; @@ -88,6 +89,16 @@ public interface EpmetAdminOpenFeignClient { @PostMapping("/sys/dict/data/dictmap/{dictType}") Result> dictMap(@PathVariable("dictType") String dictType); + /** + * 字典数据查询通用接口 + * @Param dictType + * @Return {@link Result< Map < String, String>>} + * @Author zhaoqifeng + * @Date 2021/11/19 17:36 + */ + @PostMapping("/sys/dict/data/dictTree/{dictType}") + Result> dictTree(@PathVariable("dictType") String dictType); + @PostMapping("/sys/dict/data/dictlist") Result> dictList(@RequestBody DictListFormDTO formDTO); } diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java index 6c16e8f3ae..110ba490e3 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java @@ -3,6 +3,7 @@ package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.form.DictListFormDTO; import com.epmet.commons.tools.dto.result.DictListResultDTO; +import com.epmet.commons.tools.dto.result.DictTreeResultDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; @@ -49,6 +50,11 @@ public class EpmetAdminOpenFeignClientFallback implements EpmetAdminOpenFeignCli return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "dictMap", dictType); } + @Override + public Result> dictTree(String dictType) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "dictTree", dictType); + } + @Override public Result> dictList(DictListFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "dictList", formDTO); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/DictTreeResultDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/DictTreeResultDTO.java index 7314d941a8..c8aef8f93f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/DictTreeResultDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/DictTreeResultDTO.java @@ -1,7 +1,6 @@ package com.epmet.commons.tools.dto.result; import com.epmet.commons.tools.utils.TreeStringNode; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -16,7 +15,6 @@ public class DictTreeResultDTO extends TreeStringNode impleme /** * 上级ID */ - @JsonIgnore private String pid; private String name; } From 17232934fa700781f9e4259c53d78e58c939d14c Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 22 Dec 2021 17:54:21 +0800 Subject: [PATCH 02/44] bugfix --- .../src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 54a8c7f674..4d6b728387 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -688,5 +688,5 @@ public interface EpmetUserOpenFeignClient { * @return */ @GetMapping("/epmetuser/icresiuser/geticresiuser/{icResiUserId}") - Result getIcResiUserDTO(String icResiUserId); + Result getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId); } From 78ebf8872cf649983c242fc2044752e261e8c7b7 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 22 Dec 2021 18:36:55 +0800 Subject: [PATCH 03/44] 404 --- .../java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java | 2 +- .../src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java | 2 +- .../main/java/com/epmet/controller/IcResiUserController.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index bc9346fdd0..2273a80aa0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -230,7 +230,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl demandUserRes=epmetUserOpenFeignClient.getIcResiUserDTO(fromDTO.getDemandUserId()); if(!demandUserRes.success()||null==demandUserRes.getData()){ - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询需求人信息异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询需求人信息异常"+ JSON.toJSONString(demandUserRes)); } insertEntity.setDemandUserHouseId(demandUserRes.getData().getVillageId()); // 查询需求人的居住地址 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 4d6b728387..2c4989f718 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -687,6 +687,6 @@ public interface EpmetUserOpenFeignClient { * @param icResiUserId * @return */ - @GetMapping("/epmetuser/icresiuser/geticresiuser/{icResiUserId}") + @PostMapping(value = "/epmetuser/icresiuser/geticresiuser/{icResiUserId}") Result getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index fd7f325a01..395a5d40b9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -633,7 +633,7 @@ public class IcResiUserController { * @param icResiUserId * @return */ - @GetMapping("geticresiuser/{icResiUserId}") + @PostMapping("geticresiuser/{icResiUserId}") public Result getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId){ if(StringUtils.isNotBlank(icResiUserId)){ return new Result().ok(icResiUserService.get(icResiUserId)); From ea46728d8e7456d76a6af57f69d7ca10458232eb Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 24 Dec 2021 13:08:08 +0800 Subject: [PATCH 04/44] =?UTF-8?q?=E5=B1=85=E6=B0=91=E7=AB=AF=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E9=9C=80=E6=B1=82=E5=86=85=E5=AE=B9+=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E8=AF=84=E4=BB=B7=E8=BE=93=E5=85=A5=E7=9A=84=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=83=85=E5=86=B5=E8=B5=B0=E5=86=85=E5=AE=B9=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/demand/EvaluateDemandFormDTO.java | 3 ++ .../controller/ResiDemandController.java | 1 + .../impl/IcUserDemandRecServiceImpl.java | 51 ++++++++++++++++--- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/EvaluateDemandFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/EvaluateDemandFormDTO.java index 1a0a5d28f2..ffd035954f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/EvaluateDemandFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/EvaluateDemandFormDTO.java @@ -41,4 +41,7 @@ public class EvaluateDemandFormDTO implements Serializable { private String userId; @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) private String customerId; + // 政府端:gov、居民端:resi、运营端:oper + @NotBlank(message = "app不能为空", groups = AddUserInternalGroup.class) + private String app; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java index be5daf5e3e..48ff8d7585 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiDemandController.java @@ -117,6 +117,7 @@ public class ResiDemandController { public Result evaluate(@LoginUser TokenDto tokenDto, @RequestBody EvaluateDemandFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(formDTO, EvaluateDemandFormDTO.ShowGroup.class, EvaluateDemandFormDTO.AddUserInternalGroup.class); FinishResultDTO finishResultDTO = icUserDemandRecService.evaluate(formDTO); //如果服务方是区域化党建单位,需要实时去计算他的群众满意度=服务过的需求的评价分数相加➗ 需求的总个数。 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 8c3ade3df5..ac6f6ccf9f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -27,10 +27,15 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.DictTypeEnum; 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.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.scan.param.TextScanParamDTO; +import com.epmet.commons.tools.scan.param.TextTaskDTO; +import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ReadFlagConstant; import com.epmet.constant.UserDemandConstant; import com.epmet.constant.UserMessageTypeConstant; @@ -56,6 +61,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -96,6 +102,11 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); + } + } + } + /** * 居民端,我有需求,最近预约,显示最近预约过的五个需求,按照预约时间倒 * 查询最近预约的5个编码 @@ -1255,7 +1294,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl Date: Wed, 29 Dec 2021 14:27:58 +0800 Subject: [PATCH 05/44] =?UTF-8?q?=E5=90=88=E5=B9=B6=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/feign/EpmetUserOpenFeignClient.java | 8 -------- .../feign/fallback/EpmetUserOpenFeignClientFallback.java | 4 ---- 2 files changed, 12 deletions(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 12ff017b6e..47520244f8 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -698,12 +698,4 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping(value = "/epmetuser/icresiuser/geticresiuser/{icResiUserId}") Result getIcResiUserDTO(@PathVariable("icResiUserId") String icResiUserId); - - /** - * desc:获取例行工作 数据 分页 - * @param patrolQueryFormDTO - * @return - */ - @PostMapping(value = "//epmetuser/patrolroutinework/selectList") - Result> getPatrolRoutineWorkList(@RequestBody PatrolQueryFormDTO patrolQueryFormDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index c41d75f137..91b647c878 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -518,8 +518,4 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getIcResiUserDTO", icResiUserId); } - @Override - public Result> getPatrolRoutineWorkList(PatrolQueryFormDTO patrolQueryFormDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getPatrolRoutineWorkList", patrolQueryFormDTO); - } } From 0343073e12a23850bef7c2718950b995d1bd758e Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 31 Dec 2021 15:49:30 +0800 Subject: [PATCH 06/44] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=BF=97=E6=84=BF=E8=80=85=E5=88=97=E8=A1=A8agencyId?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/resi/VolunteerCommonFormDTO.java | 4 +- .../controller/ResiVolunteerController.java | 8 +-- .../epmet/service/VolunteerInfoService.java | 12 ++++- .../impl/VolunteerInfoServiceImpl.java | 51 ++++++++++++------- .../service/impl/VolunteerServiceImpl.java | 4 +- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java index 9a5e2fdc7f..4a9973d735 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java @@ -20,9 +20,9 @@ public class VolunteerCommonFormDTO { private String customerId; /** - * 上级组织ID,使用PIDS like,查询该组织下所有志愿者,注意,是like 'agencyId:%' + * 组织ID */ - private String superiorAgencyId; + private String agencyId; private Integer pageNo = 0; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java index ed5609eed3..39da0690af 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java @@ -141,8 +141,8 @@ public class ResiVolunteerController { Integer pageNo = input.getPageNo(); Integer pageSize = input.getPageSize(); String customerId = input.getCustomerId(); - String superiorAgencyId = input.getSuperiorAgencyId(); - List l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, superiorAgencyId); + String agencyId = input.getAgencyId(); + List l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, agencyId); return new Result>().ok(l); } @@ -154,9 +154,9 @@ public class ResiVolunteerController { @PostMapping("count") public Result getVolunteerCount(@RequestBody VolunteerCommonFormDTO input) { String customerId = input.getCustomerId(); - String pidsPrefix = input.getSuperiorAgencyId(); + String agencyId = input.getAgencyId(); - Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId, pidsPrefix); + Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId, agencyId); return new Result().ok(volunteerCount); } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java index adf45e6437..f9db916bbe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java @@ -95,12 +95,20 @@ public interface VolunteerInfoService extends BaseService { */ List queryListVolunteer(String customerId,String staffId,String userRealName); - List queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId); + /** + * @param customerId + * @param pageNo + * @param pageSize + * @param agencyId 组织ID,使用PIDS like,查询该组织"及下级"所有志愿者 + * @return + */ + List queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String agencyId); /** * 查询志愿者数量 * @param customerId + * @param agencyId 组织ID,查询该组织"及下级"下所有的志愿者 * @return */ - Integer getVolunteerCount(String customerId, String pidsPrefix); + Integer getVolunteerCount(String customerId, String agencyId); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index de63c1f712..ee7f66bc8a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -359,24 +359,11 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId) { + public List queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String agencyId) { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); Optional.ofNullable(customerId).ifPresent(cid -> query.eq(VolunteerInfoEntity::getCustomerId, cid)); - Optional.ofNullable(superiorAgencyId).ifPresent(cid -> { - - // 需要查询agency的pids:id,通过这个字符串去匹配志愿者的Pids字段来查询 - String errorMsg = "【分页查询志愿者列表】失败"; - CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(superiorAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); - if (agencyInfo == null) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); - } - - String pidsAndAgencyIdPath = agencyInfo.getPids().concat(":").concat(superiorAgencyId); - if (pidsAndAgencyIdPath.startsWith(":")) { - pidsAndAgencyIdPath = pidsAndAgencyIdPath.replaceFirst(":", ""); - } - - query.likeRight(VolunteerInfoEntity::getPids, pidsAndAgencyIdPath); + Optional.ofNullable(agencyId).ifPresent(aid -> { + query.likeRight(VolunteerInfoEntity::getPids, getPidsByAgencyId(aid)); }); PageHelper.startPage(pageNo, pageSize); @@ -392,17 +379,43 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl query = new LambdaQueryWrapper<>(); Optional.ofNullable(customerId).ifPresent((cId) -> { query.eq(VolunteerInfoEntity::getCustomerId, cId); }); - Optional.ofNullable(pidsPrefix).ifPresent((pidsPrefixt) -> { - query.likeRight(VolunteerInfoEntity::getPids, pidsPrefixt); + Optional.ofNullable(agencyId).ifPresent((aid) -> { + query.likeRight(VolunteerInfoEntity::getPids, getPidsByAgencyId(aid)); }); return baseDao.selectCount(query); } + + /** + * 使用agencyId,获取pids(agencyPids:agencyId) + * @param agencyId + * @return + */ + private String getPidsByAgencyId(String agencyId) { + // 需要查询agency的pids:id,通过这个字符串去匹配志愿者的Pids字段来查询 + String errorMsg = "【分页查询志愿者列表】失败"; + CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(agencyId), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + + if (agencyInfo == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + } + + String pidsAndAgencyIdPath = agencyInfo.getPids().concat(":").concat(agencyId); + if (pidsAndAgencyIdPath.startsWith(":")) { + pidsAndAgencyIdPath = pidsAndAgencyIdPath.replaceFirst(":", ""); + } + + return pidsAndAgencyIdPath; + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java index 9aa05b6b27..a25f7d2ad7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java @@ -103,7 +103,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve String vcErrorMsg = "【志愿者分布】查询志愿者总数出错"; VolunteerCommonFormDTO volunteerCountForm = new VolunteerCommonFormDTO(); volunteerCountForm.setCustomerId(customerId); - volunteerCountForm.setSuperiorAgencyId(agencyId); + volunteerCountForm.setAgencyId(agencyId); Integer volunteerCount = getResultDataOrThrowsException(epmetHeartOpenFeignClient.getVolunteerCount(volunteerCountForm), ServiceConstant.EPMET_HEART_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), @@ -237,7 +237,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve private List listVolunteersByPage(String customerId, String agencyId, Integer pageNo, Integer pageSize) { VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO(); volunteerForm.setCustomerId(customerId); - volunteerForm.setSuperiorAgencyId(agencyId); + volunteerForm.setAgencyId(agencyId); volunteerForm.setPageNo(pageNo); volunteerForm.setPageSize(pageSize); From 63252fedcfd5e82d4eabffc32a9d26ea35124ecb Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 6 Jan 2022 15:06:35 +0800 Subject: [PATCH 07/44] =?UTF-8?q?=E3=80=90=E7=BD=91=E6=A0=BC=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=BB=9F=E8=AE=A1=E3=80=91=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/excel/ApprovaledListExcel.java | 2 ++ .../service/impl/ProjectTraceServiceImpl.java | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ApprovaledListExcel.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ApprovaledListExcel.java index ef08b3cc39..3e4022712a 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ApprovaledListExcel.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ApprovaledListExcel.java @@ -1,6 +1,7 @@ package com.epmet.excel; import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -13,6 +14,7 @@ import lombok.Setter; @Getter @Setter @EqualsAndHashCode +@ColumnWidth(20) public class ApprovaledListExcel { @ExcelProperty("项目事件标题") private String title; diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java index 33f0e8ec45..1c1a61949c 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectTraceServiceImpl.java @@ -47,7 +47,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -954,9 +953,16 @@ public class ProjectTraceServiceImpl implements ProjectTraceS formDTO.setPageNo(NumConstant.ONE); formDTO.setPageSize(NumConstant.ONE_THOUSAND); ExcelWriter excelWriter = null; + + CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staff) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取工作人员信息失败"); + } + + String sheetName = getSheetName(staff.getRealName(), formDTO.getStartTime(), formDTO.getEndTime()); try { excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("直接立项记录.xlsx", response)).build(); - WriteSheet writeSheet = EasyExcel.writerSheet().build(); + WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).build(); writeSheet.setClazz(ApprovaledListExcel.class); Integer num; //一千条一循环分批写入 @@ -976,6 +982,20 @@ public class ProjectTraceServiceImpl implements ProjectTraceS } } + private String getSheetName(String staffName, String startTime, String endTime) { + StringBuilder sb = new StringBuilder(staffName); + String s = staffName; + if (startTime == null && endTime != null) { + sb.append("截止").append(endTime); + } else if (startTime != null && endTime != null) { + sb.append(startTime) + .append("至") + .append(endTime); + } + sb.append("的上报事件(直接立项)记录"); + return sb.toString(); + } + private List queryStaffListRes(List staffList,String currentUserId) { List staffIdList = staffList.stream().map(TickStaffFormDTO::getStaffId).collect(Collectors.toList()); staffIdList.add(currentUserId); From 468ff87bb511eda5553d72a3880ea4d8659e0ccd Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 18 Jan 2022 09:36:52 +0800 Subject: [PATCH 08/44] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=201.=E3=80=90?= =?UTF-8?q?=E5=8C=BA=E5=9D=97=E9=93=BE=E3=80=91=E5=8C=BA=E5=9D=97=E9=93=BE?= =?UTF-8?q?web=E7=95=8C=E9=9D=A2=E7=94=A8=E6=88=B7=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/GovLoginController.java | 22 ++++++++++++++ .../form/BcStaffAuthenticationFormDTO.java | 24 +++++++++++++++ .../com/epmet/service/GovLoginService.java | 8 +++++ .../service/impl/GovLoginServiceImpl.java | 29 ++++++++++++++++++- 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java index 386e162c02..deaa719859 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; import java.util.List; /** @@ -121,5 +122,26 @@ public class GovLoginController { List staffOrgs = govLoginService.getMyOrgByPassword(formDTO); return new Result>().ok(staffOrgs); } + + /** + * 区块链web 系统身份认证 + * @param input + * @return + */ + @PostMapping("/blockchain/authentication") + public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) { + ValidatorUtils.validateEntity(input); + + String customerId = input.getCustomerId(); + String mobile = input.getMobile(); + String password = input.getPassword(); + + String userId = govLoginService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); + + HashMap m = new HashMap<>(); + m.put("userId", userId); + return new Result().ok(m); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java new file mode 100644 index 0000000000..202f8073c9 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName BcAdminLoginFormDTO + * @Description 区块链管理系统staff身份认证 + * @Author wangxianzhang + * @Date 2022/1/17 10:11 下午 + */ +@Data +public class BcStaffAuthenticationFormDTO { + + @NotBlank(message = "客户ID必填") + private String customerId; + + @NotBlank(message = "手机号必填") + private String mobile; + + @NotBlank(message = "密码必填") + private String password; +} diff --git a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java index ea6329ceda..2a493fd54c 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java @@ -76,4 +76,12 @@ public interface GovLoginService { * @Date 2020/6/30 22:43 **/ List getMyOrgByPassword(StaffOrgsFormDTO formDTO); + + /** + * 区块链系统通过用户密码认证身份 + * @param mobile + * @param password + * @return + */ + String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 86569434c2..8a36124e4d 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -5,8 +5,10 @@ import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; @@ -46,7 +48,7 @@ import java.util.stream.Collectors; * @Date 2020/4/20 10:56 */ @Service -public class GovLoginServiceImpl implements GovLoginService { +public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver { private static final Logger logger = LoggerFactory.getLogger(GovLoginServiceImpl.class); private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; @Autowired @@ -490,5 +492,30 @@ public class GovLoginServiceImpl implements GovLoginService { } return result.getData(); } + + @Override + public String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) { + + GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); + form.setCustomerId(customerId); + form.setMobile(mobile); + + GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId), + "查询用户失败"); + + if (staff == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId)); + } + + if (!PasswordUtils.matches(password, staff.getPassWord())) { + // 密码不匹配 + throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链获取用户信息】密码不匹配,手机号:%s", mobile)); + } + + return staff.getUserId(); + } } From a286d4030f09887a9189a8514afaa5c26ee169ab Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 20 Jan 2022 10:55:32 +0800 Subject: [PATCH 09/44] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E5=8C=BA?= =?UTF-8?q?=E5=9D=97=E9=93=BE=E7=94=A8=E6=88=B7=E8=BA=AB=E4=BB=BD=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E8=B0=83=E6=95=B4=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8Curl=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth-client/pom.xml | 7 ++++ .../result/BlockChainStaffAuthResultDTO.java | 25 +++++++++++ .../epmet/controller/GovLoginController.java | 21 ---------- .../epmet/controller/GovWebController.java | 20 +++++++++ .../com/epmet/service/GovLoginService.java | 8 ---- .../java/com/epmet/service/GovWebService.java | 9 ++++ .../service/impl/GovLoginServiceImpl.java | 25 ----------- .../epmet/service/impl/GovWebServiceImpl.java | 41 ++++++++++++++++++- 8 files changed, 101 insertions(+), 55 deletions(-) create mode 100644 epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java diff --git a/epmet-auth-client/pom.xml b/epmet-auth-client/pom.xml index 1aee53c24e..d84ead3ff5 100644 --- a/epmet-auth-client/pom.xml +++ b/epmet-auth-client/pom.xml @@ -11,4 +11,11 @@ epmet-auth-client + + + com.epmet + epmet-commons-tools + 2.0.0 + + \ No newline at end of file diff --git a/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java b/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java new file mode 100644 index 0000000000..2a1ca0dfcc --- /dev/null +++ b/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.auth.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName BlockChainStaffAuthResultDTO + * @Description 区块链用户认证结果 + * @Author wangxianzhang + * @Date 2022/1/20 10:41 上午 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BlockChainStaffAuthResultDTO { + + private String userId; + private String realName; + private String phone; + private String headUrl; + private String agencyId; + private String agencyName; + +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java index deaa719859..8745418f90 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -122,26 +122,5 @@ public class GovLoginController { List staffOrgs = govLoginService.getMyOrgByPassword(formDTO); return new Result>().ok(staffOrgs); } - - /** - * 区块链web 系统身份认证 - * @param input - * @return - */ - @PostMapping("/blockchain/authentication") - public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) { - ValidatorUtils.validateEntity(input); - - String customerId = input.getCustomerId(); - String mobile = input.getMobile(); - String password = input.getPassword(); - - String userId = govLoginService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); - - HashMap m = new HashMap<>(); - m.put("userId", userId); - return new Result().ok(m); - } - } diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java index 8a85cb9da4..9320b5f140 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java @@ -1,8 +1,10 @@ package com.epmet.controller; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.BcStaffAuthenticationFormDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.GovWebService; @@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; + /** * @author sun @@ -63,5 +67,21 @@ public class GovWebController { return new Result().ok(publicKey); } + /** + * 区块链web 系统身份认证 + * @param input + * @return + */ + @PostMapping("/blockchain/authentication") + public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) { + ValidatorUtils.validateEntity(input); + String customerId = input.getCustomerId(); + String mobile = input.getMobile(); + String password = input.getPassword(); + + BlockChainStaffAuthResultDTO r = govWebService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); + + return new Result().ok(r); + } } diff --git a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java index 2a493fd54c..ea6329ceda 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java @@ -76,12 +76,4 @@ public interface GovLoginService { * @Date 2020/6/30 22:43 **/ List getMyOrgByPassword(StaffOrgsFormDTO formDTO); - - /** - * 区块链系统通过用户密码认证身份 - * @param mobile - * @param password - * @return - */ - String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password); } diff --git a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java index 30f8d8ae4c..10d86c20b4 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java @@ -1,5 +1,6 @@ package com.epmet.service; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -16,4 +17,12 @@ public interface GovWebService { * @Description PC工作端-工作人员登录 **/ UserTokenResultDTO login(GovWebLoginFormDTO formDTO); + + /** + * 区块链系统通过用户密码认证身份 + * @param mobile + * @param password + * @return + */ + BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 8a36124e4d..8d78665550 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -492,30 +492,5 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver } return result.getData(); } - - @Override - public String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) { - - GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); - form.setCustomerId(customerId); - form.setMobile(mobile); - - GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER, - EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), - String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId), - "查询用户失败"); - - if (staff == null) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), - String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId)); - } - - if (!PasswordUtils.matches(password, staff.getPassWord())) { - // 密码不匹配 - throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链获取用户信息】密码不匹配,手机号:%s", mobile)); - } - - return staff.getUserId(); - } } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java index 9d455af694..d6edfb8657 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java @@ -1,13 +1,21 @@ package com.epmet.service.impl; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; 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.feign.ResultDataResolver; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.form.GovWebOperLoginFormDTO; import com.epmet.dto.result.GovWebOperLoginResultDTO; @@ -32,7 +40,7 @@ import java.util.Map; */ @Slf4j @Service -public class GovWebServiceImpl implements GovWebService { +public class GovWebServiceImpl implements GovWebService, ResultDataResolver { private static final Logger logger = LoggerFactory.getLogger(GovWebServiceImpl.class); @Autowired @@ -131,5 +139,36 @@ public class GovWebServiceImpl implements GovWebService { return token; } + @Override + public BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) { + + GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); + form.setCustomerId(customerId); + form.setMobile(mobile); + + // 用户认证 + GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId), + "认证失败"); + + if (staff == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId)); + } + + if (!PasswordUtils.matches(password, staff.getPassWord())) { + // 密码不匹配 + throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链用户认证】密码不匹配,手机号:%s", mobile)); + } + + // 用户基础信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staff.getUserId()); + + BlockChainStaffAuthResultDTO r = new BlockChainStaffAuthResultDTO(staff.getUserId(), staffInfo.getRealName(), + staffInfo.getMobile(), staffInfo.getHeadPhoto(), staffInfo.getAgencyId(), staffInfo.getAgencyName()); + + return r; + } } From cf7593dd7576b0b889d89e79a54edbacddd042a3 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 21 Jan 2022 14:04:00 +0800 Subject: [PATCH 10/44] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E6=8E=89=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/IcResiUserServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index e881de18f0..89dd3d511b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -596,7 +596,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl Date: Fri, 21 Jan 2022 14:16:50 +0800 Subject: [PATCH 11/44] =?UTF-8?q?=E6=B3=A8=E9=87=8Aurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/feign/EpmetUserOpenFeignClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 14377b7fe9..d929df7e4f 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -25,8 +25,8 @@ import java.util.Set; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:09 */ - @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class, url = "localhost:8087") -//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class) + // @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class, url = "localhost:8087") +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class) public interface EpmetUserOpenFeignClient { /** From b816a90c1cbb8a37ca3756ed781e68f7ff90ceb1 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 21 Jan 2022 15:24:18 +0800 Subject: [PATCH 12/44] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BB=93=E6=A1=88=E7=9A=84=E6=97=B6=E5=80=99=E5=B0=86?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=9C=80=E6=96=B0=E4=BF=A1=E6=81=AF=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=88=B0=E5=8C=BA=E5=9D=97=E9=93=BE=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/BlockChainProcessProjectFormDTO.java | 6 ++++++ .../epmet/service/impl/BlockChainProjectServiceImpl.java | 9 +++++++-- .../epmet/service/impl/BlockChainUploadServiceImpl.java | 5 +++-- .../java/com/epmet/service/impl/ProjectServiceImpl.java | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java index 4d6dfb09d0..0b2e2749cb 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java @@ -13,6 +13,12 @@ import java.util.List; public class BlockChainProcessProjectFormDTO implements Serializable { private static final long serialVersionUID = -7316616101790749793L; + + /** + * 项目基础信息 + */ + private BlockChainProjectFormDTO project; + @NotNull(message = "处理进展信息不能为空") private BlockChainProjectProcessFormDTO process; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java index 36db95499d..c648097ab2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java @@ -182,15 +182,20 @@ public class BlockChainProjectServiceImpl implements BlockChainProjectService, R @Override public void blockChainProcessProject(BlockChainProcessProjectFormDTO input) { + BlockChainProjectFormDTO project = input.getProject(); BlockChainProjectProcessFormDTO process = input.getProcess(); List assignedStaffs = input.getAssignedStaffs(); BlockChainProjectProcessAssignedStaffFormDTO handledStaff = input.getHandledStaff(); - fill(null, process, assignedStaffs, handledStaff); + fill(project, process, assignedStaffs, handledStaff); String processString = JSON.toJSONString(process); blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROCESS, processString); - + + if (project != null) { + blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROJECT, JSON.toJSONString(project)); + } + if (assignedStaffs != null && assignedStaffs.size() > 0) { String assignedStaffsString = JSON.toJSONString(assignedStaffs); blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_ASSIGNED_STAFFS, assignedStaffsString); diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java index 18f4d39d4a..d28f2c11a1 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java @@ -134,9 +134,10 @@ public class BlockChainUploadServiceImpl implements BlockChainUploadService { } Result result; - if (project == null) { - // 处理 + if (!"created".equals(processEntity.getOperation())) { + // 处理。如果是结案,则会有project对象,因为要传递结案状态给区块链,其他状态则project==null BlockChainProcessProjectFormDTO processForm = new BlockChainProcessProjectFormDTO(); + processForm.setProject(project); processForm.setProcess(process); processForm.setAssignedStaffs(assignedStaffs); processForm.setHandledStaff(handledStaff); diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index e6e70e2c73..5e2112ba9a 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -597,7 +597,7 @@ public class ProjectServiceImpl extends BaseServiceImpl Date: Sun, 13 Feb 2022 09:46:49 +0800 Subject: [PATCH 13/44] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E6=B5=8B=E8=AF=95=E5=B1=85=E6=B0=91=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet-user-server/src/main/resources/bootstrap.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index ac5d97de01..cce9a52831 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -79,6 +79,11 @@ spring: namespace: @nacos.config.namespace@ group: @nacos.config.group@ file-extension: yaml + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + management: endpoints: web: From 018c49264f614cd28c37e0b4e4e4d2fc7173c05f Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Mon, 14 Feb 2022 17:15:50 +0800 Subject: [PATCH 14/44] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83jvm=E5=86=85=E5=AD=98=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-user/epmet-user-server/deploy/docker-compose-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index b5421e4e4e..5b75e0463c 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml @@ -9,7 +9,7 @@ services: volumes: - "/opt/epmet-cloud-logs/dev:/logs" environment: - RUN_INSTRUCT: "java -Xms32m -Xmx512m -jar ./epmet-user.jar" + RUN_INSTRUCT: "java -Xms32m -Xmx1024m -jar ./epmet-user.jar" restart: "unless-stopped" deploy: resources: From f1ca1029e8be5b90adcd757f1c3d27f52801f4cb Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 15 Feb 2022 10:29:42 +0800 Subject: [PATCH 15/44] =?UTF-8?q?dto=E6=94=B9=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eGeneralDTO.java => ImportGeneralDTO.java} | 2 +- .../java/com/epmet/dao/IcBuildingDao.java | 14 ++--- .../com/epmet/model/BuildingInfoModel.java | 38 +++++++++++++ .../com/epmet/model/HouseInfoModelDTO.java | 41 -------------- .../model/ImportBuildingInfoListener.java | 56 +++++++++++++++++++ .../epmet/model/ImportHouseInfoListener.java | 48 ++++++++-------- .../java/com/epmet/redis/IcHouseRedis.java | 7 --- .../epmet/service/IcNeighborHoodService.java | 6 +- .../service/impl/BuildingServiceImpl.java | 43 +++++++++++++- .../impl/IcNeighborHoodServiceImpl.java | 10 ++-- .../main/resources/mapper/IcBuildingDao.xml | 12 ++-- 11 files changed, 180 insertions(+), 97 deletions(-) rename epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/{ImportHouseGeneralDTO.java => ImportGeneralDTO.java} (96%) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModelDTO.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportHouseGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java similarity index 96% rename from epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportHouseGeneralDTO.java rename to epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java index 6f9d3aba4e..c9d9c6d76b 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportHouseGeneralDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @DESC */ @Data -public class ImportHouseGeneralDTO implements Serializable { +public class ImportGeneralDTO implements Serializable { private static final long serialVersionUID = -345610717773879687L; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index 4e3c885065..c5ed882ca1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java @@ -19,7 +19,7 @@ package com.epmet.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.ImportHouseGeneralDTO; +import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.result.BaseInfoFamilyBuildingResultDTO; import com.epmet.dto.result.BuildingResultDTO; import com.epmet.entity.CustomerAgencyEntity; @@ -112,7 +112,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 9:48 上午 */ - List selectAllGridByOrgId(@Param("orgId")String orgId); + List selectAllGridByOrgId(@Param("orgId")String orgId); /** * @Description 查询网格下所有的小区 @@ -120,7 +120,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 10:21 上午 */ - List selectAllNeighborHoodByGridIds(@Param("orgIds")List orgId); + List selectAllNeighborHoodByGridIds(@Param("orgIds")List orgId); /** * @Description 根据小区ID查询楼栋 @@ -128,7 +128,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 1:25 下午 */ - List selectAllBuildingByNeighborHoodId(@Param("neighborHoodId")String neighborHoodId); + List selectAllBuildingByNeighborHoodId(@Param("neighborHoodId")String neighborHoodId); /** * @Description 根据楼栋ID查询楼栋单元 @@ -136,7 +136,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 1:58 下午 */ - List selectAllBuildingUnitByBuildingId(@Param("building")String building); + List selectAllBuildingUnitByBuildingId(@Param("building")String building); /** * @Description 根据ID查询小区 @@ -144,7 +144,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 3:16 下午 */ - ImportHouseGeneralDTO selectNeighborHoodById(@Param("id")String id); + ImportGeneralDTO selectNeighborHoodById(@Param("id")String id); /** * @Description 根据ID查询楼栋 @@ -152,7 +152,7 @@ public interface IcBuildingDao extends BaseDao { * @author zxc * @date 2022/2/14 4:26 下午 */ - ImportHouseGeneralDTO selectBuildingById(@Param("id")String id); + ImportGeneralDTO selectBuildingById(@Param("id")String id); /** * @Description 查询已存在的房屋 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java new file mode 100644 index 0000000000..e76c391324 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java @@ -0,0 +1,38 @@ +package com.epmet.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 10:07 上午 + * @DESC + */ +@Data +public class BuildingInfoModel { + + @ExcelProperty(value = "所属组织") + private String agencyName; + + @ExcelProperty(value = "所属网格") + private String gridName; + + @ExcelProperty(value = "小区名称") + private String neighborHoodName; + + @ExcelProperty(value = "楼栋名称") + private String buildingName; + + @ExcelProperty(value = "楼栋类型") + private String type; + + @ExcelProperty(value = "单元数") + private Integer totalUnitNum; + + @ExcelProperty(value = "层数") + private Integer totalFloorNum; + + @ExcelProperty(value = "户数") + private Integer totalHouseNum; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModelDTO.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModelDTO.java deleted file mode 100644 index 2193e9cf2d..0000000000 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModelDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.epmet.model; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -/** - * @Author zxc - * @DateTime 2022/2/13 1:26 下午 - * @DESC - */ -@Data -public class HouseInfoModelDTO { - - private String agencyName; - - private String gridName; - - private String neighborHoodName; - - private String buildingName; - - private Integer buildingUnit; - - private String doorName; - - private String houseType; - - private String purpose; - - private String rentFlag; - - private String ownerName; - - private String ownerPhone; - - private String ownerIdCard; - - private Integer num; - -} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java new file mode 100644 index 0000000000..0866793cf6 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java @@ -0,0 +1,56 @@ +package com.epmet.model; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.redis.IcHouseRedis; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2022/2/15 10:06 上午 + * @DESC + */ +public class ImportBuildingInfoListener extends AnalysisEventListener { + + List nums = new ArrayList<>(); + Integer num = NumConstant.ZERO; + + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + + String gridName = null; + String agencyName = null; + + Map gridInfos = null; + List gridInfoDTOs = null; + Map neighborHoodInfos = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; + Map buildingInfos = null; + List buildingInfoDTOs = null; + ImportGeneralDTO buildingGeneralDTO = null; + + private ImportInfoFormDTO formDTO; + private IcHouseRedis icHouseRedis; + + public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis){ + this.formDTO = formDTO; + this.icHouseRedis = icHouseRedis; + } + + @Override + public void invoke(BuildingInfoModel data, AnalysisContext context) { + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java index baa2900486..39d8820783 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java @@ -2,26 +2,22 @@ package com.epmet.model; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.CustomerGridConstant; import com.epmet.dao.IcBuildingDao; -import com.epmet.dto.ImportHouseGeneralDTO; +import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.result.ImportResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; -import com.epmet.excel.IcNeighborHoodExcel; import com.epmet.redis.IcHouseRedis; -import com.epmet.service.HouseService; import com.epmet.service.IcHouseService; import com.epmet.service.IcNeighborHoodService; import org.apache.commons.lang3.StringUtils; @@ -41,22 +37,22 @@ public class ImportHouseInfoListener extends AnalysisEventListener nums = new ArrayList<>(); Integer num = NumConstant.ZERO; - List needDisposeList = new ArrayList<>(); - List needInsertList = new ArrayList<>(); + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); String gridName = null; String agencyName = null; Map gridInfos = null; - List gridInfoDTOs = null; + List gridInfoDTOs = null; Map neighborHoodInfos = null; - List neighborHoodInfoDTOs = null; - ImportHouseGeneralDTO neighborHoodGeneralDTO = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; Map buildingInfos = null; - List buildingInfoDTOs = null; - ImportHouseGeneralDTO buildingGeneralDTO = null; + List buildingInfoDTOs = null; + ImportGeneralDTO buildingGeneralDTO = null; Map buildingUnitInfos = null; - List buildingUnitInfoDTOs = null; + List buildingUnitInfoDTOs = null; private ImportInfoFormDTO formDTO; private IcBuildingDao icBuildingDao; @@ -78,7 +74,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); + List importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); needInsertList.addAll(importInfo); Map collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting())); collect.forEach((k,v) -> { if (Integer.valueOf(v.toString()).compareTo(1) > 0){ - for (ImportHouseGeneralDTO r : needInsertList) { + for (ImportGeneralDTO r : needInsertList) { if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){ // 集合里重复的 r.setExistStatus(true); @@ -119,7 +115,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener ids = needInsertList.stream().map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList()); List existHouses = icBuildingDao.selectExistHouse(ids); existHouses.forEach(e -> { - for (ImportHouseGeneralDTO n : needInsertList) { + for (ImportGeneralDTO n : needInsertList) { if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){ // 库里存在的 n.setExistStatus(true); @@ -128,9 +124,9 @@ public class ImportHouseInfoListener extends AnalysisEventListener> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportHouseGeneralDTO::getExistStatus)); - List importHouseGeneralDTOS = groupByExistStatus.get(false); - houseInsert(importHouseGeneralDTOS); + Map> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); + List importGeneralDTOS = groupByExistStatus.get(false); + houseInsert(importGeneralDTOS); // 清除 needDisposeList = new ArrayList<>(); needInsertList = new ArrayList<>(); @@ -154,7 +150,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener gridIds = new ArrayList<>(); if (orgType.equals(CustomerGridConstant.GRID)){ @@ -412,7 +408,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houses){ + public void houseInsert(List houses){ if (!CollectionUtils.isEmpty(houses)){ icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java index 6407a7a948..dd02bcfad5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java @@ -18,24 +18,17 @@ package com.epmet.redis; import cn.hutool.core.bean.BeanUtil; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.IcHouseDao; -import com.epmet.dto.ImportHouseGeneralDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.ImportResultDTO; -import com.epmet.model.HouseInfoModel; -import com.epmet.model.HouseInfoModelDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index afadcdd449..f990efb864 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -22,7 +22,7 @@ import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcNeighborHoodDTO; -import com.epmet.dto.ImportHouseGeneralDTO; +import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.entity.IcNeighborHoodEntity; import org.springframework.web.multipart.MultipartFile; @@ -132,9 +132,9 @@ public interface IcNeighborHoodService extends BaseService * * @Param formDTO * @Param list - * @Return {@link List< ImportHouseGeneralDTO>} + * @Return {@link List< ImportGeneralDTO >} * @Author zhaoqifeng * @Date 2022/2/14 9:40 */ - List getImportInfo(ImportInfoFormDTO formDTO, List list); + List getImportInfo(ImportInfoFormDTO formDTO, List list); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 34b6723f34..ada9613c63 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -1,6 +1,9 @@ package com.epmet.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -24,9 +27,13 @@ import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportResultDTO; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; +import com.epmet.model.HouseInfoModel; +import com.epmet.model.ImportBuildingInfoListener; +import com.epmet.redis.IcHouseRedis; import com.epmet.service.BuildingService; import com.epmet.service.IcBuildingService; import com.epmet.service.IcBuildingUnitService; @@ -43,6 +50,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -75,6 +83,8 @@ public class BuildingServiceImpl implements BuildingService { private CustomerStaffAgencyDao customerStaffAgencyDao; @Resource private IcBuildingUnitDao icBuildingUnitDao; + @Autowired + private IcHouseRedis icHouseRedis; @Override @Transactional(rollbackFor = Exception.class) @@ -384,7 +394,38 @@ public class BuildingServiceImpl implements BuildingService { */ @Override public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file) throws IOException { - return null; + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + return new Result().error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) + .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis)) + .build(); + excelReader.read(readSheet); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == dto){ + return new Result<>(); + } + List nums = dto.getNums(); + Integer num = dto.getNum(); + String s = "共%s条数据,导入成功%s条。"; + if (nums.size() > NumConstant.ZERO){ + Collections.sort(nums); + s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败"; + return new Result<>().error(9999,String.format(s,num,num - nums.size())); + } + return new Result<>().ok(String.format(s,num,num)); } private List searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index c1d2cc3e9e..fdfe602d19 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -413,12 +413,12 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl} + * @Return {@link List< ImportGeneralDTO >} * @Author zhaoqifeng * @Date 2022/2/14 9:40 */ @Override - public List getImportInfo(ImportInfoFormDTO formDTO, List list) { + public List getImportInfo(ImportInfoFormDTO formDTO, List list) { list.forEach(item -> { if (StringUtils.isEmpty(item.getNeighborHoodId())) { //1.获取小区ID,判断小区是否存在,不存在则添加小区,存在则直接获取小区ID @@ -457,7 +457,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(IcNeighborHoodEntity::getGridId, info.getGridId()); @@ -485,7 +485,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl - SELECT ID AS gridId,GRID_NAME FROM customer_grid WHERE DEL_FLAG = '0' AND PID = #{orgId} - SELECT ID AS neighborHoodId, NEIGHBOR_HOOD_NAME, @@ -262,7 +262,7 @@ - SELECT ID AS buildingId, NEIGHBOR_HOOD_ID, @@ -273,7 +273,7 @@ - SELECT ID AS buildingUnitId, UNIT_NUM AS buildingUnit, @@ -284,7 +284,7 @@ - SELECT AGENCY_ID, GRID_ID, @@ -296,7 +296,7 @@ - SELECT b.ID AS buildingId, b.BUILDING_NAME, From 8c5a856d2b914dc3a396d3b5cf9182a517c0d7c9 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 15 Feb 2022 13:40:10 +0800 Subject: [PATCH 16/44] =?UTF-8?q?=E6=A5=BC=E6=A0=8B=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/ImportGeneralDTO.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java index c9d9c6d76b..9ec463096d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -122,4 +122,9 @@ public class ImportGeneralDTO implements Serializable { private String customerId; private Boolean existStatus = false; + + /** + * 楼栋重复状态 + */ + private Boolean buildingExistStatus = false; } From 634c5d59273b49ff75459c6079bd451776c7a89a Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 15 Feb 2022 13:45:12 +0800 Subject: [PATCH 17/44] =?UTF-8?q?=E6=A5=BC=E6=A0=8B=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/ImportGeneralDTO.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java index 9ec463096d..2c2b3d8379 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -127,4 +127,9 @@ public class ImportGeneralDTO implements Serializable { * 楼栋重复状态 */ private Boolean buildingExistStatus = false; + + /** + * 小区重复状态 + */ + private Boolean neighborHoodExistStatus = false; } From 969ef28f613d97ccecc6fe2b3b70811ff6c87d45 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 15 Feb 2022 14:10:55 +0800 Subject: [PATCH 18/44] =?UTF-8?q?=E6=A5=BC=E6=A0=8B=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/BuildingController.java | 2 +- .../model/ImportBuildingInfoListener.java | 263 +++++++++++++++++- .../service/impl/BuildingServiceImpl.java | 12 +- 3 files changed, 268 insertions(+), 9 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index 628a3d5c62..2ac1605193 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -219,7 +219,7 @@ public class BuildingController { formDTO.setOrgType(orgType); formDTO.setOrgId(orgId); formDTO.setUserId(tokenDTO.getUserId()); - return new Result().ok(buildingService.buildingImportExcel(formDTO,file)); + return buildingService.buildingImportExcel(formDTO,file); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java index 0866793cf6..b894c7fba2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java @@ -3,13 +3,27 @@ package com.epmet.model; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.dao.IcBuildingDao; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.result.ImportResultDTO; +import com.epmet.enums.BuildingTypeEnums; import com.epmet.redis.IcHouseRedis; +import com.epmet.service.IcNeighborHoodService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Author zxc @@ -38,19 +52,264 @@ public class ImportBuildingInfoListener extends AnalysisEventListener groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( + n -> n.getAgencyName() + "_" + n.getGridName() + "_" + + n.getNeighborHoodName() + "_" + n.getBuildingName(), Collectors.counting())); + groupByAllName.forEach((k,v) -> { + if (Integer.valueOf(v.toString()).compareTo(1) > 0){ + for (ImportGeneralDTO r : needDisposeList) { + if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + + r.getNeighborHoodName() + "_" + r.getBuildingName())){ + // 集合里重复的 + r.setExistStatus(true); + nums.add(r.getNum()); + } + } + } + }); + Map> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); + List importGeneralDTOS = groupByStatus.get(false); + if (!CollectionUtils.isEmpty(importGeneralDTOS)){ + List importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); + Map> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getBuildingExistStatus)); + List existList = groupByBuildingExistStatus.get(true); + if (!CollectionUtils.isEmpty(existList)){ + existList.forEach(e -> { + nums.add(e.getNum()); + }); + } + } + // 清除 + needDisposeList = new ArrayList<>(); + needInsertList = new ArrayList<>(); + gridName = null; + agencyName = null; + gridInfos = null; + gridInfoDTOs = null; + neighborHoodInfos = null; + neighborHoodInfoDTOs = null; + neighborHoodGeneralDTO = null; + buildingInfos = null; + buildingInfoDTOs = null; + buildingGeneralDTO = null; + } + + public void fillData(ImportGeneralDTO dto, String orgType){ + if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ + List gridIds = new ArrayList<>(); + if (orgType.equals(CustomerGridConstant.GRID)){ + gridIds = Arrays.asList(formDTO.getOrgId()); + }else if (orgType.equals(CustomerGridConstant.AGENCY)){ + gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); + } + neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; + Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), formDTO.getOrgId() + "_" + dto.getNeighborHoodName()); + // 赋值小区ID + dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); + } + if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ + //小区ID不为空赋值楼栋ID + buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getNeighborHoodId()) : buildingInfos; + Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); + dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); + if (StringUtils.isNotBlank(dto.getBuildingId())){ + // 说明数据库已存在此楼栋,不需添加 + nums.add(num); + }else { + needDisposeList.add(dto); + } + }else { + needDisposeList.add(dto); + } + } + + /** + * @Description 左侧树点击小区时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeNeighborHoodBuilding(ImportGeneralDTO dto){ + neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; + //排除不是本小区的 + if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ + nums.add(num); + }else { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); + if (null == gridInfo){ + throw new EpmetException("查询网格失败..."); + } + // 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样 + if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || + (!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){ + nums.add(num); + return; + } + dto.setNeighborHoodId(formDTO.getOrgId()); + dto.setGridId(neighborHoodGeneralDTO.getGridId()); + dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + throw new EpmetException("查询组织信息失败..."); + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto,CustomerGridConstant.NEIGHBORHOOD); + } + } + + /** + * @Description 左侧树点击网格时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeGridBuilding(ImportGeneralDTO dto){ + gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); + if (null == gridInfo){ + throw new EpmetException("查询网格失败..."); + } + //排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除 + if (!dto.getGridName().equals(gridName) || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ + nums.add(num); + }else { + // + dto.setGridId(formDTO.getOrgId()); + dto.setAgencyId(gridInfo.getPid()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + throw new EpmetException("查询组织信息失败..."); + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto, CustomerGridConstant.GRID); + } + } + + /** + * @Description 左侧树点击组织时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeAgencyBuilding(ImportGeneralDTO dto){ + agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; + //排除不是本组织的 + if (!dto.getAgencyName().equals(agencyName)){ + nums.add(num); + }else { + // 根据组织查询出所有网格,甩出不是本组织下的网格 + gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; + if (null == gridInfos){ + // 组织下确实不存在网格 + nums.add(num); + return; + } + // 根据网格名对比,没有找到的就把行号加入到未执行成功队列中 + Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); + if (null == cacheGridName){ + nums.add(num); + return; + } + dto.setGridId(cacheGridName.toString()); + dto.setAgencyId(formDTO.getOrgId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + throw new EpmetException("查询组织信息失败..."); + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto,CustomerGridConstant.AGENCY); + } + } + + /** + * @Description 获取网格信息 + * @param orgId + * @author zxc + * @date 2022/2/14 9:57 上午 + */ + public Map getGridInfos(String orgId){ + gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); + gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); + icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); + return gridInfos; + } + + /** + * @Description 获取网格下的小区 + * @param gridIds + * @author zxc + * @date 2022/2/14 10:16 上午 + */ + public Map getNeighborHoodInfos(List gridIds){ + neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); + neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); + icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); + return neighborHoodInfos; + } + /** + * @Description 获取小区下的楼栋 + * @param neighborHoodId + * @author zxc + * @date 2022/2/14 1:32 下午 + */ + public Map getBuildingInfos(String neighborHoodId){ + buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(neighborHoodId); + buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); + icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); + return buildingInfos; } @Override public void doAfterAllAnalysed(AnalysisContext context) { - + finalDispose(); + // 删除缓存 + icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); + // 放结果 + icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index ada9613c63..17909fa625 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -31,13 +31,11 @@ import com.epmet.dto.result.ImportResultDTO; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; +import com.epmet.model.BuildingInfoModel; import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportBuildingInfoListener; import com.epmet.redis.IcHouseRedis; -import com.epmet.service.BuildingService; -import com.epmet.service.IcBuildingService; -import com.epmet.service.IcBuildingUnitService; -import com.epmet.service.IcHouseService; +import com.epmet.service.*; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -85,6 +83,8 @@ public class BuildingServiceImpl implements BuildingService { private IcBuildingUnitDao icBuildingUnitDao; @Autowired private IcHouseRedis icHouseRedis; + @Autowired + private IcNeighborHoodService neighborHoodService; @Override @Transactional(rollbackFor = Exception.class) @@ -404,8 +404,8 @@ public class BuildingServiceImpl implements BuildingService { } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener - ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) - .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis)) + ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) + .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService)) .build(); excelReader.read(readSheet); } finally { From 5061020e4ca7c00c8ae388561c640cddaca355db Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 15 Feb 2022 14:38:10 +0800 Subject: [PATCH 19/44] =?UTF-8?q?=E6=9A=82=E6=8F=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/ImportGeneralDTO.java | 15 +++ .../model/ImportNeighborHoodInfoListener.java | 93 +++++++++++++++++++ .../epmet/model/NeighborHoodInfoModel.java | 32 +++++++ .../impl/IcNeighborHoodServiceImpl.java | 50 ++++++++++ 4 files changed, 190 insertions(+) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java index 2c2b3d8379..9039cda6ef 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -112,6 +112,21 @@ public class ImportGeneralDTO implements Serializable { */ private Integer num; + /** + * 关联物业 + */ + private String propertyName; + + /** + * 详细地址 + */ + private String address; + + /** + * 备注 + */ + private String remark; + /** * 房屋ID */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java new file mode 100644 index 0000000000..7d5a29af04 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java @@ -0,0 +1,93 @@ +package com.epmet.model; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.IcNeighborHoodService; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2022/2/15 2:16 下午 + * @DESC + */ +public class ImportNeighborHoodInfoListener extends AnalysisEventListener { + + List nums = new ArrayList<>(); + Integer num = NumConstant.ZERO; + + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + + String gridName = null; + String agencyName = null; + + Map gridInfos = null; + List gridInfoDTOs = null; + Map neighborHoodInfos = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; + + private ImportInfoFormDTO formDTO; + private IcHouseRedis icHouseRedis; + private IcBuildingDao icBuildingDao; + private IcNeighborHoodService neighborHoodService; + + public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService){ + this.formDTO = formDTO; + this.icHouseRedis = icHouseRedis; + this.icBuildingDao = icBuildingDao; + this.neighborHoodService = neighborHoodService; + } + + + @Override + public void invoke(NeighborHoodInfoModel data, AnalysisContext context) { + if (null == data){ + return; + } + num = num + NumConstant.ONE; + ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); + dto.setNum(num); + dto.setCustomerId(formDTO.getCustomerId()); + if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ + disposeGridNeighborHood(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ + disposeAgencyNeighborHood(dto); + } + } + + /** + * @Description 左侧树点击网格时调用 + * @param dto + * @author zxc + * @date 2022/2/15 2:37 下午 + */ + public void disposeGridNeighborHood(ImportGeneralDTO dto){ + + } + + /** + * @Description 左侧树点击组织时调用 + * @param dto + * @author zxc + * @date 2022/2/15 2:37 下午 + */ + public void disposeAgencyNeighborHood(ImportGeneralDTO dto){ + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java new file mode 100644 index 0000000000..8dbdbafccd --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java @@ -0,0 +1,32 @@ +package com.epmet.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 2:15 下午 + * @DESC + */ +@Data +public class NeighborHoodInfoModel { + + @ExcelProperty(value = "所属组织") + private String agencyName; + + @ExcelProperty(value = "所属网格") + private String gridName; + + @ExcelProperty(value = "小区名称") + private String neighborHoodName; + + @ExcelProperty(value = "关联物业") + private String propertyName; + + @ExcelProperty(value = "详细地址") + private String address; + + @ExcelProperty(value = "备注") + private String remark; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index fdfe602d19..189ac0e825 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -18,6 +18,9 @@ package com.epmet.service.impl; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -37,13 +40,20 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerGridConstant; import com.epmet.dao.CustomerGridDao; +import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcNeighborHoodDao; import com.epmet.dao.IcPropertyManagementDao; import com.epmet.dto.*; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.result.ImportResultDTO; import com.epmet.dto.result.InfoByNamesResultDTO; import com.epmet.entity.*; import com.epmet.excel.IcNeighborHoodExcel; +import com.epmet.model.BuildingInfoModel; +import com.epmet.model.ImportBuildingInfoListener; +import com.epmet.model.ImportNeighborHoodInfoListener; +import com.epmet.model.NeighborHoodInfoModel; +import com.epmet.redis.IcHouseRedis; import com.epmet.service.*; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; @@ -57,6 +67,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; @@ -82,6 +93,10 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl page(Map params) { @@ -373,6 +388,41 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl().error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this)) + .build(); + excelReader.read(readSheet); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == dto){ + return new Result<>(); + } + List nums = dto.getNums(); + Integer num = dto.getNum(); + String s = "共%s条数据,导入成功%s条。"; + if (nums.size() > NumConstant.ZERO){ + Collections.sort(nums); + s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败"; + return new Result<>().error(9999,String.format(s,num,num - nums.size())); + } + return new Result<>().ok(String.format(s,num,num)); + } + /** * @Description 小区插入,物业插入 * @param entities From 4c13d363003a7fded74a18d7f3cb5f7856916825 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 17 Feb 2022 09:14:46 +0800 Subject: [PATCH 20/44] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20-=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4user=E7=9A=84=E5=86=85=E5=AD=98=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-user/epmet-user-server/deploy/docker-compose-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index 5b75e0463c..e1e35559ff 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml @@ -9,7 +9,7 @@ services: volumes: - "/opt/epmet-cloud-logs/dev:/logs" environment: - RUN_INSTRUCT: "java -Xms32m -Xmx1024m -jar ./epmet-user.jar" + RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./epmet-user.jar" restart: "unless-stopped" deploy: resources: From 80888c09389704939e9b8df1c9971ece82b7cc22 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 17 Feb 2022 10:53:33 +0800 Subject: [PATCH 21/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/service/impl/PatrolRoutineWorkServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java index ab25b3ddd1..a93068de5b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java @@ -25,8 +25,8 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; -import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.DictTreeResultDTO; import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.DictTypeEnum; @@ -74,10 +74,7 @@ import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -168,7 +165,7 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl Date: Mon, 21 Feb 2022 09:57:58 +0800 Subject: [PATCH 22/44] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 9df4f46881..fe03008b81 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -729,39 +729,6 @@ public class RedisKeys { return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(":").concat(userId); } - /** - * 居民导入-缓存目录key - * @param importTag - * @return - */ - public static String icResiImportBaseKey(String importTag) { - return rootPrefix.concat("resi:").concat("import:").concat(importTag); - } - - /** - * 居民导入-数据分类的key - * add:新增居民 - * category:类别变更 - * transfer:调动 - * @param importTag - * @param type - * @return - */ - public static String icResiImportTypeKey(String importTag, String type) { - return icResiImportBaseKey(importTag).concat(":").concat(type); - } - - /** - * 居民导入-详细信息key - * @param importTag - * @param type - * @param resiId - * @return - */ - public static String icResiImportResiCategoryKey(String importTag, String type, String resiId) { - return icResiImportTypeKey(importTag, type).concat(":").concat(resiId); - } - public static String getTemporaryImportResultCacheKey(String customerId,String userId){ return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); } From 5d9534da94c4bfd8158fdbb7f595a9c29b0f1650 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 2 Mar 2022 10:19:18 +0800 Subject: [PATCH 23/44] error code --- .../java/com/epmet/commons/tools/exception/EpmetErrorCode.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 7992a0049a..1a965a2d74 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -250,6 +250,9 @@ public enum EpmetErrorCode { ORG_ADD_FAILED(8919,"添加失败"), ORG_EDIT_FAILED(8920,"编辑失败"), ORG_DEL_FAILED(8921,"删除失败"), + NEIGHBORHOOD_DEL_FAILED(8922,"%s内包含楼宇信息,暂无法删除"), + BUILDING_DEL_FAILED(8923,"%s内包含房屋信息,暂无法删除"), + HOUSE_DEL_FAILED(8924,"%s内包含居民信息,暂无法删除"), //通用错误码 start From 391b37ed9dac7ea77a153168482d1f1ec1f0def5 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 2 Mar 2022 11:08:08 +0800 Subject: [PATCH 24/44] del --- .../form/NeighborHoodManageDelFormDTO.java | 30 +++++++ .../NeighborHoodManageDelResultDTO.java | 22 +++++ .../epmet/constant/CustomerGridConstant.java | 1 + .../com/epmet/controller/HouseController.java | 13 +++ .../main/java/com/epmet/dao/IcHouseDao.java | 26 ++++++ .../java/com/epmet/service/HouseService.java | 9 +++ .../epmet/service/impl/HouseServiceImpl.java | 81 +++++++++++++++++++ .../src/main/resources/mapper/IcHouseDao.xml | 43 ++++++++++ .../epmet/dto/form/DelIcResiUserFormDTO.java | 8 +- .../epmet/feign/EpmetUserOpenFeignClient.java | 9 +++ .../EpmetUserOpenFeignClientFallback.java | 5 ++ .../controller/IcResiUserController.java | 33 +++++--- .../java/com/epmet/dao/IcResiUserDao.java | 9 +++ .../com/epmet/service/IcResiUserService.java | 7 ++ .../service/impl/IcResiUserServiceImpl.java | 11 +++ .../main/resources/mapper/IcResiUserDao.xml | 13 +++ 16 files changed, 310 insertions(+), 10 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java new file mode 100644 index 0000000000..22d913ee32 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/3/1 4:35 下午 + * @DESC + */ +@Data +public class NeighborHoodManageDelFormDTO implements Serializable { + + private static final long serialVersionUID = 405799151478155056L; + + public interface NeighborHoodManageDelForm{} + + @NotNull(message = "ids不能为空" , groups = NeighborHoodManageDelForm.class) + private List ids; + + /** + * 小区:neighborHood,楼栋:building,房屋:house + */ + @NotBlank(message = "type不能为空" , groups = NeighborHoodManageDelForm.class) + private String type; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java new file mode 100644 index 0000000000..bec9a06639 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/3/2 10:05 上午 + * @DESC + */ +@Data +public class NeighborHoodManageDelResultDTO implements Serializable { + + private static final long serialVersionUID = -4248802585738319974L; + + private String neighborHoodId; + private String buildingId; + private String houseId; + + private String name; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java index bfe1fbe93c..409ec696db 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java @@ -19,4 +19,5 @@ public interface CustomerGridConstant { String NEIGHBORHOOD = "neighborHood"; String BUILDING = "building"; + String HOUSE = "house"; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 017da95fd9..f4c3fce570 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -292,4 +292,17 @@ public class HouseController implements ResultDataResolver { return new Result<>().error(9999,String.format(s,num,num)); } + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + @PostMapping("delete") + public Result allDelete(@RequestBody NeighborHoodManageDelFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, NeighborHoodManageDelFormDTO.NeighborHoodManageDelForm.class); + houseService.allDelete(formDTO); + return new Result(); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index a394aaaef5..28c0014f19 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.HouseInfoDTO; +import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.excel.IcHouseExcel; import org.apache.ibatis.annotations.Mapper; @@ -74,4 +75,29 @@ public interface IcHouseDao extends BaseDao { @Param("buildingUnitId")String buildingUnitId, @Param("doorName")String doorName, @Param("houseId")String houseId); + + /** + * Desc: 根据小区IDs查询小区下是否有存在楼栋的 + * @param ids + * @author zxc + * @date 2022/3/2 9:51 上午 + */ + List selectExistBuildingByNeighborHoodIds(@Param("ids")List ids); + + /** + * Desc: 根据楼栋IDs查询楼栋下是否有存在房屋的 + * @param ids + * @author zxc + * @date 2022/3/2 9:53 上午 + */ + List selectExistHouseByBuildingIds(@Param("ids")List ids); + + /** + * Desc: 根据房屋ID查询名字 + * @param ids + * @author zxc + * @date 2022/3/2 11:00 上午 + */ + List selectHouseNames(@Param("ids")List ids); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index ad5d1d69cb..14dec2f1a9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -19,6 +19,7 @@ package com.epmet.service; import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.form.NeighborHoodManageDelFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.excel.IcHouseExcel; @@ -62,4 +63,12 @@ public interface HouseService { void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception; List queryListHouseInfo(Set houseIds, String customerId); + + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + void allDelete(NeighborHoodManageDelFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 4c809cb812..3c9269c53d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -14,6 +14,8 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerGridConstant; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcHouseDao; @@ -24,13 +26,16 @@ import com.epmet.dto.IcBuildingUnitDTO; import com.epmet.dto.IcHouseDTO; import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.form.NeighborHoodManageDelFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; import com.epmet.excel.IcHouseExcel; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.redis.IcHouseRedis; import com.epmet.service.HouseService; @@ -77,6 +82,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { private IcHouseRedis icHouseRedis; @Autowired private AgencyService agencyservice; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Override @@ -329,4 +336,78 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { }); return result; } + + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + @Override + public void allDelete(NeighborHoodManageDelFormDTO formDTO) { + if (CollectionUtils.isEmpty(formDTO.getIds())){ + return; + } + List ids = formDTO.getIds(); + if (formDTO.getType().equals(CustomerGridConstant.NEIGHBORHOOD)){ + List exists = icHouseDao.selectExistBuildingByNeighborHoodIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e.getNeighborHoodId())){ + ids.remove(i); + continue; + } + } + }); + } + icNeighborHoodDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getMsg(),collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); + } + }else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)){ + List exists = icHouseDao.selectExistHouseByBuildingIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e.getBuildingId())){ + ids.remove(i); + continue; + } + } + }); + } + icBuildingDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); + EpmetErrorCode.BUILDING_DEL_FAILED.setMsg(String.format(EpmetErrorCode.BUILDING_DEL_FAILED.getMsg(),collect)); + throw new EpmetException(EpmetErrorCode.BUILDING_DEL_FAILED.getCode()); + } + }else if (formDTO.getType().equals(CustomerGridConstant.HOUSE)){ + Result> existUsers = epmetUserOpenFeignClient.getExistUserByHouseIds(ids); + if (!existUsers.success()){ + throw new EpmetException("根据房屋IDs查询房屋下是否有存在居民失败..."); + } + List exists = existUsers.getData(); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e)){ + ids.remove(i); + continue; + } + } + }); + } + icHouseDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + List list = icHouseDao.selectHouseNames(exists); + String collect = list.stream().collect(Collectors.joining("、")); + EpmetErrorCode.HOUSE_DEL_FAILED.setMsg(String.format(EpmetErrorCode.HOUSE_DEL_FAILED.getMsg(),collect)); + throw new EpmetException(EpmetErrorCode.HOUSE_DEL_FAILED.getCode()); + } + } + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 08adc876d0..9647aa4a70 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -329,4 +329,47 @@ ih.DEL_FLAG = '0' AND ih.ID = #{houseId} + + + + + + + + + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java index 558bb88b7f..98526ad993 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java @@ -4,7 +4,9 @@ import com.epmet.commons.tools.enums.IcFormCodeEnum; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.List; /** * @Description 删除居民 @@ -18,10 +20,14 @@ public class DelIcResiUserFormDTO implements Serializable { public interface IdGroup { } - @NotBlank(message = "icResiUserId不能为空", groups = IdGroup.class) private String icResiUserId; + + @NotNull(message = "userIds不能为空", groups = IdGroup.class) + private List userIds; + @NotBlank(message = "token获取的customerId不能为空", groups = IdGroup.class) private String customerId; + private String formCode= IcFormCodeEnum.RESI_BASE_INFO.getCode(); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 9cfd689cfc..1d55f30f87 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -712,4 +712,13 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/statsresiwarn/list2") Result> getPersonCategoryList(@RequestBody StatsResiListFormDTO formDTO); + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("/epmetuser/icresiuser/getexistuserbyhouseids") + Result> getExistUserByHouseIds(@RequestBody List ids); + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index bde8bf2e8c..0f9f38ea5c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -527,4 +527,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> getPersonCategoryList(StatsResiListFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getPersonCategoryList", formDTO); } + + @Override + public Result> getExistUserByHouseIds(List ids) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getExistUserByHouseIds", ids); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 67c1aabd7e..8e37bc0958 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -181,15 +181,19 @@ public class IcResiUserController { public Result delete(@LoginUser TokenDto tokenDto, @RequestBody DelIcResiUserFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(formDTO, DelIcResiUserFormDTO.IdGroup.class); - icResiUserService.delete(formDTO); - //推送MQ事件 - IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); - mqMsg.setCustomerId(tokenDto.getCustomerId()); - mqMsg.setIcResiUser(formDTO.getIcResiUserId()); - SystemMsgFormDTO form = new SystemMsgFormDTO(); - form.setMessageType(SystemMessageType.IC_RESI_USER_DEL); - form.setContent(mqMsg); - epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); +// icResiUserService.delete(formDTO); + icResiUserService.deleteBatchIds(formDTO.getUserIds()); + formDTO.getUserIds().forEach(userId -> { + //推送MQ事件 + IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); + mqMsg.setCustomerId(tokenDto.getCustomerId()); + mqMsg.setIcResiUser(userId); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(SystemMessageType.IC_RESI_USER_DEL); + form.setContent(mqMsg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); + }); + return new Result(); } @@ -712,4 +716,15 @@ public class IcResiUserController { ValidatorUtils.validateEntity(formDTO, PersonWarnRightListFormDTO.PersonWarnRightListForm.class); return new Result().ok(icResiUserService.personWarnRightList(formDTO,tokenDto)); } + + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("getexistuserbyhouseids") + public Result> getExistUserByHouseIds(@RequestBody List ids){ + return new Result>().ok(icResiUserService.getExistUserByHouseIds(ids)); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index d152fc3776..cdb0a0be13 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -261,4 +261,13 @@ public interface IcResiUserDao extends BaseDao { */ Map getDataAnalyseCount(@Param("customerId") String customerId, @Param("tableName") String tableName, @Param("columnList") List columnList, @Param("id") String id, @Param("level") String level); + + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + List getExistUserByHouseIds(@Param("ids") List ids); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index dc2c2a76d5..59ec56519b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -209,4 +209,11 @@ public interface IcResiUserService extends BaseService { */ PersonWarnRightListResultDTO personWarnRightList(PersonWarnRightListFormDTO formDTO, TokenDto tokenDto); + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + List getExistUserByHouseIds(List ids); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index f912200041..9601599fc4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -1201,6 +1201,17 @@ public class IcResiUserServiceImpl extends BaseServiceImpl getExistUserByHouseIds(List ids) { + return baseDao.getExistUserByHouseIds(ids); + } + /** * @Description 居民分类 和 网格名 处理 * @param list diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 28396dd34e..c34664ed92 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -624,4 +624,17 @@ ) + + + From 49cde60fb04609c68026da7547930f7fa8d7976d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 2 Mar 2022 13:30:46 +0800 Subject: [PATCH 25/44] del --- .../com/epmet/service/impl/HouseServiceImpl.java | 12 +++++++++--- .../src/main/resources/mapper/IcHouseDao.xml | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 3c9269c53d..f0923f1129 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -361,7 +361,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } }); } - icNeighborHoodDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(ids)){ + icNeighborHoodDao.deleteBatchIds(ids); + } if (!CollectionUtils.isEmpty(exists)){ String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getMsg(),collect)); @@ -379,7 +381,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } }); } - icBuildingDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(ids)){ + icBuildingDao.deleteBatchIds(ids); + } if (!CollectionUtils.isEmpty(exists)){ String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); EpmetErrorCode.BUILDING_DEL_FAILED.setMsg(String.format(EpmetErrorCode.BUILDING_DEL_FAILED.getMsg(),collect)); @@ -401,7 +405,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } }); } - icHouseDao.deleteBatchIds(ids); + if (!CollectionUtils.isEmpty(ids)){ + icHouseDao.deleteBatchIds(ids); + } if (!CollectionUtils.isEmpty(exists)){ List list = icHouseDao.selectHouseNames(exists); String collect = list.stream().collect(Collectors.joining("、")); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 9647aa4a70..40984e17f1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -343,7 +343,7 @@ #{id} ) - GROUP BY id + GROUP BY nh.id @@ -359,7 +359,7 @@ #{id} ) - GROUP BY id + GROUP BY b.id From e6f1298f4e4eb0a30e8814b6a4aae6ff2ae1d866 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 2 Mar 2022 13:46:37 +0800 Subject: [PATCH 26/44] =?UTF-8?q?=E9=A1=BF=E5=8F=B7=E6=94=B9=E9=80=97?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/HouseServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index f0923f1129..5dee8cd9b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -365,7 +365,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { icNeighborHoodDao.deleteBatchIds(ids); } if (!CollectionUtils.isEmpty(exists)){ - String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getMsg(),collect)); throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); } @@ -385,7 +385,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { icBuildingDao.deleteBatchIds(ids); } if (!CollectionUtils.isEmpty(exists)){ - String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining("、")); + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); EpmetErrorCode.BUILDING_DEL_FAILED.setMsg(String.format(EpmetErrorCode.BUILDING_DEL_FAILED.getMsg(),collect)); throw new EpmetException(EpmetErrorCode.BUILDING_DEL_FAILED.getCode()); } @@ -410,7 +410,7 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } if (!CollectionUtils.isEmpty(exists)){ List list = icHouseDao.selectHouseNames(exists); - String collect = list.stream().collect(Collectors.joining("、")); + String collect = list.stream().collect(Collectors.joining(",")); EpmetErrorCode.HOUSE_DEL_FAILED.setMsg(String.format(EpmetErrorCode.HOUSE_DEL_FAILED.getMsg(),collect)); throw new EpmetException(EpmetErrorCode.HOUSE_DEL_FAILED.getCode()); } From fdd3bb8c0daa936e7c0cda3726de68ef9901c353 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 2 Mar 2022 15:41:52 +0800 Subject: [PATCH 27/44] del --- .../main/java/com/epmet/controller/IcResiUserController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 8e37bc0958..67104b06f8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -181,9 +181,9 @@ public class IcResiUserController { public Result delete(@LoginUser TokenDto tokenDto, @RequestBody DelIcResiUserFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(formDTO, DelIcResiUserFormDTO.IdGroup.class); -// icResiUserService.delete(formDTO); - icResiUserService.deleteBatchIds(formDTO.getUserIds()); formDTO.getUserIds().forEach(userId -> { + formDTO.setIcResiUserId(userId); + icResiUserService.delete(formDTO); //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(tokenDto.getCustomerId()); From ecf29145735187304e16f0802652b38191b97cae Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 3 Mar 2022 11:04:15 +0800 Subject: [PATCH 28/44] del --- .../commons/tools/exception/EpmetErrorCode.java | 4 +--- .../com/epmet/service/impl/HouseServiceImpl.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 1a965a2d74..4614beb5ba 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -250,9 +250,7 @@ public enum EpmetErrorCode { ORG_ADD_FAILED(8919,"添加失败"), ORG_EDIT_FAILED(8920,"编辑失败"), ORG_DEL_FAILED(8921,"删除失败"), - NEIGHBORHOOD_DEL_FAILED(8922,"%s内包含楼宇信息,暂无法删除"), - BUILDING_DEL_FAILED(8923,"%s内包含房屋信息,暂无法删除"), - HOUSE_DEL_FAILED(8924,"%s内包含居民信息,暂无法删除"), + NEIGHBORHOOD_DEL_FAILED(8922,""), //通用错误码 start diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 5dee8cd9b6..932ac048ea 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -365,8 +365,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { icNeighborHoodDao.deleteBatchIds(ids); } if (!CollectionUtils.isEmpty(exists)){ - String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); - EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getMsg(),collect)); + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含楼宇信息,暂无法删除",collect)); throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); } }else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)){ @@ -385,9 +385,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { icBuildingDao.deleteBatchIds(ids); } if (!CollectionUtils.isEmpty(exists)){ - String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); - EpmetErrorCode.BUILDING_DEL_FAILED.setMsg(String.format(EpmetErrorCode.BUILDING_DEL_FAILED.getMsg(),collect)); - throw new EpmetException(EpmetErrorCode.BUILDING_DEL_FAILED.getCode()); + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含房屋信息,暂无法删除",collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); } }else if (formDTO.getType().equals(CustomerGridConstant.HOUSE)){ Result> existUsers = epmetUserOpenFeignClient.getExistUserByHouseIds(ids); @@ -410,9 +410,9 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } if (!CollectionUtils.isEmpty(exists)){ List list = icHouseDao.selectHouseNames(exists); - String collect = list.stream().collect(Collectors.joining(",")); - EpmetErrorCode.HOUSE_DEL_FAILED.setMsg(String.format(EpmetErrorCode.HOUSE_DEL_FAILED.getMsg(),collect)); - throw new EpmetException(EpmetErrorCode.HOUSE_DEL_FAILED.getCode()); + String collect = list.stream().collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含居民信息,暂无法删除",collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); } } } From 9b1c47f235772328229056961c8e30d833a97b66 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 3 Mar 2022 15:24:58 +0800 Subject: [PATCH 29/44] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V0.0.13__ImportTaskCommentModify.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql new file mode 100644 index 0000000000..de7c4f70a0 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql @@ -0,0 +1 @@ +alter table import_task modify column PROCESS_STATUS varchar(32) comment '处理状态。processing:处理中;finished_success:成功;finished_fail:未完全成功' \ No newline at end of file From cf24e1cd7929960eab496b7f0760cc8379a41726 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 15:11:08 +0800 Subject: [PATCH 30/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/impl/IcNeighborHoodServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 3064679e2c..6093297b5f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -71,6 +71,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.entity.ContentType; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -231,8 +232,9 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { - executorService.submit(() -> { +// executorService.submit(() -> { // importNeighbor(formDTO,file,importTask); log.info("neighborhoodImport thread start====="); ExcelReader excelReader = null; @@ -264,7 +266,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl(); } From f5459c41d74e4e2da07d016c9b8abea7e47df84f Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 15:43:41 +0800 Subject: [PATCH 31/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/controller/IcNeighborHoodController.java | 3 +++ .../java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 107b6c612e..04cb5f66aa 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -40,6 +40,7 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcNeighborHoodService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -132,9 +133,11 @@ public class IcNeighborHoodController { * @date 2022/2/12 10:47 上午 */ @PostMapping("neighborhoodimport") + @Transactional(rollbackFor = Exception.class) public Result neighborhoodImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, @RequestParam("orgId")String orgId, @RequestParam("orgType")String orgType) throws IOException { + log.info("地址:" + file.getResource().getURI().getPath().toString()); ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setOrgType(orgType); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 6093297b5f..fd7651a7b5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -243,6 +243,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl Date: Mon, 7 Mar 2022 15:56:17 +0800 Subject: [PATCH 32/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/IcNeighborHoodController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 04cb5f66aa..ab912450f5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -137,7 +137,6 @@ public class IcNeighborHoodController { public Result neighborhoodImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, @RequestParam("orgId")String orgId, @RequestParam("orgType")String orgType) throws IOException { - log.info("地址:" + file.getResource().getURI().getPath().toString()); ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); formDTO.setCustomerId(tokenDTO.getCustomerId()); formDTO.setOrgType(orgType); From 31cd47027aa509c8bc58ceb22bd3c01a15636b74 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 16:41:58 +0800 Subject: [PATCH 33/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IcNeighborHoodController.java | 15 ++++++++++++++- .../com/epmet/service/IcNeighborHoodService.java | 3 ++- .../service/impl/IcNeighborHoodServiceImpl.java | 10 +--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index ab912450f5..85797b6e4a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -151,7 +152,19 @@ public class IcNeighborHoodController { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); } log.info("插入任务结果"+ JSON.toJSONString(importTask.getData())); - icNeighborHoodService.neighborhoodImport(formDTO,file,importTask); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + log.error("读取文件失败"); + }finally { + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } + icNeighborHoodService.neighborhoodImport(formDTO,inputStream,importTask); return new Result(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 1d6193834f..1f32607a65 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -31,6 +31,7 @@ import com.epmet.entity.IcPropertyManagementEntity; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.InputStream; import java.util.Collection; import java.util.List; import java.util.Map; @@ -129,7 +130,7 @@ public interface IcNeighborHoodService extends BaseService * @author zxc * @date 2022/2/12 11:11 上午 */ - Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + Result neighborhoodImport(ImportInfoFormDTO formDTO, InputStream inputStream, Result importTask) throws IOException; /** * 获取导入小区,楼栋,单元ID diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index fd7651a7b5..fa0ab9072e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -233,20 +233,12 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { + public Result neighborhoodImport(ImportInfoFormDTO formDTO, InputStream inputStream,Result importTask) { // executorService.submit(() -> { // importNeighbor(formDTO,file,importTask); log.info("neighborhoodImport thread start====="); ExcelReader excelReader = null; try { - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - log.error(e.getMessage()); - throw new EpmetException("读取文件失败"); - } - excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) From e5ed3985254ae05f04dfdbe8c7d006b194bc2c2d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 16:49:03 +0800 Subject: [PATCH 34/44] =?UTF-8?q?=E6=B5=8B=E8=AF=95async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/controller/IcNeighborHoodController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 85797b6e4a..df0120d0a3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -156,13 +156,12 @@ public class IcNeighborHoodController { try { inputStream = file.getInputStream(); }catch (Exception e){ - log.error("读取文件失败"); - }finally { ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); input.setOperatorId(formDTO.getUserId()); input.setTaskId(importTask.getData().getTaskId()); input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); epmetCommonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); } icNeighborHoodService.neighborhoodImport(formDTO,inputStream,importTask); return new Result(); From 87ae44c389121dbc600bb4e52070fcea4df9e24e Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 8 Mar 2022 11:18:12 +0800 Subject: [PATCH 35/44] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6=E7=BB=9F=E8=AE=A1=E5=AF=BC=E5=87=BA=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/govorg/result/GridInfoResultDTO.java | 1 + .../excel/GridLivelyDetailExcel.java | 81 ++++++++ .../dataaggre/excel/GridLivelyExcel.java | 4 +- .../govorg/impl/GovOrgServiceImpl.java | 195 +++++++++++++++++- .../mapper/govorg/CustomerGridDao.xml | 4 +- 5 files changed, 277 insertions(+), 8 deletions(-) create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java index 45618fbff5..a4e155231f 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java @@ -37,5 +37,6 @@ public class GridInfoResultDTO implements Serializable { */ private String gridId = ""; private String gridName = ""; + private String pids = ""; } \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java new file mode 100644 index 0000000000..ce6d2b5365 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dataaggre.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; + +/** + * @Description 网格活跃度文件导出-活跃网格sheet-接口返参 + * @Author sun + */ +@Data +public class GridLivelyDetailExcel { + + LinkedList livelyExcelList; + List livelyGrid; + List ordinaryGrid; + List lazyGrid; + + //活跃网格 + @Data + public static class LivelyGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "活跃网格名称",width = 20) + private String gridName; + @Excel(name = "活跃天数",width = 20) + private Integer datyNum; + } + //正常网格 + @Data + public static class OrdinaryGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "正常运行网格名称", width = 20) + private String gridName; + @Excel(name = "活跃天数", width = 20) + private Integer datyNum; + } + //僵尸网格 + @Data + public static class LazyGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "僵尸网格名称",width = 20) + private String gridName; + @Excel(name = "活跃天数",width = 20) + private Integer datyNum; + } +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java index 331511dbe6..39740aa2a2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java @@ -18,7 +18,7 @@ package com.epmet.dataaggre.excel; import cn.afterturn.easypoi.excel.annotation.Excel; -import com.alibaba.excel.annotation.ExcelIgnore; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.Data; @@ -66,7 +66,7 @@ public class GridLivelyExcel { //正常运行网格数占比 - @Excel(name = "正常运行网格数占比",width = 15) + @Excel(name = "正常运行网格数占比",width = 20) @ExcelProperty("正常运行网格数占比") @ColumnWidth(15) private String gridOrdinaryRatio; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 7acb871048..6b2cb560fe 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -2,9 +2,7 @@ package com.epmet.dataaggre.service.govorg.impl; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.write.metadata.WriteSheet; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import com.alibaba.fastjson.JSON; import com.dingtalk.api.request.OapiRobotSendRequest; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -16,10 +14,11 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.dataaggre.constant.DataSourceConstant; @@ -31,6 +30,7 @@ import com.epmet.dataaggre.dto.govorg.form.*; import com.epmet.dataaggre.dto.govorg.result.*; import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; +import com.epmet.dataaggre.excel.GridLivelyDetailExcel; import com.epmet.dataaggre.excel.GridLivelyExcel; import com.epmet.dataaggre.service.commonservice.AreaCodeService; import com.epmet.dataaggre.service.datastats.DataStatsService; @@ -51,6 +51,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.commons.CommonsMultipartFile; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; @@ -677,13 +678,131 @@ public class GovOrgServiceImpl implements GovOrgService { return subList; } + private GridLivelyDetailExcel gridActiveList(GridLivelyFormDTO formDTO) { + GridLivelyDetailExcel result = new GridLivelyDetailExcel(); + LinkedList livelyExcelList = new LinkedList<>(); + List livelyGrid = new ArrayList<>(); + List ordinaryGrid = new ArrayList<>(); + List lazyGrid = new ArrayList<>(); + //用于存放存在例行工作或上报事件的网格Id,供后边寻找活跃度为0的僵尸网格使用 + Set gridSet = new HashSet<>(); + //0.查询当前组织的直属下级组织列表及组织下的网格总数 + LinkedList subList = customerAgencyDao.subAgencyListAndGridSumNum(formDTO.getAgencyId()); + //1.查询当前组织下所有网格列表 + List gridList = customerGridDao.selectAgencyGridList(formDTO.getAgencyId()); + Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoResultDTO :: getGridId, v -> v, (v1, v2) -> v1)); + //2.查询直属下级组织下网格在查询时间段内存在例行工作次数的网格,一天一条 + List workList = epmetUserService.getGridDateRoutineWorkList(formDTO); + //3.查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格,一天一条 + List projectList = dataStatsService.getGridDateProjectIncrList(formDTO); + //4.汇总数据,一个网格一天只记录一条数据,这条数据可能是例行工作的也可能是上报事件的,也可能某一天两个数都有,但只记录一条 + Set map = workList.stream().map(o -> o.getGridId() + o.getDateId()).collect(Collectors.toSet()); + projectList.stream().filter(pro -> !map.contains(pro.getGridId() + pro.getDateId())).forEach(p -> workList.add(p)); + //5.按组织封装数据 + //计算百分比使用,保留小数点后两位 + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.TWO); + subList.forEach(sub -> { + //5-1.组装存在活跃度的数据【网格活跃天数大于0的】 + Map hash = new HashMap<>(); + workList.forEach(w -> { + if (w.getPids().contains(sub.getAgencyId())) { + if (hash.containsKey(w.getGridId())) { + hash.put(w.getGridId(), hash.get(w.getGridId()) + NumConstant.ONE); + } else { + hash.put(w.getGridId(), NumConstant.ONE); + } + } + }); + //活跃网格数、普通网格数、僵尸网格数 + int gridLivelyNum = 0; + int gridOrdinaryNum = 0; + for (Map.Entry ma : hash.entrySet()){ + gridSet.add(ma.getKey()); + if (ma.getValue() >= NumConstant.FIVE) {//活跃网格 + gridLivelyNum++; + GridLivelyDetailExcel.LivelyGrid lively = new GridLivelyDetailExcel.LivelyGrid(); + lively.setAgencyId(sub.getAgencyId()); + lively.setAgencyName(sub.getAgencyName()); + lively.setGridId(ma.getKey()); + lively.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + lively.setDatyNum(ma.getValue()); + livelyGrid.add(lively); + } else if (ma.getValue() >= NumConstant.TWO && ma.getValue() < NumConstant.FIVE) {//正常网格 + gridOrdinaryNum++; + GridLivelyDetailExcel.OrdinaryGrid ordinary = new GridLivelyDetailExcel.OrdinaryGrid(); + ordinary.setAgencyId(sub.getAgencyId()); + ordinary.setAgencyName(sub.getAgencyName()); + ordinary.setGridId(ma.getKey()); + ordinary.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + ordinary.setDatyNum(ma.getValue()); + ordinaryGrid.add(ordinary); + }else if (ma.getValue() < NumConstant.TWO) {//部分僵尸网格[这是活跃天数为1的,还有部分活跃天数为0的] + GridLivelyDetailExcel.LazyGrid lazy = new GridLivelyDetailExcel.LazyGrid(); + lazy.setAgencyId(sub.getAgencyId()); + lazy.setAgencyName(sub.getAgencyName()); + lazy.setGridId(ma.getKey()); + lazy.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + lazy.setDatyNum(ma.getValue()); + lazyGrid.add(lazy); + } + } + GridLivelyExcel gridLively = new GridLivelyExcel(); + gridLively.setAgencyId(sub.getAgencyId()); + gridLively.setAgencyName(sub.getAgencyName()); + gridLively.setGridSumNum(sub.getGridSumNum()); + gridLively.setGridLivelyNum(gridLivelyNum); + gridLively.setGridLivelyRatio((sub.getGridSumNum() == 0 || gridLivelyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLivelyNum / (float) sub.getGridSumNum()) * 100) + "%"); + gridLively.setGridOrdinaryNum(gridOrdinaryNum); + gridLively.setGridOrdinaryRatio((sub.getGridSumNum() == 0 || gridOrdinaryNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridOrdinaryNum / (float) sub.getGridSumNum()) * 100) + "%"); + int gridLazyNum = sub.getGridSumNum() - gridLivelyNum - gridOrdinaryNum; + gridLively.setGridLazyNum(gridLazyNum < 0 ? 0 : gridLazyNum); + gridLively.setGridLazyRatio((sub.getGridSumNum() == 0 || gridLazyNum < 0) ? "0%" : numberFormat.format(((float) gridLazyNum / (float) sub.getGridSumNum()) * 100) + "%"); + livelyExcelList.add(gridLively); + + //5-2.组装不存在活跃度的数据【网格活跃天数为0的】 + gridList.forEach(g->{ + if(g.getPids().contains(sub.getAgencyId())&&!gridSet.contains(g.getGridId())){ + GridLivelyDetailExcel.LazyGrid lazy = new GridLivelyDetailExcel.LazyGrid(); + lazy.setAgencyId(sub.getAgencyId()); + lazy.setAgencyName(sub.getAgencyName()); + lazy.setGridId(g.getGridId()); + lazy.setGridName(null!=gridMap.get(g.getGridId())?gridMap.get(g.getGridId()).getGridName():""); + lazy.setDatyNum(NumConstant.ZERO); + lazyGrid.add(lazy); + } + }); + }); + //5-3.网格运行情况合计 + if (!CollectionUtils.isEmpty(livelyExcelList)){ + GridLivelyExcel gridLively = new GridLivelyExcel(); + gridLively.setAgencyName("合计"); + gridLively.setGridSumNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridSumNum).sum()); + gridLively.setGridLivelyNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridLivelyNum).sum()); + gridLively.setGridLivelyRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridLivelyNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridLivelyNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + gridLively.setGridOrdinaryNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridOrdinaryNum).sum()); + gridLively.setGridOrdinaryRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridOrdinaryNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridOrdinaryNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + gridLively.setGridLazyNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridLazyNum).sum()); + gridLively.setGridLazyRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridLazyNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridLazyNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + livelyExcelList.add(gridLively); + } + + //6.封装并返回 + result.setLivelyExcelList(livelyExcelList); + result.setLivelyGrid(livelyGrid); + result.setOrdinaryGrid(ordinaryGrid); + result.setLazyGrid(lazyGrid); + return result; + } + /** * @Author sun * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 **/ @Override public void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO) { - ExcelWriter excelWriter = null; + //easyExcel导出 + /*ExcelWriter excelWriter = null; try { excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("网格活跃度统计表.xlsx", response)).build(); WriteSheet writeSheet = EasyExcel.writerSheet(excelSheetName(formDTO)).build(); @@ -696,7 +815,73 @@ public class GovOrgServiceImpl implements GovOrgService { if (excelWriter != null) { excelWriter.finish(); } + }*/ + //easyPoi导出 + //1.获取当前组织缓存信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId()); + if (null == agencyInfo) { + throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); + } + //2.查询网格活跃度数据 + GridLivelyDetailExcel resultDTO = gridActiveList(formDTO); + if(null==resultDTO||CollectionUtils.isEmpty(resultDTO.getLivelyExcelList())){ + log.warn(String.format("网格员活跃度统计数据为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + //3.生成多sheet页excel文件并写入数据导出文件 + List> headerList = new ArrayList<>(); + String titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计表"); + headerList.add(getHaderMap(resultDTO.getLivelyExcelList(), titleName, "各街镇网格运行情况", GridLivelyExcel.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"活跃网格明细"); + headerList.add(getHaderMap(resultDTO.getLivelyGrid(), titleName, "活跃网格统计", GridLivelyDetailExcel.LivelyGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"正常运行网格明细"); + headerList.add(getHaderMap(resultDTO.getOrdinaryGrid(), titleName, "正常运行网格统计", GridLivelyDetailExcel.OrdinaryGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"僵尸网格明细"); + headerList.add(getHaderMap(resultDTO.getLazyGrid(), titleName, "僵尸网格统计", GridLivelyDetailExcel.LazyGrid.class)); + try { + Workbook workbook = ExcelExportUtil.exportExcel(headerList, ExcelType.XSSF); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + String fileName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计.xls"); + response.setHeader("Content-Disposition", "attachment;filename=" +fileName); + ServletOutputStream out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + log.error("网格活跃度导出失败", e); + } + } + /** + * @Author sun + * data 业务数据集合 + * title sheet页主标题 + * name sheet页名称 + * cl sheet页列头对应实体类 + * @Description 生成多sheet页excel文件模板数据 + **/ + private Map getHaderMap(Collection data, String title, String name, Class cl){ + Map map = new HashMap<>(); + map.put("data",data); + ExportParams param1 = new ExportParams(title, name); + map.put("title", param1); + map.put("entity", cl); + return map; + } + /** + * @Author sun + * @Description excel文件sheet页主标题拼接 + **/ + private String excelTitleName(String startTime, String endTime, String name){ + StringBuilder titleName = new StringBuilder(); + SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy年MM月dd日"); + try{ + titleName.append("(").append(format2.format(format1.parse(startTime))).append("至").append(format2.format(format1.parse(endTime))).append(")").append(name); + } catch (Exception e) { + e.printStackTrace(); } + return titleName.toString(); } private String excelSheetName(GridLivelyFormDTO formDTO){ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml index 60350c7a1e..adc659eae6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml @@ -6,12 +6,14 @@ From 2351f777cf0474b327331c4b5ddecc295f207ce1 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 8 Mar 2022 17:49:24 +0800 Subject: [PATCH 38/44] =?UTF-8?q?=E5=A4=9A=E4=BD=99=E7=9A=84=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi-partymember/resi-partymember-server/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/epmet-module/resi-partymember/resi-partymember-server/pom.xml b/epmet-module/resi-partymember/resi-partymember-server/pom.xml index 2402119744..912fe79e30 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/pom.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/pom.xml @@ -64,12 +64,6 @@ 2.0.0 compile - - com.epmet - resi-partymember--client - 2.0.0 - compile - info.debatty java-string-similarity From caae7f60a1973ce20ba25aa93f1ea7523908860a Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 8 Mar 2022 21:20:52 +0800 Subject: [PATCH 39/44] =?UTF-8?q?ttl=E6=94=B9=E9=80=A0=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-commons/epmet-commons-tools/pom.xml | 5 + .../commons/tools/config/AsyncConfig.java | 3 +- .../tools/constant/ThreadLocalConstant.java | 4 - .../feign/EpmetBaseRequestInterceptor.java | 19 ++-- .../FeignHystrixConcurrencyStrategy.java | 104 +++++++++++++++--- .../commons/tools/filter/GlobalFilter.java | 53 ++++++++- .../tools/utils/EpmetRequestHolder.java | 67 +++++++++++ .../controller/IcResiUserController.java | 57 ++++------ .../service/IcResiUserImportService.java | 2 + .../impl/IcResiUserImportServiceImpl.java | 57 ++++++---- 10 files changed, 278 insertions(+), 93 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index 31e2276fc4..cafd5f7023 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -161,6 +161,11 @@ 2.6.0 compile + + com.alibaba + transmittable-thread-local + 2.12.4 + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java index 2778f3c9ef..f094348322 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java @@ -1,5 +1,6 @@ package com.epmet.commons.tools.config; +import com.alibaba.ttl.threadpool.TtlExecutors; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -69,7 +70,7 @@ public class AsyncConfig { @Bean public ExecutorService executorService() { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); + return TtlExecutors.getTtlExecutorService(executor.getThreadPoolExecutor()); } /** diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java index 9061c2e8d3..40d69ebcf4 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java @@ -22,8 +22,4 @@ public class ThreadLocalConstant { */ public static final ThreadLocal requestParam = new ThreadLocal(); - /** - * 可被子线程继承的,追加的request headers - */ - public static final InheritableThreadLocal> inheritableAdditionalHeaders = new InheritableThreadLocal<>(); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index d19a1145d2..2cfa8ea3ad 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -1,6 +1,6 @@ package com.epmet.commons.tools.feign; -import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.epmet.commons.tools.utils.EpmetRequestHolder; import feign.RequestInterceptor; import feign.RequestTemplate; import org.slf4j.Logger; @@ -21,23 +21,17 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { - // 自定义追加的request header,可被子线程继承拷贝 - Map inheritableAdditionalHeaders = FeignHystrixConcurrencyStrategy.hystrixAdditionHeaders.get(); - Map requestHeaders = getHeadersFromRequest(); + Map requestHeaders = EpmetRequestHolder.getAllHeaders(); - log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:"+inheritableAdditionalHeaders); +// Map requestHeaders = getHeadersFromRequest(); + + log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:" + requestHeaders); if (requestHeaders != null && requestHeaders.size() > 0) { for (Map.Entry kv : requestHeaders.entrySet()) { template.header(kv.getKey(), kv.getValue()); } } - - if (inheritableAdditionalHeaders != null && inheritableAdditionalHeaders.size() > 0) { - for (Map.Entry kv : inheritableAdditionalHeaders.entrySet()) { - template.header(kv.getKey(), kv.getValue()); - } - } } /** @@ -47,6 +41,9 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { HashMap headers = new HashMap<>(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if (requestAttributes == null) { + return null; + } HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Enumeration headerNames = request.getHeaderNames(); if (headerNames != null) { diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java index 0d2998ccd3..2a63841ac9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java @@ -1,6 +1,6 @@ package com.epmet.commons.tools.feign; -import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.alibaba.ttl.TtlRunnable; import com.netflix.hystrix.HystrixThreadPoolKey; import com.netflix.hystrix.HystrixThreadPoolProperties; import com.netflix.hystrix.strategy.HystrixPlugins; @@ -12,17 +12,15 @@ import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; import com.netflix.hystrix.strategy.properties.HystrixProperty; +import com.netflix.hystrix.util.PlatformSpecific; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; /** * 自定义Feign的隔离策略 @@ -37,7 +35,6 @@ import java.util.concurrent.TimeUnit; @Component public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy { - public static final ThreadLocal> hystrixAdditionHeaders = new ThreadLocal<>(); private static final Logger log = LoggerFactory.getLogger(FeignHystrixConcurrencyStrategy.class); private HystrixConcurrencyStrategy delegate; @@ -77,23 +74,57 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy @Override public Callable wrapCallable(Callable callable) { - Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - return new WrappedCallable<>(callable, requestAttributes, inheritableAdditionalHeaders); + return new WrappedCallable<>(callable, requestAttributes); } @Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty corePoolSize, HystrixProperty maximumPoolSize, HystrixProperty keepAliveTime, TimeUnit unit, BlockingQueue workQueue) { - return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, - unit, workQueue); +// return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + + final ThreadFactory threadFactory = getThreadFactory(threadPoolKey); + + final int dynamicCoreSize = corePoolSize.get(); + final int dynamicMaximumSize = maximumPoolSize.get(); + + if (dynamicCoreSize > dynamicMaximumSize) { + log.error("Epmet Hystrix ThreadPool configuration at startup for : " + threadPoolKey.name() + " is trying to set coreSize = " + + dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " + + dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value"); + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime.get(), unit, workQueue, threadFactory); + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicMaximumSize, keepAliveTime.get(), unit, workQueue, threadFactory); + } } @Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) { - return this.delegate.getThreadPool(threadPoolKey, threadPoolProperties); +// return this.delegate.getThreadPool(threadPoolKey, threadPoolProperties); + + final ThreadFactory threadFactory = getThreadFactory(threadPoolKey); + + final boolean allowMaximumSizeToDivergeFromCoreSize = threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get(); + final int dynamicCoreSize = threadPoolProperties.coreSize().get(); + final int keepAliveTime = threadPoolProperties.keepAliveTimeMinutes().get(); + final int maxQueueSize = threadPoolProperties.maxQueueSize().get(); + final BlockingQueue workQueue = getBlockingQueue(maxQueueSize); + + if (allowMaximumSizeToDivergeFromCoreSize) { + final int dynamicMaximumSize = threadPoolProperties.maximumSize().get(); + if (dynamicCoreSize > dynamicMaximumSize) { + log.error("Epmet Hystrix ThreadPool configuration at startup for : " + threadPoolKey.name() + " is trying to set coreSize = " + + dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " + + dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value"); + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicMaximumSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } } @Override @@ -106,21 +137,41 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy return this.delegate.getRequestVariable(rv); } + /** + * 从父类复制过来的 + * @param threadPoolKey + * @return + */ + private ThreadFactory getThreadFactory(final HystrixThreadPoolKey threadPoolKey) { + if (!PlatformSpecific.isAppEngineStandardEnvironment()) { + return new ThreadFactory() { + private final AtomicInteger threadNumber = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r, "hystrix-" + threadPoolKey.name() + "-" + threadNumber.incrementAndGet()); + thread.setDaemon(true); + return thread; + } + + }; + } else { + return PlatformSpecific.getAppEngineThreadFactory(); + } + } + static class WrappedCallable implements Callable { private final Callable target; private final RequestAttributes requestAttributes; - private final Map inheritableAdditionalHeaders; - public WrappedCallable(Callable target, RequestAttributes requestAttributes, Map inheritableAdditionalHeaders) { + public WrappedCallable(Callable target, RequestAttributes requestAttributes) { this.target = target; this.requestAttributes = requestAttributes; - this.inheritableAdditionalHeaders = inheritableAdditionalHeaders; } @Override public T call() throws Exception { try { - hystrixAdditionHeaders.set(inheritableAdditionalHeaders); RequestContextHolder.setRequestAttributes(requestAttributes); return target.call(); } finally { @@ -128,4 +179,25 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy } } } + + /** + * 自定义线程池类,使用Ttl包装过,解决异步环境下线程上下文透传问题 + */ + static class WrappedThreadPoolExecutor extends ThreadPoolExecutor { + private static final RejectedExecutionHandler defaultHandler = new AbortPolicy(); + + public WrappedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, + BlockingQueue workQueue) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + } + public WrappedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, + BlockingQueue workQueue, ThreadFactory threadFactory) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, defaultHandler); + } + + @Override + public void execute(Runnable command) { + super.execute(TtlRunnable.get(command)); + } + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java index 4aa7beab20..d27a5dbe0f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java @@ -1,10 +1,16 @@ package com.epmet.commons.tools.filter; import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import lombok.extern.slf4j.Slf4j; import javax.servlet.*; import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.util.Enumeration; +import java.util.HashMap; /** * @Description 全局过滤器,可在请求结束的时候清除线程变量残留 @@ -12,20 +18,59 @@ import java.io.IOException; * @date 2021.07.19 10:19:24 */ @WebFilter(value = "/*") +@Slf4j public class GlobalFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { + // 获取request中的header,放入RequestHeaderHolder,用于异步环境下的上下文透传 + HashMap headerMap = getHeadersFromRequest((HttpServletRequest) servletRequest); + EpmetRequestHolder.addHeaders(headerMap); + filterChain.doFilter(servletRequest, servletResponse); } catch (Throwable e) { throw e; } finally { // 清除线程变量残留 - ThreadLocalConstant.sqlFilter.remove(); - ThreadLocalConstant.requirePermissionTl.remove(); - ThreadLocalConstant.requestParam.remove(); - ThreadLocalConstant.inheritableAdditionalHeaders.remove(); + clear(ThreadLocalConstant.sqlFilter, "sqlFilter"); + clear(ThreadLocalConstant.requirePermissionTl, "requirePermissionTl"); + clear(ThreadLocalConstant.requestParam, "requestParam"); + EpmetRequestHolder.clearAllHeaders(); + System.out.println("清理完成"); + } + } + + /** + * 从header里面获取headers + */ + public HashMap getHeadersFromRequest(HttpServletRequest request) { + HashMap headers = new HashMap<>(); + Enumeration headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasMoreElements()) { + String name = headerNames.nextElement(); + Enumeration values = request.getHeaders(name); + while (values.hasMoreElements()) { + String value = values.nextElement(); + headers.put(name, value); + } + } + } + return headers; + } + + /** + * 清空threadlocal + * @param tl + * @param tag + */ + public void clear(ThreadLocal tl, String tag) { + try { + tl.remove(); + } catch (Throwable t) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(t); + log.error("【GlobalFilter】清空ThreadLocal失败,{}, {}", tag, errorMsg); } } } \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java new file mode 100644 index 0000000000..80849ebfc3 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java @@ -0,0 +1,67 @@ +package com.epmet.commons.tools.utils; + +import com.alibaba.ttl.TransmittableThreadLocal; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 请求header holder,可用于异步环境下request header的透传。详情结合 alibaba transmitable-thread-local + */ +public class EpmetRequestHolder { + + public static final TransmittableThreadLocal> requestHeaderTtl = new TransmittableThreadLocal<>(); + + /** + * 存储 + * @param headerName + * @param headerValue + */ + public static void addHeader(String headerName, String headerValue) { + if (StringUtils.isBlank(headerName)) { + return; + } + before(); + requestHeaderTtl.get().put(headerName, headerValue); + } + + public static void addHeaders(Map headers) { + if (headers == null) { + return; + } + before(); + requestHeaderTtl.get().putAll(headers); + } + + private static void before() { + if (requestHeaderTtl.get() == null) { + requestHeaderTtl.set(new HashMap<>()); + } + } + + /** + * 获取 + * @param headerName + * @return + */ + public static String getHeader(String headerName) { + return requestHeaderTtl.get().get(headerName); + } + + /** + * 获取所有 + * @return + */ + public static Map getAllHeaders() { + return requestHeaderTtl.get(); + } + + /** + * 清空内容 + */ + public static void clearAllHeaders() { + requestHeaderTtl.remove(); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index e09f7427c5..bde8165171 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -35,7 +35,6 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.feign.EpmetBaseRequestInterceptor; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; @@ -43,10 +42,7 @@ import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.HttpClientManager; -import com.epmet.commons.tools.utils.IpUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.SystemMessageType; import com.epmet.constants.ImportTaskConstants; @@ -67,7 +63,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.tomcat.util.http.MimeHeaders; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; @@ -75,7 +70,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -83,13 +77,11 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -135,6 +127,8 @@ public class IcResiUserController implements ResultDataResolver { private LoginUserUtil loginUserUtil; @Autowired private RequestInterceptor requestInterceptor; + @Autowired + private ExecutorService executorService; /** * 模板枚举 @@ -467,12 +461,8 @@ public class IcResiUserController implements ResultDataResolver { throw new RenException("上传失败"); } - HashMap headers = ((EpmetBaseRequestInterceptor) requestInterceptor).getHeadersFromRequest(); - - ThreadLocalConstant.inheritableAdditionalHeaders.set(headers); - // 三.异步执行导入 - new Thread(() -> { + executorService.execute(() -> { try { List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); @@ -491,31 +481,12 @@ public class IcResiUserController implements ResultDataResolver { } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } - - // 清理tl对象 - ThreadLocalConstant.inheritableAdditionalHeaders.remove(); } - }).start(); + }); return new Result(); } -// private HashMap getHeadersFromRequest(HttpServletRequest request) { -// HashMap headers = new HashMap<>(); -// Enumeration headerNames = request.getHeaderNames(); -// if (headerNames != null) { -// while (headerNames.hasMoreElements()) { -// String name = headerNames.nextElement(); -// Enumeration values = request.getHeaders(name); -// while (values.hasMoreElements()) { -// String value = values.nextElement(); -// headers.put(name, value); -// } -// } -// } -// return headers; -// } - @PostMapping("test") public Result>> test(@LoginUser TokenDto tokenDto, @RequestBody DynamicQueryFormDTO formDTO) { formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); @@ -747,4 +718,22 @@ public class IcResiUserController implements ResultDataResolver { ValidatorUtils.validateEntity(formDTO, PersonWarnRightListFormDTO.PersonWarnRightListForm.class); return new Result().ok(icResiUserService.personWarnRightList(formDTO,tokenDto)); } + +// public static ThreadLocal tl = new ThreadLocal(); + + @PostMapping("test-async") + public Result testAsync(HttpServletRequest request){ +// tl.set("wxz"); + executorService.submit(() -> { + try { + Thread.sleep(500l); + System.out.println("["+Thread.currentThread().getId() + "]:" + EpmetRequestHolder.getHeader("app")); + System.out.println("---"); + } catch (InterruptedException e) { + e.printStackTrace(); + } +// icResiUserImportService.testAsync(); + }); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 7358dcd961..05fb431c32 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -32,4 +32,6 @@ public interface IcResiUserImportService { * @param resultDescPath 结果描述文件,excel等文件,有错误的话需要传入,成功则不需要 */ void finishImportTask(String importTaskId, String operatorId, String processStatus, String resultDesc, String resultDescPath); + + Object testAsync(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 62b7dbf697..302d3d7b01 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -24,7 +24,9 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcResiUserDao; @@ -213,9 +215,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res @Override public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) { - String app = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); - String client = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String currUserAgencyId = userService.getLoginUserDetails(app, client, loginUserId).getAgencyId(); @@ -316,7 +318,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ private void initImportThreadLocal(String customerId) { // 生成importTag,用于标记唯一一次导入操作,导入完成之后,用来删除redis里面临时的key - String operatorId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String operatorId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String importTag = operatorId + System.currentTimeMillis(); // 错误信息 @@ -356,10 +358,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private void importIcResiBaseInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId, String tableName, String customerId) { - String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); - String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + String loginUserApp = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String loginUserClient = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("importIcResiBaseInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -472,7 +474,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("AGENCY_ID", currUserAgencyId); columnAndValues.put("PIDS", currUserAgencyPids); - columnAndValues.put("CUSTOMER_ID", ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase())); + columnAndValues.put("CUSTOMER_ID", EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase())); columnAndValues.put("UPDATED_BY", currentUserId); @@ -542,10 +544,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res LinkedHashMap columnAndValues = new LinkedHashMap<>(); - String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); - String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + String loginUserApp = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String loginUserClient = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("persistIcResiExtraInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -1281,8 +1283,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Date now = new Date(); - String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); - String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); @@ -1378,8 +1380,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Set newResiKeys = redisUtils.keys(RedisKeys.icResiImportTypeKey(newlyOrChangedResi.get().getImportTag(), "add").concat("*")); - String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); - String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); @@ -1416,8 +1418,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ public void saveTransferedResiRecord(Map transferedResis) { Date now = new Date(); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserCustomerId, loginUserId); for (Map.Entry resi : transferedResis.entrySet()) { @@ -1831,11 +1835,18 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } public void printLog(String positionPrefix) { - String app = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); - String client = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, app, client, loginUserCustomerId); } + + @Override + public Object testAsync() { + IcNeighborHoodDTO nform = new IcNeighborHoodDTO(); + govOrgOpenFeignClient.getNeighborHoodOptions(nform); + return null; + } } From 0f5238059615698925fd28f692b9a3288b0d2477 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 9 Mar 2022 12:42:34 +0800 Subject: [PATCH 40/44] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6=E7=BB=9F=E8=AE=A1=E6=94=B9=E4=B8=BA=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=82=20xlsx=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../govorg/impl/GovOrgServiceImpl.java | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 6b2cb560fe..2635efc937 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -18,7 +18,6 @@ import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.dataaggre.constant.DataSourceConstant; @@ -829,15 +828,7 @@ public class GovOrgServiceImpl implements GovOrgService { return; } //3.生成多sheet页excel文件并写入数据导出文件 - List> headerList = new ArrayList<>(); - String titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计表"); - headerList.add(getHaderMap(resultDTO.getLivelyExcelList(), titleName, "各街镇网格运行情况", GridLivelyExcel.class)); - titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"活跃网格明细"); - headerList.add(getHaderMap(resultDTO.getLivelyGrid(), titleName, "活跃网格统计", GridLivelyDetailExcel.LivelyGrid.class)); - titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"正常运行网格明细"); - headerList.add(getHaderMap(resultDTO.getOrdinaryGrid(), titleName, "正常运行网格统计", GridLivelyDetailExcel.OrdinaryGrid.class)); - titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"僵尸网格明细"); - headerList.add(getHaderMap(resultDTO.getLazyGrid(), titleName, "僵尸网格统计", GridLivelyDetailExcel.LazyGrid.class)); + List> headerList = getHeaderList(formDTO,agencyInfo,resultDTO); try { Workbook workbook = ExcelExportUtil.exportExcel(headerList, ExcelType.XSSF); response.setCharacterEncoding("UTF-8"); @@ -852,6 +843,20 @@ public class GovOrgServiceImpl implements GovOrgService { log.error("网格活跃度导出失败", e); } } + + private List> getHeaderList(GridLivelyFormDTO formDTO, AgencyInfoCache agencyInfo,GridLivelyDetailExcel resultDTO) { + List> headerList = new ArrayList<>(); + String titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计表"); + headerList.add(getHaderMap(resultDTO.getLivelyExcelList(), titleName, "各街镇网格运行情况", GridLivelyExcel.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"活跃网格明细"); + headerList.add(getHaderMap(resultDTO.getLivelyGrid(), titleName, "活跃网格统计", GridLivelyDetailExcel.LivelyGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"正常运行网格明细"); + headerList.add(getHaderMap(resultDTO.getOrdinaryGrid(), titleName, "正常运行网格统计", GridLivelyDetailExcel.OrdinaryGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"僵尸网格明细"); + headerList.add(getHaderMap(resultDTO.getLazyGrid(), titleName, "僵尸网格统计", GridLivelyDetailExcel.LazyGrid.class)); + return headerList; + } + /** * @Author sun * data 业务数据集合 @@ -902,25 +907,38 @@ public class GovOrgServiceImpl implements GovOrgService { **/ @Override public void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO) { - List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); + /*List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); if(CollectionUtils.isEmpty(data)){ log.warn(String.format("网格员活跃度统计数据查询为空,入参【%s】", JSON.toJSONString(formDTO))); return; } ExportParams exportParams = new ExportParams(); - String sheetName = excelSheetName(formDTO); exportParams.setSheetName(sheetName); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, - GridLivelyExcel.class, data); - + GridLivelyExcel.class, data);*/ + //1.获取当前组织缓存信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId()); + if (null == agencyInfo) { + throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); + } + //2.查询网格活跃度数据 + GridLivelyDetailExcel resultDTO = gridActiveList(formDTO); + if (null == resultDTO || CollectionUtils.isEmpty(resultDTO.getLivelyExcelList())) { + log.warn(String.format("网格员活跃度统计数据为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + //3.生成多sheet页excel文件并写入数据导出文件 + List> headerList = getHeaderList(formDTO,agencyInfo,resultDTO); // 文件名 - String resultDescFileName = sheetName.concat(".xls"); + String sheetName = excelSheetName(formDTO); + String resultDescFileName = sheetName.concat(".xlsx"); FileItemFactory factory = new DiskFileItemFactory(16, null); FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); OutputStream os = null; Result uploadResult = null; try { + Workbook workbook = ExcelExportUtil.exportExcel(headerList, ExcelType.XSSF); os = fileItem.getOutputStream(); workbook.write(os); uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); @@ -946,17 +964,18 @@ public class GovOrgServiceImpl implements GovOrgService { log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败"); } else { //EPMETV3群机器人 - String secret = DingDingRobotConstant.V3_ROBOT_SECRET; - String url = DingDingRobotConstant.V3_ROBOT_URL; - // String secret = DingDingRobotConstant.YZM_TEST_SECRET; - // String url = DingDingRobotConstant.YZM_TEST_URL; + // String secret = DingDingRobotConstant.V3_ROBOT_SECRET; + // String url = DingDingRobotConstant.V3_ROBOT_URL; + String secret = DingDingRobotConstant.YZM_TEST_SECRET; + String url = DingDingRobotConstant.YZM_TEST_URL; DingTextBriefNessFormDTO dingTalkTextMsg=new DingTextBriefNessFormDTO(); dingTalkTextMsg.setMsgtype("text"); //小雷哥手机号:18660295251, OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); - at.setAtMobiles(Arrays.asList("18660295251")); + // at.setAtMobiles(Arrays.asList("18660295251")); + at.setAtMobiles(Arrays.asList("15764229697")); at.setIsAtAll(false); dingTalkTextMsg.setAt(at); @@ -965,7 +984,7 @@ public class GovOrgServiceImpl implements GovOrgService { text.setContent("网格活跃度统计: \n" + "起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n" + "文件下载地址: " + uploadResult.getData().getUrl() + "\n"+ - "请查收@18660295251"); + "请查收@15764229697"); dingTalkTextMsg.setText(text); HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(dingTalkTextMsg), url, secret); } From f9fb6ae6453e692384b2df7144c89eed670b8966 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 9 Mar 2022 12:57:57 +0800 Subject: [PATCH 41/44] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6=E7=BB=9F=E8=AE=A1=E6=94=B9=E4=B8=BA=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=82=20xlsx=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/govorg/impl/GovOrgServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 2635efc937..dc63adc141 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -964,18 +964,18 @@ public class GovOrgServiceImpl implements GovOrgService { log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败"); } else { //EPMETV3群机器人 - // String secret = DingDingRobotConstant.V3_ROBOT_SECRET; - // String url = DingDingRobotConstant.V3_ROBOT_URL; - String secret = DingDingRobotConstant.YZM_TEST_SECRET; - String url = DingDingRobotConstant.YZM_TEST_URL; + String secret = DingDingRobotConstant.V3_ROBOT_SECRET; + String url = DingDingRobotConstant.V3_ROBOT_URL; + // String secret = DingDingRobotConstant.YZM_TEST_SECRET; + // String url = DingDingRobotConstant.YZM_TEST_URL; DingTextBriefNessFormDTO dingTalkTextMsg=new DingTextBriefNessFormDTO(); dingTalkTextMsg.setMsgtype("text"); //小雷哥手机号:18660295251, OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); - // at.setAtMobiles(Arrays.asList("18660295251")); - at.setAtMobiles(Arrays.asList("15764229697")); + at.setAtMobiles(Arrays.asList("18660295251")); + // at.setAtMobiles(Arrays.asList("15764229697")); at.setIsAtAll(false); dingTalkTextMsg.setAt(at); @@ -984,7 +984,7 @@ public class GovOrgServiceImpl implements GovOrgService { text.setContent("网格活跃度统计: \n" + "起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n" + "文件下载地址: " + uploadResult.getData().getUrl() + "\n"+ - "请查收@15764229697"); + "请查收@18660295251"); dingTalkTextMsg.setText(text); HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(dingTalkTextMsg), url, secret); } From 4cfb8ddbaf88fe5133a1384d075e03a73c8f71e9 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 9 Mar 2022 14:23:50 +0800 Subject: [PATCH 42/44] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E7=9A=84=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E8=A1=97=E9=81=93=E7=9A=84=E6=95=B0=E6=8D=AE=E5=9C=A8?= =?UTF-8?q?=E8=A1=A8=E9=87=8C=E5=90=8C=E4=B8=80=E5=A4=A9=E4=BC=9A=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E4=B8=A4=E6=9D=A1=EF=BC=8C=E4=B8=80=E6=9D=A1=E6=98=AF?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E7=9A=84=E4=B8=80=E6=9D=A1=E6=98=AF=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=BB=9F=E8=AE=A1=E7=9A=84=EF=BC=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=95=B0=E6=8D=AE=E6=97=B6=E5=88=86=E5=88=AB=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E7=BB=84=E7=BB=87=E7=BD=91=E6=A0=BC=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/datastats/DatsStatsDao.xml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml index 26f74c4124..891e6f2cf4 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml @@ -1033,7 +1033,13 @@ AND date_id #{endTime} - GROUP BY date_id, agency_id + + + GROUP BY date_id, agency_id + + + GROUP BY date_id, grid_id + ORDER BY date_id ASC @@ -1041,7 +1047,13 @@ AND date_id =]]> #{startTime} AND date_id #{endTime} - GROUP BY date_id, agency_id + + + GROUP BY date_id, agency_id + + + GROUP BY date_id, grid_id + ORDER BY date_id DESC From 85e019535b252afac08dc5934be1f956bfb196cb Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 9 Mar 2022 15:51:47 +0800 Subject: [PATCH 43/44] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E7=82=B9=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/OperCustomizeOpenFeignClient.java | 11 ++++++- .../ResiCategoryStatsConfigController.java | 11 +++++++ .../IcStatsResiWarnBuildingResultDTO.java | 32 ++++++++++++++++++- .../controller/StatsResiWarnController.java | 17 +++++++--- .../epmet/service/StatsResiWarnService.java | 18 +++++++++-- .../impl/StatsResiWarnServiceImpl.java | 6 ++++ 6 files changed, 86 insertions(+), 9 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index 133f98ab11..c714bd77e1 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -102,10 +102,19 @@ public interface OperCustomizeOpenFeignClient { Result> getCategoryList(@RequestBody IcResiCategoryStatsConfigDTO dto); - + /** + * 获取居民类别配置表ic_resi_category_stats_config,根据token里的客户id查询,可根据状态筛选:显示:show;隐藏:hidden; + * @param formDTO + * @return + */ @PostMapping("/oper/customize/resicategorystatsconfig/resicategorystatslistshowd") Result> resiCategoryStatsListShowd(@RequestBody IcResiCategoryStatsConfigFormDTO formDTO); + /** + * 查询ic_resi_category_warn_config,返回预警的类别 + * @param customerId + * @return + */ @PostMapping("/oper/customize/resicategorystatsconfig/resicategorywarnlist") Result> resiCategoryWarnList(@RequestParam String customerId); diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java index f43e75bf97..3c2004e714 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java @@ -128,6 +128,12 @@ public class ResiCategoryStatsConfigController { return new Result().ok(resiCategoryStatsConfigService.info(formDTO.getId(),tokenDTO.getCustomerId())); } + /** + * 获取居民类别配置表ic_resi_category_stats_config,根据token里的客户id查询,可根据状态筛选:显示:show;隐藏:hidden; + * @param tokenDTO + * @param formDTO + * @return + */ @PostMapping("resicategorystatslistshowd") public Result> resiCategoryStatsListShowd(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ //获取预警配置列表 @@ -145,6 +151,11 @@ public class ResiCategoryStatsConfigController { return new Result>().ok(ConvertUtils.sourceToTarget(statsConfigEntityList, IcResiCategoryStatsConfigDTO.class)); } + /** + * 查询ic_resi_category_warn_config,返回预警的类别 + * @param customerId + * @return + */ @PostMapping("resicategorywarnlist") public Result> resiCategoryWarnList(@RequestParam String customerId){ //获取预警配置列表 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java index 3d4253f721..f4c317274a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java @@ -20,7 +20,6 @@ package com.epmet.dto.result; import lombok.Data; import java.io.Serializable; -import java.util.Date; import java.util.List; @@ -38,21 +37,52 @@ public class IcStatsResiWarnBuildingResultDTO implements Serializable { /** * 预警配置ID + * ic_resi_category_warn_config.id */ private String configId; + /** + * ic_resi_category_warn_config.label + * 类别名 + */ private String label; + /** + * 排序 + */ private Integer sort; + + /** + * 等级1阈值 + */ private Integer level1; private Integer levelCount1; + + /** + * 等级2阈值 + */ private Integer level2; private Integer levelCount2; + + /** + * 等级3阈值 + */ private Integer level3; private Integer levelCount3; + /** + * 管理平台分类图标 + */ private String managementIcon; + + /** + * 数据平台分类图标 + */ private String dataIcon; + + /** + * 房屋显示分类图标 + */ private String houseShowIcon; private Integer count; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java index 33855a2b2c..3d18050f66 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java @@ -17,19 +17,15 @@ package com.epmet.controller; -import com.epmet.common.token.annotation.Login; 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.dto.form.CategoryCountListFormDTO; import com.epmet.dto.form.StatsResiListFormDTO; import com.epmet.dto.form.StatsResiWarnCountFormDTO; import com.epmet.dto.form.StatsResiWarnFormDTO; -import com.epmet.dto.result.CategoryCountListResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; -import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; import com.epmet.service.IcStatsResiWarnService; import com.epmet.service.StatsResiWarnService; import org.springframework.beans.factory.annotation.Autowired; @@ -80,6 +76,12 @@ public class StatsResiWarnController { return new Result>().ok(statsResiWarnService.list2(formDTO)); } + /** + * 可视化分析-人员预警,各类别楼栋数量展示 + * @param tokenDto + * @param formDTO 只有agencyId + * @return + */ @PostMapping("buildingwarnlist") public Result buildingWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedBuilding.class); @@ -89,6 +91,13 @@ public class StatsResiWarnController { return new Result().ok(icStatsResiWarnBuildingResultDTOS); } + + /** + * 可视化分析-人员预警,楼栋列表展示 + * @param tokenDto + * @param formDTO + * @return + */ @PostMapping("userwarnlist") public Result userWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedUser.class); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java index f0c4e5f5f5..7c5477b61b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java @@ -17,12 +17,9 @@ package com.epmet.service; -import com.epmet.dto.form.CategoryCountListFormDTO; import com.epmet.dto.form.StatsResiListFormDTO; -import com.epmet.dto.result.CategoryCountListResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; -import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; import java.util.List; import java.util.Map; @@ -35,8 +32,23 @@ import java.util.Map; */ public interface StatsResiWarnService{ + /** + * 可视化分析-人员预警,各类别楼栋数量展示 + * @param customerId + * @param agencyID + * @return + */ List buildingwWarnList(String customerId,String agencyID); + /** + * 可视化分析-人员预警,楼栋列表展示 + * @param customerId + * @param configId + * @param buildingIdList + * @param pageNo + * @param pageSize + * @return + */ Map userWarnList(String customerId, String configId, List buildingIdList, Integer pageNo, Integer pageSize); List list(String customerId,String id, String level); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java index c6b33e482b..789b189016 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java @@ -50,6 +50,12 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { @Resource private IcResiUserDao icResiUserDao; + /** + * 可视化分析-人员预警,各类别楼栋数量展示 + * @param customerId + * @param agencyID + * @return + */ @Override public List buildingwWarnList(String customerId,String agencyID) { List result = new ArrayList<>(); From dd5f9e18f2d9d51ac15a28034cc2e2289fef2b20 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 10 Mar 2022 09:11:14 +0800 Subject: [PATCH 44/44] =?UTF-8?q?=E4=BA=BA=E5=91=98=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/PersonWarnRightListFormDTO.java | 2 ++ .../result/PersonWarnRightListResultDTO.java | 3 +++ .../service/impl/IcResiUserServiceImpl.java | 24 ++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java index 977390e31a..9be92d4233 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java @@ -22,4 +22,6 @@ public class PersonWarnRightListFormDTO implements Serializable { @NotNull(message = "pageSize不能为空",groups = PersonWarnRightListForm.class) private Integer pageSize; + + private String categoryCode; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java index c98b26cbec..a2739c6857 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java @@ -35,6 +35,9 @@ public class PersonWarnRightListResultDTO implements Serializable { */ private List type; + @JsonIgnore + private String sortString; + /** * 所属网格 */ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index bab73c6909..df7bcd4458 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -1186,8 +1186,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl configList = configListResult.getData(); - PageInfo> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectResiUsers(configList.stream().map(m -> m.getColumnName()).collect(Collectors.toList()), staffInfo.getAgencyId())); + List configListOrigin = configListResult.getData(); + List configList = new ArrayList<>(); + if (StringUtils.isNotBlank(formDTO.getCategoryCode())){ + for (CustomerCategoryShowAndWarnListResultDTO c : configListOrigin) { + if (c.getColumnName().equals(formDTO.getCategoryCode())){ + configList.add(c); + } + } + }else { + configList = configListOrigin; + } + List finalConfigList = configList; + PageInfo> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectResiUsers(finalConfigList.stream().map(m -> m.getColumnName()).collect(Collectors.toList()), staffInfo.getAgencyId())); List> list = pageInfo.getList(); if (CollectionUtils.isEmpty(list)) { return result; @@ -1200,7 +1211,14 @@ public class IcResiUserServiceImpl extends BaseServiceImpl houseInfos = houseInfosResult.getData(); userList.forEach(u -> houseInfos.stream().filter(h -> h.getHomeId().equals(u.getHomeId())).forEach(h -> u.setFamily(h.getAllName()))); - result.setList(userList); + // 类型+网格+家庭 排序 + userList.forEach(u -> { + String types = u.getType().stream().map(String::valueOf).collect(Collectors.joining("、")); + String s = types + u.getGridName() + u.getFamily(); + u.setSortString(s); + }); + List finalResult = userList.stream().sorted(Comparator.comparing(PersonWarnRightListResultDTO.PersonWarnRightList::getSortString)).collect(Collectors.toList()); + result.setList(finalResult); return result; }