diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsIndexStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsIndexStatisticsController.java index 0f787e7..73a5094 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsIndexStatisticsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsIndexStatisticsController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -157,6 +158,10 @@ public class EhsIndexStatisticsController extends BaseController { List> list = ehsIndexStatisticsService.getHiddenDangerTypeMapList(); return AjaxResult.success(list); } + + public static void main(String[] args) { + System.out.println(DateUtil.year(new Date())); + } /** * 隐患数据统计分析 */ @@ -165,6 +170,9 @@ public class EhsIndexStatisticsController extends BaseController { public AjaxResult getHiddenDangerDataMapList(String year) { JSONArray row = new JSONArray(); + if(StringUtils.isEmpty(year)){ + year = DateUtil.year(new Date())+""; + } List> list = ehsIndexStatisticsService.getHiddenDangerDataMapList(year); if(StringUtils.isNotEmpty(list)){ LinkedHashMap>> nameList = list.stream().collect(Collectors.groupingBy(e -> e.get("name"), LinkedHashMap::new, Collectors.toList())); diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 6411445..09bb31a 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://120.46.159.203:13306/ehs-tanghe?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false + url: jdbc:mysql://192.168.10.54:33306/ehs-tanghe?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false username: root - password: a8EYUSoT8wHbuRkX + password: d86834af4bb81bce # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml index 9ac10e3..3d0ed35 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml @@ -266,61 +266,20 @@ SELECT d.dict_value FROM ( + WITH RECURSIVE months AS ( SELECT - DATE_FORMAT( date_add( CONCAT( #{yearStr}, '-01-01' ), INTERVAL ROW MONTH ), '%Y-%m' ) date_time - FROM - ( + CONCAT( #{yearStr}, '-01-01' ) AS month_date UNION ALL SELECT - @ROW := @ROW + 1 AS ROW + DATE_ADD( month_date, INTERVAL 1 MONTH ) AS month_date FROM - ( - SELECT - 0 UNION ALL - SELECT - 1 UNION ALL - SELECT - 2 UNION ALL - SELECT - 3 UNION ALL - SELECT - 4 UNION ALL - SELECT - 5 UNION ALL - SELECT - 6 UNION ALL - SELECT - 7 UNION ALL - SELECT - 8 UNION ALL - SELECT - 9 - ) t, - ( - SELECT - 0 UNION ALL - SELECT - 1 UNION ALL - SELECT - 2 UNION ALL - SELECT - 3 UNION ALL - SELECT - 4 UNION ALL - SELECT - 5 UNION ALL - SELECT - 6 UNION ALL - SELECT - 7 UNION ALL - SELECT - 8 UNION ALL - SELECT - 9 - ) t2, - ( SELECT @ROW :=- 1 ) r - ) se + months WHERE - DATE_FORMAT( date_add( CONCAT( #{yearStr}, '-01-01' ), INTERVAL ROW MONTH ), '%Y-%m' ) <= DATE_FORMAT( CONCAT( #{yearStr}, '-12-01' ), '%Y-%m' )) s, + month_date < CONCAT( #{yearStr}, '-12-01' ) + ) SELECT + DATE_FORMAT( month_date, '%Y-%m' ) AS date_time + FROM + months + ) s, sys_dict_data d WHERE d.dict_type = 'hidden_danger_grade'