大屏安全趋势接口

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.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord; import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics; 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.*;
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.service.IHiddenDangerInspectRecordService; import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -272,4 +269,14 @@ public class HiddenDangerInspectRecordController {
public Result<List<HiddenDangerInspectionStatistics>> selectHiddenDangerStateTrendByWeek(@RequestBody Map<String, Object> map) { public Result<List<HiddenDangerInspectionStatistics>> selectHiddenDangerStateTrendByWeek(@RequestBody Map<String, Object> map) {
return Result.success(hiddenDangerInspectRecordService.selectHiddenDangerStateTrendByWeek(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.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord; import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics; 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.*;
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 org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -68,4 +65,6 @@ public interface HiddenDangerInspectRecordMapper extends BaseMapper<HiddenDanger
List<String> getGroupByProjectSn(); List<String> getGroupByProjectSn();
HiddenDangerInspectionStatistics statisticsByStatue(DateTime startTime, DateTime endTime, String projectSn); HiddenDangerInspectionStatistics statisticsByStatue(DateTime startTime, DateTime endTime, String projectSn);
List<DangerInspectionPassMonthStaticsVo> getDangerInspectionPassMonthStatics(Map<String, Object> map);
} }

View File

@ -391,34 +391,48 @@
<select id="getTotalAndWeekHiddenDanger" <select id="getTotalAndWeekHiddenDanger"
resultType="com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger" resultType="com.zhgd.xmgl.modules.dangerous.entity.vo.TotalAndWeekHiddenDanger"
parameterType="java.lang.String"> parameterType="java.lang.String">
SELECT SELECT count(1) allTotalNum,
count( 1 ) allTotalNum,
IFNULL(SUM((IF(STATUS = 1 OR STATUS = 4, 1, 0))), 0) allRectificationNum, 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((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(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), 1,
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 0)), 0) weekRectificationNum,
FROM IFNULL(SUM((IF(YEARWEEK(CURRENT_DATE, 1) = YEARWEEK(inspect_time, 1) AND
hidden_danger_inspection_record !(STATUS = 1 OR STATUS = 4 OR STATUS IS NULL), 1, 0))), 0) weekNoRectificationNum
WHERE FROM hidden_danger_inspection_record
project_sn = #{projectSn} WHERE project_sn = #{projectSn}
</select> </select>
<select id="selectHiddenDangerTypeRatio" resultType="com.zhgd.jeecg.common.mybatis.EntityMap"> <select id="selectHiddenDangerTypeRatio" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
SELECT COUNT(1) num, t.inspect_type_name FROM hidden_danger_inspection_record h 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 LEFT JOIN inspect_type t ON h.inspect_type_id = t.id
WHERE h.project_sn = #{projectSn} GROUP BY t.inspect_type_name WHERE h.project_sn = #{projectSn}
GROUP BY t.inspect_type_name
</select> </select>
<select id="getGroupByProjectSn" resultType="java.lang.String"> <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>
<select id="statisticsByStatue" resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics"> <select id="statisticsByStatue"
SELECT resultType="com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics">
IFNULL(sum(if(project_sn = #{projectSn} AND create_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) increaseNum , SELECT IFNULL(sum(if(project_sn = #{projectSn} AND create_time BETWEEN #{startTime} AND #{endTime}, 1, 0)),
IFNULL(sum(if(`status` = 4 AND project_sn = #{projectSn} AND update_time BETWEEN #{startTime} AND #{endTime}, 1, 0)), 0) solveNum, 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 IFNULL(sum(if(`status` != 1 AND `status` != 4 AND project_sn = #{projectSn}, 1, 0)), 0) unResolveNum
FROM hidden_danger_inspection_record FROM hidden_danger_inspection_record
</select> </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> </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.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord; import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectionStatistics; 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.*;
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 javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@ -77,4 +74,5 @@ public interface IHiddenDangerInspectRecordService extends IService<HiddenDanger
Result<HiddenDangerInspectRecord> edit(HiddenDangerInspectRecord hiddenDangerInspectRecord); 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 javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @Description: 隐患检查记录 * @Description: 隐患检查记录
@ -494,6 +495,27 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
return result; 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;
}
/** /**
* 设置全部占比 * 设置全部占比
* *