数据统计分析查询指定月份隐患数量后端接口开发

main
15036302109 4 months ago
parent 27f63166e4
commit be9df5a5bd

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.ehs; package com.ruoyi.web.controller.ehs;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
@ -85,9 +86,16 @@ public class EhsIndexStatisticsController extends BaseController {
*/ */
@ApiOperation("隐患情况---按行政区域统计") @ApiOperation("隐患情况---按行政区域统计")
@GetMapping("/getHiddenDangerSituationList") @GetMapping("/getHiddenDangerSituationList")
public AjaxResult getHiddenDangerSituationList() public AjaxResult getHiddenDangerSituationList(String targetTime)
{ {
List<HiddenDangerStatisticsVo> 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<HiddenDangerStatisticsVo> list = ehsIndexStatisticsService.getHiddenDangerSituationList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
@ -113,9 +121,16 @@ public class EhsIndexStatisticsController extends BaseController {
} }
@ApiOperation("部门上报隐患排名") @ApiOperation("部门上报隐患排名")
@GetMapping("/getHiddenDangerRankVoByDeptIdList") @GetMapping("/getHiddenDangerRankVoByDeptIdList")
public AjaxResult getHiddenDangerRankVoByDeptIdList() public AjaxResult getHiddenDangerRankVoByDeptIdList(String targetTime)
{ {
List<HiddenDangerRankVo> 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<HiddenDangerRankVo> list = ehsIndexStatisticsService.getHiddenDangerRankVoByDeptIdList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
@ -123,9 +138,16 @@ public class EhsIndexStatisticsController extends BaseController {
*/ */
@ApiOperation("行业领域统计数量") @ApiOperation("行业领域统计数量")
@GetMapping("/getEnterpriseMapList") @GetMapping("/getEnterpriseMapList")
public AjaxResult getEnterpriseMapList() public AjaxResult getEnterpriseMapList(String targetTime)
{ {
List<Map<String,Object>> 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<Map<String,Object>> list = ehsIndexStatisticsService.getEnterpriseMapList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
@ -133,9 +155,16 @@ public class EhsIndexStatisticsController extends BaseController {
*/ */
@ApiOperation("经济类型统计数量") @ApiOperation("经济类型统计数量")
@GetMapping("/geteconomicTypeMapList") @GetMapping("/geteconomicTypeMapList")
public AjaxResult geteconomicTypeMapList() public AjaxResult geteconomicTypeMapList(String targetTime)
{ {
List<Map<String,Object>> 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<Map<String,Object>> list = ehsIndexStatisticsService.geteconomicTypeMapList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
@ -143,9 +172,16 @@ public class EhsIndexStatisticsController extends BaseController {
*/ */
@ApiOperation("企业规模统计数量") @ApiOperation("企业规模统计数量")
@GetMapping("/getenterpriseScaleMapList") @GetMapping("/getenterpriseScaleMapList")
public AjaxResult getenterpriseScaleMapList() public AjaxResult getenterpriseScaleMapList(String targetTime)
{ {
List<Map<String,Object>> 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<Map<String,Object>> list = ehsIndexStatisticsService.getenterpriseScaleMapList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/** /**
@ -194,9 +230,16 @@ public class EhsIndexStatisticsController extends BaseController {
*/ */
@ApiOperation("隐患整改进度分析统计") @ApiOperation("隐患整改进度分析统计")
@GetMapping("/getHiddenDangerStatusMapList") @GetMapping("/getHiddenDangerStatusMapList")
public AjaxResult getHiddenDangerStatusMapList() public AjaxResult getHiddenDangerStatusMapList(String targetTime)
{ {
List<Map<String,Object>> 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<Map<String,Object>> list = ehsIndexStatisticsService.getHiddenDangerStatusMapList(dateTime);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
} }

@ -6,6 +6,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerStatisticsVo;
import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo; import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -17,14 +18,14 @@ public interface EhsIndexStatisticsMapper {
List<HiddenDangerVo> getHiddenDangerVoList(@Param("vo") HiddenDangerVo vo); List<HiddenDangerVo> getHiddenDangerVoList(@Param("vo") HiddenDangerVo vo);
List<HiddenDangerStatisticsVo> getHiddenDangerSituationList(); List<HiddenDangerStatisticsVo> getHiddenDangerSituationList(@Param("targetTime") Date targetTime);
List<HiddenDangerStatisticsVo> getHiddenDangerSituationByEnterpriseNameList(); List<HiddenDangerStatisticsVo> getHiddenDangerSituationByEnterpriseNameList();
List<HiddenDangerRankVo> getHiddenDangerRankVoList(); List<HiddenDangerRankVo> getHiddenDangerRankVoList();
List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList(); List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList(@Param("targetTime") Date targetTime);
List<Map<String,Object>> getEnterpriseMapList(@Param("deptId") Long deptId); List<Map<String,Object>> getEnterpriseMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId);
List<Map<String,Object>> geteconomicTypeMapList(@Param("deptId") Long deptId); List<Map<String,Object>> geteconomicTypeMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId);
List<Map<String,Object>> getenterpriseScaleMapList(@Param("deptId") Long deptId); List<Map<String,Object>> getenterpriseScaleMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId);
List<Map<String,Object>> getHiddenDangerTypeMapList(@Param("deptId") Long deptId); List<Map<String,Object>> getHiddenDangerTypeMapList(@Param("deptId") Long deptId);
List<Map<String,Object>> getHiddenDangerStatusMapList(@Param("deptId") Long deptId); List<Map<String,Object>> getHiddenDangerStatusMapList(@Param("targetTime") Date targetTime, @Param("deptId") Long deptId);
List<Map<String,Object>> getHiddenDangerDataMapList(@Param("yearStr") String yearStr,@Param("deptId") Long deptId); List<Map<String,Object>> getHiddenDangerDataMapList(@Param("yearStr") String yearStr,@Param("deptId") Long deptId);
} }

@ -6,6 +6,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerStatisticsVo;
import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo; import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -20,7 +21,7 @@ public interface EhsIndexStatisticsService {
/** /**
* *
*/ */
List<HiddenDangerStatisticsVo> getHiddenDangerSituationList(); List<HiddenDangerStatisticsVo> getHiddenDangerSituationList(Date targetTime);
/** /**
* *
*/ */
@ -29,11 +30,11 @@ public interface EhsIndexStatisticsService {
* *
*/ */
List<HiddenDangerRankVo> getHiddenDangerRankVoList(); List<HiddenDangerRankVo> getHiddenDangerRankVoList();
List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList(); List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList(Date targetTime);
List<Map<String,Object>> getEnterpriseMapList(); List<Map<String,Object>> getEnterpriseMapList(Date targetTime);
List<Map<String,Object>> geteconomicTypeMapList(); List<Map<String,Object>> geteconomicTypeMapList(Date targetTime);
List<Map<String,Object>> getenterpriseScaleMapList(); List<Map<String,Object>> getenterpriseScaleMapList(Date targetTime);
List<Map<String,Object>> getHiddenDangerTypeMapList(); List<Map<String,Object>> getHiddenDangerTypeMapList();
List<Map<String,Object>> getHiddenDangerDataMapList(String yearStr); List<Map<String,Object>> getHiddenDangerDataMapList(String yearStr);
List<Map<String,Object>> getHiddenDangerStatusMapList( ); List<Map<String,Object>> getHiddenDangerStatusMapList(Date targetTime);
} }

@ -14,6 +14,7 @@ import com.ruoyi.ehsIndexStatistics.vo.HiddenDangerVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -86,8 +87,8 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
} }
@Override @Override
public List<HiddenDangerStatisticsVo> getHiddenDangerSituationList() { public List<HiddenDangerStatisticsVo> getHiddenDangerSituationList(Date targetTime) {
return mapper.getHiddenDangerSituationList(); return mapper.getHiddenDangerSituationList(targetTime);
} }
@Override @Override
public List<HiddenDangerStatisticsVo> getHiddenDangerSituationByEnterpriseNameList() { public List<HiddenDangerStatisticsVo> getHiddenDangerSituationByEnterpriseNameList() {
@ -99,11 +100,11 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
return mapper.getHiddenDangerRankVoList(); return mapper.getHiddenDangerRankVoList();
} }
@Override @Override
public List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList() { public List<HiddenDangerRankVo> getHiddenDangerRankVoByDeptIdList(Date targetTime) {
return mapper.getHiddenDangerRankVoByDeptIdList(); return mapper.getHiddenDangerRankVoByDeptIdList(targetTime);
} }
@Override @Override
public List<Map<String,Object>> getEnterpriseMapList() { public List<Map<String,Object>> getEnterpriseMapList(Date targetTime) {
Long deptId = null; Long deptId = null;
// 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文
SysUser currentUser = SecurityUtils.getLoginUser().getUser(); SysUser currentUser = SecurityUtils.getLoginUser().getUser();
@ -114,10 +115,10 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
deptParentId.longValue() != 0) { deptParentId.longValue() != 0) {
deptId = currentUser.getDept().getDeptId().longValue(); deptId = currentUser.getDept().getDeptId().longValue();
} }
return mapper.getEnterpriseMapList(deptId); return mapper.getEnterpriseMapList(targetTime, deptId);
} }
@Override @Override
public List<Map<String,Object>> geteconomicTypeMapList() { public List<Map<String,Object>> geteconomicTypeMapList(Date targetTime) {
Long deptId = null; Long deptId = null;
// 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文
SysUser currentUser = SecurityUtils.getLoginUser().getUser(); SysUser currentUser = SecurityUtils.getLoginUser().getUser();
@ -128,10 +129,10 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
deptParentId.longValue() != 0) { deptParentId.longValue() != 0) {
deptId = currentUser.getDept().getDeptId().longValue(); deptId = currentUser.getDept().getDeptId().longValue();
} }
return mapper.geteconomicTypeMapList(deptId); return mapper.geteconomicTypeMapList(targetTime, deptId);
} }
@Override @Override
public List<Map<String,Object>> getenterpriseScaleMapList() { public List<Map<String,Object>> getenterpriseScaleMapList(Date targetTime) {
Long deptId = null; Long deptId = null;
// 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文
SysUser currentUser = SecurityUtils.getLoginUser().getUser(); SysUser currentUser = SecurityUtils.getLoginUser().getUser();
@ -142,7 +143,7 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
deptParentId.longValue() != 0) { deptParentId.longValue() != 0) {
deptId = currentUser.getDept().getDeptId().longValue(); deptId = currentUser.getDept().getDeptId().longValue();
} }
return mapper.getenterpriseScaleMapList(deptId); return mapper.getenterpriseScaleMapList(targetTime, deptId);
} }
@Override @Override
public List<Map<String,Object>> getHiddenDangerTypeMapList() { public List<Map<String,Object>> getHiddenDangerTypeMapList() {
@ -174,7 +175,7 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
} }
@Override @Override
public List<Map<String,Object>> getHiddenDangerStatusMapList() { public List<Map<String,Object>> getHiddenDangerStatusMapList(Date targetTime) {
Long deptId = null; Long deptId = null;
// 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文 // 如果登录用户不是超级管理员,并且他的部门不是唐河县应急管理局(根节点),那么只能查询当前登录用户他的部门创建的公文
SysUser currentUser = SecurityUtils.getLoginUser().getUser(); SysUser currentUser = SecurityUtils.getLoginUser().getUser();
@ -185,6 +186,6 @@ public class EhsIndexStatisticsServiceImpl implements EhsIndexStatisticsService
deptParentId.longValue() != 0) { deptParentId.longValue() != 0) {
deptId = currentUser.getDept().getDeptId().longValue(); deptId = currentUser.getDept().getDeptId().longValue();
} }
return mapper.getHiddenDangerStatusMapList(deptId); return mapper.getHiddenDangerStatusMapList(targetTime, deptId);
} }
} }

@ -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( from sys_dict_data c left join(
SELECT SELECT
r.area_id , 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>= 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, (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,
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) 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 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 >= 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.status = 10 THEN r.hd_count ELSE 0 END ) 'totalHaveNum',
@ -164,7 +166,7 @@ SELECT
FROM FROM
ehs_hidden_danger ehs_hidden_danger
WHERE 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 GROUP BY
d.dept_id, d.dept_id,
d.dept_name d.dept_name
@ -183,6 +185,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.enterprise_type = d.dict_value LEFT JOIN sys_dict_data d ON e.enterprise_type = d.dict_value
AND d.dict_type = 'enterprise_type' AND d.dict_type = 'enterprise_type'
<where> <where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if> <if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where> </where>
GROUP BY GROUP BY
@ -199,6 +202,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.economic_type = d.dict_value LEFT JOIN sys_dict_data d ON e.economic_type = d.dict_value
AND d.dict_type = 'economic_type' AND d.dict_type = 'economic_type'
<where> <where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if> <if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where> </where>
GROUP BY GROUP BY
@ -215,6 +219,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.enterprise_scale = d.dict_value LEFT JOIN sys_dict_data d ON e.enterprise_scale = d.dict_value
AND d.dict_type = 'enterprise_scale' AND d.dict_type = 'enterprise_scale'
<where> <where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if> <if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where> </where>
GROUP BY GROUP BY
@ -246,6 +251,7 @@ SELECT
LEFT JOIN sys_dict_data d ON e.status = d.dict_value LEFT JOIN sys_dict_data d ON e.status = d.dict_value
AND d.dict_type = 'hidden_danger_status' AND d.dict_type = 'hidden_danger_status'
<where> <where>
AND DATE_FORMAT(e.check_time,'%Y-%m') = DATE_FORMAT(#{targetTime},'%Y-%m')
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if> <if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
</where> </where>
GROUP BY GROUP BY

Loading…
Cancel
Save