|
@@ -19,6 +19,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.DayOfWeek;
|
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
@@ -168,28 +169,31 @@ public class ReportServiceImpl implements ReportService {
|
|
|
PackageCodeTypeRes res = new PackageCodeTypeRes();
|
|
|
int before=0;//往期
|
|
|
int present=0;//同期
|
|
|
+ //封装入参
|
|
|
+ Map<String,LocalDateTime> map=null;
|
|
|
+ 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"));
|
|
|
+ if(1==reportReq.getValue()){//周
|
|
|
+ map=getBeforeWeekTimes();
|
|
|
+ }
|
|
|
+ if(2==reportReq.getValue()){//月
|
|
|
+ map=getBeforeMonthTime();
|
|
|
+ }
|
|
|
+ }
|
|
|
//1.生成码数量
|
|
|
- getGenerateCodeNum(reportReq, res,present,before);
|
|
|
+ getGenerateCodeNum(reportReq, res,present,before,map);
|
|
|
//2.下载码数量
|
|
|
- getLoadCodeNum(reportReq, res,present,before);
|
|
|
+ getLoadCodeNum(reportReq, res,present,before,map);
|
|
|
//3.激活码数量
|
|
|
- getActivateCodeNum(reportReq, res,present,before);
|
|
|
+ getActivateCodeNum(reportReq, res,present,before,map);
|
|
|
//返回参数
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- private void getGenerateCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before) {
|
|
|
- //封装入参
|
|
|
- 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"));
|
|
|
- }
|
|
|
- LocalDateTime beforeTime=null;
|
|
|
- LocalDateTime presentTime=null;//todayOfLastWeek
|
|
|
- List<ListPackageCodeVo> createList = reportServiceMapper.queryPackageCodeNum(reportReq);
|
|
|
+ private void getGenerateCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before,Map<String,LocalDateTime> map) {
|
|
|
+ List<ListPackageCodeVo> createList = reportServiceMapper.queryPackageCodeNum(reportReq,map.get("beginDate"), map.get("endDate"));
|
|
|
/**
|
|
|
* 处理逻辑
|
|
|
* 1.取出本周的数据集
|
|
@@ -217,8 +221,8 @@ public class ReportServiceImpl implements ReportService {
|
|
|
res.setCreatePercent(result);//获取同比增长率
|
|
|
}
|
|
|
}
|
|
|
- private void getLoadCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before) {
|
|
|
- List<ListPackageCodeVo> loadList = reportServiceMapper.queryLoadPackageCodeNum(reportReq);
|
|
|
+ private void getLoadCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before,Map<String,LocalDateTime> map) {
|
|
|
+ List<ListPackageCodeVo> loadList = reportServiceMapper.queryLoadPackageCodeNum(reportReq,map.get("beginDate"), map.get("endDate"));
|
|
|
for (int i = 0; i < loadList.size(); i++) {
|
|
|
if("0".equals(loadList.get(i).getPercent())) {
|
|
|
if (QrTypeEnum.CARTON.getCode().equals(loadList.get(i).getQrType())) {
|
|
@@ -240,8 +244,8 @@ public class ReportServiceImpl implements ReportService {
|
|
|
res.setLoadPercent(result);//获取同比增长率
|
|
|
}
|
|
|
}
|
|
|
- private void getActivateCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before) {
|
|
|
- List<ListPackageCodeVo> activateList = reportServiceMapper.queryActivateCodeNum(reportReq);
|
|
|
+ private void getActivateCodeNum(ReportReq reportReq, PackageCodeTypeRes res, int present, int before,Map<String,LocalDateTime> map) {
|
|
|
+ List<ListPackageCodeVo> activateList = reportServiceMapper.queryActivateCodeNum(reportReq,map.get("beginDate"), map.get("endDate"));
|
|
|
for (int i = 0; i < activateList.size(); i++) {
|
|
|
if("0".equals(activateList.get(i).getPercent())) {
|
|
|
if (QrTypeEnum.CARTON.getCode().equals(activateList.get(i).getQrType())) {
|
|
@@ -263,9 +267,6 @@ public class ReportServiceImpl implements ReportService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* @param preNum 同期数
|
|
|
* @param sufNum 往期数
|
|
@@ -342,7 +343,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* 获取上月月初和月末日期
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,LocalDateTime> getBeforeTime(){
|
|
|
+ public Map<String,LocalDateTime> getBeforeMonthTime(){
|
|
|
Map<String,LocalDateTime> map=new HashMap<String,LocalDateTime>();
|
|
|
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
String localTime = fmt.format(LocalDateTime.now());
|
|
@@ -350,8 +351,23 @@ public class ReportServiceImpl implements ReportService {
|
|
|
LocalDateTime localDateTime = date2.minusMonths(1);
|
|
|
LocalDateTime with = localDateTime.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
LocalDateTime with2 = localDateTime.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
- map.put("startMonth",localDateTime.with(TemporalAdjusters.lastDayOfMonth()));
|
|
|
- map.put("endMonth",localDateTime.with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
+ map.put("beginDate",localDateTime.with(TemporalAdjusters.lastDayOfMonth()));
|
|
|
+ map.put("endDate",localDateTime.with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取上周周一和周末的数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,LocalDateTime> getBeforeWeekTimes(){
|
|
|
+ Map<String,LocalDateTime> map=new HashMap<String,LocalDateTime>();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ LocalDateTime todayOfLastWeek = now.minusDays(7);
|
|
|
+ LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+ LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+ map.put("beginDate",monday);
|
|
|
+ map.put("endDate",sunday);
|
|
|
return map;
|
|
|
}
|
|
|
|