|
@@ -19,9 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@Transactional
|
|
@Transactional
|
|
@@ -123,4 +121,29 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|
// 添加扫码行为记录
|
|
// 添加扫码行为记录
|
|
return statisticsMapper.insert(new Statistics(bo,equipment));
|
|
return statisticsMapper.insert(new Statistics(bo,equipment));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Integer> getTimeDis(String option) {
|
|
|
|
+ Map<String, Integer> map = new LinkedHashMap<>();
|
|
|
|
+ if (option.equals("day")){
|
|
|
|
+ List<String> days = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<30;i++)
|
|
|
|
+ days.add(LocalDateTime.now(ZoneId.of("Asia/Shanghai")).plusDays(-i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
|
+ for (String day : days)
|
|
|
|
+ map.put(day,statisticsMapper.selectTimeDisByDay(day));
|
|
|
|
+ } else if (option.equals("year")){
|
|
|
|
+ List<String> years = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<12;i++)
|
|
|
|
+ years.add(LocalDateTime.now(ZoneId.of("Asia/Shanghai")).plusYears(-i).format(DateTimeFormatter.ofPattern("yyyy")));
|
|
|
|
+ for (String year : years)
|
|
|
|
+ map.put(year,statisticsMapper.selectTimeDisByYear(year));
|
|
|
|
+ } else {
|
|
|
|
+ List<String> months = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<12;i++)
|
|
|
|
+ months.add(LocalDateTime.now(ZoneId.of("Asia/Shanghai")).plusMonths(-i).format(DateTimeFormatter.ofPattern("yyyy-MM")));
|
|
|
|
+ for (String month : months)
|
|
|
|
+ map.put(month,statisticsMapper.selectTimeDisByMonth(month));
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
}
|
|
}
|