|
@@ -2,15 +2,12 @@ package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
import com.abi.qms.platform.dao.enums.QrTypeEnum;
|
|
|
import com.abi.qms.platform.dao.mapper.ReportServiceMapper;
|
|
|
-import com.abi.qms.platform.dao.vo.result.ListBrandCodeReportVO;
|
|
|
-import com.abi.qms.platform.dao.vo.result.ListFactoryCodeReportVO;
|
|
|
-import com.abi.qms.platform.dao.vo.result.ListMaterialCodeReportVO;
|
|
|
-import com.abi.qms.platform.dao.vo.result.ListPackageCodeVo;
|
|
|
+import com.abi.qms.platform.dao.vo.result.*;
|
|
|
+import com.abi.qms.platform.dto.req.QueryWxFactoryReq;
|
|
|
import com.abi.qms.platform.dto.req.ReportReq;
|
|
|
-import com.abi.qms.platform.dto.res.ListBrandCodeReportRes;
|
|
|
-import com.abi.qms.platform.dto.res.ListFactoryCodeReportRes;
|
|
|
-import com.abi.qms.platform.dto.res.ListMaterialCodeRankingReportRes;
|
|
|
-import com.abi.qms.platform.dto.res.PackageCodeTypeRes;
|
|
|
+import com.abi.qms.platform.dto.res.*;
|
|
|
+import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.UserUtil;
|
|
|
import com.abi.qms.platform.service.ReportService;
|
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -40,6 +37,10 @@ public class ReportServiceImpl implements ReportService {
|
|
|
@Autowired
|
|
|
private ReportServiceMapper reportServiceMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserUtil userUtil;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 品牌使用码量占比(603版 已废弃)
|
|
|
*
|
|
@@ -117,6 +118,51 @@ public class ReportServiceImpl implements ReportService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统计下单量
|
|
|
+ * @author lu
|
|
|
+ * @date 2021/6/10 11:35
|
|
|
+ * @param queryWxFactoryReq
|
|
|
+ * @return com.abi.qms.platform.dto.res.QueryWxFactoryRes
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public QueryWxFactoryRes queryWxFactory(QueryWxFactoryReq queryWxFactoryReq) {
|
|
|
+ // 是小程序用户主账号 1-是 0-不是
|
|
|
+ Integer isMainAccount = userUtil.getWholeUser().getIsMainAccount();
|
|
|
+ QueryWxFactoryRes res = new QueryWxFactoryRes();
|
|
|
+ if (isMainAccount.equals(0)) {
|
|
|
+ //子账号报表
|
|
|
+ //获取现在时间
|
|
|
+ queryWxFactoryReq.setNow(LocalDateTime.now());
|
|
|
+ //获取前三个月的时间
|
|
|
+ queryWxFactoryReq.setMonth(getMonth());
|
|
|
+ List<QueryWxFactoryVO> queryWxFactoryVO = reportServiceMapper.queryWxFactory(queryWxFactoryReq);
|
|
|
+ AssertUtil.isNull(queryWxFactoryVO,"报表数据查询为空");
|
|
|
+ List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactoryVO, QueryWxFactoryRes.QueryWxFactoryBean.class);
|
|
|
+ queryWxFactoryBeans.forEach(beans->{
|
|
|
+ beans.setInStock(beans.getTotal() - beans.getActivation());
|
|
|
+ });
|
|
|
+ res.setQueryWxFactoryBeanList(queryWxFactoryBeans);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ //下单量-激活量-库存
|
|
|
+ List<QueryWxFactoryVO> queryWxFactoryVO = reportServiceMapper.queryWxFactory(queryWxFactoryReq);
|
|
|
+ AssertUtil.isNull(queryWxFactoryVO,"查询为空");
|
|
|
+ List<QueryWxFactoryRes.QueryWxFactoryBean> queryWxFactoryBeans = PojoConverterUtils.copyList(queryWxFactoryVO, QueryWxFactoryRes.QueryWxFactoryBean.class);
|
|
|
+ Long total = queryWxFactoryBeans.stream().mapToLong(QueryWxFactoryRes.QueryWxFactoryBean::getTotal).sum();
|
|
|
+ Long activation = queryWxFactoryBeans.stream().mapToLong(QueryWxFactoryRes.QueryWxFactoryBean::getActivation).sum();
|
|
|
+ Long stock= total-activation;
|
|
|
+ QueryWxFactoryRes.QueryWxFactoryBean factoryBean= new QueryWxFactoryRes.QueryWxFactoryBean();
|
|
|
+ factoryBean.setActivation(activation);
|
|
|
+ factoryBean.setInStock(stock);
|
|
|
+ factoryBean.setTotal(total);
|
|
|
+ List<QueryWxFactoryRes.QueryWxFactoryBean> list = new ArrayList<>();
|
|
|
+ list.add(factoryBean);
|
|
|
+ res.setQueryWxFactoryBeanList(list);
|
|
|
+ return res;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设置时间区间值
|
|
|
* @param reportReq
|
|
@@ -366,4 +412,17 @@ public class ReportServiceImpl implements ReportService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private LocalDateTime getMonth(){
|
|
|
+ Calendar calStart = Calendar.getInstance();
|
|
|
+ calStart.add(Calendar.MONTH, -3);//上一月
|
|
|
+ calStart.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ calStart.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calStart.set(Calendar.SECOND, 0);
|
|
|
+ calStart.set(Calendar.MINUTE, 0);
|
|
|
+ calStart.set(Calendar.MILLISECOND, 0);
|
|
|
+ Instant instant = calStart.toInstant();
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+ return instant.atZone(zoneId).toLocalDateTime();
|
|
|
+ }
|
|
|
}
|