|
@@ -234,12 +234,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
reportReq.setBeginTime(reportReq.getBeginTime());
|
|
|
reportReq.setEndTime(reportReq.getEndTime());
|
|
|
}
|
|
|
- if("1".equals(reportReq.getValue().toString())){//周
|
|
|
- map=getBeforeWeekTimes();
|
|
|
- }
|
|
|
- if("2".equals(reportReq.getValue().toString())){//月
|
|
|
- map=getBeforeMonthTime();
|
|
|
- }
|
|
|
+ map=getBeforeWeekTime(reportReq.getValue().toString());//1周 2月
|
|
|
return map;
|
|
|
}
|
|
|
/**
|
|
@@ -404,32 +399,25 @@ public class ReportServiceImpl implements ReportService {
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 获取上月月初和月末日期
|
|
|
- * @return
|
|
|
- */
|
|
|
- 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());
|
|
|
- LocalDateTime date2 = LocalDateTime.parse(localTime, fmt);
|
|
|
- LocalDateTime localDateTime = date2.minusMonths(1);
|
|
|
- map.put("beginDate",localDateTime.with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
- map.put("endDate",localDateTime.with(TemporalAdjusters.lastDayOfMonth()));
|
|
|
- return map;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取上周周一和周末的数据
|
|
|
+ * 获取往期时间(1-周,2-月)
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,LocalDateTime> getBeforeWeekTimes(){
|
|
|
+ public Map<String,LocalDateTime> getBeforeWeekTime(String value){
|
|
|
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);
|
|
|
+ if("1".equals(value)){
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ LocalDateTime todayOfLastWeek = now.minusDays(7);
|
|
|
+ map.put("beginDate",todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1));
|
|
|
+ map.put("endDate",todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1));
|
|
|
+ }else{
|
|
|
+ DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime date2 = LocalDateTime.parse(fmt.format(LocalDateTime.now()), fmt);
|
|
|
+ LocalDateTime localDateTime = date2.minusMonths(1);
|
|
|
+ map.put("beginDate",localDateTime.with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
+ map.put("endDate",localDateTime.with(TemporalAdjusters.lastDayOfMonth()));
|
|
|
+ }
|
|
|
return map;
|
|
|
}
|
|
|
|