|
|
@ -1,8 +1,10 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dto.project.form.MonthProjectListFormDTO; |
|
|
|
import com.epmet.dto.project.form.ProjectStatsFormDTO; |
|
|
|
import com.epmet.dto.stats.DimAgencyDTO; |
|
|
|
import com.epmet.entity.issue.IssueEntity; |
|
|
|
import com.epmet.entity.project.ProjectEntity; |
|
|
@ -19,6 +21,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.DateFormat; |
|
|
@ -62,33 +65,43 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Description 数据-项目-机关日(月)统计 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void agencyProjectStats() { |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
try { |
|
|
|
log.info("for循环统计机关-项目-日月数据,当前统计的客户Id:" + customerId); |
|
|
|
//遍历统计每一个客户数据
|
|
|
|
customerAgencyStats(customerId); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("项目-机关-数据统计程序错误,对应客户Id:" + customerId, e); |
|
|
|
log.error("Error creating model JSON", e); |
|
|
|
public void agencyProjectStats(ProjectStatsFormDTO formDTO) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//入参有时间的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (null != formDTO.getDate() && StringUtils.isNotBlank(formDTO.getDate())) { |
|
|
|
date = DateUtils.parse(formDTO.getDate(), DateUtils.DATE_PATTERN); |
|
|
|
} |
|
|
|
//入参有客户Id的则按客户Id执行,没有的则全部客户都执行
|
|
|
|
if (null != formDTO.getCustomerId() && StringUtils.isNotBlank(formDTO.getCustomerId())) { |
|
|
|
log.info("单独统计客户机关-项目-日月数据,当前统计的客户Id:" + formDTO.getCustomerId()); |
|
|
|
customerAgencyStats(formDTO.getCustomerId(), date); |
|
|
|
} else { |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
try { |
|
|
|
log.info("for循环统计机关-项目-日月数据,当前统计的客户Id:" + customerId); |
|
|
|
//遍历统计每一个客户数据
|
|
|
|
customerAgencyStats(customerId, date); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("项目-机关-数据统计程序错误,对应客户Id:" + customerId, e); |
|
|
|
log.error("Error creating model JSON", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 分别统计机关日/月数据 |
|
|
|
**/ |
|
|
|
public void customerAgencyStats(String customerId) { |
|
|
|
Date date = yesterDay(); |
|
|
|
public void customerAgencyStats(String customerId, Date date) { |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); |
|
|
|
|
|
|
@ -115,7 +128,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
//5.1:执行机关日数据统计
|
|
|
|
try { |
|
|
|
log.info("StatsProjectServiceImpl.customerAgencyStats-开始执行机关日统计方法,方法名:agencyDateProjectStats,客户Id:" + customerId); |
|
|
|
agencyDateProjectStats(customerId, dimId, dimAgencyList, projectList, processList); |
|
|
|
agencyDateProjectStats(customerId, dimId, date, dimAgencyList, projectList, processList); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyDateProjectStats", customerId, dimId.getDateId()), e); |
|
|
|
} |
|
|
@ -138,8 +151,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关日统计 |
|
|
|
**/ |
|
|
|
private String agencyDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimAgencyDTO> dimAgencyList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
private String agencyDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, Date date, List<DimAgencyDTO> dimAgencyList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
//批量机关日统计新增对象
|
|
|
|
List<FactAgencyProjectDailyEntity> projectDateEntityList = new ArrayList<>(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
@ -277,7 +289,6 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Description 数据-项目-机关月统计 |
|
|
|
**/ |
|
|
|
private String agencyMonthProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//批量月数据新增对象
|
|
|
|
List<FactAgencyProjectMonthlyEntity> monthlyEntityList = new ArrayList<>(); |
|
|
|
|
|
|
@ -353,36 +364,46 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关日(月)统计 |
|
|
|
* @Description 数据-项目-网格日(月)统计 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void gridProjectStats() { |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
try { |
|
|
|
log.info("for循环统计网格-项目-日月数据,当前统计的客户Id:" + customerId); |
|
|
|
//遍历统计每一个客户数据
|
|
|
|
customerGridStats(customerId); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("项目-网格-数据统计程序错误,对应客户Id:" + customerId, e); |
|
|
|
log.error("Error creating model JSON", e); |
|
|
|
public void gridProjectStats(ProjectStatsFormDTO formDTO) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//入参有时间的则按具体时间执行,没有的则按当前时间前一天执行
|
|
|
|
if (null != formDTO.getDate() && StringUtils.isNotBlank(formDTO.getDate())) { |
|
|
|
date = DateUtils.parse(formDTO.getDate(), DateUtils.DATE_PATTERN); |
|
|
|
} |
|
|
|
//入参有客户Id的则按客户Id执行,没有的则全部客户都执行
|
|
|
|
if (null != formDTO.getCustomerId() && StringUtils.isNotBlank(formDTO.getCustomerId())) { |
|
|
|
log.info("单独统计客户网格-项目-日月数据,当前统计的客户Id:" + formDTO.getCustomerId()); |
|
|
|
customerGridStats(formDTO.getCustomerId(), date); |
|
|
|
} else { |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
try { |
|
|
|
log.info("for循环统计网格-项目-日月数据,当前统计的客户Id:" + customerId); |
|
|
|
//遍历统计每一个客户数据
|
|
|
|
customerGridStats(customerId, date); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("项目-网格-数据统计程序错误,对应客户Id:" + customerId, e); |
|
|
|
log.error("Error creating model JSON", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 分别统计网格日/月数据 |
|
|
|
**/ |
|
|
|
public void customerGridStats(String customerId) { |
|
|
|
Date date = yesterDay(); |
|
|
|
public void customerGridStats(String customerId, Date date) { |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); |
|
|
|
|
|
|
@ -407,7 +428,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
//5.1:执行网格日数据统计
|
|
|
|
try { |
|
|
|
log.info("StatsProjectServiceImpl.customerGridStats-开始执行机关日统计方法,方法名:gridDateProjectStats,客户Id:" + customerId); |
|
|
|
gridDateProjectStats(customerId, dimId, dimGridList, projectList, processList); |
|
|
|
gridDateProjectStats(customerId, dimId, date, dimGridList, projectList, processList); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "gridDateProjectStats", customerId, dimId.getDateId()), e); |
|
|
|
} |
|
|
@ -431,8 +452,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-网格日统计 |
|
|
|
**/ |
|
|
|
private String gridDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimGridEntity> dimGridList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
private String gridDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, Date date, List<DimGridEntity> dimGridList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
//批量网格日统计新增对象
|
|
|
|
List<FactGridProjectDailyEntity> gridDateEntityList = new ArrayList<>(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
|