| 
						
						
						
					 | 
				
				 | 
				
					@ -1,55 +1,54 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 package com.epmet.dataaggre.service.datastats.impl; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.constant.StrConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.enums.OrgLevelEnum; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.commons.tools.utils.ExcelUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.constant.DataSourceConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.constant.OrgConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dao.datastats.DataStatsDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.datastats.form.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.datastats.result.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.epmet.dataaggre.excel.CustomerDataManageExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 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.opercrm.CustomerRelation; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import com.github.pagehelper.PageHelper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import org.apache.commons.collections4.CollectionUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.math.BigDecimal; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.math.RoundingMode; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.text.NumberFormat; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.text.ParseException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.text.SimpleDateFormat; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.util.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.util.concurrent.atomic.AtomicInteger; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.util.concurrent.atomic.AtomicReference; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.enums.OrgLevelEnum; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ExcelUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.constant.DataSourceConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.constant.OrgConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dao.datastats.DataStatsDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.datastats.form.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.datastats.result.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.dataaggre.excel.CustomerDataManageExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					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.opercrm.CustomerRelation; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.github.pagehelper.PageHelper; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.collections4.CollectionUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.math.BigDecimal; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.math.RoundingMode; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.text.NumberFormat; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.text.ParseException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.text.SimpleDateFormat; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.concurrent.atomic.AtomicInteger; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.concurrent.atomic.AtomicReference; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * @Author sun | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -1556,7 +1555,7 @@ public class DataStatsServiceImpl implements DataStatsService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, Integer> closeProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //巡查次数和时间
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getOrgId, o -> o, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subAgencyList.forEach(agency->{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String gridId = agency.getGridId(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -1567,7 +1566,7 @@ public class DataStatsServiceImpl implements DataStatsService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,gridId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,gridId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                PatrolDailySumResult patrolRecordDTO = patrolListMap.get(agency.getAllParentIds()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                PatrolDailySumResult patrolRecordDTO = patrolListMap.get(gridId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                setPatrolAttr(resultDTO, patrolRecordDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                result.add(resultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -1595,9 +1594,9 @@ public class DataStatsServiceImpl implements DataStatsService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, Integer> closeProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, Integer> closeProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //巡查次数和时间
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<String> agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,formDTO.getStartDateId(),formDTO.getEndDateId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<String> agencyIdList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getOrgId, o -> o, (o1, o2) -> o1)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            subAgencyList.forEach(agency->{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String agencyId = agency.getAgencyId(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -1607,8 +1606,7 @@ public class DataStatsServiceImpl implements DataStatsService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                resultDTO.setTopicToIssueTotal(getTotal(toIssueStartMap,toIssueEndMap,agencyId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                resultDTO.setIssueToProjectTotal(getTotal(toProjectStartMap,toProjectEndMap,agencyId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                resultDTO.setClosedProjectTotal(getTotal(closeProjectStartMap,closeProjectEndMap,agencyId)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String fullAgencyId = agency.getPids().concat(StrConstant.COLON).concat(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                PatrolDailySumResult patrolRecordDTO = patrolListMap.get(fullAgencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                PatrolDailySumResult patrolRecordDTO = patrolListMap.get(agencyId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                setPatrolAttr(resultDTO,patrolRecordDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                result.add(resultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |