|
@@ -3,10 +3,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.ListSkuCodeReportVO;
|
|
|
import com.abi.qms.platform.dao.vo.result.ListPackageCodeVo;
|
|
|
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.ListSkuCodeRankingReportRes;
|
|
|
import com.abi.qms.platform.dto.res.PackageCodeTypeRes;
|
|
|
import com.abi.qms.platform.service.ReportService;
|
|
@@ -52,21 +54,16 @@ public class ReportServiceImpl implements ReportService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ListBrandCodeReportRes queryBrandCodeProportion(ReportReq reportReq) {
|
|
|
- if(!ObjectUtils.isEmpty(reportReq) &&
|
|
|
- null == reportReq.getEndTime() &&
|
|
|
- null == reportReq.getBeginTime()){
|
|
|
- HashMap<String, LocalDateTime> timestamp = getTimestamp(reportReq.getValue());
|
|
|
- reportReq.setBeginTime( timestamp.get("startTime"));
|
|
|
- reportReq.setEndTime( timestamp.get("endTime"));
|
|
|
- }
|
|
|
+ //参数设置初始化
|
|
|
+ setQueryTime(reportReq);
|
|
|
//查询 品牌数量
|
|
|
List<ListBrandCodeReportVO> listReportVOS = reportServiceMapper.queryBrandCodeProportion(reportReq);
|
|
|
if(!CollectionUtils.isEmpty(listReportVOS)){
|
|
|
//求总和
|
|
|
Long collect = listReportVOS.stream().collect(Collectors.summingLong(ListBrandCodeReportVO::getQrNumber));
|
|
|
listReportVOS.forEach(listReportVO->{
|
|
|
- long l = listReportVO.getQrNumber() / collect * 100;
|
|
|
- listReportVO.setPercent(new DecimalFormat("#0.00").format(l + 0.000001d)+"%");
|
|
|
+ Double val = new Double(listReportVO.getQrNumber() / collect * 100);
|
|
|
+ listReportVO.setPercent(new DecimalFormat("#0.00").format(val + 0.000001d)+"%");
|
|
|
});
|
|
|
}
|
|
|
// 封装出参
|
|
@@ -91,12 +88,56 @@ public class ReportServiceImpl implements ReportService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 包材厂使用码量,下载率
|
|
|
+ * @param reportReq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ListFactoryCodeReportRes queryFactoryCodeTotalReport(ReportReq reportReq) {
|
|
|
+ //参数设置初始化
|
|
|
+ setQueryTime(reportReq);
|
|
|
+ //包材厂生成包数量
|
|
|
+ List<ListFactoryCodeReportVO> listFactoryCodeTotalReportVOS = reportServiceMapper.queryFactoryCodeTotal(reportReq,0);
|
|
|
+ //包材厂包下载量
|
|
|
+ List<ListFactoryCodeReportVO> listFactoryCodeDownloadTotalReportVOS = reportServiceMapper.queryFactoryCodeTotal(reportReq,1);
|
|
|
+ Map<String, Long> FactoryCodeDownloadTotalMaps = listFactoryCodeTotalReportVOS.stream().collect(Collectors.toMap(ListFactoryCodeReportVO::getFactoryName, ListFactoryCodeReportVO::getQrNumber));
|
|
|
+ listFactoryCodeTotalReportVOS.forEach(listReportVO->{
|
|
|
+ Double val = 0d;
|
|
|
+ if (null != FactoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName())){
|
|
|
+ val = new Double(FactoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName()) / listReportVO.getQrNumber() * 100);
|
|
|
+ }
|
|
|
+ listReportVO.setDownloadNumber(new DecimalFormat("#0.00").format(val + 0.000001d)+"%");
|
|
|
+ });
|
|
|
+ // 封装出参
|
|
|
+ ListFactoryCodeReportRes res = new ListFactoryCodeReportRes();
|
|
|
+ List<ListFactoryCodeReportRes.FactoryCodeReportResBean> reportFactoryRes = PojoConverterUtils.copyList(listFactoryCodeTotalReportVOS, ListFactoryCodeReportRes.FactoryCodeReportResBean.class);
|
|
|
+ res.setFactoryCodeResReportList(reportFactoryRes);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置时间区间值
|
|
|
+ * @param reportReq
|
|
|
+ */
|
|
|
+ private void setQueryTime(ReportReq reportReq){
|
|
|
+ if(!ObjectUtils.isEmpty(reportReq) &&
|
|
|
+ null == reportReq.getEndTime() &&
|
|
|
+ null == reportReq.getBeginTime() &&
|
|
|
+ !ObjectUtils.isEmpty(reportReq.getValue())){
|
|
|
+ HashMap<String, LocalDateTime> timestamp = getTimestamp(reportReq.getValue());
|
|
|
+ reportReq.setBeginTime( timestamp.get("startTime"));
|
|
|
+ reportReq.setEndTime( timestamp.get("endTime"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据类型获取时间范围
|
|
|
* @param timeType (0-当天,1-本周,2-本月)
|
|
|
* @return key 开始时间:startTime 结束时间:endTime
|
|
|
*/
|
|
|
- private static HashMap<String, LocalDateTime> getTimestamp(Integer timeType) {
|
|
|
+ private HashMap<String, LocalDateTime> getTimestamp(Integer timeType) {
|
|
|
HashMap<String, LocalDateTime> hashMap = new HashMap<String, LocalDateTime>();
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
@@ -114,7 +155,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
"endTime",
|
|
|
longTurnData( getTimestampByOffsetDay(calendar
|
|
|
.getMaximum(Calendar.DAY_OF_WEEK)
|
|
|
- - calendar.get(Calendar.DAY_OF_WEEK) + 1)));
|
|
|
+ - calendar.get(Calendar.DAY_OF_WEEK) + 2)));
|
|
|
}
|
|
|
|
|
|
//本月
|
|
@@ -138,7 +179,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param l 时间毫秒值
|
|
|
* @return java.time.LocalDateTime
|
|
|
*/
|
|
|
- private static LocalDateTime longTurnData(Long l) {
|
|
|
+ private LocalDateTime longTurnData(Long l) {
|
|
|
Instant instant = Instant.ofEpochMilli(l);
|
|
|
ZoneId zone = ZoneId.systemDefault();
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
|
|
@@ -152,7 +193,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param day
|
|
|
* @return long
|
|
|
*/
|
|
|
- public static long getTimestampByOffsetDay(int day){
|
|
|
+ public long getTimestampByOffsetDay(int day){
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, day);
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|