|
@ -1,7 +1,8 @@ |
|
|
package com.epmet.dataaggre.service.datastats.impl; |
|
|
package com.epmet.dataaggre.service.datastats.impl; |
|
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.epmet.commons.tools.enums.OrgLevelEnum; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
@ -18,7 +19,9 @@ import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; |
|
|
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; |
|
|
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; |
|
|
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |
|
|
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |
|
|
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |
|
|
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |
|
|
|
|
|
import com.epmet.dataaggre.entity.epmetuser.StatsStaffPatrolRecordDailyEntity; |
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
|
|
|
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; |
|
|
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |
|
|
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
@ -54,6 +57,8 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private FactGridMemberStatisticsDailyDao factGridMemberStatisticsDailyDao; |
|
|
private FactGridMemberStatisticsDailyDao factGridMemberStatisticsDailyDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private StatsStaffPatrolRecordDailyService statsStaffPatrolRecordDailyService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -1469,40 +1474,104 @@ public class DataStatsServiceImpl implements DataStatsService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public WorkFactResultDTO getSubWorkFact(BaseDataFormDTO formDTO) { |
|
|
public List<WorkFactResultDTO> getSubWorkFact(BaseDataFormDTO formDTO) { |
|
|
//入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
//入参有日期的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
if (StringUtils.isBlank(formDTO.getType())){ |
|
|
if (StringUtils.isBlank(formDTO.getType())){ |
|
|
formDTO.setType("yesterday"); |
|
|
formDTO.setType("yesterday"); |
|
|
} |
|
|
} |
|
|
|
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
if (StringUtils.isBlank(formDTO.getDateId())) { |
|
|
Date yesterday = DateUtils.addDateDays(new Date(), -1); |
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
formDTO.setDateId(format.format(yesterday)); |
|
|
} |
|
|
} |
|
|
String startDate,endDate; |
|
|
String startDate = null; |
|
|
|
|
|
String endDate = null; |
|
|
Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); |
|
|
boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); |
|
|
switch (formDTO.getType()){ |
|
|
switch (formDTO.getType()){ |
|
|
case "yesterday": |
|
|
case "yesterday": |
|
|
startDate = DateUtils.getBeforeNDay(NumConstant.ONE); |
|
|
startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); |
|
|
endDate = startDate; |
|
|
endDate = formDTO.getDateId(); |
|
|
break; |
|
|
break; |
|
|
case "thisWeek": |
|
|
case "thisWeek": |
|
|
startDate = DateUtils.getWeekStart(formDTO.getDateId()); |
|
|
startDate = DateUtils.getWeekStart(formDTO.getDateId()); |
|
|
|
|
|
startDate = DateUtils.getBeforeNDay(startDate,1); |
|
|
|
|
|
DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
if (!isYesterday){ |
|
|
if (!isYesterday){ |
|
|
endDate = DateUtils.getWeekEnd(formDTO.getDateId()); |
|
|
endDate = DateUtils.getWeekEnd(formDTO.getDateId()); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case "thisMonth": |
|
|
case "thisMonth": |
|
|
startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
|
|
|
startDate = DateUtils.getBeforeNDay(startDate,1); |
|
|
if (!isYesterday) { |
|
|
if (!isYesterday) { |
|
|
endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
} |
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
log.warn("==========="); |
|
|
} |
|
|
} |
|
|
|
|
|
formDTO.setStartDateId(startDate); |
|
|
|
|
|
formDTO.setEndDateId(endDate); |
|
|
|
|
|
List<WorkFactResultDTO> result = new ArrayList<>(); |
|
|
|
|
|
//如果是社区 则下级是网格 查询网格的数据
|
|
|
|
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
|
|
|
|
|
|
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); |
|
|
|
|
|
if (subAgencyList.size() < NumConstant.ONE) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> agencyList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); |
|
|
|
|
|
//查询组织的话题转议题数据
|
|
|
|
|
|
List<SubAgencyFormDTO.Topic> toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getStartDateId()); |
|
|
|
|
|
List<SubAgencyFormDTO.Topic> toIssueEnd = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getEndDateId()); |
|
|
|
|
|
Map<String, Integer> toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
|
|
Map<String, Integer> toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); |
|
|
|
|
|
//查询组织的议题转项目数据
|
|
|
|
|
|
List<SubAgencyIssueResultDTO> toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getStartDateId()); |
|
|
|
|
|
List<SubAgencyIssueResultDTO> toProjectEnd = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getEndDateId()); |
|
|
|
|
|
Map<String, Integer> toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
|
|
Map<String, Integer> toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); |
|
|
|
|
|
//查询组织已关闭的项目数据
|
|
|
|
|
|
List<SubAgencyProjectResultDTO> closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getStartDateId()); |
|
|
|
|
|
List<SubAgencyProjectResultDTO> closeProjectEnd = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getEndDateId()); |
|
|
|
|
|
Map<String, Integer> closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
|
|
Map<String, Integer> closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); |
|
|
|
|
|
//巡查次数和时间
|
|
|
|
|
|
List<StatsStaffPatrolRecordDailyEntity> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyList,formDTO.getStartDateId(),formDTO.getEndDateId()); |
|
|
|
|
|
Map<String, StatsStaffPatrolRecordDailyEntity> patrolListMap = patrolList.stream().collect(Collectors.toMap(StatsStaffPatrolRecordDailyEntity::getAgencyId, o -> o, (o1, o2) -> o1)); |
|
|
|
|
|
|
|
|
|
|
|
subAgencyList.forEach(agency->{ |
|
|
|
|
|
String agencyId = agency.getAgencyId(); |
|
|
|
|
|
WorkFactResultDTO resultDTO = new WorkFactResultDTO(); |
|
|
|
|
|
resultDTO.setOrgId(agencyId); |
|
|
|
|
|
resultDTO.setOrgName(agency.getAgencyName()); |
|
|
|
|
|
resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,agencyId)); |
|
|
|
|
|
resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,agencyId)); |
|
|
|
|
|
resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,agencyId)); |
|
|
|
|
|
StatsStaffPatrolRecordDailyEntity patrolRecordDTO = patrolListMap.get(agencyId); |
|
|
|
|
|
if (patrolRecordDTO != null){ |
|
|
|
|
|
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); |
|
|
|
|
|
Integer totalTime = patrolRecordDTO.getTotalTime(); |
|
|
|
|
|
resultDTO.setPatrolTotalTime(totalTime.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
result.add(resultDTO); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
private Integer getTotal(Map<String,Integer> startMap, Map<String,Integer> endMap,String agencyId){ |
|
|
|
|
|
Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO); |
|
|
|
|
|
Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO); |
|
|
|
|
|
if (total1.equals(total2)){ |
|
|
|
|
|
log.warn("===========相等,total:{}",total1); |
|
|
|
|
|
} |
|
|
|
|
|
return Math.max(total2-total1,0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String getPercentage(Integer countInt, Integer totalInt) { |
|
|
private String getPercentage(Integer countInt, Integer totalInt) { |
|
|