|
@@ -78,6 +78,8 @@ public class ReportServiceImpl implements ReportService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ListMaterialCodeRankingReportRes queryMaterialCodeRanking(ReportReq reportReq) {
|
|
|
+ //参数设置初始化
|
|
|
+ setQueryTime(reportReq);
|
|
|
List<ListMaterialCodeReportVO> listMaterialCodeReportVOS = reportServiceMapper.queryMaterialCodeRanking(reportReq);
|
|
|
// 封装出参
|
|
|
ListMaterialCodeRankingReportRes res = new ListMaterialCodeRankingReportRes();
|
|
@@ -97,24 +99,16 @@ public class ReportServiceImpl implements ReportService {
|
|
|
//参数设置初始化
|
|
|
setQueryTime(reportReq);
|
|
|
//包材厂生成包数量
|
|
|
- List<ListFactoryCodeReportVO> listFactoryCodeTotalReportVOS = reportServiceMapper.queryFactoryCodeTotal(reportReq,0);
|
|
|
- //包材厂包下载量
|
|
|
- List<ListFactoryCodeReportVO> listFactoryCodeDownloadTotalReportVOS = reportServiceMapper.queryFactoryCodeTotal(reportReq,1);
|
|
|
- Map<String, Long> factoryCodeDownloadTotalMaps = listFactoryCodeDownloadTotalReportVOS.stream().collect(Collectors.toMap(ListFactoryCodeReportVO::getFactoryName, ListFactoryCodeReportVO::getQrNumber));
|
|
|
- if(!CollectionUtils.isEmpty(listFactoryCodeTotalReportVOS)) {
|
|
|
- listFactoryCodeTotalReportVOS.forEach(listReportVO -> {
|
|
|
- Double val = 0d;
|
|
|
- //计算下载率
|
|
|
- if (null != factoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName())) {
|
|
|
- val = factoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName()).doubleValue() / listReportVO.getQrNumber().doubleValue() * 100;
|
|
|
- }
|
|
|
- //下载率取整
|
|
|
- listReportVO.setDownloadNumber(new BigDecimal(Math.floor(val)).longValue());
|
|
|
- });
|
|
|
- }
|
|
|
+ List<ListFactoryCodeReportVO> listFactoryCodeTotalReportVOS = reportServiceMapper.queryFactoryCodeTotal(reportReq);
|
|
|
// 封装出参
|
|
|
ListFactoryCodeReportRes res = new ListFactoryCodeReportRes();
|
|
|
List<ListFactoryCodeReportRes.FactoryCodeReportResBean> reportFactoryRes = PojoConverterUtils.copyList(listFactoryCodeTotalReportVOS, ListFactoryCodeReportRes.FactoryCodeReportResBean.class);
|
|
|
+ reportFactoryRes.forEach(reportFactoryRe ->{
|
|
|
+ //需求未定,暂时不做处理
|
|
|
+ reportFactoryRe.setQrDownloadNumber(0l);
|
|
|
+ reportFactoryRe.setQrNumber(0l);
|
|
|
+ reportFactoryRe.setDownloadNumber(0l);
|
|
|
+ });
|
|
|
res.setFactoryCodeResReportList(reportFactoryRes);
|
|
|
return res;
|
|
|
}
|
|
@@ -170,9 +164,9 @@ public class ReportServiceImpl implements ReportService {
|
|
|
null == reportReq.getEndTime() &&
|
|
|
null == reportReq.getBeginTime() &&
|
|
|
!ObjectUtils.isEmpty(reportReq.getValue())){
|
|
|
- HashMap<String, String> timestamp = getTimestamp(reportReq.getValue());
|
|
|
- reportReq.setBeginTime( timestamp.get("startTime"));
|
|
|
- reportReq.setEndTime( timestamp.get("endTime"));
|
|
|
+ Map<String, String> timestamp = getTimestamp(reportReq.getValue());
|
|
|
+ reportReq.setBeginTime( timestamp.get("beginDate"));
|
|
|
+ reportReq.setEndTime( timestamp.get("endDate"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -181,69 +175,44 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param timeType (0-当天,1-本周,2-本月)
|
|
|
* @return key 开始时间:startTime 结束时间:endTime
|
|
|
*/
|
|
|
- private HashMap<String, String> getTimestamp(Integer timeType) {
|
|
|
- HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
-
|
|
|
+ private static Map<String,String> getTimestamp(Integer timeType) {
|
|
|
+ SimpleDateFormat startFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
+ SimpleDateFormat endFormat = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
|
|
|
+ Map<String,String> map=new HashMap<String,String>();
|
|
|
+ Calendar calStart = Calendar.getInstance();
|
|
|
+ Calendar calEnd = Calendar.getInstance();
|
|
|
//当天
|
|
|
if (timeType == 0){
|
|
|
- hashMap.put("startTime", longTurnData(getTimestampByOffsetDay(0)));
|
|
|
- hashMap.put("endTime", longTurnData(getTimestampByOffsetDay(1)));
|
|
|
+ calStart.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calEnd.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
}
|
|
|
//本周
|
|
|
if (timeType == 1){
|
|
|
- hashMap.put(
|
|
|
- "startTime",
|
|
|
- longTurnData(getTimestampByOffsetDay(0 - calendar.get(Calendar.DAY_OF_WEEK) + 2)) );
|
|
|
- hashMap.put(
|
|
|
- "endTime",
|
|
|
- longTurnData( getTimestampByOffsetDay(calendar
|
|
|
- .getMaximum(Calendar.DAY_OF_WEEK)
|
|
|
- - calendar.get(Calendar.DAY_OF_WEEK) + 2)));
|
|
|
+ int day_of_week = calStart.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
+ 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)
|
|
|
+ day_of_week = 7;
|
|
|
+ calEnd.add(Calendar.DATE, -day_of_week + 7);
|
|
|
}
|
|
|
|
|
|
//本月
|
|
|
if (timeType == 2){
|
|
|
- hashMap.put(
|
|
|
- "startTime",
|
|
|
- longTurnData(getTimestampByOffsetDay(0 - calendar.get(Calendar.DAY_OF_MONTH) + 1)));
|
|
|
- hashMap.put(
|
|
|
- "endTime",
|
|
|
- longTurnData( getTimestampByOffsetDay(calendar
|
|
|
- .getMaximum(Calendar.DAY_OF_MONTH)
|
|
|
- - calendar.get(Calendar.DAY_OF_MONTH))));
|
|
|
- }
|
|
|
- return hashMap;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 时间格式转化
|
|
|
- * @author ludashi
|
|
|
- * @date 2021/6/3 13:37
|
|
|
- * @param l 时间毫秒值
|
|
|
- * @return String
|
|
|
- */
|
|
|
- private static String longTurnData(Long l) {
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Date date = new Date(l);
|
|
|
- return simpleDateFormat.format(date);
|
|
|
- }
|
|
|
+ calStart.set(calStart.get(Calendar.YEAR), calStart.get(Calendar.MONDAY), calStart.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
|
|
+ calStart.set(Calendar.DAY_OF_MONTH, calStart.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
|
|
|
- /**
|
|
|
- * 时间定义
|
|
|
- * @author ludashi
|
|
|
- * @date 2021/6/3 13:12
|
|
|
- * @param day
|
|
|
- * @return long
|
|
|
- */
|
|
|
- public long getTimestampByOffsetDay(int day){
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, day);
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
- return calendar.getTimeInMillis();
|
|
|
+ calEnd.set(calEnd.get(Calendar.YEAR), calEnd.get(Calendar.MONDAY), calEnd.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
|
|
|
+ calEnd.set(Calendar.DAY_OF_MONTH, calEnd.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ calEnd.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+ }
|
|
|
+ String beginTime = startFormat.format(calStart.getTime());
|
|
|
+ String endTime = endFormat.format(calEnd.getTime());
|
|
|
+ map.put("beginDate",beginTime);
|
|
|
+ map.put("endDate",endTime);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -406,6 +375,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取进三个月的
|
|
|
* @author lu
|