From 1d0f29b3fafe48814fa666ec728c4b2ac39b2ac3 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 12 May 2021 11:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=A4=E7=BB=84=E6=95=B0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/utils/DateUtils.java | 18 +++++ .../dto/group/form/GroupTotalFormDTO.java | 4 +- .../extract/FactOriginGroupMainDailyDao.java | 6 ++ .../com/epmet/dao/group/GroupDataDao.java | 5 -- .../FactOriginGroupMainDailyEntity.java | 5 ++ .../com/epmet/service/StatsGroupService.java | 2 + .../FactOriginGroupMainDailyService.java | 6 ++ .../FactOriginGroupMainDailyServiceImpl.java | 9 +++ .../epmet/service/group/GroupDataService.java | 5 -- .../group/impl/GroupDataServiceImpl.java | 11 --- .../service/impl/StatsGroupServiceImpl.java | 69 +++++++++++-------- .../extract/FactOriginGroupMainDailyDao.xml | 11 +++ .../resources/mapper/group/GroupDataDao.xml | 10 --- 13 files changed, 100 insertions(+), 61 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index c79f891d7c..a2f88e4133 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -800,4 +800,22 @@ public class DateUtils { } return date; } + + /** + * 格式化日期 + * @param dateStr String 字符型日期 + * @param format String 格式 + * @return Date 日期 + */ + public static Date parseDate(String dateStr, String format) { + Date date = null; + try { + DateFormat dateFormat = new SimpleDateFormat(format); + date = dateFormat.parse(dateStr); + } catch (Exception e) { + e.printStackTrace(); + } + return date; + } + } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupTotalFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupTotalFormDTO.java index ce3c23761d..7d91c9c3fc 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupTotalFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/GroupTotalFormDTO.java @@ -18,7 +18,7 @@ public class GroupTotalFormDTO implements Serializable { */ private String customerId = ""; /** - * 需要执行的日期(格式:yyyy-MM-dd)2020-01-01 + * 需要执行的日期(格式:yyyyMMdd) */ - private String date = ""; + private String dateId = ""; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java index 911d8b7993..7ffdf0c1f3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java @@ -199,4 +199,10 @@ public interface FactOriginGroupMainDailyDao extends BaseDao selectOrgGroupCount(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("level") String level); + + /** + * @Author sun + * @Description 查询客户小组维度下有效群组列表 + **/ + List selectCustomerGroupList(@Param("customerId") String customerId, @Param("dateId") String dateId); } 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 0e29f1530a..bf35e1fe88 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 @@ -92,9 +92,4 @@ public interface GroupDataDao { **/ List groupExtracting(@Param("customerId")String customerId,@Param("dateId") String dateId); - /** - * @Author sun - * @Description 查询客户下有效群组列表 - **/ - List selectCustomerGroupList(@Param("customerId")String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/extract/FactOriginGroupMainDailyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/extract/FactOriginGroupMainDailyEntity.java index 8bb0ba12a1..34b01407d6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/extract/FactOriginGroupMainDailyEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/extract/FactOriginGroupMainDailyEntity.java @@ -116,4 +116,9 @@ Ps: 如果一个小组被拒绝,当前小组的状态将永久停留在“审 */ private Integer isOwnerParty; + /** + * 小组类型(ordinary:楼院小组 branch:支部小组) + */ + private String groupType; + } 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 1fcb3da75b..c6019d1490 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 @@ -3,6 +3,8 @@ package com.epmet.service; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.group.form.GroupTotalFormDTO; +import java.text.ParseException; + /** * @Author zxc * @CreateTime 2020/6/16 14:14 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java index 730acde2c8..9b4350b1fb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java @@ -105,4 +105,10 @@ public interface FactOriginGroupMainDailyService extends BaseService */ List getOrgGroupCount(String customerId, String monthId, String level); + + /** + * @Author sun + * @Description 查询客户小组维度下有效群组列表 + **/ + List getGroupListByCustomerId(String customerId, String dateId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java index 94fadea5fe..718a045131 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java @@ -136,4 +136,13 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl getGroupListByCustomerId(String customerId, String dateId) { + return baseDao.selectCustomerGroupList(customerId, dateId); + } + } 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 e971566233..76865ba242 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 @@ -67,9 +67,4 @@ public interface GroupDataService { **/ List extractGroupData(Boolean isFirst,String customerId,String dateId); - /** - * @Author sun - * @Description 查询客户下有效群组列表 - **/ - List getGroupListByCustomerId(String customerId); } 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 ca2c54b87d..93d6b4a7db 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 @@ -211,15 +211,4 @@ public class GroupDataServiceImpl implements GroupDataService { return groupDataDao.groupExtracting(customerId,isFirst?null:dateId); } - - /** - * @Author sun - * @Description 查询客户下有效群组列表 - **/ - @Override - public List getGroupListByCustomerId(String customerId) { - return groupDataDao.selectCustomerGroupList(customerId); - } - - } 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 4be803a4a6..f222a9ee8e 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 @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.convert.DateConverter; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.GroupConstant; import com.epmet.dto.AgencySubTreeDto; @@ -9,24 +10,29 @@ import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.group.form.GroupTotalFormDTO; import com.epmet.dto.group.result.*; import com.epmet.dto.stats.DimAgencyDTO; +import com.epmet.entity.evaluationindex.extract.FactOriginGroupMainDailyEntity; import com.epmet.entity.group.ResiGroupEntity; import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.FactGroupTotalAgencyDailyEntity; import com.epmet.entity.stats.FactGroupTotalGridDailyEntity; import com.epmet.service.StatsGroupService; +import com.epmet.service.evaluationindex.extract.todata.FactOriginGroupMainDailyService; import com.epmet.service.group.GroupDataService; import com.epmet.service.org.CustomerGridService; import com.epmet.service.stats.*; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -63,6 +69,8 @@ public class StatsGroupServiceImpl implements StatsGroupService { private FactGroupTotalGridDailyService factGroupTotalGridDailyService; @Autowired private FactGroupTotalAgencyDailyService factGroupTotalAgencyDailyService; + @Autowired + private FactOriginGroupMainDailyService factOriginGroupMainDailyService; /** * @param @@ -352,15 +360,16 @@ public class StatsGroupServiceImpl implements StatsGroupService { **/ @Override public void gridGroupTotal(GroupTotalFormDTO formDTO) { - Date date = DateUtils.yesterDay(); //入参有日期的则按具体时间执行,没有的则按当前时间前一天执行 - if (null != formDTO && StringUtils.isNotBlank(formDTO.getDate())) { - date = DateUtils.parse(formDTO.getDate(), DateUtils.DATE_PATTERN); + if (StringUtils.isBlank(formDTO.getDateId())) { + Date yesterday = DateUtils.addDateDays(new Date(), -1); + SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); + formDTO.setDateId(format.format(yesterday)); } //入参有客户Id的则按客户Id执行,没有的则全部客户都执行 if (null != formDTO && StringUtils.isNotBlank(formDTO.getCustomerId())) { log.info("单独统计客户网格-小组总数日统计数据,当前统计的客户Id:" + formDTO.getCustomerId()); - gridGroupStats(formDTO.getCustomerId(), date); + gridGroupStats(formDTO.getCustomerId(), formDTO.getDateId()); } else { int pageNo = 1; int pageSize = 100; @@ -373,7 +382,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { try { log.info("for循环统计网格-小组总数日统计数据,当前统计的客户Id:" + customerId); //遍历统计每一个客户数据 - gridGroupStats(customerId, date); + gridGroupStats(customerId, formDTO.getDateId()); } catch (Exception e) { log.error("小组总数-网格日统计-程序错误,对应客户Id:" + customerId, e); log.error("Error creating model JSON", e); @@ -389,8 +398,9 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @Author sun * @Description 小组总数-网格日统计数据 **/ - private void gridGroupStats(String customerId, Date date) { + private void gridGroupStats(String customerId, String dateId) { //1:查询各维度表Id,方便使用 + Date date = DateUtils.parseDate(dateId,DateUtils.DATE_PATTERN_YYYYMMDD); DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); //2:根据客户Id查询网格维度表数据 @@ -399,18 +409,18 @@ public class StatsGroupServiceImpl implements StatsGroupService { //3.根据客户Id查询客户下有效的群组列表数据 log.info("StatsGroupServiceImpl.customerGridStats-根据客户Id查询客户下有效的群组列表数据,对应客户Id:" + customerId); - List groupList = groupDataService.getGroupListByCustomerId(customerId); + List groupList = factOriginGroupMainDailyService.getGroupListByCustomerId(customerId, dateId); //4.分别计算每个网格下审核通过的小组数据 List list = new ArrayList<>(); + DimIdGenerator.DimIdBean finalDimId = dimId; dimGridList.forEach(grid -> { FactGroupTotalGridDailyEntity entity = new FactGroupTotalGridDailyEntity(); AtomicInteger total = new AtomicInteger(0); AtomicInteger ordinary = new AtomicInteger(0); AtomicInteger branch = new AtomicInteger(0); groupList.forEach(group -> { - if (grid.getId().equals(group.getGridId()) && "approved".equals(group.getState())) { - + if (grid.getId().equals(group.getGridId()) && "approved".equals(group.getGroupState())) { total.addAndGet(1); if ("ordinary".equals(group.getGroupType())) { ordinary.addAndGet(1); @@ -424,11 +434,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { entity.setCustomerId(grid.getCustomerId()); entity.setAgencyId(grid.getAgencyId()); entity.setGridId(grid.getId()); - entity.setDateId(dimId.getDateId()); - entity.setWeekId(dimId.getWeekId()); - entity.setMonthId(dimId.getMonthId()); - entity.setQuarterId(dimId.getQuarterId()); - entity.setYearId(dimId.getYearId()); + entity.setDateId(finalDimId.getDateId()); + entity.setWeekId(finalDimId.getWeekId()); + entity.setMonthId(finalDimId.getMonthId()); + entity.setQuarterId(finalDimId.getQuarterId()); + entity.setYearId(finalDimId.getYearId()); entity.setGroupTotal(total.get()); entity.setOrdinaryTotal(ordinary.get()); entity.setBranchTotal(branch.get()); @@ -457,15 +467,16 @@ public class StatsGroupServiceImpl implements StatsGroupService { **/ @Override public void agencyGroupTotal(GroupTotalFormDTO formDTO) { - Date date = DateUtils.yesterDay(); - //入参有时间的则按具体时间执行,没有的则按当前时间前一天执行 - if (null != formDTO && StringUtils.isNotBlank(formDTO.getDate())) { - date = DateUtils.parse(formDTO.getDate(), DateUtils.DATE_PATTERN); + //入参有日期的则按具体时间执行,没有的则按当前时间前一天执行 + if (StringUtils.isBlank(formDTO.getDateId())) { + Date yesterday = DateUtils.addDateDays(new Date(), -1); + SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); + formDTO.setDateId(format.format(yesterday)); } //入参有客户Id的则按客户Id执行,没有的则全部客户都执行 if (null != formDTO && StringUtils.isNotBlank(formDTO.getCustomerId())) { log.info("单独统计客户组织下-小组总数日统计数据,当前统计的客户Id:" + formDTO.getCustomerId()); - agencyGroupStats(formDTO.getCustomerId(), date); + agencyGroupStats(formDTO.getCustomerId(), formDTO.getDateId()); } else { int pageNo = 1; int pageSize = 100; @@ -477,7 +488,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { try { log.info("for循环统计机关-小组总数日统计数据,当前统计的客户Id:" + customerId); //遍历统计每一个客户数据 - agencyGroupStats(customerId, date); + agencyGroupStats(customerId, formDTO.getDateId()); } catch (Exception e) { log.error("小组总数-机关日统计程序错误,对应客户Id:" + customerId, e); log.error("Error creating model JSON", e); @@ -493,8 +504,9 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @Author sun * @Description 小组总数-机关日统计数据 **/ - private void agencyGroupStats(String customerId, Date date) { + private void agencyGroupStats(String customerId, String dateId) { //1:查询各维度表Id,方便使用 + Date date = DateUtils.parseDate(dateId,DateUtils.DATE_PATTERN_YYYYMMDD); DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); //2:根据客户Id查询机关维度表数据 @@ -508,10 +520,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { //4.根据客户Id查询客户下有效的群组列表数据 log.info("StatsGroupServiceImpl.agencyGroupStats-根据客户Id查询客户下有效的群组列表数据,对应客户Id:" + customerId); - List groupList = groupDataService.getGroupListByCustomerId(customerId); + List groupList = factOriginGroupMainDailyService.getGroupListByCustomerId(customerId, dateId); List list = new ArrayList<>(); //5.遍历组织维度数据分别计算每个组织下群组数据 + DimIdGenerator.DimIdBean finalDimId = dimId; agencyList.forEach(agency->{ FactGroupTotalAgencyDailyEntity entity = new FactGroupTotalAgencyDailyEntity(); //5-1.汇总组织及所有下级组织列表 @@ -538,7 +551,7 @@ public class StatsGroupServiceImpl implements StatsGroupService { //5-3.根据汇总的网格列表统计对应的群组数据 agencyGridList.forEach(gridId -> { groupList.forEach(group -> { - if (gridId.equals(group.getGridId()) && "approved".equals(group.getState())) { + if (gridId.equals(group.getGridId()) && "approved".equals(group.getGroupState())) { total.addAndGet(1); if ("ordinary".equals(group.getGroupType())) { ordinary.addAndGet(1); @@ -553,11 +566,11 @@ public class StatsGroupServiceImpl implements StatsGroupService { entity.setCustomerId(agency.getCustomerId()); entity.setAgencyId(agency.getId()); entity.setPid(agency.getPid()); - entity.setDateId(dimId.getDateId()); - entity.setWeekId(dimId.getWeekId()); - entity.setMonthId(dimId.getMonthId()); - entity.setQuarterId(dimId.getQuarterId()); - entity.setYearId(dimId.getYearId()); + entity.setDateId(finalDimId.getDateId()); + entity.setWeekId(finalDimId.getWeekId()); + entity.setMonthId(finalDimId.getMonthId()); + entity.setQuarterId(finalDimId.getQuarterId()); + entity.setYearId(finalDimId.getYearId()); entity.setGroupTotal(total.get()); entity.setOrdinaryTotal(ordinary.get()); entity.setBranchTotal(branch.get()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml index 3107a108d9..2f40e1de70 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml @@ -340,4 +340,15 @@ AND f.GROUP_STATE = 'approved' GROUP BY f.AGENCY_ID + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml index 1bf3357347..a1b2b223ab 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml @@ -228,14 +228,4 @@ - - \ No newline at end of file