Переглянути джерело

小时警情和月份警情添加开始和结束时间

yq 3 роки тому
батько
коміт
aa990a85ae

+ 6 - 4
mhfire-controller/src/main/java/com/bizmatics/mhfire/controller/web/AlertControllerWeb.java

@@ -31,8 +31,9 @@ public class AlertControllerWeb {
      * @return
      */
     @GetMapping("/alertStatisticsByHouse")
-    public ApiResult<Map<String, List<AlertStatisticsVO>>> getAlertStatisticsByHouse() {
-        return ApiResult.success(alertService.getAlertStatisticsByHouse());
+    public ApiResult<Map<String, List<AlertStatisticsVO>>> getAlertStatisticsByHouse(@RequestParam Date startTime,
+                                                                                     @RequestParam Date endTime) {
+        return ApiResult.success(alertService.getAlertStatisticsByHouse(startTime,endTime));
     }
 
 
@@ -42,8 +43,9 @@ public class AlertControllerWeb {
      * @return
      */
     @GetMapping("/alertStatisticsByMonth")
-    public ApiResult<Map<String, List<AlertStatisticsVO>>> getAlertStatisticsByMonth() {
-        return ApiResult.success(alertService.getAlertStatisticsByMonth());
+    public ApiResult<Map<String, List<AlertStatisticsVO>>> getAlertStatisticsByMonth(@RequestParam Date startTime,
+                                                                                     @RequestParam Date endTime) {
+        return ApiResult.success(alertService.getAlertStatisticsByMonth(startTime,endTime));
     }
 
 

+ 4 - 4
mhfire-service/src/main/java/com/bizmatics/mhfire/service/AlertService.java

@@ -18,18 +18,18 @@ public interface AlertService  extends CrudService<Alert> {
 
 
     /**
-     * 查询当天24小时警情
+     * 按小时统计警情
      * @return
      */
-    Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse();
+    Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse(Date startTime,Date endTime);
 
 
 
     /**
-     * 查询每年12个月警情
+     * 按月份统计警情
      * @return
      */
-    Map<String, List<AlertStatisticsVO>> getAlertStatisticsByMonth();
+    Map<String, List<AlertStatisticsVO>> getAlertStatisticsByMonth(Date startTime,Date endTime);
 
 
     /**

+ 4 - 9
mhfire-service/src/main/java/com/bizmatics/mhfire/service/impl/AlertServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.bizmatics.common.core.bean.CommonPage;
-import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.common.core.util.StringUtils;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.mhfire.model.Alert;
@@ -28,10 +27,8 @@ public class AlertServiceImpl extends AbstractCrudService<AlertMapper, Alert> im
     private static final String[] ALERT_TYPE = {"火灾","社会救助","抢险救援"};
 
     @Override
-    public Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse() {
-        Date date = new Date();
-        Date startTime = DateUtils.getDayStartTime(date);
-        Map<String, List<AlertStatisticsVO>> typeMap = enhanceList(baseMapper.getCountByHorse(startTime, date));
+    public Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse(Date startTime,Date endTime) {
+        Map<String, List<AlertStatisticsVO>> typeMap = enhanceList(baseMapper.getCountByHorse(startTime, endTime));
         perfect(typeMap,24);
         return typeMap;
     }
@@ -75,10 +72,8 @@ public class AlertServiceImpl extends AbstractCrudService<AlertMapper, Alert> im
 
 
     @Override
-    public Map<String, List<AlertStatisticsVO>> getAlertStatisticsByMonth() {
-        Date date = new Date();
-        Date startTime = DateUtils.getDayStartTime(date);
-        Map<String, List<AlertStatisticsVO>> typeMap = enhanceList(baseMapper.getCountByMonth(startTime, date));
+    public Map<String, List<AlertStatisticsVO>> getAlertStatisticsByMonth(Date startTime,Date endTime) {
+        Map<String, List<AlertStatisticsVO>> typeMap = enhanceList(baseMapper.getCountByMonth(startTime, endTime));
         perfect(typeMap,12);
         return typeMap;
     }