From 5d6474621178e70a7bd45ad21688012895fbcc68 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Mon, 13 Dec 2021 22:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E5=BF=97?= =?UTF-8?q?=E6=84=BF=E8=80=85=E5=88=86=E5=B8=83=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/DemandServiceCountResultDTO.java | 4 +++ .../dao/heart/IcUserDemandServiceDao.java | 2 +- .../service/heart/HeartDemandService.java | 2 +- .../heart/impl/HeartDemandServiceImpl.java | 4 +-- .../epmet/service/impl/DemandServiceImpl.java | 31 ++++++++++--------- .../mapper/heart/IcUserDemandServiceDao.xml | 7 +++-- .../epmet/controller/VolunteerController.java | 6 ---- .../service/impl/VolunteerServiceImpl.java | 13 ++++---- 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java index 57cc894ae4..16cbee4538 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java @@ -10,6 +10,10 @@ import lombok.Data; */ @Data public class DemandServiceCountResultDTO { + // 服务者ID private String serverId; + // 服务类型 private String serviceType; + // 服务次数 + private int serveTimes; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java index 602c04da5e..165ae6b91c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java @@ -40,5 +40,5 @@ public interface IcUserDemandServiceDao extends BaseDao listDemandServiceCountPage(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType); + List listDemandServeTimes(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java index 1a106fa881..baaa29c97b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java @@ -11,5 +11,5 @@ import java.util.List; *@Date 2021/12/8 */ public interface HeartDemandService { - List listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize); + List listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java index a4192fcd30..c33f426ad5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java @@ -29,11 +29,11 @@ public class HeartDemandServiceImpl implements HeartDemandService { private IcUserDemandServiceDao demandServiceDao; @Override - public List listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) { + public List listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) { return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() { @Override public void doSelect() { - demandServiceDao.listDemandServiceCountPage(customerId, endTime, "volunteer"); + demandServiceDao.listDemandServeTimes(customerId, endTime, "volunteer"); } }); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java index e165e95a75..66cbf1058d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java @@ -101,7 +101,7 @@ public class DemandServiceImpl implements DemandService { // 分片开始下标 int shardingStartIndex = 0; // 分片大小(条数) - int shardingSize = 2; + int shardingSize = 100; // 分片去确定党员身份,防止in条件过大 while (true) { @@ -130,43 +130,44 @@ public class DemandServiceImpl implements DemandService { //2. 查询志愿者服务次数 // 总服务次数 - int totalDemandServiceCount = 0; + int totalDemandServeTimes = 0; // 党员服务次数 - int partymemberDemandServiceCount = 0; + int partymemberDemandServeTimes = 0; // 居民服务次数 - int resiDemandServiceCount = 0; + int resiDemandServeTimes = 0; int serviceCountPageNo = 0; int serviceCountPageSize = 1000; while (true) { - List damendServiceCounts = heartDemandService.listDemandServiceCountPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize); + // 取出每一个服务者的服务次数 + List damendServeTimes = heartDemandService.listDemandServeTimesPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize); - for (DemandServiceCountResultDTO damendServiceCount : damendServiceCounts) { - String serverId = damendServiceCount.getServerId(); + for (DemandServiceCountResultDTO damendServiceTimes : damendServeTimes) { + String serverId = damendServiceTimes.getServerId(); if (partymemberVolunteerUserIds.contains(serverId)) { - partymemberDemandServiceCount++; + partymemberDemandServeTimes += damendServiceTimes.getServeTimes(); } else { - resiDemandServiceCount++; + resiDemandServeTimes += damendServiceTimes.getServeTimes(); } } - totalDemandServiceCount += damendServiceCounts.size(); - - if (damendServiceCounts.size() <= serviceCountPageSize) { + if (damendServeTimes.size() <= serviceCountPageSize) { break; } } + totalDemandServeTimes = partymemberDemandServeTimes + resiDemandServeTimes; + // 3.持久化 FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity(); insert.setDateId(DimIdGenerator.getDateDimId(belongTime)); insert.setCustomerId(customerId); insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime)); - insert.setPartyServiceTotal(partymemberDemandServiceCount); - insert.setServiceTotal(totalDemandServiceCount); + insert.setPartyServiceTotal(partymemberDemandServeTimes); + insert.setServiceTotal(totalDemandServeTimes); insert.setPartyTotal(partymemberVolunteerCount); - insert.setResiServiceTotal(resiDemandServiceCount); + insert.setResiServiceTotal(resiDemandServeTimes); insert.setResiTotal(resiVolunteerCount); insert.setVolunteerTotal(volunteerTotalCount); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml index 1c13f56e87..ddebabef66 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml @@ -20,14 +20,15 @@ - + select service.SERVER_ID, SERVICE_TYPE, count(1) as SERVE_TIMES from ic_user_demand_rec damend inner join ic_user_demand_service service on (damend.ID = service.DEMAND_REC_ID and service.DEL_FLAG = 0) where damend.DEL_FLAG = 0 and damend.STATUS = 'finished' - and damend.REPORT_TIME #{endTime} and damend.CUSTOMER_ID = #{customerId} + and service.SERVICE_END_TIME #{endTime} and service.SERVICE_TYPE = #{serviceType} + group by service.SERVER_ID, SERVICE_TYPE \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java index 40ea2d8807..aedfe54e49 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java @@ -29,11 +29,6 @@ public class VolunteerController { @Autowired private VolunteerService volunteerService; - //public VolunteerController(VolunteerService volunteerService, IcResiUserDao icResiUserDao, GovOrgOpenFeignClient govOrgOpenFeignClient) { - // this.volunteerService = volunteerService; - // System.out.println(this); - //} - /** * 志愿者分布查询 * @@ -42,7 +37,6 @@ public class VolunteerController { */ @PostMapping("distribution") public Result getVolunteerDistribution(@RequestBody VolunteerCommonFormDTO input) { - System.out.println(this); ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.GetVolunteerDistribution.class); String customerId = input.getCustomerId(); 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 d259315211..edc1149e6f 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 @@ -141,15 +141,16 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve continue; } - List volunteer = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); - if (CollectionUtils.isEmpty(volunteer)) { - // 此人没有志愿者信息 - continue; - } + // 查询志愿者类别 + List volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); + //if (CollectionUtils.isEmpty(volunteerCategories)) { + // // 此人没有志愿者信息 + // continue; + //} // 将志愿者类型列表字符串,切割放到set中 Set volunteerTypes = new HashSet(); - for (String vTypesString : volunteer) { + for (String vTypesString : volunteerCategories) { String[] vTypes = vTypesString.split(","); if (vTypes != null && vTypes.length > 0) { volunteerTypes.addAll(Arrays.asList(vTypes));