|
@@ -127,18 +127,29 @@ public class ReportServiceImpl implements ReportService {
|
|
|
QueryWxFactoryRes res = new QueryWxFactoryRes();
|
|
|
if (isMainAccount.equals(0)) {
|
|
|
//子账号报表
|
|
|
+ //返回数据初始化(4个月份)
|
|
|
+ List<QueryWxFactoryVO> queryWxFactorySumSummary = new ArrayList<QueryWxFactoryVO>();
|
|
|
+ getMonthFactorySumSummaryInit(3,queryWxFactorySumSummary);
|
|
|
//获取现在时间 获取前三个月的时间
|
|
|
//总量=下单量
|
|
|
List<QueryWxFactoryVO> queryWxFactorySumNumber = reportServiceMapper.queryWxFactorySumNumber(queryWxFactoryReq,getMonth());
|
|
|
- AssertUtil.isNull(queryWxFactorySumNumber,"查询为空!");
|
|
|
+ Map<String, Long> sumNumberMap = queryWxFactorySumNumber.stream().collect(Collectors.toMap(QueryWxFactoryVO::getMonth, QueryWxFactoryVO::getTotal));
|
|
|
//激活量
|
|
|
List<QueryWxFactoryVO> queryWxFactoryActivationNumber = reportServiceMapper.queryWxFactoryActivationNumber(queryWxFactoryReq,getMonth());
|
|
|
Map<String, Long> activationNumberMap = queryWxFactoryActivationNumber.stream().collect(Collectors.toMap(QueryWxFactoryVO::getMonth, QueryWxFactoryVO::getActivation));
|
|
|
- queryWxFactorySumNumber.forEach(factorySumNumber->{
|
|
|
- Long aLong = (null == activationNumberMap.get(factorySumNumber.getMonth()) ? 0L : activationNumberMap.get(factorySumNumber.getMonth()));
|
|
|
- factorySumNumber.setActivation(aLong);
|
|
|
+ //信息汇总
|
|
|
+ queryWxFactorySumSummary.forEach(factorySumNumber->{
|
|
|
+ //存在总量
|
|
|
+ if(null != sumNumberMap.get(factorySumNumber.getMonth())){
|
|
|
+ factorySumNumber.setTotal(sumNumberMap.get(factorySumNumber.getMonth()));
|
|
|
+ }
|
|
|
+ //存在下载量
|
|
|
+ if(null != activationNumberMap.get(factorySumNumber.getMonth())){
|
|
|
+ factorySumNumber.setActivation(activationNumberMap.get(factorySumNumber.getMonth()));
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
- List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactorySumNumber, QueryWxFactoryRes.QueryWxFactoryBean.class);
|
|
|
+ List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactorySumSummary, QueryWxFactoryRes.QueryWxFactoryBean.class);
|
|
|
queryWxFactoryBeans.forEach(beans->{
|
|
|
beans.setInStock(beans.getTotal() - beans.getActivation());
|
|
|
});
|
|
@@ -209,12 +220,14 @@ public class ReportServiceImpl implements ReportService {
|
|
|
//本周
|
|
|
if (timeType == 1){
|
|
|
int day_of_week = calStart.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
- if (day_of_week == 0)
|
|
|
+ if (day_of_week == 0){
|
|
|
day_of_week = 7;
|
|
|
+ }
|
|
|
calStart.add(Calendar.DATE, -day_of_week + 1);
|
|
|
day_of_week = calEnd.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
- if (day_of_week == 0)
|
|
|
+ if (day_of_week == 0) {
|
|
|
day_of_week = 7;
|
|
|
+ }
|
|
|
calEnd.add(Calendar.DATE, -day_of_week + 7);
|
|
|
}
|
|
|
|
|
@@ -402,7 +415,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @date 2021/6/10 17:03
|
|
|
* @return java.time.LocalDateTime
|
|
|
*/
|
|
|
- private LocalDateTime getMonth(){
|
|
|
+ private static LocalDateTime getMonth(){
|
|
|
Calendar calStart = Calendar.getInstance();
|
|
|
calStart.add(Calendar.MONTH, -3);//上一月
|
|
|
calStart.set(Calendar.DAY_OF_MONTH, 1);
|
|
@@ -414,4 +427,25 @@ public class ReportServiceImpl implements ReportService {
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
return instant.atZone(zoneId).toLocalDateTime();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计下单量信息数据初始化
|
|
|
+ * @param monthNumber 前几个月
|
|
|
+ * @param queryWxFactorySumSummary 初始化对象list
|
|
|
+ */
|
|
|
+ private void getMonthFactorySumSummaryInit(int monthNumber,List<QueryWxFactoryVO> queryWxFactorySumSummary){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ for (int i = monthNumber*-1 ; i <= 0; i++) {
|
|
|
+ Calendar calStart = Calendar.getInstance();
|
|
|
+ calStart.add(Calendar.MONTH, i);//上一月
|
|
|
+ calStart.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ calStart.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ String month = sdf.format(calStart.getTime());
|
|
|
+ QueryWxFactoryVO queryWxFactoryVO = new QueryWxFactoryVO();
|
|
|
+ queryWxFactoryVO.setMonth(month);
|
|
|
+ queryWxFactoryVO.setTotal(0L);//总量初始化为0
|
|
|
+ queryWxFactoryVO.setActivation(0L);//下载量初始化为0
|
|
|
+ queryWxFactorySumSummary.add(queryWxFactoryVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|