‘liusuyi’
2023-06-24 98505f497a12382b259f643232f2c6c63f5004f8
增加历史报警数据按command和时间区间查询
已修改11个文件
200 ■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/controller/GlobalAlarmController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/domain/GlobalAlarmCondition.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/IGlobalAlarmService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/stealAlarm/mapper/ArdAlarmStealelecMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/tubeAlarm/controller/ArdAlarmTubeController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/alarm/ArdAlarmStealelecMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/alarm/ArdAlarmTubeMapper.xml 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/alarm/config/controller/ArdAlarmTypeConfigController.java
@@ -5,6 +5,8 @@
import javax.servlet.http.HttpServletResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicParameters;
import com.ruoyi.alarm.config.domain.ArdAlarmTypeConfig;
import com.ruoyi.alarm.config.service.IArdAlarmTypeConfigService;
import io.swagger.annotations.Api;
@@ -83,7 +85,6 @@
    @Log(title = "批量配置报警类型", businessType = BusinessType.INSERT)
    @PostMapping("/batchConfig")
    @ApiOperation("批量配置报警类型")
    @ApiOperationSupport(includeParameters = {"map.userId", "map.commands"})
    public AjaxResult addBatch(@RequestBody Map<String,Object> map)
    {
        return AjaxResult.success(ardAlarmTypeConfigService.insertArdAlarmTypeConfig(map));
ard-work/src/main/java/com/ruoyi/alarm/config/service/impl/ArdAlarmTypeConfigServiceImpl.java
@@ -106,8 +106,16 @@
    @Override
    public int insertArdAlarmTypeConfig(Map<String,Object> configInfo) {
        String userId =(String) configInfo.get("userId");
        if(userId==null)
        {
            return 0;
        }
        ardAlarmTypeConfigMapper.deleteArdAlarmTypeConfigByCurrentUserId(userId);
        List<Integer> commands=(List<Integer>) configInfo.get("commands");
        if(commands==null)
        {
            return 0;
        }
        if(commands.size()==0)
        {
            return 0;
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/controller/GlobalAlarmController.java
@@ -8,9 +8,15 @@
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -52,4 +58,16 @@
        Map<String, Integer> stringIntegerMap = globalAlarmService.selectAlarmLogsCount();
        return AjaxResult.success(stringIntegerMap);
    }
    @GetMapping("/List")
    @ApiOperation(value = "历史报警报警聚合接口",notes = "通过command和时间查询历史数据")
    @ApiOperationSupport(includeParameters = {"command","beginTime","endTime"},order = 4)
    @ApiImplicitParams({
            @ApiImplicitParam(name="command",value="报警标识",dataType="integer",paramType="query",example="1001",required=true),
            @ApiImplicitParam(name="beginTime",value="开始时间",dataType="string",paramType="query",example="2023-06-15 00:00:00",required=true),
            @ApiImplicitParam(name="endTime",value="结束时间",dataType="string",paramType="query",example="2023-06-15 14:18:23",required=true),
    })
    public AjaxResult selectAlarmList(Integer command, String beginTime,String endTime) {
        Object alarmList = globalAlarmService.selectAlarmList(command,beginTime,endTime);
        return AjaxResult.success(alarmList);
    }
}
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/domain/GlobalAlarmCondition.java
@@ -22,4 +22,6 @@
    @ApiModelProperty(value = "报警类型", name = "command", notes = "用来区分报警类型的标记", required = true)
    Integer command;
    String id;
    Date beginTime;
    Date endTime;
}
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/IGlobalAlarmService.java
@@ -3,6 +3,7 @@
import com.ruoyi.alarm.globalAlarm.domain.GlobalAlarmCondition;
import com.ruoyi.alarm.globalAlarm.domain.GlobalAlarmData;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -18,4 +19,5 @@
    Object updateAlarmViewTime(GlobalAlarmCondition condition);
    public void receiveAlarm(String topic,String message);
    public Map<String,Integer> selectAlarmLogsCount();
    Object selectAlarmList(Integer command, String beginTime, String endTime);
}
ard-work/src/main/java/com/ruoyi/alarm/globalAlarm/service/impl/GlobalAlarmServiceImpl.java
@@ -70,6 +70,7 @@
    private IHikClientService hikClientService;
    @Resource
    private RedisCache redisCache;
    /**
     * @描述 按条件查询报警
     * @参数 [condition]
@@ -133,6 +134,7 @@
                return null;
        }
    }
    /**
     * @描述 按条件更新查看时间
     * @参数 [condition]
@@ -165,6 +167,7 @@
                return null;
        }
    }
    /**
     * @描述 异步处理接收的报警
     * @参数 [topic, message]
@@ -302,20 +305,18 @@
                double distance = GisTool.getDistance(cmd.getTargetPosition(), camPosition);
                if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) {
                    distanceMap.put(camera.getId(), distance);
                    if(StringUtils.isNull(camera.getCamAlarmGuideEnable()))
                    {
                    if (StringUtils.isNull(camera.getCamAlarmGuideEnable())) {
                        camera.setCamAlarmGuideEnable(0);
                    }
                    guideMap.put(camera.getId(),camera.getCamAlarmGuideEnable());
                    guideMap.put(camera.getId(), camera.getCamAlarmGuideEnable());
                }
            }
            if (distanceMap.size() > 0) {
                log.debug("尝试查找最近光电");
                //获取距离字典中最近的一个相机ID
                String minDistanceCameraId = ArdTool.getKeyByMinValue(distanceMap);
                log.debug("查找到最近光电:"+minDistanceCameraId+",尝试引导");
                if(guideMap.get(minDistanceCameraId).equals(0))
                {
                log.debug("查找到最近光电:" + minDistanceCameraId + ",尝试引导");
                if (guideMap.get(minDistanceCameraId).equals(0)) {
                    log.debug("该光电未开启报警引导");
                    return "";
                }
@@ -366,4 +367,25 @@
        countMap.put("1014 ", count1014);
        return countMap;
    }
    @Override
    public Object selectAlarmList(Integer command, String beginTime, String endTime) {
        Map<String, Object> params = new HashMap<>();
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        switch (command) {
            case 1001:
                ArdAlarmStealelec aas = new ArdAlarmStealelec();
                aas.setParams(params);
                List<ArdAlarmStealelec> ardAlarmStealelecs = ardAlarmStealelecMapper.selectArdAlarmStealelecList(aas);
                return ardAlarmStealelecs;
            case 1014:
                ArdAlarmTube aat = new ArdAlarmTube();
                aat.setParams(params);
                List<ArdAlarmTube> ardAlarmTubes = ardAlarmTubeMapper.selectArdAlarmTubeList(aat);
                return ardAlarmTubes;
        }
        return null;
    }
}
ard-work/src/main/java/com/ruoyi/alarm/stealAlarm/mapper/ArdAlarmStealelecMapper.java
@@ -10,6 +10,13 @@
public interface ArdAlarmStealelecMapper{
    /**
     * 查询盗电报警列表
     *
     * @param ardAlarmStealelec 盗电报警
     * @return 盗电报警集合
     */
    public List<ArdAlarmStealelec> selectArdAlarmStealelecList(ArdAlarmStealelec ardAlarmStealelec);
    int insertArdAlarmStealelec(ArdAlarmStealelec record);
    ArdAlarmStealelec selectByPrimaryKey(String id);
    List<ArdAlarmStealelec> selectRealByCondition(@Param("refreshTime")String refreshTime,@Param("deptId")Long deptId);
ard-work/src/main/java/com/ruoyi/alarm/tubeAlarm/controller/ArdAlarmTubeController.java
@@ -5,6 +5,7 @@
import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube;
import com.ruoyi.alarm.tubeAlarm.service.IArdAlarmTubeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -40,6 +41,7 @@
     */
    @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:list')")
    @GetMapping("/list")
    @ApiOperation("查询管线泄露报警列表")
    public TableDataInfo list(ArdAlarmTube ardAlarmTube)
    {
        startPage();
ard-work/src/main/resources/mapper/alarm/ArdAlarmStealelecMapper.xml
@@ -16,8 +16,22 @@
        <result column="dept_id" property="deptId"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, name, describe, catalog_text, description, start_time, end_time,view_time,longitude,latitude,altitude,create_by,create_time,user_id,dept_id
        id
        , name, describe, catalog_text, description, start_time, end_time,view_time,longitude,latitude,altitude,create_by,create_time,user_id,dept_id
    </sql>
    <select id="selectArdAlarmStealelecList" parameterType="ArdAlarmStealelec" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from ard_alarm_stealelec
        <where>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND start_time &gt;= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND start_time &lt;= to_timestamp(#{params.endTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
        </where>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
@@ -79,7 +93,9 @@
        ORDER BY aas.start_time DESC LIMIT 50
    </select>
    <select id="selectCountByStartTime" resultType="Integer">
        select count(DISTINCT aas."describe") from ard_alarm_stealelec aas where aas.start_time >= ( CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE )
        select count(DISTINCT aas."describe")
        from ard_alarm_stealelec aas
        where aas.start_time >= (CURRENT_TIMESTAMP - INTERVAL '%${refreshTime}%' MINUTE)
    </select>
    <update id="updateViewTimeByDescribe" parameterType="String">
        update ard_alarm_stealelec
ard-work/src/main/resources/mapper/alarm/ArdAlarmTubeMapper.xml
@@ -5,49 +5,73 @@
<mapper namespace="com.ruoyi.alarm.tubeAlarm.mapper.ArdAlarmTubeMapper">
    <resultMap type="ArdAlarmTube" id="ArdAlarmTubeResult">
        <result property="id"    column="id"    />
        <result property="host"    column="host"    />
        <result property="tubeId"    column="tube_id"    />
        <result property="tubeName"    column="tube_name"    />
        <result property="tubeType"    column="tube_type"    />
        <result property="pipeDiameter"    column="pipe_diameter"    />
        <result property="color"    column="color"    />
        <result property="position"    column="position"    />
        <result property="type"    column="type"    />
        <result property="alarmType"    column="alarm_type"    />
        <result property="alarmTime"    column="alarm_time"    />
        <result property="watcher"    column="watcher"    />
        <result property="createTime"    column="create_time"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="altitude"    column="altitude"    />
        <result property="recordUrl"    column="record_url"    />
        <result property="viewTime"    column="view_time"    />
        <result property="id" column="id"/>
        <result property="host" column="host"/>
        <result property="tubeId" column="tube_id"/>
        <result property="tubeName" column="tube_name"/>
        <result property="tubeType" column="tube_type"/>
        <result property="pipeDiameter" column="pipe_diameter"/>
        <result property="color" column="color"/>
        <result property="position" column="position"/>
        <result property="type" column="type"/>
        <result property="alarmType" column="alarm_type"/>
        <result property="alarmTime" column="alarm_time"/>
        <result property="watcher" column="watcher"/>
        <result property="createTime" column="create_time"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="altitude" column="altitude"/>
        <result property="recordUrl" column="record_url"/>
        <result property="viewTime" column="view_time"/>
    </resultMap>
    <sql id="selectArdAlarmTubeVo">
        select id, host, tube_id, tube_name, tube_type, pipe_diameter, color, position, type, alarm_type, alarm_time, watcher, create_time, longitude, latitude, altitude, record_url, view_time from ard_alarm_tube
        select id,
               host,
               tube_id,
               tube_name,
               tube_type,
               pipe_diameter,
               color,
               position,
               type,
               alarm_type,
               alarm_time,
               watcher,
               create_time,
               longitude,
               latitude,
               altitude,
               record_url,
               view_time
        from ard_alarm_tube
    </sql>
    <select id="selectArdAlarmTubeList" parameterType="ArdAlarmTube" resultMap="ArdAlarmTubeResult">
        <include refid="selectArdAlarmTubeVo"/>
        <where>
            <if test="host != null  and host != ''"> and host = #{host}</if>
            <if test="tubeId != null  and tubeId != ''"> and tube_id = #{tubeId}</if>
            <if test="tubeName != null  and tubeName != ''"> and tube_name like '%'||#{tubeName}||'%'</if>
            <if test="tubeType != null  and tubeType != ''"> and tube_type = #{tubeType}</if>
            <if test="pipeDiameter != null  and pipeDiameter != ''"> and pipe_diameter = #{pipeDiameter}</if>
            <if test="color != null  and color != ''"> and color = #{color}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if>
            <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
            <if test="watcher != null  and watcher != ''"> and watcher = #{watcher}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="altitude != null  and altitude != ''"> and altitude = #{altitude}</if>
            <if test="recordUrl != null  and recordUrl != ''"> and record_url = #{recordUrl}</if>
            <if test="viewTime != null "> and view_time = #{viewTime}</if>
            <if test="host != null  and host != ''">and host = #{host}</if>
            <if test="tubeId != null  and tubeId != ''">and tube_id = #{tubeId}</if>
            <if test="tubeName != null  and tubeName != ''">and tube_name like '%'||#{tubeName}||'%'</if>
            <if test="tubeType != null  and tubeType != ''">and tube_type = #{tubeType}</if>
            <if test="pipeDiameter != null  and pipeDiameter != ''">and pipe_diameter = #{pipeDiameter}</if>
            <if test="color != null  and color != ''">and color = #{color}</if>
            <if test="position != null  and position != ''">and position = #{position}</if>
            <if test="type != null  and type != ''">and type = #{type}</if>
            <if test="alarmType != null  and alarmType != ''">and alarm_type = #{alarmType}</if>
            <!--<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>-->
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND alarm_time &gt;= to_timestamp(#{params.beginTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND alarm_time &lt;= to_timestamp(#{params.endTime},'yyyy-MM-DD HH24:MI:ss')
            </if>
            <if test="watcher != null  and watcher != ''">and watcher = #{watcher}</if>
            <if test="longitude != null  and longitude != ''">and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''">and latitude = #{latitude}</if>
            <if test="altitude != null  and altitude != ''">and altitude = #{altitude}</if>
            <if test="recordUrl != null  and recordUrl != ''">and record_url = #{recordUrl}</if>
            <if test="viewTime != null ">and view_time = #{viewTime}</if>
        </where>
    </select>
@@ -125,7 +149,9 @@
    </update>
    <delete id="deleteArdAlarmTubeById" parameterType="String">
        delete from ard_alarm_tube where id = #{id}
        delete
        from ard_alarm_tube
        where id = #{id}
    </delete>
    <delete id="deleteArdAlarmTubeByIds" parameterType="String">
@@ -145,8 +171,7 @@
                        aat.latitude,
                        aat.altitude,
                        aat.record_url,
                        ROW_NUMBER() OVER ( PARTITION BY aat.tube_id ORDER BY aat.alarm_time DESC ) AS rn,
                         COUNT(CASE WHEN aat.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aat.tube_id ) AS COUNT,
                        ROW_NUMBER() OVER ( PARTITION BY aat.tube_id ORDER BY aat.alarm_time DESC ) AS rn, COUNT(CASE WHEN aat.view_time IS NULL THEN 1 END) OVER ( PARTITION BY aat.tube_id ) AS COUNT,
                    COUNT ( aat.alarm_time ) OVER ( PARTITION BY tube_id ) AS total
                 FROM
                     ard_alarm_tube aat
@@ -165,7 +190,7 @@
        update ard_alarm_tube
        set view_time=#{viewTime}
        where tube_id = #{tubeId}
          and alarm_time&lt;=#{alarmTime}
          and alarm_time &lt;= #{alarmTime}
          and view_time is null
    </update>
</mapper>
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
@@ -50,6 +50,7 @@
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @ApiModelProperty(value = "动态参数", name = "params", notes = "根据不同的查询字段自由配置参数")
    private Map<String, Object> params;
    @ApiModelProperty(value = "页码", name = "pageNum", notes = "页码", required = true)
    private Integer pageNum;
    @ApiModelProperty(value = "页大小", name = "pageSize", notes = "页大小", required = true)