|
@ -1,61 +1,63 @@ |
|
|
package com.epmet.dataaggre.service.datastats.impl; |
|
|
package com.epmet.dataaggre.service.datastats.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.tools.enums.OrgLevelEnum; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
import com.epmet.commons.tools.enums.OrgLevelEnum; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
|
import com.epmet.commons.tools.utils.excel.ExportMultiView; |
|
|
import com.epmet.dataaggre.dao.datastats.DataStatsDao; |
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; |
|
|
import com.epmet.dataaggre.constant.OrgConstant; |
|
|
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; |
|
|
import com.epmet.dataaggre.dao.datastats.DataStatsDao; |
|
|
import com.epmet.dataaggre.dto.datastats.form.*; |
|
|
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; |
|
|
import com.epmet.dataaggre.dto.datastats.result.*; |
|
|
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; |
|
|
import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; |
|
|
import com.epmet.dataaggre.dto.datastats.form.*; |
|
|
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; |
|
|
import com.epmet.dataaggre.dto.datastats.result.*; |
|
|
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; |
|
|
import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; |
|
|
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; |
|
|
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; |
|
|
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; |
|
|
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; |
|
|
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; |
|
|
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; |
|
|
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; |
|
|
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; |
|
|
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; |
|
|
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; |
|
|
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |
|
|
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; |
|
|
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |
|
|
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; |
|
|
import com.epmet.dataaggre.excel.CustomerDataManageExcel; |
|
|
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; |
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; |
|
|
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; |
|
|
import com.epmet.dataaggre.excel.CustomerDataManageExcel; |
|
|
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; |
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import org.springframework.stereotype.Service; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.text.NumberFormat; |
|
|
import java.math.BigDecimal; |
|
|
import java.text.ParseException; |
|
|
import java.math.RoundingMode; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.NumberFormat; |
|
|
import java.util.*; |
|
|
import java.text.ParseException; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Author sun |
|
|
* @Author sun |
|
@ -1878,7 +1880,32 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
@Override |
|
|
@Override |
|
|
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
String openTime = formDTO.getStartTime(); |
|
|
String openTime = formDTO.getStartTime(); |
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> result = operateExport(formDTO).getList(); |
|
|
CustomerDataManageResultDTO operateExport = operateExport(formDTO); |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> result = operateExport.getList(); |
|
|
|
|
|
setTotal(result); |
|
|
|
|
|
formDTO.setStartTime(openTime); |
|
|
|
|
|
String fileName = excelName(formDTO); |
|
|
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(fileName,fileName); |
|
|
|
|
|
//exportParams.setAutoSize(true);
|
|
|
|
|
|
List<ExportMultiView> exportList = new ArrayList<>(); |
|
|
|
|
|
List<CustomerDataManageExcel> excelList = ConvertUtils.sourceToTarget(result, CustomerDataManageExcel.class); |
|
|
|
|
|
exportList.add(new ExportMultiView(exportParams,excelList,CustomerDataManageExcel.class)); |
|
|
|
|
|
if (formDTO.isExport()){ |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> gridResult = operateExport.getAllGridList(); |
|
|
|
|
|
setTotal(gridResult); |
|
|
|
|
|
ExportParams exportParams2 = new ExportParams(fileName,"网格数据"); |
|
|
|
|
|
//exportParams2.setAutoSize(true);
|
|
|
|
|
|
List<CustomerDataManageExcel> excelList2 = ConvertUtils.sourceToTarget(gridResult, CustomerDataManageExcel.class); |
|
|
|
|
|
exportList.add(new ExportMultiView(exportParams2,excelList2,CustomerDataManageExcel.class)); |
|
|
|
|
|
} |
|
|
|
|
|
//ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class);
|
|
|
|
|
|
|
|
|
|
|
|
ExcelUtils.exportMultiSheetExcel(fileName, exportList, response); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setTotal(List<CustomerDataManageResultDTO.CustomerDataManage> result) { |
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); |
|
|
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); |
|
|
c.setOrgName("合计"); |
|
|
c.setOrgName("合计"); |
|
@ -1897,9 +1924,6 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); |
|
|
c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); |
|
|
result.add(c); |
|
|
result.add(c); |
|
|
} |
|
|
} |
|
|
formDTO.setStartTime(openTime); |
|
|
|
|
|
String fileName = excelName(formDTO); |
|
|
|
|
|
ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -1958,8 +1982,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { |
|
|
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { |
|
|
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>(); |
|
|
|
|
|
//1.必要参数校验及处理
|
|
|
//1.必要参数校验及处理
|
|
|
String startTimeForm = formDTO.getStartTime(); |
|
|
String startTimeForm = formDTO.getStartTime(); |
|
|
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { |
|
|
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { |
|
@ -1974,7 +1997,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//2.查询组织信息,判断查询下级组织还是网格数据
|
|
|
//2.查询组织信息,判断查询下级组织还是网格数据
|
|
|
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); |
|
|
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport()); |
|
|
if (null == agencyGrid) { |
|
|
if (null == agencyGrid) { |
|
|
return new CustomerDataManageResultDTO(); |
|
|
return new CustomerDataManageResultDTO(); |
|
|
} |
|
|
} |
|
@ -1982,7 +2005,22 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); |
|
|
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); |
|
|
formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); |
|
|
formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); |
|
|
formDTO.setIdList(idList); |
|
|
formDTO.setIdList(idList); |
|
|
|
|
|
//获取组织级别数据
|
|
|
|
|
|
CustomerDataManageResultDTO resultDTO = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAgencyGridList(),agencyGrid.getLevel()); |
|
|
resultDTO.setTotal(idList.size()); |
|
|
resultDTO.setTotal(idList.size()); |
|
|
|
|
|
if (formDTO.isExport()){ |
|
|
|
|
|
formDTO.setDataType(OrgTypeEnum.GRID.getCode()); |
|
|
|
|
|
idList = agencyGrid.getAllGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); |
|
|
|
|
|
formDTO.setIdList(idList); |
|
|
|
|
|
CustomerDataManageResultDTO allGridData = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAllGridList(),agencyGrid.getLevel()); |
|
|
|
|
|
resultDTO.setAllGridList(allGridData.getList()); |
|
|
|
|
|
} |
|
|
|
|
|
return resultDTO; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public CustomerDataManageResultDTO getDataManageResultDTO(CustomerDataManageFormDTO formDTO, String startTimeForm, List<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList,String orgLevel) { |
|
|
|
|
|
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); |
|
|
|
|
|
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据
|
|
|
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据
|
|
|
formDTO.setSourceType("end"); |
|
|
formDTO.setSourceType("end"); |
|
@ -2029,7 +2067,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//5.封装数据
|
|
|
//5.封装数据
|
|
|
for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { |
|
|
for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGridList) { |
|
|
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); |
|
|
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); |
|
|
dto.setOrgId(org.getOrgId()); |
|
|
dto.setOrgId(org.getOrgId()); |
|
|
dto.setOrgName(org.getOrgName()); |
|
|
dto.setOrgName(org.getOrgName()); |
|
@ -2083,12 +2121,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
int patrolDurationInteger = NumConstant.ZERO; |
|
|
int patrolDurationInteger = NumConstant.ZERO; |
|
|
HashSet set = new HashSet(); |
|
|
HashSet set = new HashSet(); |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { |
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { |
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && org.getOrgId().equals(u.getOrgId())) { |
|
|
patroCount += u.getPatrolCount(); |
|
|
patroCount += u.getPatrolCount(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
set.add(u.getStaffId()); |
|
|
set.add(u.getStaffId()); |
|
|
} |
|
|
} |
|
|
if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) { |
|
|
if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && u.getOrgId().contains(org.getOrgId())) { |
|
|
patroCount += u.getPatrolCount(); |
|
|
patroCount += u.getPatrolCount(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
patrolDurationInteger += u.getPatrolDurationInteger(); |
|
|
set.add(u.getStaffId()); |
|
|
set.add(u.getStaffId()); |
|
@ -2099,10 +2137,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve |
|
|
int patrolRoutineWorkTimes = NumConstant.ZERO; |
|
|
int patrolRoutineWorkTimes = NumConstant.ZERO; |
|
|
if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) { |
|
|
if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) { |
|
|
for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) { |
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(work.getOrgId())) { |
|
|
if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && org.getOrgId().equals(work.getOrgId())) { |
|
|
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); |
|
|
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); |
|
|
set.add(work.getStaffId()); |
|
|
set.add(work.getStaffId()); |
|
|
} else if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && work.getOrgId().contains(org.getOrgId())) { |
|
|
} else if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && work.getOrgId().contains(org.getOrgId())) { |
|
|
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); |
|
|
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); |
|
|
set.add(work.getStaffId()); |
|
|
set.add(work.getStaffId()); |
|
|
} |
|
|
} |
|
|