查询最近10天和各10条AI分析硬件设备报警记录

This commit is contained in:
guoshengxiong 2025-11-17 18:18:11 +08:00
parent 1e6b1af5e5
commit 3808817e5b
7 changed files with 122 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmTotalVo;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmTrendVo;
import com.zhgd.xmgl.modules.video.entity.vo.Recent10DayRecordsVo;
import com.zhgd.xmgl.modules.video.service.IAiAnalyseHardWareAlarmRecordService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import io.swagger.annotations.Api;
@ -317,6 +318,18 @@ public class AiAnalyseHardWareAlarmRecordController {
}
@ApiOperation(value = "查询最近10天和各10条AI分析硬件设备报警记录", notes = "查询最近10天和各10条AI分析硬件设备报警记录", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "location", value = "位置", paramType = "body", dataType = "long"),
@ApiImplicitParam(name = "alarmType", value = "类型(字典)", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间,格式2020-08-16 00:00:00", dataType = "String", paramType = "body", required = false),
@ApiImplicitParam(name = "endTime", value = "结束时间,格式2020-08-16 23:59:59", dataType = "String", paramType = "body", required = false),
})
@PostMapping(value = "/getRecent10DayRecords")
public Result<List<Recent10DayRecordsVo>> getRecent10DayRecords(@RequestBody Map<String, Object> param) {
return Result.success(aiAnalyseHardWareAlarmRecordService.getRecent10DayRecords(param));
}
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.video.entity.bo;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class Recent10DayRecordsBo extends AiAnalyseHardWareAlarmRecord {
/**
* 日期
*/
@ApiModelProperty("日期")
private String date;
}

View File

@ -0,0 +1,17 @@
package com.zhgd.xmgl.modules.video.entity.vo;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class Recent10DayRecordsVo {
/**
* 日期
*/
@ApiModelProperty("日期")
private String date;
private List<AiAnalyseHardWareAlarmRecord> records;
}

View File

@ -6,6 +6,7 @@ import com.zhgd.annotation.DataScope;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import com.zhgd.xmgl.modules.video.entity.bo.Recent10DayRecordsBo;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmRecordVo;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmTotalVo;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
@ -173,4 +174,6 @@ public interface AiAnalyseHardWareAlarmRecordMapper extends BaseMapper<AiAnalyse
* @return
*/
AiAnalyseHardWareAlarmRecord getAllocateNewestRecord(HashMap<String, Object> map);
List<Recent10DayRecordsBo> getRecent10DayRecords(Map<String, Object> param);
}

View File

@ -576,4 +576,73 @@
order by a.create_time desc
limit 1
</select>
<select id="getRecent10DayRecords" resultType="com.zhgd.xmgl.modules.video.entity.bo.Recent10DayRecordsBo">
SELECT
dates.alarm_date as date,
a.*
FROM (
SELECT DISTINCT DATE(create_time) as alarm_date
FROM ai_analyse_hard_ware_alarm_record
where 1=1
<if test="projectSn != null and projectSn != ''">
and project_sn = #{projectSn}
</if>
<if test="alarmType != null and alarmType != ''">
and alarm_type = #{alarmType}
</if>
<if test="location != null and location != ''">
and location like CONCAT(CONCAT('%', #{location}), '%')
</if>
<if test="startTime != null and startTime != ''">
AND create_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND create_time <![CDATA[<=]]> if(LENGTH(#{endTime}) = 10, CONCAT(DATE_FORMAT(#{endTime}, '%Y-%m-%d'), ' 23:59:59'), #{endTime})
</if>
ORDER BY alarm_date DESC
LIMIT 10
) dates
LEFT JOIN ai_analyse_hard_ware_alarm_record a ON (
DATE(a.create_time) = dates.alarm_date AND
(
SELECT COUNT(*)
FROM ai_analyse_hard_ware_alarm_record a2
WHERE DATE(a2.create_time) = dates.alarm_date
AND a2.create_time >= a.create_time
<if test="projectSn != null and projectSn != ''">
and project_sn = #{projectSn}
</if>
<if test="alarmType != null and alarmType != ''">
and alarm_type = #{alarmType}
</if>
<if test="location != null and location != ''">
and location like CONCAT(CONCAT('%', #{location}), '%')
</if>
<if test="startTime != null and startTime != ''">
AND create_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND create_time <![CDATA[<=]]> if(LENGTH(#{endTime}) = 10, CONCAT(DATE_FORMAT(#{endTime}, '%Y-%m-%d'), ' 23:59:59'), #{endTime})
</if>
) &lt;= 10
)
WHERE a.id IS NOT NULL
<if test="projectSn != null and projectSn != ''">
and project_sn = #{projectSn}
</if>
<if test="alarmType != null and alarmType != ''">
and alarm_type = #{alarmType}
</if>
<if test="location != null and location != ''">
and location like CONCAT(CONCAT('%', #{location}), '%')
</if>
<if test="startTime != null and startTime != ''">
AND create_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND create_time <![CDATA[<=]]> if(LENGTH(#{endTime}) = 10, CONCAT(DATE_FORMAT(#{endTime}, '%Y-%m-%d'), ' 23:59:59'), #{endTime})
</if>
ORDER BY dates.alarm_date DESC, a.create_time DESC
</select>
</mapper>

View File

@ -172,7 +172,9 @@
FROM video_item t1
INNER JOIN project_video_config t2 ON t2.id = t1.video_id
WHERE t2.is_enable = 1
and t2.project_sn = #{projectSn}
<if test="projectSn != null and projectSn != ''">
and t2.project_sn = #{projectSn}
</if>
order by t1.sort_num
<if test="deviceState != null and deviceState != ''">
and t1.device_state = #{deviceState}

View File

@ -8,6 +8,7 @@ import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmTotalVo;
import com.zhgd.xmgl.modules.video.entity.vo.AiAnalyseHardWareAlarmTrendVo;
import com.zhgd.xmgl.modules.video.entity.vo.Recent10DayRecordsVo;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import java.math.BigDecimal;
@ -174,4 +175,5 @@ public interface IAiAnalyseHardWareAlarmRecordService extends IService<AiAnalyse
void setFalsePositive(AiAnalyseHardWareAlarmRecord taskProgressMaterialRel);
List<Recent10DayRecordsVo> getRecent10DayRecords(Map<String, Object> param);
}