From be9df5a5bd6af84324e98c37095fe1124645c5e3 Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Mon, 15 Jul 2024 11:14:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E5=88=86?= =?UTF-8?q?=E6=9E=90=E6=9F=A5=E8=AF=A2=E6=8C=87=E5=AE=9A=E6=9C=88=E4=BB=BD?= =?UTF-8?q?=E9=9A=90=E6=82=A3=E6=95=B0=E9=87=8F=E5=90=8E=E7=AB=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ehs/EhsIndexStatisticsController.java | 67 +++++++++++++++---- .../mapper/EhsIndexStatisticsMapper.java | 13 ++-- .../service/EhsIndexStatisticsService.java | 13 ++-- .../impl/EhsIndexStatisticsServiceImpl.java | 25 +++---- .../mapper/ehs/EhsIndexStatisticsMapper.xml | 14 ++-- 5 files changed, 92 insertions(+), 40 deletions(-) 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 73a5094..96796b2 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 @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.ehs; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; @@ -85,9 +86,16 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("隐患情况---按行政区域统计") @GetMapping("/getHiddenDangerSituationList") - public AjaxResult getHiddenDangerSituationList() + public AjaxResult getHiddenDangerSituationList(String targetTime) { - List list = ehsIndexStatisticsService.getHiddenDangerSituationList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List list = ehsIndexStatisticsService.getHiddenDangerSituationList(dateTime); return AjaxResult.success(list); } @@ -113,9 +121,16 @@ public class EhsIndexStatisticsController extends BaseController { } @ApiOperation("部门上报隐患排名") @GetMapping("/getHiddenDangerRankVoByDeptIdList") - public AjaxResult getHiddenDangerRankVoByDeptIdList() + public AjaxResult getHiddenDangerRankVoByDeptIdList(String targetTime) { - List list = ehsIndexStatisticsService.getHiddenDangerRankVoByDeptIdList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List list = ehsIndexStatisticsService.getHiddenDangerRankVoByDeptIdList(dateTime); return AjaxResult.success(list); } /** @@ -123,9 +138,16 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("行业领域统计数量") @GetMapping("/getEnterpriseMapList") - public AjaxResult getEnterpriseMapList() + public AjaxResult getEnterpriseMapList(String targetTime) { - List> list = ehsIndexStatisticsService.getEnterpriseMapList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List> list = ehsIndexStatisticsService.getEnterpriseMapList(dateTime); return AjaxResult.success(list); } /** @@ -133,9 +155,16 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("经济类型统计数量") @GetMapping("/geteconomicTypeMapList") - public AjaxResult geteconomicTypeMapList() + public AjaxResult geteconomicTypeMapList(String targetTime) { - List> list = ehsIndexStatisticsService.geteconomicTypeMapList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List> list = ehsIndexStatisticsService.geteconomicTypeMapList(dateTime); return AjaxResult.success(list); } /** @@ -143,9 +172,16 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("企业规模统计数量") @GetMapping("/getenterpriseScaleMapList") - public AjaxResult getenterpriseScaleMapList() + public AjaxResult getenterpriseScaleMapList(String targetTime) { - List> list = ehsIndexStatisticsService.getenterpriseScaleMapList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List> list = ehsIndexStatisticsService.getenterpriseScaleMapList(dateTime); return AjaxResult.success(list); } /** @@ -194,9 +230,16 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("隐患整改进度分析统计") @GetMapping("/getHiddenDangerStatusMapList") - public AjaxResult getHiddenDangerStatusMapList() + public AjaxResult getHiddenDangerStatusMapList(String targetTime) { - List> list = ehsIndexStatisticsService.getHiddenDangerStatusMapList(); + DateTime dateTime = null; + if (targetTime != null) { + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if (targetTime == null) { + dateTime = DateTime.now(); + } + List> list = ehsIndexStatisticsService.getHiddenDangerStatusMapList(dateTime); return AjaxResult.success(list); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/mapper/EhsIndexStatisticsMapper.java b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/mapper/EhsIndexStatisticsMapper.java index ebf38d8..4bb4814 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/mapper/EhsIndexStatisticsMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/mapper/EhsIndexStatisticsMapper.java @@ -6,6 +6,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerStatisticsVo; import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; import java.util.Map; @@ -17,14 +18,14 @@ public interface EhsIndexStatisticsMapper { List getHiddenDangerVoList(@Param("vo") HiddenDangerVo vo); - List getHiddenDangerSituationList(); + List getHiddenDangerSituationList(@Param("targetTime") Date targetTime); List getHiddenDangerSituationByEnterpriseNameList(); List getHiddenDangerRankVoList(); - List getHiddenDangerRankVoByDeptIdList(); - List> getEnterpriseMapList(@Param("deptId") Long deptId); - List> geteconomicTypeMapList(@Param("deptId") Long deptId); - List> getenterpriseScaleMapList(@Param("deptId") Long deptId); + List getHiddenDangerRankVoByDeptIdList(@Param("targetTime") Date targetTime); + List> getEnterpriseMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId); + List> geteconomicTypeMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId); + List> getenterpriseScaleMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId); List> getHiddenDangerTypeMapList(@Param("deptId") Long deptId); - List> getHiddenDangerStatusMapList(@Param("deptId") Long deptId); + List> getHiddenDangerStatusMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId); List> getHiddenDangerDataMapList(@Param("yearStr") String yearStr,@Param("deptId") Long deptId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/EhsIndexStatisticsService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/EhsIndexStatisticsService.java index 1620c4f..55bd195 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/EhsIndexStatisticsService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/EhsIndexStatisticsService.java @@ -6,6 +6,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerStatisticsVo; import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; import java.util.Map; @@ -20,7 +21,7 @@ public interface EhsIndexStatisticsService { /** * 按行政区域统计 */ - List getHiddenDangerSituationList(); + List getHiddenDangerSituationList(Date targetTime); /** * 按公司统计 */ @@ -29,11 +30,11 @@ public interface EhsIndexStatisticsService { * 上报隐患排名 */ List getHiddenDangerRankVoList(); - List getHiddenDangerRankVoByDeptIdList(); - List> getEnterpriseMapList(); - List> geteconomicTypeMapList(); - List> getenterpriseScaleMapList(); + List getHiddenDangerRankVoByDeptIdList(Date targetTime); + List> getEnterpriseMapList(Date targetTime); + List> geteconomicTypeMapList(Date targetTime); + List> getenterpriseScaleMapList(Date targetTime); List> getHiddenDangerTypeMapList(); List> getHiddenDangerDataMapList(String yearStr); - List> getHiddenDangerStatusMapList( ); + List> getHiddenDangerStatusMapList(Date targetTime); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/impl/EhsIndexStatisticsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/impl/EhsIndexStatisticsServiceImpl.java index d313e88..51a7064 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/impl/EhsIndexStatisticsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsIndexStatistics/service/impl/EhsIndexStatisticsServiceImpl.java @@ -14,6 +14,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -86,8 +87,8 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService } @Override - public List getHiddenDangerSituationList() { - return mapper.getHiddenDangerSituationList(); + public List getHiddenDangerSituationList(Date targetTime) { + return mapper.getHiddenDangerSituationList(targetTime); } @Override public List getHiddenDangerSituationByEnterpriseNameList() { @@ -99,11 +100,11 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService return mapper.getHiddenDangerRankVoList(); } @Override - public List getHiddenDangerRankVoByDeptIdList() { - return mapper.getHiddenDangerRankVoByDeptIdList(); + public List getHiddenDangerRankVoByDeptIdList(Date targetTime) { + return mapper.getHiddenDangerRankVoByDeptIdList(targetTime); } @Override - public List> getEnterpriseMapList() { + public List> getEnterpriseMapList(Date targetTime) { Long deptId = null; // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 SysUser currentUser = SecurityUtils.getLoginUser().getUser(); @@ -114,10 +115,10 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService deptParentId.longValue() != 0) { deptId = currentUser.getDept().getDeptId().longValue(); } - return mapper.getEnterpriseMapList(deptId); + return mapper.getEnterpriseMapList(targetTime, deptId); } @Override - public List> geteconomicTypeMapList() { + public List> geteconomicTypeMapList(Date targetTime) { Long deptId = null; // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 SysUser currentUser = SecurityUtils.getLoginUser().getUser(); @@ -128,10 +129,10 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService deptParentId.longValue() != 0) { deptId = currentUser.getDept().getDeptId().longValue(); } - return mapper.geteconomicTypeMapList(deptId); + return mapper.geteconomicTypeMapList(targetTime, deptId); } @Override - public List> getenterpriseScaleMapList() { + public List> getenterpriseScaleMapList(Date targetTime) { Long deptId = null; // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 SysUser currentUser = SecurityUtils.getLoginUser().getUser(); @@ -142,7 +143,7 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService deptParentId.longValue() != 0) { deptId = currentUser.getDept().getDeptId().longValue(); } - return mapper.getenterpriseScaleMapList(deptId); + return mapper.getenterpriseScaleMapList(targetTime, deptId); } @Override public List> getHiddenDangerTypeMapList() { @@ -174,7 +175,7 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService } @Override - public List> getHiddenDangerStatusMapList() { + public List> getHiddenDangerStatusMapList(Date targetTime) { Long deptId = null; // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 SysUser currentUser = SecurityUtils.getLoginUser().getUser(); @@ -185,6 +186,6 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService deptParentId.longValue() != 0) { deptId = currentUser.getDept().getDeptId().longValue(); } - return mapper.getHiddenDangerStatusMapList(deptId); + return mapper.getHiddenDangerStatusMapList(targetTime, deptId); } } diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml index 3d0ed35..add17df 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml @@ -90,9 +90,11 @@ select c.dict_label 'name',c.dict_value dept_id,ifnull(a.thisUnitNum,0) thisUnit from sys_dict_data c left join( SELECT r.area_id , - (select count(1) from ehs_enterprise e where e.area_id = d.dict_value and e.create_time>= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' )) thisUnitNum, - (select count(1) from ehs_enterprise e where e.area_id = d.dict_value) totalUnitNum, - sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ) 'thisReportNum', +-- (select count(1) from ehs_enterprise e where e.area_id = d.dict_value and e.create_time>= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' )) thisUnitNum, + (SELECT count(1) FROM ehs_enterprise e WHERE e.area_id = d.dict_value AND e.create_time BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59')) thisUnitNum, + (select count(1) from ehs_enterprise e where e.area_id = d.dict_value) totalUnitNum, +-- sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ) 'thisReportNum', + sum( CASE WHEN r.hidden_danger_id IS NOT NULL AND r.check_time BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59') THEN r.hd_count ELSE 0 END ) 'thisReportNum', sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ) 'totalReportNum', sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN r.hd_count ELSE 0 END ) 'thisHaveNum', sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END ) 'totalHaveNum', @@ -164,7 +166,7 @@ SELECT FROM ehs_hidden_danger WHERE - DATE_FORMAT( NOW(), '%Y-%m' ) = DATE_FORMAT( check_time, '%Y-%m' )) r ON r.dept_id = d.dept_id + DATE_FORMAT( #{targetTime}, '%Y-%m' ) = DATE_FORMAT( check_time, '%Y-%m' )) r ON r.dept_id = d.dept_id GROUP BY d.dept_id, d.dept_name @@ -183,6 +185,7 @@ SELECT LEFT JOIN sys_dict_data d ON e.enterprise_type = d.dict_value AND d.dict_type = 'enterprise_type' + AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m') and dept_id = #{deptId} GROUP BY @@ -199,6 +202,7 @@ SELECT LEFT JOIN sys_dict_data d ON e.economic_type = d.dict_value AND d.dict_type = 'economic_type' + AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m') and dept_id = #{deptId} GROUP BY @@ -215,6 +219,7 @@ SELECT LEFT JOIN sys_dict_data d ON e.enterprise_scale = d.dict_value AND d.dict_type = 'enterprise_scale' + AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m') and dept_id = #{deptId} GROUP BY @@ -246,6 +251,7 @@ SELECT LEFT JOIN sys_dict_data d ON e.status = d.dict_value AND d.dict_type = 'hidden_danger_status' + AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m') and dept_id = #{deptId} GROUP BY