diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleFormDTO.java index b3d731a8d3..a6c73d386f 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleFormDTO.java @@ -27,4 +27,9 @@ public class GridGroupPeopleFormDTO implements Serializable { * 人员状态 */ private String status = "removed"; + + /** + * dateID + */ + private String dateId; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleTotalFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleTotalFormDTO.java index 637f10be08..b36204f1b0 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleTotalFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupPeopleTotalFormDTO.java @@ -27,4 +27,9 @@ public class GridGroupPeopleTotalFormDTO implements Serializable { * 人员状态 */ private String status = "removed"; + + /** + * dateID + */ + private String dateId; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupTotalFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupTotalFormDTO.java index 3e97445cea..f39002e5ad 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupTotalFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GridGroupTotalFormDTO.java @@ -22,4 +22,9 @@ public class GridGroupTotalFormDTO implements Serializable { * 小组状态 */ private String state = "approved"; + + /** + * dateID + */ + private String dateId; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupIncrFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupIncrFormDTO.java index 6d6e981037..79ac84ff44 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupIncrFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupIncrFormDTO.java @@ -24,7 +24,7 @@ public class GroupIncrFormDTO implements Serializable { private String customerId; /** - * 日期(昨日) + * dateID */ - private String yesterday; + private String dateId; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java index c33979545d..b2f6f399f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java @@ -1,14 +1,13 @@ package com.epmet.controller; -import com.epmet.commons.tools.constant.NumConstant; import com.epmet.service.StatsGroupService; -import com.epmet.service.stats.DimCustomerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; +import java.util.Date; /** * @Author zxc @@ -20,8 +19,6 @@ public class StatsGroupController { @Autowired private StatsGroupService statsGroupService; - @Autowired - private DimCustomerService dimCustomerService; /** * 网格数、小组数、网格下所有组内人数(不去重) @@ -35,16 +32,8 @@ public class StatsGroupController { * @author zxc */ @PostMapping("groupgriddaily") - public void groupGridDaily(){ - Integer pageNo = NumConstant.ONE; - Integer pageSize = NumConstant.ONE_HUNDRED; - List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); - if (customerIds.size() == NumConstant.ZERO){ - return; - } - customerIds.forEach(customerId -> { - statsGroupService.groupGridDaily(customerId); - }); + public void groupGridDaily(@RequestParam(value = "date",required = false)Date date){ + statsGroupService.groupGridDaily(date); } /** @@ -53,16 +42,8 @@ public class StatsGroupController { * @author zxc */ @PostMapping("groupagencydaily") - public void groupAgencyDaily(){ - Integer pageNo = NumConstant.ONE; - Integer pageSize = NumConstant.ONE_HUNDRED; - List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); - if (customerIds.size() == NumConstant.ZERO){ - return; - } - customerIds.forEach(customerId -> { - statsGroupService.groupAgencyDaily(customerId); - }); + public void groupAgencyDaily(@RequestParam(value = "date",required = false)Date date){ + statsGroupService.groupAgencyDaily(date); } /** @@ -71,8 +52,8 @@ public class StatsGroupController { * @author zxc */ @PostMapping("groupagencymonthly") - public void groupAgencyMonthly(){ - statsGroupService.groupAgencyMonthly(); + public void groupAgencyMonthly(@RequestParam(value = "date",required = false)Date date){ + statsGroupService.groupAgencyMonthly(date); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java index 5a226cad20..28703e70e9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java @@ -50,29 +50,29 @@ public interface GroupDataDao { * @param * @author zxc */ - List getAgencyGroupTotalCount(@Param("allGrid") List allGrid); + List getAgencyGroupTotalCount(@Param("allGrid") List allGrid,@Param("dateId")String dateId); /** * @Description 查询机关下网格内的小组人数 【待优化】 * @param * @author zxc */ - List selectAgencyGridGroupPeopleTotal(@Param("allGrid") List allGrid); + List selectAgencyGridGroupPeopleTotal(@Param("allGrid") List allGrid,@Param("dateId")String dateId); /** * @Description 查询机关下每个小组的人数 【待优化】 * @param * @author zxc */ - List selectAgencyEveryGroupPeopleCount(@Param("allGrid") List allGrid); + List selectAgencyEveryGroupPeopleCount(@Param("allGrid") List allGrid,@Param("dateId")String dateId); /** * @Description 查询机关下的小组日增数 【待优化】 * @param - * @param yesterday + * @param dateId * @author zxc */ - List selectAgencyGroupIncr(@Param("allGrid") List allGrid,@Param("yesterday")String yesterday); + List selectAgencyGroupIncr(@Param("allGrid") List allGrid,@Param("dateId")String dateId); /** * @Description 查询机关下所有网格小组人数 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java index aaf4312dd9..853d8dea9d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java @@ -48,7 +48,7 @@ public interface FactGroupAgencyDailyDao extends BaseDao getLastDayAgency(); + List getLastDayAgency(@Param("monthId") String monthId); /** * @Description 查询 月的小组增量 @@ -56,5 +56,12 @@ public interface FactGroupAgencyDailyDao extends BaseDao getMonthGroupIncr(@Param("monthId")String monthId); + + /** + * @Description 删除当天已存在数据 + * @param dateId + * @author zxc + */ + void deleteInsertAgencyDailyByDateId(@Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java index 0e0ed99f21..cf43e681ca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java @@ -40,5 +40,12 @@ public interface FactGroupAgencyMonthlyDao extends BaseDao agencyMonth); + + /** + * @Description 删除已存在的月数据 + * @param monthId + * @author zxc + */ + void deleteInsertAgencyMonthlyByMonthId(@Param("monthId")String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java index 8c1a636d3c..6e0ddae225 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupGridDailyDao.java @@ -40,5 +40,12 @@ public interface FactGroupGridDailyDao extends BaseDao * @author zxc */ void insertGroupGridDaily(@Param("formDto") List formDto); + + /** + * @Description 删除已存在的数据【当天】防止当天数据多条 + * @param dateId + * @author zxc + */ + void deleteInsertDateId(@Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java index 8042fd0c83..b3444d34d4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java @@ -1,5 +1,7 @@ package com.epmet.service; +import java.util.Date; + /** * @Author zxc * @CreateTime 2020/6/16 14:14 @@ -10,18 +12,18 @@ public interface StatsGroupService { * @Description 统计 “小组” 有关数据, dim:【网格-日】 * @author zxc */ - void groupGridDaily(String customerId); + void groupGridDaily(Date date); /** * @Description 统计 “小组” 有关数据, dim:【机关-日】 * @author zxc */ - void groupAgencyDaily(String customerId); + void groupAgencyDaily(Date date); /** * @Description 统计 “小组” 有关数据, dim:【机关-月】 * @author zxc */ - void groupAgencyMonthly(); + void groupAgencyMonthly(Date date); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java index babd6e6503..be00cca1dd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java @@ -25,21 +25,21 @@ public interface GroupDataService { * @param allGrid * @author zxc */ - List getAgencyGroupTotalCount(List allGrid); + List getAgencyGroupTotalCount(List allGrid,String dateId); /** * @Description 查询机关下网格内的小组人数 * @param * @author zxc */ - List selectAgencyGridGroupPeopleTotal(List allGrid); + List selectAgencyGridGroupPeopleTotal(List allGrid,String dateId); /** * @Description 查询机关下每个小组的人数 * @param * @author zxc */ - List selectAgencyEveryGroupPeopleCount(List allGrid); + List selectAgencyEveryGroupPeopleCount(List allGrid,String dateId); /** * @Description 查询机关下的小组日增数 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java index cb548823c7..d938799b41 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java @@ -41,6 +41,7 @@ public class GroupDataServiceImpl implements GroupDataService { if (gridsInfo.size() == NumConstant.ZERO){ return new ArrayList<>(); } + String dateId = dimTime.getDateId(); gridsInfo.forEach(grid -> { GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO(); BeanUtils.copyProperties(dimTime,dailyResult); @@ -52,6 +53,7 @@ public class GroupDataServiceImpl implements GroupDataService { // 1. 网格下有多少小组,只算 state = ‘approved’ GridGroupTotalFormDTO formDTO = new GridGroupTotalFormDTO(); formDTO.setCustomerId(customerId); + formDTO.setDateId(dateId); List gridGroupTotalResultDTOS = groupDataDao.selectGridGroupTotal(formDTO); if (gridGroupTotalResultDTOS.size() == NumConstant.ZERO){ result.forEach(grid -> { @@ -70,6 +72,7 @@ public class GroupDataServiceImpl implements GroupDataService { // 2. 网格下所有组内人数和(不需要去重) 人员状态 != "removed" GridGroupPeopleTotalFormDTO peopleTotalFormDTO = new GridGroupPeopleTotalFormDTO(); peopleTotalFormDTO.setCustomerId(customerId); + peopleTotalFormDTO.setDateId(dateId); List gridGroupPeopleTotalResultDTOS = groupDataDao.selectGridGroupPeopleTotal(peopleTotalFormDTO); result.forEach(grid -> { gridGroupPeopleTotalResultDTOS.forEach(groupPeopleTotal -> { @@ -85,6 +88,7 @@ public class GroupDataServiceImpl implements GroupDataService { // 4. 网格下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID GridGroupPeopleFormDTO everyGroupPeople = new GridGroupPeopleFormDTO(); everyGroupPeople.setCustomerId(customerId); + everyGroupPeople.setDateId(dateId); List everyGroupPeopleCount = groupDataDao.selectEveryGroupPeopleCount(everyGroupPeople); Map> collect = everyGroupPeopleCount.stream().collect(Collectors.groupingBy(every -> every.getGridId())); Set>> entries = collect.entrySet(); @@ -111,7 +115,7 @@ public class GroupDataServiceImpl implements GroupDataService { // 5. 网格下小组增量 GroupIncrFormDTO groupIncr = new GroupIncrFormDTO(); groupIncr.setCustomerId(customerId); - groupIncr.setYesterday(dimTime.getDateId()); + groupIncr.setDateId(dateId); List groupIncrResult = groupDataDao.selectGroupIncr(groupIncr); result.forEach(grid -> { groupIncrResult.forEach(gridIncr -> { @@ -128,11 +132,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @param * @author zxc */ - public List getAgencyGroupTotalCount(List allGrid){ + public List getAgencyGroupTotalCount(List allGrid,String dateId){ if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); } - return groupDataDao.getAgencyGroupTotalCount(allGrid); + return groupDataDao.getAgencyGroupTotalCount(allGrid,dateId); } /** @@ -141,11 +145,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @author zxc */ @Override - public List selectAgencyGridGroupPeopleTotal(List allGrid) { + public List selectAgencyGridGroupPeopleTotal(List allGrid,String dateId) { if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); } - return groupDataDao.selectAgencyGridGroupPeopleTotal(allGrid); + return groupDataDao.selectAgencyGridGroupPeopleTotal(allGrid,dateId); } /** @@ -153,24 +157,24 @@ public class GroupDataServiceImpl implements GroupDataService { * @param * @author zxc */ - public List selectAgencyEveryGroupPeopleCount(List allGrid){ + public List selectAgencyEveryGroupPeopleCount(List allGrid,String dateId){ if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); } - return groupDataDao.selectAgencyEveryGroupPeopleCount(allGrid); + return groupDataDao.selectAgencyEveryGroupPeopleCount(allGrid,dateId); } /** * @Description 查询机关下的小组日增数 * @param - * @param yesterday + * @param dateId * @author zxc */ - public List selectAgencyGroupIncr(List allGrid,String yesterday){ + public List selectAgencyGroupIncr(List allGrid,String dateId){ if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); } - return groupDataDao.selectAgencyGroupIncr(allGrid, yesterday); + return groupDataDao.selectAgencyGroupIncr(allGrid, dateId); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index 82278d4340..4ba2b1492b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -42,6 +42,8 @@ public class StatsGroupServiceImpl implements StatsGroupService { private FactGroupAgencyDailyService factGroupAgencyDailyService; @Autowired private FactGroupAgencyMonthlyService factGroupAgencyMonthlyService; + @Autowired + private DimCustomerService dimCustomerService; /** * @Description 统计【网格-日】 @@ -49,11 +51,20 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @author zxc */ @Override - public void groupGridDaily(String customerId) { - DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); - List gridsInfo = dimGridService.getGridListByCustomerId(customerId); - List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); - factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); + public void groupGridDaily(Date date) { + Integer pageNo = NumConstant.ONE; + Integer pageSize = NumConstant.ONE_HUNDRED; + List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); + if (customerIds.size() == NumConstant.ZERO){ + return; + } + customerIds.forEach(customerId -> { + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); + List gridsInfo = dimGridService.getGridListByCustomerId(customerId); + List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); + factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); + }); + } /** @@ -61,12 +72,20 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @author zxc */ @Override - public void groupAgencyDaily(String customerId) { - DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); - List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); - List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); - factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily); + public void groupAgencyDaily(Date date) { + Integer pageNo = NumConstant.ONE; + Integer pageSize = NumConstant.ONE_HUNDRED; + List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); + if (customerIds.size() == NumConstant.ZERO){ + return; + } + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); + customerIds.forEach(customerId -> { + List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); + List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); + factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily); + }); } /** @@ -74,10 +93,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @author zxc String customerId */ @Override - public void groupAgencyMonthly() { - List lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(); - DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); - List monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(dimIdBean.getMonthId()); + public void groupAgencyMonthly(Date date) { + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(date); + String monthId = dimIdBean.getMonthId(); + List lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(monthId); + List monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(monthId); if (monthGroupIncr.size() == NumConstant.ZERO){ lastDayAgency.forEach(agency -> { agency.setGroupIncr(NumConstant.ZERO); @@ -99,6 +119,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { return new ArrayList<>(); } List result = new ArrayList<>(); + String dateId = timeDim.getDateId(); List agencyList = dimAgencyService.getAgencyListByCustomerId(customerId); agencyList.forEach(agency -> { AgencyGroupDailyResultDTO agencyResult = new AgencyGroupDailyResultDTO(); @@ -113,11 +134,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { agencyResult.setGridTotal(allGrid.size()); // TODO 2. 机关下有多少小组,只算 state = ‘approved’ - List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid); + List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); agencyResult.setGroupTotalCount(groupCount); // TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" - List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid); + List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId); Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); agencyResult.setGroupMemberTotalCount(groupPeopleCount); @@ -127,7 +148,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); // TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID - List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid); + List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId); List sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList()); Integer groupPeopleMedian; if (sorted.size() == NumConstant.ONE){ @@ -147,7 +168,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId()); } // TODO 6. 机关下小组增量 - List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, timeDim.getDateId()); + List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId); Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); agencyResult.setGroupIncr(groupIncr); result.add(agencyResult); @@ -222,12 +243,15 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @param * @author zxc */ - public DimIdGenerator.DimIdBean getDimIdBean(){ + public DimIdGenerator.DimIdBean getDimIdBean(Date date){ + if (date != null){ + return DimIdGenerator.getDimIdBean(date); + } ZoneId zoneId = ZoneId.systemDefault(); LocalDate localDate = LocalDate.now().minusDays(NumConstant.ONE); ZonedDateTime zdt = localDate.atStartOfDay(zoneId); - Date date = Date.from(zdt.toInstant()); - return DimIdGenerator.getDimIdBean(date); + Date result = Date.from(zdt.toInstant()); + return DimIdGenerator.getDimIdBean(result); } public List getAgencyAllGrid(String customerId,String agencyId){ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java index 30ff917431..ba2eced61e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java @@ -109,7 +109,7 @@ public interface FactGroupAgencyDailyService extends BaseService getLastDayAgency(); + List getLastDayAgency(String monthId); /** * @Description 查询 月的小组增量 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java index dc34d3b9e7..f04d3dfe83 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java @@ -103,7 +103,7 @@ public class FactGroupAgencyDailyServiceImpl extends BaseServiceImpl agencyList) { if (agencyList.size() != NumConstant.ZERO){ + baseDao.deleteInsertAgencyDailyByDateId(agencyList.get(NumConstant.ZERO).getDateId()); baseDao.insertGroupAgencyDaily(agencyList); } @@ -121,8 +122,8 @@ public class FactGroupAgencyDailyServiceImpl extends BaseServiceImpl getLastDayAgency(){ - return baseDao.getLastDayAgency(); + public List getLastDayAgency(String monthId){ + return baseDao.getLastDayAgency(monthId); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java index 85a216373d..a9ba8ff7ac 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java @@ -108,6 +108,7 @@ public class FactGroupAgencyMonthlyServiceImpl extends BaseServiceImpl #{dateId} GROUP BY grid_id @@ -31,6 +32,7 @@ AND rg.state = #{state} AND rg.customer_id = #{customerId} AND rgm.status != #{status} + AND DATE_FORMAT(rgm.created_time,'%Y%m%d') #{dateId} GROUP BY rg.grid_id @@ -49,6 +51,7 @@ AND rg.state = #{state} AND rg.customer_id = #{customerId} AND rgm.STATUS != #{status} + AND DATE_FORMAT(rgm.created_time,'%Y%m%d') #{dateId} GROUP BY rgm.resi_group_id @@ -63,7 +66,7 @@ WHERE state = #{state} AND customer_id = #{customerId} - AND DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) = #{yesterday} + AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId} GROUP BY grid_id @@ -80,6 +83,7 @@ DEL_FLAG = 0 AND state = 'approved' AND grid_id = #{grid} + AND DATE_FORMAT(created_time,'%Y%m%d') #{dateId} GROUP BY grid_id @@ -99,6 +103,7 @@ AND rg.state = 'approved' AND rg.grid_id = #{grid} AND rgm.status != 'removed' + AND DATE_FORMAT(rgm.created_time,'%Y%m%d') #{dateId} GROUP BY rg.grid_id @@ -118,6 +123,7 @@ AND rg.state = 'approved' AND rg.grid_id = #{grid} AND rgm.STATUS != 'removed' + AND DATE_FORMAT(rgm.created_time,'%Y%m%d') #{dateId} GROUP BY rgm.resi_group_id @@ -134,7 +140,7 @@ WHERE state = 'approved' AND grid_id = #{grid} - AND DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) = #{yesterday} + AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId} GROUP BY grid_id diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml index 283cd62e9b..90bcc53b5d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml @@ -67,7 +67,7 @@ - SELECT ID AS id, AGENCY_ID AS agencyId, @@ -87,11 +87,13 @@ MIN_MEMBER_GROUP_ID AS minMemberGroupId FROM fact_group_agency_daily - WHERE del_flag = '0' - GROUP BY - AGENCY_ID - ORDER BY - DATE_ID DESC + WHERE + del_flag = '0' + AND DATE_FORMAT(date_id,'%Y%m') = #{monthId} + GROUP BY + AGENCY_ID + ORDER BY + DATE_ID DESC @@ -108,5 +110,13 @@ agency_id + + + DELETE + FROM + fact_group_agency_daily + WHERE + date_id = #{dateId} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml index 73f80a1ce0..35242c9a0e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml @@ -63,5 +63,13 @@ + + + DELETE + FROM + fact_group_agency_monthly + WHERE + month_id = #{monthId} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml index 03b90c7c14..0692607ad3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupGridDailyDao.xml @@ -65,4 +65,13 @@ + + + DELETE + FROM + fact_group_grid_daily + WHERE + date_id = #{dateId} + + \ No newline at end of file