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 c9f9f21..2e6e5b4 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 @@ -90,6 +90,7 @@ public class EhsIndexStatisticsController extends BaseController { { DateTime dateTime = null; if (targetTime != null) { + targetTime = targetTime + "-01 00:00:00"; dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); } if (targetTime == null) { @@ -104,9 +105,17 @@ public class EhsIndexStatisticsController extends BaseController { */ @ApiOperation("按地址统计") @GetMapping("/getHiddenDangerSituationByEnterpriseNameList") - public AjaxResult getHiddenDangerSituationByEnterpriseNameList() + public AjaxResult getHiddenDangerSituationByEnterpriseNameList(String targetTime) { - List list = ehsIndexStatisticsService.getHiddenDangerSituationByEnterpriseNameList(); + DateTime dateTime = null; + if (targetTime != null) { + targetTime = targetTime + "-01 00:00:00"; + dateTime = DateUtil.parse(targetTime, "yyyy-MM-dd HH:mm:ss"); + } + if(targetTime == null) { + dateTime = DateTime.now(); + } + List list = ehsIndexStatisticsService.getHiddenDangerSituationByEnterpriseNameList(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 4bb4814..7dd3476 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 @@ -19,7 +19,7 @@ public interface EhsIndexStatisticsMapper { List getHiddenDangerVoList(@Param("vo") HiddenDangerVo vo); List getHiddenDangerSituationList(@Param("targetTime") Date targetTime); - List getHiddenDangerSituationByEnterpriseNameList(); + List getHiddenDangerSituationByEnterpriseNameList(@Param("targetTime") Date targetTime); List getHiddenDangerRankVoList(); List getHiddenDangerRankVoByDeptIdList(@Param("targetTime") Date targetTime); List> getEnterpriseMapList(@Param("targetTime") Date targetTime, @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 55bd195..15cbcfe 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 @@ -25,7 +25,7 @@ public interface EhsIndexStatisticsService { /** * 按公司统计 */ - List getHiddenDangerSituationByEnterpriseNameList(); + List getHiddenDangerSituationByEnterpriseNameList(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 51a7064..4557518 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 @@ -91,8 +91,8 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService return mapper.getHiddenDangerSituationList(targetTime); } @Override - public List getHiddenDangerSituationByEnterpriseNameList() { - return mapper.getHiddenDangerSituationByEnterpriseNameList(); + public List getHiddenDangerSituationByEnterpriseNameList(Date targetTime) { + return mapper.getHiddenDangerSituationByEnterpriseNameList(targetTime); } @Override diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml index a2daadf..e858b28 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsIndexStatisticsMapper.xml @@ -90,18 +90,16 @@ 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 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', - 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 ) 'thisNotNum', - sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status != 10 THEN r.hd_count ELSE 0 END ) 'totalNotNum', - CONCAT(round(ifnull(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 )/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 ),0)*100,2),'%') 'thisRate', - CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ),0)*100,2),'%') 'totalRate' + 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 BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59') 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', + 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') and r.status != 10 THEN r.hd_count ELSE 0 END ) 'thisNotNum', + sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status != 10 THEN r.hd_count ELSE 0 END ) 'totalNotNum', + CONCAT(round(ifnull(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') and r.status = 10 THEN r.hd_count ELSE 0 END )/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 ),0)*100,2),'%') 'thisRate', + CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ),0)*100,2),'%') 'totalRate' FROM sys_dict_data d LEFT JOIN ehs_hidden_danger r ON r.area_id = d.dict_value @@ -116,13 +114,13 @@ SELECT resultType="com.ruoyi.ehsIndexStatistics.vo.HiddenDangerStatisticsVo"> SELECT d.dept_name 'name', - 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.check_time BETWEEN DATE_FORMAT( #{targetTime}, '%Y-%m-01 00:00:00' ) AND CONCAT(LAST_DAY(#{targetTime}), ' 23:59:59') 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', - 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 ) 'thisNotNum', + 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') AND r.STATUS != 10 THEN r.hd_count ELSE 0 END) 'thisNotNum', sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status != 10 THEN r.hd_count ELSE 0 END ) 'totalNotNum', - CONCAT(round(ifnull(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 )/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 ),0)*100,2),'%') 'thisRate', + CONCAT(round(ifnull(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') and r.status = 10 THEN r.hd_count ELSE 0 END )/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 ),0)*100,2),'%') 'thisRate', CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ),0)*100,2),'%') 'totalRate' FROM sys_dept d left join ehs_hidden_danger r on r.dept_id = d.dept_id