大屏安全趋势接口

This commit is contained in:
guo 2023-07-13 09:25:47 +08:00
parent 46f4e8c448
commit 55be346128
7 changed files with 98 additions and 49 deletions

View File

@ -5,10 +5,7 @@ import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.ProjectInspectRecordCountVo;
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
import com.zhgd.xmgl.modules.dangerous.entity.vo.*;
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -272,4 +269,14 @@ public class HiddenDangerInspectRecordController {
public Result<List<HiddenDangerInspectionStatistics>> selectHiddenDangerStateTrendByWeek(@RequestBody Map<String, Object> map) {
return Result.success(hiddenDangerInspectRecordService.selectHiddenDangerStateTrendByWeek(map));
}
@ApiOperation(value = "查询过去一个月的新增问题趋势", notes = "查询过去一个月的新增问题趋势", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
})
@PostMapping(value = "/getDangerInspectionPassMonthStatics")
public Result<List<DangerInspectionPassMonthStaticsVo>> getDangerInspectionPassMonthStatics(@RequestBody Map<String, Object> map) {
return Result.success(hiddenDangerInspectRecordService.getDangerInspectionPassMonthStatics(map));
}
}

View File

@ -0,0 +1,9 @@
package com.zhgd.xmgl.modules.dangerous.entity.vo;
import lombok.Data;
@Data
public class DangerInspectionPassMonthStaticsVo {
private Integer num;
private String day;
}

View File

@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.ProjectInspectRecordCountVo;
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
import com.zhgd.xmgl.modules.dangerous.entity.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -68,4 +65,6 @@ public interface HiddenDangerInspectRecordMapper extends BaseMapper<HiddenDanger
List<String> getGroupByProjectSn();
HiddenDangerInspectionStatistics statisticsByStatue(DateTime startTime, DateTime endTime, String projectSn);
List<DangerInspectionPassMonthStaticsVo> getDangerInspectionPassMonthStatics(Map<String, Object> map);
}

View File

@ -3,10 +3,10 @@
<mapper namespace="com.zhgd.xmgl.modules.dangerous.mapper.HiddenDangerInspectRecordMapper">
<select id="selectHiddenDangerInspectRecordById" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
SELECT a.*,
b.enterprise_name,
d.real_name create_user_name,
e.real_name change_user_name,
f.real_name review_user_name,
b.enterprise_name,
d.real_name create_user_name,
e.real_name change_user_name,
f.real_name review_user_name,
t.inspect_type_name
from hidden_danger_inspection_record a
LEFT JOIN enterprise_info b ON a.enterprise_sn = b.enterprise_sn
@ -124,7 +124,7 @@
round(IFNULL(TRUNCATE(IFNULL(rectifyCompleteNum, 0) / IFNULL(inspectNum, 0), 4), 0) * 100,
2) completeRatio,
round(IFNULL(TRUNCATE(IFNULL(closeNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) closeRatio,
tp.totalNum-tp.weekInspectNum-tp.monthInspectNum AS otherInspectNum <!--其他数量,就是除了月、周的检查数量-->
tp.totalNum - tp.weekInspectNum - tp.monthInspectNum AS otherInspectNum <!--其他数量,就是除了月、周的检查数量-->
from (
SELECT count(1) totalNum,
IFNULL(SUM((CASE WHEN a.record_type = 2 THEN 1 ELSE 0 END)), 0) investigateNum,
@ -145,7 +145,7 @@
IFNULL(SUM((CASE WHEN tr.frequency_type = 3 THEN 1 ELSE 0 END)), 0) weekInspectNum, <!--周检查数量-->
IFNULL(SUM((CASE WHEN tr.frequency_type = 4 THEN 1 ELSE 0 END)), 0) monthInspectNum <!--月检查数量-->
from hidden_danger_inspection_record a
left join inspect_task_record tr on tr.id=a.task_id
left join inspect_task_record tr on tr.id = a.task_id
WHERE a.project_sn = #{projectSn}
<if test="createUser != null and createUser != ''">
and a.create_user = #{createUser}
@ -194,16 +194,16 @@
IFNULL(SUM((CASE
WHEN (a.status = 2 OR a.status = 3)
AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
ELSE 0 END)),
0) overdueNotCloseNum,
IFNULL(SUM((CASE
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time
THEN 1
ELSE 0 END)),
0) overdueRectificationNum,
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum
from hidden_danger_inspection_record a
ELSE 0 END)),
0) overdueNotCloseNum,
IFNULL(SUM((CASE
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time
THEN 1
ELSE 0 END)),
0) overdueRectificationNum,
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum
from hidden_danger_inspection_record a
WHERE a.project_sn = #{projectSn}
) tp
</select>
@ -391,34 +391,48 @@
<select id="getTotalAndWeekHiddenDanger"
resultType="com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger"
parameterType="java.lang.String">
SELECT
count( 1 ) allTotalNum,
IFNULL( SUM(( IF ( STATUS = 1 OR STATUS = 4, 1, 0 ))), 0 ) allRectificationNum,
IFNULL( SUM(( IF (!( STATUS = 1 OR STATUS = 4 ) OR STATUS IS NULL, 1, 0 ))), 0 ) allNoRectificationNum,
IFNULL( SUM( YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) ),0 ) weekTotalNum,
IFNULL( SUM( IF ( YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) AND ( STATUS = 1 OR STATUS = 4 ), 1, 0 )), 0 ) weekRectificationNum,
IFNULL( SUM(( IF ( YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) AND !( STATUS = 1 OR STATUS = 4 OR STATUS IS NULL ), 1, 0 ))), 0 ) weekNoRectificationNum
FROM
hidden_danger_inspection_record
WHERE
project_sn = #{projectSn}
SELECT count(1) allTotalNum,
IFNULL(SUM((IF(STATUS = 1 OR STATUS = 4, 1, 0))), 0) allRectificationNum,
IFNULL(SUM((IF(!(STATUS = 1 OR STATUS = 4) OR STATUS IS NULL, 1, 0))), 0) allNoRectificationNum,
IFNULL(SUM(YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1)), 0) weekTotalNum,
IFNULL(SUM(IF(YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) AND (STATUS = 1 OR STATUS = 4), 1,
0)), 0) weekRectificationNum,
IFNULL(SUM((IF(YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) AND
!(STATUS = 1 OR STATUS = 4 OR STATUS IS NULL), 1, 0))), 0) weekNoRectificationNum
FROM hidden_danger_inspection_record
WHERE project_sn = #{projectSn}
</select>
<select id="selectHiddenDangerTypeRatio" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
SELECT COUNT(1) num, t.inspect_type_name FROM hidden_danger_inspection_record h
LEFT JOIN inspect_type t ON h.inspect_type_id = t.id
WHERE h.project_sn = #{projectSn} GROUP BY t.inspect_type_name
SELECT COUNT(1) num, t.inspect_type_name
FROM hidden_danger_inspection_record h
LEFT JOIN inspect_type t ON h.inspect_type_id = t.id
WHERE h.project_sn = #{projectSn}
GROUP BY t.inspect_type_name
</select>
<select id="getGroupByProjectSn" resultType="java.lang.String">
SELECT project_sn FROM hidden_danger_inspection_record GROUP BY project_sn
SELECT project_sn
FROM hidden_danger_inspection_record
GROUP BY project_sn
</select>
<select id="statisticsByStatue" resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics">
SELECT
IFNULL(sum(if(project_sn = #{projectSn} AND create_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) increaseNum ,
IFNULL(sum(if(`status` = 4 AND project_sn = #{projectSn} AND update_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) solveNum,
IFNULL(sum(if(`status` != 1 AND `status` != 4 AND project_sn = #{projectSn}, 1, 0)), 0) unResolveNum
<select id="statisticsByStatue"
resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics">
SELECT IFNULL(sum(if(project_sn = #{projectSn} AND create_time BETWEEN #{startTime} AND #{endTime}, 1, 0)),
0) increaseNum,
IFNULL(sum(if(`status` = 4 AND project_sn = #{projectSn} AND
update_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) solveNum,
IFNULL(sum(if(`status` != 1 AND `status` != 4 AND project_sn = #{projectSn}, 1, 0)), 0) unResolveNum
FROM hidden_danger_inspection_record
</select>
<select id="getDangerInspectionPassMonthStatics"
resultType="com.zhgd.xmgl.modules.dangerous.entity.vo.DangerInspectionPassMonthStaticsVo">
SELECT DATE_FORMAT(a.inspect_time, "%Y-%m-%d") day, count(1) num
FROM hidden_danger_inspection_record a
WHERE a.project_sn = #{projectSn}
and a.inspect_time >= CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -30 DAY), '%Y-%m-%d'), ' 00:00:00')
group by day
</select>
</mapper>

View File

@ -6,10 +6,7 @@ import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllTodayDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.AllWeekDataHdirVO;
import com.zhgd.xmgl.modules.dangerous.entity.vo.ProjectInspectRecordCountVo;
import com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger;
import com.zhgd.xmgl.modules.dangerous.entity.vo.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -77,4 +74,5 @@ public interface IHiddenDangerInspectRecordService extends IService<HiddenDanger
Result<HiddenDangerInspectRecord> edit(HiddenDangerInspectRecord hiddenDangerInspectRecord);
List<DangerInspectionPassMonthStaticsVo> getDangerInspectionPassMonthStatics(Map<String, Object> map);
}

View File

@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 隐患检查记录
@ -494,6 +495,27 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
return result;
}
@Override
public List<DangerInspectionPassMonthStaticsVo> getDangerInspectionPassMonthStatics(Map<String, Object> map) {
List<DangerInspectionPassMonthStaticsVo> monthStatics = hiddenDangerInspectRecordMapper.getDangerInspectionPassMonthStatics(map);
return fillData(monthStatics);
}
private List<DangerInspectionPassMonthStaticsVo> fillData(List<DangerInspectionPassMonthStaticsVo> monthStatics) {
List<DangerInspectionPassMonthStaticsVo> rtVos = new ArrayList<>();
Map<String, DangerInspectionPassMonthStaticsVo> map = monthStatics.stream().collect(Collectors.toMap(e -> e.getDay(), e -> e, (o, o2) -> o));
for (String orderDay : com.zhgd.xmgl.util.DateUtil.getDaysBetweenLastMonth()) {
DangerInspectionPassMonthStaticsVo vo = map.get(orderDay);
if (vo == null) {
vo = new DangerInspectionPassMonthStaticsVo();
vo.setDay(orderDay);
vo.setNum(0);
}
rtVos.add(vo);
}
return rtVos;
}
/**
* 设置全部占比
*

View File

@ -76,4 +76,4 @@
order by a.create_time desc
</select>
</mapper>
</mapper>