Browse Source

Merge remote-tracking branch 'origin/dev_data_stats' into dev_data_stats

dev_shibei_match
wangchao 5 years ago
parent
commit
2a3bb4deab
  1. 37
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java
  2. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml

37
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java

@ -129,6 +129,13 @@ public class StatsGroupServiceImpl implements StatsGroupService {
factGroupAgencyMonthlyService.insertAgencyGroupMonthly(lastDayAgency);
}
/**
* @Description 网格小组 机关- 数据统计处理
* @param customerAgencyInfos
* @param timeDim
* @param customerId
* @author zxc
*/
public List<AgencyGroupDailyResultDTO> getAgencyGroupDaily(List<DimAgencyDTO> customerAgencyInfos, DimIdGenerator.DimIdBean timeDim,String customerId){
if (customerAgencyInfos.size() == NumConstant.ZERO){
return new ArrayList<>();
@ -143,10 +150,10 @@ public class StatsGroupServiceImpl implements StatsGroupService {
agencyResult.setCustomerId(customerId);
BeanUtils.copyProperties(timeDim,agencyResult);
//机关下的所有网格(包括直属网格)
List<String> allGrid = this.getAllGrid(agencyId);
List<String> allGrid = this.getAllGrid(agencyId,customerId);
String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId);
agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId);
// TODO 1. 机关下有多少网格
// 1. 机关下有多少网格
List<GridIdListByCustomerResultDTO> customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId);
AtomicReference<Integer> gridSize = new AtomicReference<>(0);
if (customerGridIdList.size() != NumConstant.ZERO){
@ -161,22 +168,19 @@ public class StatsGroupServiceImpl implements StatsGroupService {
}else {
agencyResult.setGridTotal(NumConstant.ZERO);
}
// TODO 2. 机关下有多少小组,只算 state = ‘approved’
// 2. 机关下有多少小组,只算 state = ‘approved’
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId);
Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount));
agencyResult.setGroupTotalCount(groupCount);
// TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
// 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
List<AgencyGridGroupPeopleTotalResultDTO> agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId);
Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal));
agencyResult.setGroupMemberTotalCount(groupPeopleCount);
// TODO 4. 机关下小组平均人数
// 4. 机关下小组平均人数
agencyResult.setGroupMemberAvgCount(
agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO :
agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount());
// TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID
// 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID
List<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId);
List<AgencyGridGroupPeopleResultDTO> sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList());
Integer groupPeopleMedian;
@ -190,13 +194,12 @@ public class StatsGroupServiceImpl implements StatsGroupService {
(sorted.get(sorted.size() / NumConstant.TWO - NumConstant.ONE).getGroupCount() + sorted.get(sorted.size() / 2).getGroupCount()) / 2 :
sorted.get(sorted.size() / NumConstant.TWO).getGroupCount();
agencyResult.setGroupMedian(groupPeopleMedian);
agencyResult.setGroupMemberMaxCount(sorted.get(NumConstant.ZERO).getGroupCount());
agencyResult.setMaxMemberGroupId(sorted.get(NumConstant.ZERO).getGroupId());
agencyResult.setGroupMemberMinCount(sorted.get(sorted.size() - NumConstant.ONE).getGroupCount());
agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId());
}
// TODO 6. 机关下小组增量
// 6. 机关下小组增量
List<AgencyGroupIncrResultDTO> agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId);
Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr));
agencyResult.setGroupIncr(groupIncr);
@ -210,9 +213,9 @@ public class StatsGroupServiceImpl implements StatsGroupService {
* @param agencyId
* @author zxc
*/
public List<String> getAllGrid(String agencyId){
public List<String> getAllGrid(String agencyId,String customerId){
List<String> result = new ArrayList<>();
List<AgencySubTreeDto> allAgency = dimAgencyService.getAllAgency(null);
List<AgencySubTreeDto> allAgency = dimAgencyService.getAllAgency(customerId);
Map<String,Set<String>> subGridOfAgency = new HashMap<>();
allAgency.forEach(agency -> {
@ -237,7 +240,6 @@ public class StatsGroupServiceImpl implements StatsGroupService {
* @author zxc
*/
void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map<String,Set<String>> subGridOfAgency){
//向map中放入数据
if(subGridOfAgency.containsKey(pid)){
//包含key
@ -254,13 +256,10 @@ public class StatsGroupServiceImpl implements StatsGroupService {
Set<String> grids = new HashSet<>(agency.getGridIds());
subGridOfAgency.put(pid,grids);
}
//定义递归出口
if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){
return ;
}
//定义递归入口
agency.getSubAgencies().forEach(obj -> {
initAgencyGridMap(pid,obj,subGridOfAgency);
@ -285,8 +284,4 @@ public class StatsGroupServiceImpl implements StatsGroupService {
return DimIdGenerator.getDimIdBean(result);
}
public List<String> getAgencyAllGrid(String customerId,String agencyId){
return null;
}
}

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml

@ -27,7 +27,7 @@
AND ORIGIN = 'issue'
AND STATUS = 'closed'
AND CUSTOMER_ID = #{customerId}
AND UPDATED_TIME <![CDATA[ <= ]]> #{date}
AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') <![CDATA[ <= ]]> #{date}
GROUP BY
AGENCY_ID, CLOSED_STATUS
</select>
@ -44,7 +44,7 @@
AND ORIGIN = 'issue'
AND STATUS = 'closed'
AND CUSTOMER_ID = #{customerId}
AND UPDATED_TIME = #{date}
AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') = #{date}
GROUP BY
AGENCY_ID, CLOSED_STATUS
</select>
@ -60,7 +60,7 @@
AND ORIGIN = 'issue'
AND STATUS = 'closed'
AND CUSTOMER_ID = #{customerId}
AND UPDATED_TIME <![CDATA[ <= ]]> #{date}
AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') <![CDATA[ <= ]]> #{date}
</select>
<select id="selectGridClosedProjectInc" resultType="com.epmet.dto.project.ProjectGridDTO">
SELECT
@ -74,7 +74,7 @@
AND ORIGIN = 'issue'
AND STATUS = 'closed'
AND CUSTOMER_ID = #{customerId}
AND UPDATED_TIME = #{date}
AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') = #{date}
</select>
</mapper>

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml

@ -91,11 +91,7 @@
fact_group_agency_daily
WHERE
del_flag = '0'
AND DATE_FORMAT(date_id,'%Y%m') = #{monthId}
GROUP BY
AGENCY_ID
ORDER BY
DATE_ID DESC
AND date_id = (SELECT MAX(date_id) FROM fact_group_agency_daily WHERE del_flag = '0')
</select>
<!-- 查询 月的小组增量 -->
@ -107,7 +103,7 @@
fact_group_agency_daily
WHERE
del_flag = '0'
AND SUBSTRING( date_id, 1, 6 ) = #{monthId}
AND month_id = #{monthId}
GROUP BY
agency_id
</select>

Loading…
Cancel
Save