Browse Source

事件趋势

lyq 1 year ago
parent
commit
d0532b8171

+ 8 - 0
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/controller/CenterEventReportController.java

@@ -115,6 +115,14 @@ public class CenterEventReportController extends BaseController {
     @ApiOperation("事件趋势")
     @PostMapping("/getEventTrend")
     public R getEventTrend(@RequestBody VisuForestCloudMapVO visuForestCloudMapVO) {
+        String format = "%Y-%m";
+        LocalDate localDate = LocalDate.now();
+        if (visuForestCloudMapVO.getYearMonth().contains(String.valueOf(localDate.getYear()))) {
+            format = "%Y";
+        } else if (visuForestCloudMapVO.getYearMonth().contains(localDate.format(DateTimeFormatter.ofPattern(YYYY_MM_DD)))) {
+            format = "%Y-%m-%d";
+        }
+        visuForestCloudMapVO.setDay(format);
         List<Map<String, Object>> result = centerEventReportService.getEventCountGroupByYearMonth(visuForestCloudMapVO);
         return R.ok(completionDate(result, visuForestCloudMapVO.getYearMonth(), "day", "daycount"));
     }

+ 2 - 2
src/main/resources/mapper/centereventteventcatalogue/CenterEventReportMapper.xml

@@ -290,7 +290,7 @@
     <select id="getEventCountGroupByYearMonth" parameterType="VisuForestCloudMapVO"
             resultType="java.util.LinkedHashMap">
         select day,count(*) daycount from (
-        select DATE_FORMAT(a.create_time,'%Y-%m') day
+        select DATE_FORMAT(a.create_time,#{day}) day
         from centerevent_t_eventcatalogue a
         left join centerevent_t_dept_event d on d.event_code = a.event_code and d.event_status_value !=
         'forest_event_status_3'
@@ -298,7 +298,7 @@
         where a.event_status_value in ('forest_event_status_2','forest_event_status_5','forest_event_status_6')
         and data_status = '0'
         <if test="yearMonth != null and yearMonth.size > 0">
-            and DATE_FORMAT(a.create_time,'%Y-%m') in
+            and DATE_FORMAT(a.create_time,#{day}) in
             <foreach item="item" collection="yearMonth" open="(" separator="," close=")">
                 #{item}
             </foreach>