工程安全分析
This commit is contained in:
parent
b648e0d38e
commit
2ae29be1a3
|
|
@ -0,0 +1,62 @@
|
|||
package com.securitycontrol.screen.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.securitycontrol.screen.domain.EngineeringSafetyAnalysis;
|
||||
import com.securitycontrol.screen.service.EngineeringSafetyAnalysisService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.securitycontrol.common.core.web.controller.BaseController;
|
||||
import com.securitycontrol.common.core.web.page.TableDataInfo;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
|
||||
/**
|
||||
* 工程安全分析Controller
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@Api(tags = "工程安全分析接口")
|
||||
@RestController
|
||||
@RequestMapping("/largeScreen/engineeringSafetyAnalysis")
|
||||
public class EngineeringSafetyAnalysisController extends BaseController {
|
||||
@Autowired
|
||||
private EngineeringSafetyAnalysisService environmentalReadingsService;
|
||||
|
||||
/**
|
||||
* 查询安全隐患列表
|
||||
*/
|
||||
@ApiOperation(value = "查询安全隐患列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
startPage();
|
||||
List<EngineeringSafetyAnalysis> list = environmentalReadingsService.selectEnvironmentalReadingsList(environmentalReadings);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询环境监测趋势列表
|
||||
*/
|
||||
@ApiOperation(value = "查询环境监测趋势列表")
|
||||
@GetMapping("/environmental")
|
||||
public TableDataInfo environmental(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
List<EngineeringSafetyAnalysis> list = environmentalReadingsService.environmentalList(environmentalReadings);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询安全隐患分布列表
|
||||
*/
|
||||
@ApiOperation(value = "查询安全隐患分布列表")
|
||||
@GetMapping("/hazards")
|
||||
public TableDataInfo hazards(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
List<EngineeringSafetyAnalysis> list = environmentalReadingsService.hazardsList(environmentalReadings);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.securitycontrol.screen.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.securitycontrol.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 工程安全分析 monitoring_points,environmental_readings,hazards
|
||||
*
|
||||
* @author lsun
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class EngineeringSafetyAnalysis extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 监测点编号 */
|
||||
private String id;
|
||||
|
||||
/** 环境数据记录日期 */
|
||||
@ApiModelProperty(value = "环境数据记录日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
|
||||
/** 温度,单位°C */
|
||||
@ApiModelProperty(value = "温度,单位°C")
|
||||
private BigDecimal temperature;
|
||||
|
||||
/** 湿度,单位% */
|
||||
@ApiModelProperty(value = "湿度,单位%")
|
||||
private BigDecimal humidity;
|
||||
|
||||
/** 风速,单位m/s */
|
||||
@ApiModelProperty(value = "风速,单位m/s")
|
||||
private BigDecimal windSpeed;
|
||||
|
||||
/** 气体值,单位ppm */
|
||||
@ApiModelProperty(value = "气体值,单位ppm")
|
||||
private BigDecimal gasValue;
|
||||
|
||||
/** 工程标段 */
|
||||
@ApiModelProperty(value = "工程标段")
|
||||
private String bidCode;
|
||||
|
||||
/** 隐患类型,如高空坠物风险 */
|
||||
@ApiModelProperty(value = "隐患类型,如高空坠物风险")
|
||||
private String type;
|
||||
|
||||
/** 隐患等级,如重大隐患、较大隐患、一般隐患 */
|
||||
@ApiModelProperty(value = "隐患等级,如重大隐患、较大隐患、一般隐患")
|
||||
private String level;
|
||||
|
||||
/** 隐患发生时间 */
|
||||
@ApiModelProperty(value = "隐患发生时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date timestamp;
|
||||
|
||||
/** 监测点名称,如A区塔吊作业点 */
|
||||
@ApiModelProperty(value = "监测点名称,如A区塔吊作业点")
|
||||
private String name;
|
||||
|
||||
/** 监测点id */
|
||||
@ApiModelProperty(value = "监测点id")
|
||||
private String monitoringPointId;
|
||||
|
||||
/** 数量 */
|
||||
@ApiModelProperty(value = "数量")
|
||||
private String count;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.securitycontrol.screen.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.securitycontrol.screen.domain.EngineeringSafetyAnalysis;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
public interface EngineeringSafetyAnalysisMapper {
|
||||
|
||||
/**
|
||||
* 查询安全隐患列表
|
||||
*
|
||||
* @param environmentalReadings 安全隐患
|
||||
* @return 安全隐患集合
|
||||
*/
|
||||
public List<EngineeringSafetyAnalysis> selectEnvironmentalReadingsList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
|
||||
/**
|
||||
* 查询环境监测趋势列表
|
||||
*
|
||||
* @param environmentalReadings 环境监测趋势
|
||||
* @return 环境监测趋势
|
||||
*/
|
||||
List<EngineeringSafetyAnalysis> environmentalList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
|
||||
/**
|
||||
* 查询安全隐患发布列表
|
||||
*
|
||||
* @param environmentalReadings 安全隐患发布
|
||||
* @return 安全隐患集合发布
|
||||
*/
|
||||
List<EngineeringSafetyAnalysis> hazardsList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.securitycontrol.screen.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.securitycontrol.screen.domain.EngineeringSafetyAnalysis;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
public interface EngineeringSafetyAnalysisService {
|
||||
/**
|
||||
* 查询安全隐患列表
|
||||
*
|
||||
* @param environmentalReadings 查询安全隐患列表
|
||||
* @return 安全隐患集合
|
||||
*/
|
||||
public List<EngineeringSafetyAnalysis> selectEnvironmentalReadingsList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
|
||||
/**
|
||||
* 查询环境监测趋势列表
|
||||
*
|
||||
* @param environmentalReadings 查询环境监测趋势列表
|
||||
* @return 环境监测趋势集合
|
||||
*/
|
||||
List<EngineeringSafetyAnalysis> environmentalList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
|
||||
/**
|
||||
* 查询安全隐患发布列表
|
||||
*
|
||||
* @param environmentalReadings 查询安全隐患发布列表
|
||||
* @return 安全隐患发布集合
|
||||
*/
|
||||
List<EngineeringSafetyAnalysis> hazardsList(EngineeringSafetyAnalysis environmentalReadings);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.securitycontrol.screen.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.securitycontrol.screen.domain.EngineeringSafetyAnalysis;
|
||||
import com.securitycontrol.screen.mapper.EngineeringSafetyAnalysisMapper;
|
||||
import com.securitycontrol.screen.service.EngineeringSafetyAnalysisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@Service
|
||||
public class EngineeringSafetyAnalysisServiceImpl implements EngineeringSafetyAnalysisService {
|
||||
|
||||
@Autowired
|
||||
private EngineeringSafetyAnalysisMapper engineeringSafetyAnalysisMapper;
|
||||
|
||||
/**
|
||||
* 查询安全隐患列表
|
||||
*
|
||||
* @param environmentalReadings 安全隐患
|
||||
* @return 安全隐患
|
||||
*/
|
||||
@Override
|
||||
public List<EngineeringSafetyAnalysis> selectEnvironmentalReadingsList(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
return engineeringSafetyAnalysisMapper.selectEnvironmentalReadingsList(environmentalReadings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询环境监测趋势列表
|
||||
*
|
||||
* @param environmentalReadings 环境监测趋势
|
||||
* @return 环境监测趋势
|
||||
*/
|
||||
@Override
|
||||
public List<EngineeringSafetyAnalysis> environmentalList(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
return engineeringSafetyAnalysisMapper.environmentalList(environmentalReadings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询安全隐患发布列表
|
||||
*
|
||||
* @param environmentalReadings 安全隐患发布
|
||||
* @return 安全隐患发布
|
||||
*/
|
||||
@Override
|
||||
public List<EngineeringSafetyAnalysis> hazardsList(EngineeringSafetyAnalysis environmentalReadings) {
|
||||
return engineeringSafetyAnalysisMapper.hazardsList(environmentalReadings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.securitycontrol.screen.mapper.EngineeringSafetyAnalysisMapper">
|
||||
<resultMap type="com.securitycontrol.screen.domain.EngineeringSafetyAnalysis" id="EngineeringSafetyAnalysisResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="date" column="date" />
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="humidity" column="humidity" />
|
||||
<result property="windSpeed" column="wind_speed" />
|
||||
<result property="gasValue" column="gas_value" />
|
||||
<result property="bidCode" column="bid_code" />
|
||||
|
||||
<result property="monitoringPointId" column="monitoring_point_id" />
|
||||
<result property="count" column="count" />
|
||||
|
||||
<result property="type" column="type" />
|
||||
<result property="level" column="level" />
|
||||
<result property="timestamp" column="timestamp" />
|
||||
<result property="name" column="name" />
|
||||
</resultMap>
|
||||
|
||||
<!--查询安全隐患集合列表-->
|
||||
<select id="selectEnvironmentalReadingsList" parameterType="com.securitycontrol.screen.domain.EngineeringSafetyAnalysis" resultMap="EngineeringSafetyAnalysisResult">
|
||||
SELECT
|
||||
h.id AS id,
|
||||
h.type AS type,
|
||||
h.level AS level,
|
||||
h.timestamp AS timestamp,
|
||||
h.bid_code,
|
||||
mp.id AS monitoring_point_id ,
|
||||
mp.name AS name,
|
||||
COALESCE(ale.avg_temperature, '-') AS temperature,
|
||||
COALESCE(ale.avg_humidity, '-') AS humidity,
|
||||
COALESCE(ale.avg_wind_speed, '-') AS wind_speed,
|
||||
COALESCE(ale.avg_gas_value, '-') AS gas_value
|
||||
FROM
|
||||
hazards h
|
||||
LEFT JOIN
|
||||
monitoring_points mp ON h.bid_code = mp.bid_code
|
||||
LEFT JOIN
|
||||
(
|
||||
-- 子查询:获取每个 bid_code 最新日期的环境数据平均值
|
||||
SELECT
|
||||
er.bid_code,
|
||||
AVG(er.temperature) AS avg_temperature,
|
||||
AVG(er.humidity) AS avg_humidity,
|
||||
AVG(er.wind_speed) AS avg_wind_speed,
|
||||
AVG(er.gas_value) AS avg_gas_value
|
||||
FROM
|
||||
environmental_readings er
|
||||
JOIN (
|
||||
-- 找到每个 bid_code 的最新日期
|
||||
SELECT
|
||||
bid_code,
|
||||
MAX(date) AS max_date
|
||||
FROM
|
||||
environmental_readings
|
||||
GROUP BY
|
||||
bid_code
|
||||
) AS latest_dates ON er.bid_code = latest_dates.bid_code AND er.date = latest_dates.max_date
|
||||
GROUP BY
|
||||
er.bid_code
|
||||
) ale ON h.bid_code = ale.bid_code
|
||||
WHERE
|
||||
(#{bidCode} IS NULL OR #{bidCode} = '' OR h.bid_code = #{bidCode})
|
||||
<if test="name != null and name != ''">
|
||||
AND mp.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
ORDER BY h.timestamp DESC
|
||||
</select>
|
||||
|
||||
<!--查询环境监测列表-->
|
||||
<select id="environmentalList" parameterType="com.securitycontrol.screen.domain.EngineeringSafetyAnalysis" resultMap="EngineeringSafetyAnalysisResult">
|
||||
SELECT
|
||||
date,
|
||||
AVG(temperature) AS temperature,
|
||||
AVG(humidity) AS humidity,
|
||||
AVG(wind_speed) AS wind_speed,
|
||||
AVG(gas_value) AS gas_value
|
||||
FROM
|
||||
environmental_readings
|
||||
WHERE
|
||||
bid_code = #{bidCode}
|
||||
GROUP BY
|
||||
date
|
||||
ORDER BY
|
||||
date ASC
|
||||
</select>
|
||||
|
||||
<!--查询安全隐患发布列表-->
|
||||
<select id="hazardsList" parameterType="com.securitycontrol.screen.domain.EngineeringSafetyAnalysis" resultMap="EngineeringSafetyAnalysisResult">
|
||||
SELECT
|
||||
level,
|
||||
COUNT(*) AS count
|
||||
FROM
|
||||
hazards
|
||||
WHERE
|
||||
bid_code = #{bidCode}
|
||||
GROUP BY
|
||||
level
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue