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

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

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

Loading…
Cancel
Save