refactor(video): AI 域 ORM 改造 — DO 继承 TenantBaseDO + Mapper 继承 BaseMapperX
- 8 个 AI DO 加 @TableName、继承 TenantBaseDO、主键改 Long - 9 个 AI Mapper 继承 BaseMapperX,简单 CRUD 改为 default 方法 - Service/Controller 适配类型变化(Integer→Long、删除手动 setCreateTime) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_alert")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "AI告警记录")
|
||||
public class AiAlert {
|
||||
public class AiAlert extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Long id;
|
||||
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_algo_template")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "算法参数模板")
|
||||
public class AiAlgoTemplate {
|
||||
public class AiAlgoTemplate extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板唯一ID")
|
||||
private String templateId;
|
||||
@@ -24,10 +32,4 @@ public class AiAlgoTemplate {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_algorithm")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "算法注册表")
|
||||
public class AiAlgorithm {
|
||||
public class AiAlgorithm extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "算法编码")
|
||||
private String algoCode;
|
||||
@@ -30,10 +38,4 @@ public class AiAlgorithm {
|
||||
|
||||
@Schema(description = "最后同步时间")
|
||||
private String syncTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_config_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "配置变更日志")
|
||||
public class AiConfigLog {
|
||||
public class AiConfigLog extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Long id;
|
||||
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_config_snapshot")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "配置版本快照")
|
||||
public class AiConfigSnapshot {
|
||||
public class AiConfigSnapshot extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Long id;
|
||||
|
||||
@@ -34,6 +42,6 @@ public class AiConfigSnapshot {
|
||||
@Schema(description = "操作人")
|
||||
private String createdBy;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@Schema(description = "创建时间(业务字段,记录快照生成时间)")
|
||||
private String createdAt;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_edge_device")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "边缘设备状态")
|
||||
public class AiEdgeDevice {
|
||||
public class AiEdgeDevice extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备唯一ID")
|
||||
private String deviceId;
|
||||
@@ -37,6 +45,6 @@ public class AiEdgeDevice {
|
||||
@Schema(description = "当前配置版本")
|
||||
private String configVersion;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@Schema(description = "更新时间(业务字段)")
|
||||
private String updatedAt;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_roi")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "ROI区域配置")
|
||||
public class AiRoi {
|
||||
public class AiRoi extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "UUID,与FastAPI端同步用")
|
||||
private String roiId;
|
||||
@@ -45,10 +53,4 @@ public class AiRoi {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.viewsh.module.video.aiot.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.viewsh.framework.tenant.core.db.TenantBaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@TableName("wvp_ai_roi_algo_bind")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "ROI算法绑定")
|
||||
public class AiRoiAlgoBind {
|
||||
public class AiRoiAlgoBind extends TenantBaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "数据库自增ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "UUID,同步用")
|
||||
private String bindId;
|
||||
@@ -33,10 +41,4 @@ public class AiRoiAlgoBind {
|
||||
|
||||
@Schema(description = "覆盖模板的局部参数JSON")
|
||||
private String paramOverride;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.viewsh.module.video.aiot.controller;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlert;
|
||||
import com.viewsh.module.video.aiot.service.IAiAlertService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -27,7 +27,7 @@ public class AiAlertController {
|
||||
|
||||
@Operation(summary = "告警列表(分页、筛选)")
|
||||
@GetMapping("/list")
|
||||
public PageInfo<AiAlert> queryList(
|
||||
public PageResult<AiAlert> queryList(
|
||||
@Parameter(description = "摄像头ID") @RequestParam(required = false) String cameraId,
|
||||
@Parameter(description = "告警类型") @RequestParam(required = false) String alertType,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AiAlgorithmController {
|
||||
|
||||
@Operation(summary = "启用/禁用算法")
|
||||
@PostMapping("/toggle/{id}")
|
||||
public void toggleActive(@PathVariable Integer id, @RequestParam Integer isActive) {
|
||||
public void toggleActive(@PathVariable Long id, @RequestParam Integer isActive) {
|
||||
algorithmService.toggleActive(id, isActive);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.viewsh.module.video.aiot.dao.AiEdgeDeviceMapper;
|
||||
import com.viewsh.module.video.aiot.dao.AiRoiMapper;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigService;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigSnapshotService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -66,7 +66,7 @@ public class AiConfigController {
|
||||
|
||||
@Operation(summary = "查询版本列表")
|
||||
@GetMapping("/versions")
|
||||
public PageInfo<AiConfigSnapshot> queryVersions(
|
||||
public PageResult<AiConfigSnapshot> queryVersions(
|
||||
@Parameter(description = "范围类型:CAMERA/ROI/BIND") @RequestParam(required = false) String scopeType,
|
||||
@Parameter(description = "范围ID") @RequestParam(required = false) String scopeId,
|
||||
@Parameter(description = "摄像头ID") @RequestParam(required = false) String cameraId,
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.viewsh.module.video.aiot.controller;
|
||||
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigLog;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigLogService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -21,7 +21,7 @@ public class AiConfigLogController {
|
||||
|
||||
@Operation(summary = "分页查询变更日志")
|
||||
@GetMapping("/list")
|
||||
public PageInfo<AiConfigLog> queryList(
|
||||
public PageResult<AiConfigLog> queryList(
|
||||
@Parameter(description = "配置类型") @RequestParam(required = false) String configType,
|
||||
@Parameter(description = "配置ID") @RequestParam(required = false) String configId,
|
||||
@RequestParam int page,
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.viewsh.module.video.aiot.controller;
|
||||
import com.viewsh.module.video.aiot.bean.AiEdgeDevice;
|
||||
import com.viewsh.module.video.aiot.service.IAiEdgeDeviceService;
|
||||
import com.viewsh.module.video.vmanager.bean.WVPResult;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -36,11 +36,11 @@ public class AiEdgeDeviceController {
|
||||
|
||||
@Operation(summary = "边缘设备分页查询")
|
||||
@GetMapping("/page")
|
||||
public WVPResult<PageInfo<AiEdgeDevice>> queryPage(
|
||||
public WVPResult<PageResult<AiEdgeDevice>> queryPage(
|
||||
@RequestParam(defaultValue = "1") int pageNo,
|
||||
@RequestParam(defaultValue = "20") int pageSize,
|
||||
@RequestParam(required = false) String status) {
|
||||
PageInfo<AiEdgeDevice> pageInfo = edgeDeviceService.queryPage(pageNo, pageSize, status);
|
||||
PageResult<AiEdgeDevice> pageInfo = edgeDeviceService.queryPage(pageNo, pageSize, status);
|
||||
return WVPResult.success(pageInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.viewsh.module.video.aiot.bean.AiRoiAlgoBind;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoiDetail;
|
||||
import com.viewsh.module.video.aiot.service.IAiRoiService;
|
||||
import com.viewsh.module.video.aiot.service.IAiScreenshotService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -35,7 +35,7 @@ public class AiRoiController {
|
||||
|
||||
@Operation(summary = "分页查询ROI列表")
|
||||
@GetMapping("/list")
|
||||
public PageInfo<AiRoi> queryList(
|
||||
public PageResult<AiRoi> queryList(
|
||||
@Parameter(description = "通道国标编号") @RequestParam(required = false) String cameraId,
|
||||
@Parameter(description = "设备国标编号") @RequestParam(required = false) String deviceId,
|
||||
@Parameter(description = "关键字") @RequestParam(required = false) String query,
|
||||
@@ -46,7 +46,7 @@ public class AiRoiController {
|
||||
|
||||
@Operation(summary = "ROI详情(含关联算法)")
|
||||
@GetMapping("/{id}")
|
||||
public AiRoiDetail queryDetail(@PathVariable Integer id) {
|
||||
public AiRoiDetail queryDetail(@PathVariable Long id) {
|
||||
return roiService.queryDetail(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlert;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiAlertMapper {
|
||||
public interface AiAlertMapper extends BaseMapperX<AiAlert> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_alert (alert_id, camera_id, roi_id, bind_id, alert_type, target_class, " +
|
||||
"confidence, bbox, message, image_path, duration_minutes, extra_data, received_at) " +
|
||||
"VALUES (#{alertId}, #{cameraId}, #{roiId}, #{bindId}, #{alertType}, #{targetClass}, " +
|
||||
"#{confidence}, #{bbox}, #{message}, #{imagePath}, #{durationMinutes}, #{extraData}, #{receivedAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiAlert alert);
|
||||
|
||||
@Select("SELECT COUNT(1) FROM wvp_ai_alert WHERE alert_id=#{alertId}")
|
||||
@Select("SELECT COUNT(1) FROM wvp_ai_alert WHERE alert_id=#{alertId} AND deleted=0")
|
||||
int countByAlertId(@Param("alertId") String alertId);
|
||||
|
||||
@Select("SELECT a.*, r.name AS roi_name, " +
|
||||
@@ -23,7 +23,7 @@ public interface AiAlertMapper {
|
||||
"FROM wvp_ai_alert a " +
|
||||
"LEFT JOIN wvp_ai_roi r ON a.roi_id = r.roi_id " +
|
||||
"LEFT JOIN wvp_stream_proxy sp ON a.camera_id = sp.camera_code " +
|
||||
"WHERE a.alert_id=#{alertId}")
|
||||
"WHERE a.alert_id=#{alertId} AND a.deleted=0")
|
||||
@Results({
|
||||
@Result(property = "roiName", column = "roi_name"),
|
||||
@Result(property = "cameraName", column = "camera_name")
|
||||
@@ -36,7 +36,7 @@ public interface AiAlertMapper {
|
||||
"FROM wvp_ai_alert a " +
|
||||
"LEFT JOIN wvp_ai_roi r ON a.roi_id = r.roi_id " +
|
||||
"LEFT JOIN wvp_stream_proxy sp ON a.camera_id = sp.camera_code " +
|
||||
"WHERE 1=1 " +
|
||||
"WHERE a.deleted=0 " +
|
||||
"<if test='cameraId != null'> AND a.camera_id=#{cameraId}</if> " +
|
||||
"<if test='alertType != null'> AND a.alert_type=#{alertType}</if> " +
|
||||
"<if test='startTime != null'> AND a.received_at >= #{startTime}</if> " +
|
||||
@@ -47,30 +47,20 @@ public interface AiAlertMapper {
|
||||
@Result(property = "roiName", column = "roi_name"),
|
||||
@Result(property = "cameraName", column = "camera_name")
|
||||
})
|
||||
List<AiAlert> queryList(@Param("cameraId") String cameraId,
|
||||
@Param("alertType") String alertType,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_alert WHERE alert_id=#{alertId}")
|
||||
int deleteByAlertId(@Param("alertId") String alertId);
|
||||
|
||||
@Delete(value = {"<script>" +
|
||||
"DELETE FROM wvp_ai_alert WHERE alert_id IN " +
|
||||
"<foreach collection='alertIds' item='id' open='(' separator=',' close=')'>" +
|
||||
"#{id}" +
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
int deleteByAlertIds(@Param("alertIds") List<String> alertIds);
|
||||
IPage<AiAlert> queryList(IPage<AiAlert> page,
|
||||
@Param("cameraId") String cameraId,
|
||||
@Param("alertType") String alertType,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@Select("SELECT alert_type, COUNT(*) as cnt FROM wvp_ai_alert " +
|
||||
"WHERE received_at >= #{startTime} GROUP BY alert_type")
|
||||
"WHERE received_at >= #{startTime} AND deleted=0 GROUP BY alert_type")
|
||||
List<java.util.Map<String, Object>> statisticsByType(@Param("startTime") String startTime);
|
||||
|
||||
@Select("SELECT camera_id, COUNT(*) as cnt FROM wvp_ai_alert " +
|
||||
"WHERE received_at >= #{startTime} GROUP BY camera_id ORDER BY cnt DESC")
|
||||
"WHERE received_at >= #{startTime} AND deleted=0 GROUP BY camera_id ORDER BY cnt DESC")
|
||||
List<java.util.Map<String, Object>> statisticsByCamera(@Param("startTime") String startTime);
|
||||
|
||||
@Update("UPDATE wvp_ai_alert SET duration_minutes=#{durationMinutes} WHERE alert_id=#{alertId}")
|
||||
@Update("UPDATE wvp_ai_alert SET duration_minutes=#{durationMinutes} WHERE alert_id=#{alertId} AND deleted=0")
|
||||
int updateDuration(@Param("alertId") String alertId, @Param("durationMinutes") double durationMinutes);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,36 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlgoTemplate;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiAlgoTemplateMapper {
|
||||
public interface AiAlgoTemplateMapper extends BaseMapperX<AiAlgoTemplate> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_algo_template (template_id, template_name, algo_code, params, " +
|
||||
"description, create_time, update_time) " +
|
||||
"VALUES (#{templateId}, #{templateName}, #{algoCode}, #{params}, " +
|
||||
"#{description}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiAlgoTemplate template);
|
||||
default int add(AiAlgoTemplate template) {
|
||||
return insert(template);
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_algo_template SET template_name=#{templateName}, algo_code=#{algoCode}, " +
|
||||
"params=#{params}, description=#{description}, update_time=#{updateTime} " +
|
||||
"WHERE template_id=#{templateId}")
|
||||
int updateByTemplateId(AiAlgoTemplate template);
|
||||
default int updateByTemplateId(AiAlgoTemplate template) {
|
||||
return update(template, new LambdaQueryWrapper<AiAlgoTemplate>()
|
||||
.eq(AiAlgoTemplate::getTemplateId, template.getTemplateId()));
|
||||
}
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_algo_template WHERE template_id=#{templateId}")
|
||||
int deleteByTemplateId(@Param("templateId") String templateId);
|
||||
default int deleteByTemplateId(String templateId) {
|
||||
return delete(AiAlgoTemplate::getTemplateId, templateId);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_algo_template WHERE template_id=#{templateId}")
|
||||
AiAlgoTemplate queryByTemplateId(@Param("templateId") String templateId);
|
||||
default AiAlgoTemplate queryByTemplateId(String templateId) {
|
||||
return selectOne(AiAlgoTemplate::getTemplateId, templateId);
|
||||
}
|
||||
|
||||
@Select(value = {"<script>" +
|
||||
"SELECT * FROM wvp_ai_algo_template WHERE 1=1 " +
|
||||
"SELECT * FROM wvp_ai_algo_template WHERE deleted=0 " +
|
||||
"<if test='algoCode != null'> AND algo_code=#{algoCode}</if> " +
|
||||
"ORDER BY id DESC" +
|
||||
"</script>"})
|
||||
|
||||
@@ -1,40 +1,44 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlgorithm;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiAlgorithmMapper {
|
||||
public interface AiAlgorithmMapper extends BaseMapperX<AiAlgorithm> {
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_algorithm ORDER BY id")
|
||||
List<AiAlgorithm> queryAll();
|
||||
default List<AiAlgorithm> queryAll() {
|
||||
return selectList(new LambdaQueryWrapper<AiAlgorithm>().orderByAsc(AiAlgorithm::getId));
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_algorithm WHERE is_active=1 ORDER BY id")
|
||||
List<AiAlgorithm> queryActive();
|
||||
default List<AiAlgorithm> queryActive() {
|
||||
return selectList(new LambdaQueryWrapper<AiAlgorithm>()
|
||||
.eq(AiAlgorithm::getIsActive, 1)
|
||||
.orderByAsc(AiAlgorithm::getId));
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_algorithm WHERE algo_code=#{algoCode}")
|
||||
AiAlgorithm queryByCode(@Param("algoCode") String algoCode);
|
||||
default AiAlgorithm queryByCode(String algoCode) {
|
||||
return selectOne(AiAlgorithm::getAlgoCode, algoCode);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_algorithm WHERE id=#{id}")
|
||||
AiAlgorithm queryById(@Param("id") Integer id);
|
||||
default AiAlgorithm queryById(Long id) {
|
||||
return selectById(id);
|
||||
}
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_algorithm (algo_code, algo_name, target_class, param_schema, " +
|
||||
"description, is_active, sync_time, create_time, update_time) " +
|
||||
"VALUES (#{algoCode}, #{algoName}, #{targetClass}, #{paramSchema}, " +
|
||||
"#{description}, #{isActive}, #{syncTime}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiAlgorithm algorithm);
|
||||
default int add(AiAlgorithm algorithm) {
|
||||
return insert(algorithm);
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_algorithm SET algo_name=#{algoName}, target_class=#{targetClass}, " +
|
||||
"param_schema=#{paramSchema}, description=#{description}, is_active=#{isActive}, " +
|
||||
"sync_time=#{syncTime}, update_time=#{updateTime} WHERE algo_code=#{algoCode}")
|
||||
int updateByCode(AiAlgorithm algorithm);
|
||||
default int updateByCode(AiAlgorithm algorithm) {
|
||||
return update(algorithm, new LambdaQueryWrapper<AiAlgorithm>()
|
||||
.eq(AiAlgorithm::getAlgoCode, algorithm.getAlgoCode()));
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_algorithm SET is_active=#{isActive}, update_time=#{updateTime} WHERE id=#{id}")
|
||||
int updateActive(@Param("id") Integer id, @Param("isActive") Integer isActive, @Param("updateTime") String updateTime);
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_algorithm WHERE id=#{id}")
|
||||
int delete(@Param("id") Integer id);
|
||||
@Update("UPDATE wvp_ai_algorithm SET is_active=#{isActive}, update_time=#{updateTime} WHERE id=#{id} AND deleted=0")
|
||||
int updateActive(@Param("id") Long id, @Param("isActive") Integer isActive, @Param("updateTime") String updateTime);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigLog;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiConfigLogMapper {
|
||||
public interface AiConfigLogMapper extends BaseMapperX<AiConfigLog> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_config_log (config_type, config_id, old_value, new_value, updated_by, updated_at) " +
|
||||
"VALUES (#{configType}, #{configId}, #{oldValue}, #{newValue}, #{updatedBy}, #{updatedAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiConfigLog log);
|
||||
default int add(AiConfigLog log) {
|
||||
return insert(log);
|
||||
}
|
||||
|
||||
@Select(value = {"<script>" +
|
||||
"SELECT * FROM wvp_ai_config_log WHERE 1=1 " +
|
||||
"SELECT * FROM wvp_ai_config_log WHERE deleted=0 " +
|
||||
"<if test='configType != null'> AND config_type=#{configType}</if> " +
|
||||
"<if test='configId != null'> AND config_id=#{configId}</if> " +
|
||||
"ORDER BY id DESC" +
|
||||
"</script>"})
|
||||
List<AiConfigLog> queryList(@Param("configType") String configType,
|
||||
@Param("configId") String configId);
|
||||
IPage<AiConfigLog> queryList(IPage<AiConfigLog> page,
|
||||
@Param("configType") String configType,
|
||||
@Param("configId") String configId);
|
||||
}
|
||||
|
||||
@@ -1,41 +1,44 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigSnapshot;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiConfigSnapshotMapper {
|
||||
public interface AiConfigSnapshotMapper extends BaseMapperX<AiConfigSnapshot> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_config_snapshot (version, scope_type, scope_id, camera_id, snapshot, " +
|
||||
"change_type, change_desc, created_by, created_at) " +
|
||||
"VALUES (#{version}, #{scopeType}, #{scopeId}, #{cameraId}, #{snapshot}, " +
|
||||
"#{changeType}, #{changeDesc}, #{createdBy}, #{createdAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiConfigSnapshot snapshot);
|
||||
default int add(AiConfigSnapshot snapshot) {
|
||||
return insert(snapshot);
|
||||
}
|
||||
|
||||
default AiConfigSnapshot queryById(Long id) {
|
||||
return selectById(id);
|
||||
}
|
||||
|
||||
@Select("SELECT COALESCE(MAX(version), 0) FROM wvp_ai_config_snapshot " +
|
||||
"WHERE scope_type=#{scopeType} AND scope_id=#{scopeId}")
|
||||
"WHERE scope_type=#{scopeType} AND scope_id=#{scopeId} AND deleted=0")
|
||||
int getMaxVersion(@Param("scopeType") String scopeType, @Param("scopeId") String scopeId);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_config_snapshot WHERE id=#{id}")
|
||||
AiConfigSnapshot queryById(@Param("id") Long id);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_config_snapshot " +
|
||||
"WHERE scope_type=#{scopeType} AND scope_id=#{scopeId} AND version=#{version}")
|
||||
"WHERE scope_type=#{scopeType} AND scope_id=#{scopeId} AND version=#{version} AND deleted=0")
|
||||
AiConfigSnapshot queryByVersion(@Param("scopeType") String scopeType,
|
||||
@Param("scopeId") String scopeId,
|
||||
@Param("version") Integer version);
|
||||
|
||||
@Select(value = {"<script>" +
|
||||
"SELECT * FROM wvp_ai_config_snapshot WHERE 1=1 " +
|
||||
"SELECT * FROM wvp_ai_config_snapshot WHERE deleted=0 " +
|
||||
"<if test='scopeType != null'> AND scope_type=#{scopeType}</if> " +
|
||||
"<if test='scopeId != null'> AND scope_id=#{scopeId}</if> " +
|
||||
"<if test='cameraId != null'> AND camera_id=#{cameraId}</if> " +
|
||||
"ORDER BY version DESC" +
|
||||
"</script>"})
|
||||
List<AiConfigSnapshot> queryList(@Param("scopeType") String scopeType,
|
||||
@Param("scopeId") String scopeId,
|
||||
@Param("cameraId") String cameraId);
|
||||
IPage<AiConfigSnapshot> queryList(IPage<AiConfigSnapshot> page,
|
||||
@Param("scopeType") String scopeType,
|
||||
@Param("scopeId") String scopeId,
|
||||
@Param("cameraId") String cameraId);
|
||||
}
|
||||
|
||||
@@ -1,57 +1,60 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiEdgeDevice;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiEdgeDeviceMapper {
|
||||
public interface AiEdgeDeviceMapper extends BaseMapperX<AiEdgeDevice> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_edge_device (device_id, status, last_heartbeat, uptime_seconds, " +
|
||||
"frames_processed, alerts_generated, stream_stats, stream_count, config_version, updated_at) " +
|
||||
"VALUES (#{deviceId}, #{status}, #{lastHeartbeat}, #{uptimeSeconds}, " +
|
||||
"#{framesProcessed}, #{alertsGenerated}, #{streamStats}, #{streamCount}, #{configVersion}, #{updatedAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiEdgeDevice device);
|
||||
default int add(AiEdgeDevice device) {
|
||||
return insert(device);
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_edge_device SET status=#{status}, last_heartbeat=#{lastHeartbeat}, " +
|
||||
"uptime_seconds=#{uptimeSeconds}, frames_processed=#{framesProcessed}, " +
|
||||
"alerts_generated=#{alertsGenerated}, stream_stats=#{streamStats}, " +
|
||||
"stream_count=#{streamCount}, config_version=#{configVersion}, " +
|
||||
"updated_at=#{updatedAt} WHERE device_id=#{deviceId}")
|
||||
int updateByDeviceId(AiEdgeDevice device);
|
||||
default int updateByDeviceId(AiEdgeDevice device) {
|
||||
return update(device, new LambdaQueryWrapper<AiEdgeDevice>()
|
||||
.eq(AiEdgeDevice::getDeviceId, device.getDeviceId()));
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_edge_device WHERE device_id=#{deviceId}")
|
||||
AiEdgeDevice queryByDeviceId(@Param("deviceId") String deviceId);
|
||||
default AiEdgeDevice queryByDeviceId(String deviceId) {
|
||||
return selectOne(AiEdgeDevice::getDeviceId, deviceId);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_edge_device ORDER BY updated_at DESC")
|
||||
List<AiEdgeDevice> queryAll();
|
||||
default List<AiEdgeDevice> queryAll() {
|
||||
return selectList(new LambdaQueryWrapper<AiEdgeDevice>().orderByDesc(AiEdgeDevice::getUpdatedAt));
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_edge_device SET status='offline', updated_at=#{now} " +
|
||||
"WHERE status='online' AND last_heartbeat < #{threshold}")
|
||||
"WHERE status='online' AND last_heartbeat < #{threshold} AND deleted=0")
|
||||
int markOffline(@Param("threshold") String threshold, @Param("now") String now);
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_edge_device WHERE device_id != #{keepDeviceId}")
|
||||
@Update("UPDATE wvp_ai_edge_device SET deleted=1 WHERE device_id != #{keepDeviceId} AND deleted=0")
|
||||
int deleteAllExcept(@Param("keepDeviceId") String keepDeviceId);
|
||||
|
||||
@Update("UPDATE wvp_ai_edge_device SET device_id=#{newDeviceId} WHERE id=#{id}")
|
||||
int renameDeviceId(@Param("id") Integer id, @Param("newDeviceId") String newDeviceId);
|
||||
@Update("UPDATE wvp_ai_edge_device SET device_id=#{newDeviceId} WHERE id=#{id} AND deleted=0")
|
||||
int renameDeviceId(@Param("id") Long id, @Param("newDeviceId") String newDeviceId);
|
||||
|
||||
@Update("UPDATE wvp_ai_edge_device SET device_id=#{newDeviceId} WHERE device_id=#{oldDeviceId}")
|
||||
@Update("UPDATE wvp_ai_edge_device SET device_id=#{newDeviceId} WHERE device_id=#{oldDeviceId} AND deleted=0")
|
||||
int renameByDeviceId(@Param("oldDeviceId") String oldDeviceId, @Param("newDeviceId") String newDeviceId);
|
||||
|
||||
@Select({"<script>" +
|
||||
"SELECT * FROM wvp_ai_edge_device " +
|
||||
"WHERE 1=1 " +
|
||||
"WHERE deleted=0 " +
|
||||
"<if test='status != null'> AND status=#{status}</if> " +
|
||||
"ORDER BY updated_at DESC" +
|
||||
"</script>"})
|
||||
List<AiEdgeDevice> queryPage(@Param("status") String status);
|
||||
IPage<AiEdgeDevice> queryPage(IPage<AiEdgeDevice> page, @Param("status") String status);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM wvp_ai_edge_device WHERE status=#{status}")
|
||||
@Select("SELECT COUNT(*) FROM wvp_ai_edge_device WHERE status=#{status} AND deleted=0")
|
||||
int countByStatus(@Param("status") String status);
|
||||
|
||||
@Select("SELECT COUNT(*) FROM wvp_ai_edge_device")
|
||||
@Select("SELECT COUNT(*) FROM wvp_ai_edge_device WHERE deleted=0")
|
||||
int countAll();
|
||||
}
|
||||
|
||||
@@ -1,48 +1,54 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoiAlgoBind;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiRoiAlgoBindMapper {
|
||||
public interface AiRoiAlgoBindMapper extends BaseMapperX<AiRoiAlgoBind> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_roi_algo_bind (bind_id, roi_id, algo_code, params, priority, enabled, " +
|
||||
"template_id, param_override, create_time, update_time) " +
|
||||
"VALUES (#{bindId}, #{roiId}, #{algoCode}, #{params}, #{priority}, #{enabled}, " +
|
||||
"#{templateId}, #{paramOverride}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiRoiAlgoBind bind);
|
||||
default int add(AiRoiAlgoBind bind) {
|
||||
return insert(bind);
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_roi_algo_bind SET params=#{params}, priority=#{priority}, " +
|
||||
"enabled=#{enabled}, template_id=#{templateId}, param_override=#{paramOverride}, " +
|
||||
"update_time=#{updateTime} WHERE bind_id=#{bindId}")
|
||||
int updateByBindId(AiRoiAlgoBind bind);
|
||||
default int updateByBindId(AiRoiAlgoBind bind) {
|
||||
return update(bind, new LambdaQueryWrapper<AiRoiAlgoBind>()
|
||||
.eq(AiRoiAlgoBind::getBindId, bind.getBindId()));
|
||||
}
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_roi_algo_bind WHERE bind_id=#{bindId}")
|
||||
int deleteByBindId(@Param("bindId") String bindId);
|
||||
default int deleteByBindId(String bindId) {
|
||||
return delete(AiRoiAlgoBind::getBindId, bindId);
|
||||
}
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_roi_algo_bind WHERE roi_id=#{roiId}")
|
||||
int deleteByRoiId(@Param("roiId") String roiId);
|
||||
default int deleteByRoiId(String roiId) {
|
||||
return delete(AiRoiAlgoBind::getRoiId, roiId);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE roi_id=#{roiId} ORDER BY priority DESC, id")
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE roi_id=#{roiId} AND deleted=0 ORDER BY priority DESC, id")
|
||||
List<AiRoiAlgoBind> queryByRoiId(@Param("roiId") String roiId);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE bind_id=#{bindId}")
|
||||
AiRoiAlgoBind queryByBindId(@Param("bindId") String bindId);
|
||||
default AiRoiAlgoBind queryByBindId(String bindId) {
|
||||
return selectOne(AiRoiAlgoBind::getBindId, bindId);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE roi_id=#{roiId} AND algo_code=#{algoCode}")
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE roi_id=#{roiId} AND algo_code=#{algoCode} AND deleted=0")
|
||||
AiRoiAlgoBind queryByRoiIdAndAlgoCode(@Param("roiId") String roiId, @Param("algoCode") String algoCode);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind WHERE template_id=#{templateId}")
|
||||
List<AiRoiAlgoBind> queryByTemplateId(@Param("templateId") String templateId);
|
||||
default List<AiRoiAlgoBind> queryByTemplateId(String templateId) {
|
||||
return selectList(AiRoiAlgoBind::getTemplateId, templateId);
|
||||
}
|
||||
|
||||
@Select("SELECT b.* FROM wvp_ai_roi_algo_bind b " +
|
||||
"INNER JOIN wvp_ai_roi r ON b.roi_id = r.roi_id " +
|
||||
"WHERE r.camera_id=#{cameraId} ORDER BY b.priority DESC, b.id")
|
||||
"WHERE r.camera_id=#{cameraId} AND b.deleted=0 AND r.deleted=0 ORDER BY b.priority DESC, b.id")
|
||||
List<AiRoiAlgoBind> queryByCameraId(@Param("cameraId") String cameraId);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi_algo_bind ORDER BY priority DESC, id")
|
||||
List<AiRoiAlgoBind> queryAll();
|
||||
default List<AiRoiAlgoBind> queryAll() {
|
||||
return selectList(new LambdaQueryWrapper<AiRoiAlgoBind>().orderByDesc(AiRoiAlgoBind::getPriority).orderByAsc(AiRoiAlgoBind::getId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,83 @@
|
||||
package com.viewsh.module.video.aiot.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoi;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AiRoiMapper {
|
||||
public interface AiRoiMapper extends BaseMapperX<AiRoi> {
|
||||
|
||||
@Insert("INSERT INTO wvp_ai_roi (roi_id, camera_id, channel_db_id, device_id, name, roi_type, " +
|
||||
"coordinates, color, priority, enabled, extra_params, description, create_time, update_time) " +
|
||||
"VALUES (#{roiId}, #{cameraId}, #{channelDbId}, #{deviceId}, #{name}, #{roiType}, " +
|
||||
"#{coordinates}, #{color}, #{priority}, #{enabled}, #{extraParams}, #{description}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(AiRoi roi);
|
||||
default int add(AiRoi roi) {
|
||||
return insert(roi);
|
||||
}
|
||||
|
||||
@Update("UPDATE wvp_ai_roi SET camera_id=#{cameraId}, channel_db_id=#{channelDbId}, device_id=#{deviceId}, " +
|
||||
"name=#{name}, roi_type=#{roiType}, coordinates=#{coordinates}, color=#{color}, " +
|
||||
"priority=#{priority}, enabled=#{enabled}, extra_params=#{extraParams}, " +
|
||||
"description=#{description}, update_time=#{updateTime} WHERE id=#{id}")
|
||||
int update(AiRoi roi);
|
||||
default int update(AiRoi roi) {
|
||||
return updateById(roi);
|
||||
}
|
||||
|
||||
@Delete("DELETE FROM wvp_ai_roi WHERE roi_id=#{roiId}")
|
||||
int deleteByRoiId(@Param("roiId") String roiId);
|
||||
default int deleteByRoiId(String roiId) {
|
||||
return delete(AiRoi::getRoiId, roiId);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE id=#{id}")
|
||||
AiRoi queryById(@Param("id") Integer id);
|
||||
default AiRoi queryById(Long id) {
|
||||
return selectById(id);
|
||||
}
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE roi_id=#{roiId}")
|
||||
AiRoi queryByRoiId(@Param("roiId") String roiId);
|
||||
default AiRoi queryByRoiId(String roiId) {
|
||||
return selectOne(AiRoi::getRoiId, roiId);
|
||||
}
|
||||
|
||||
@Select(value = {"<script>" +
|
||||
"SELECT * FROM wvp_ai_roi WHERE 1=1 " +
|
||||
"SELECT * FROM wvp_ai_roi WHERE deleted=0 " +
|
||||
"<if test='cameraId != null'> AND camera_id=#{cameraId}</if> " +
|
||||
"<if test='deviceId != null'> AND device_id=#{deviceId}</if> " +
|
||||
"<if test='query != null'> AND (name LIKE concat('%',#{query},'%') OR camera_id LIKE concat('%',#{query},'%'))</if> " +
|
||||
"ORDER BY priority DESC, id DESC" +
|
||||
"</script>"})
|
||||
List<AiRoi> queryList(@Param("cameraId") String cameraId,
|
||||
@Param("deviceId") String deviceId,
|
||||
@Param("query") String query);
|
||||
IPage<AiRoi> queryList(IPage<AiRoi> page,
|
||||
@Param("cameraId") String cameraId,
|
||||
@Param("deviceId") String deviceId,
|
||||
@Param("query") String query);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id=#{cameraId} AND enabled=1 ORDER BY priority DESC")
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id=#{cameraId} AND enabled=1 AND deleted=0 ORDER BY priority DESC")
|
||||
List<AiRoi> queryByCameraId(@Param("cameraId") String cameraId);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id=#{cameraId} ORDER BY priority DESC")
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id=#{cameraId} AND deleted=0 ORDER BY priority DESC")
|
||||
List<AiRoi> queryAllByCameraId(@Param("cameraId") String cameraId);
|
||||
|
||||
@Select("SELECT * FROM wvp_ai_roi ORDER BY priority DESC, id DESC")
|
||||
List<AiRoi> queryAll();
|
||||
default List<AiRoi> queryAll() {
|
||||
return selectList(new LambdaQueryWrapper<AiRoi>().orderByDesc(AiRoi::getPriority).orderByDesc(AiRoi::getId));
|
||||
}
|
||||
|
||||
@Select("SELECT DISTINCT camera_id FROM wvp_ai_roi WHERE device_id=#{deviceId}")
|
||||
@Select("SELECT DISTINCT camera_id FROM wvp_ai_roi WHERE device_id=#{deviceId} AND deleted=0")
|
||||
List<String> queryDistinctCameraIdsByDeviceId(@Param("deviceId") String deviceId);
|
||||
|
||||
@Select("SELECT DISTINCT device_id FROM wvp_ai_roi WHERE camera_id=#{cameraId} AND device_id IS NOT NULL LIMIT 1")
|
||||
@Select("SELECT DISTINCT device_id FROM wvp_ai_roi WHERE camera_id=#{cameraId} AND device_id IS NOT NULL AND deleted=0 LIMIT 1")
|
||||
String queryDeviceIdByCameraId(@Param("cameraId") String cameraId);
|
||||
|
||||
@Update("UPDATE wvp_ai_roi SET device_id=#{deviceId} WHERE device_id IS NULL OR device_id=''")
|
||||
@Update("UPDATE wvp_ai_roi SET device_id=#{deviceId} WHERE (device_id IS NULL OR device_id='') AND deleted=0")
|
||||
int backfillDeviceId(@Param("deviceId") String deviceId);
|
||||
|
||||
@Update("UPDATE wvp_ai_roi SET device_id=#{deviceId}")
|
||||
@Update("UPDATE wvp_ai_roi SET device_id=#{deviceId} WHERE deleted=0")
|
||||
int updateAllDeviceId(@Param("deviceId") String deviceId);
|
||||
|
||||
/**
|
||||
* 将 ROI 表中 camera_id 从 app/stream 格式更新为 camera_code
|
||||
*/
|
||||
@Update("UPDATE wvp_ai_roi SET camera_id = #{cameraCode} WHERE camera_id = #{oldCameraId}")
|
||||
@Update("UPDATE wvp_ai_roi SET camera_id = #{cameraCode} WHERE camera_id = #{oldCameraId} AND deleted=0")
|
||||
int updateCameraId(@Param("oldCameraId") String oldCameraId, @Param("cameraCode") String cameraCode);
|
||||
|
||||
/**
|
||||
* 查询使用非 camera_code 格式的 ROI(即 camera_id 不以 cam_ 开头的记录)
|
||||
*/
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id NOT LIKE 'cam_%'")
|
||||
@Select("SELECT * FROM wvp_ai_roi WHERE camera_id NOT LIKE 'cam_%' AND deleted=0")
|
||||
List<AiRoi> queryWithLegacyCameraId();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.viewsh.module.video.aiot.service;
|
||||
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlert;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -12,7 +12,7 @@ public interface IAiAlertService {
|
||||
|
||||
AiAlert queryByAlertId(String alertId);
|
||||
|
||||
PageInfo<AiAlert> queryList(String cameraId, String alertType, String startTime, String endTime, int page, int count);
|
||||
PageResult<AiAlert> queryList(String cameraId, String alertType, String startTime, String endTime, int page, int count);
|
||||
|
||||
void delete(String alertId);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IAiAlgorithmService {
|
||||
|
||||
List<AiAlgorithm> queryActive();
|
||||
|
||||
void toggleActive(Integer id, Integer isActive);
|
||||
void toggleActive(Long id, Integer isActive);
|
||||
|
||||
void syncFromEdge();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.viewsh.module.video.aiot.service;
|
||||
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigLog;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
public interface IAiConfigLogService {
|
||||
|
||||
void addLog(String configType, String configId, String oldValue, String newValue, String updatedBy);
|
||||
|
||||
PageInfo<AiConfigLog> queryList(String configType, String configId, int page, int count);
|
||||
PageResult<AiConfigLog> queryList(String configType, String configId, int page, int count);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.viewsh.module.video.aiot.service;
|
||||
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigSnapshot;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IAiConfigSnapshotService {
|
||||
/**
|
||||
* 查询版本列表
|
||||
*/
|
||||
PageInfo<AiConfigSnapshot> queryVersions(String scopeType, String scopeId, String cameraId, int page, int count);
|
||||
PageResult<AiConfigSnapshot> queryVersions(String scopeType, String scopeId, String cameraId, int page, int count);
|
||||
|
||||
/**
|
||||
* 查看快照详情
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.viewsh.module.video.aiot.service;
|
||||
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiEdgeDevice;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -16,7 +16,7 @@ public interface IAiEdgeDeviceService {
|
||||
|
||||
void checkOffline();
|
||||
|
||||
PageInfo<AiEdgeDevice> queryPage(int page, int count, String status);
|
||||
PageResult<AiEdgeDevice> queryPage(int page, int count, String status);
|
||||
|
||||
Map<String, Object> getStatistics();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.viewsh.module.video.aiot.service;
|
||||
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoi;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoiAlgoBind;
|
||||
import com.viewsh.module.video.aiot.bean.AiRoiDetail;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,11 +13,11 @@ public interface IAiRoiService {
|
||||
|
||||
void delete(String roiId);
|
||||
|
||||
AiRoiDetail queryDetail(Integer id);
|
||||
AiRoiDetail queryDetail(Long id);
|
||||
|
||||
List<AiRoi> queryByCameraId(String cameraId);
|
||||
|
||||
PageInfo<AiRoi> queryList(String cameraId, String deviceId, String query, int page, int count);
|
||||
PageResult<AiRoi> queryList(String cameraId, String deviceId, String query, int page, int count);
|
||||
|
||||
void bindAlgo(AiRoiAlgoBind bind);
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.viewsh.module.video.aiot.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiAlert;
|
||||
import com.viewsh.module.video.aiot.dao.AiAlertMapper;
|
||||
import com.viewsh.module.video.aiot.service.IAiAlertService;
|
||||
import com.viewsh.module.video.aiot.util.CosUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -38,7 +39,7 @@ public class AiAlertServiceImpl implements IAiAlertService {
|
||||
log.debug("[AiAlert] 告警已存在, 跳过: alertId={}", alert.getAlertId());
|
||||
return;
|
||||
}
|
||||
alertMapper.add(alert);
|
||||
alertMapper.insert(alert);
|
||||
log.info("[AiAlert] 告警入库: alertId={}, type={}, camera={}", alert.getAlertId(), alert.getAlertType(), alert.getCameraId());
|
||||
}
|
||||
|
||||
@@ -48,21 +49,21 @@ public class AiAlertServiceImpl implements IAiAlertService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AiAlert> queryList(String cameraId, String alertType, String startTime, String endTime, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<AiAlert> list = alertMapper.queryList(cameraId, alertType, startTime, endTime);
|
||||
return new PageInfo<>(list);
|
||||
public PageResult<AiAlert> queryList(String cameraId, String alertType, String startTime, String endTime, int page, int count) {
|
||||
IPage<AiAlert> ipage = new Page<>(page, count);
|
||||
IPage<AiAlert> result = alertMapper.queryList(ipage, cameraId, alertType, startTime, endTime);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String alertId) {
|
||||
alertMapper.deleteByAlertId(alertId);
|
||||
alertMapper.delete(AiAlert::getAlertId, alertId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(List<String> alertIds) {
|
||||
if (alertIds != null && !alertIds.isEmpty()) {
|
||||
alertMapper.deleteByAlertIds(alertIds);
|
||||
alertMapper.deleteBatch(AiAlert::getAlertId, alertIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@@ -35,14 +33,9 @@ public class AiAlgoTemplateServiceImpl implements IAiAlgoTemplateService {
|
||||
@Autowired
|
||||
private IAiRedisConfigService redisConfigService;
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AiAlgoTemplate template) {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
template.setUpdateTime(now);
|
||||
|
||||
if (!ObjectUtils.isEmpty(template.getTemplateId())) {
|
||||
AiAlgoTemplate existing = templateMapper.queryByTemplateId(template.getTemplateId());
|
||||
if (existing != null) {
|
||||
@@ -57,7 +50,6 @@ public class AiAlgoTemplateServiceImpl implements IAiAlgoTemplateService {
|
||||
if (ObjectUtils.isEmpty(template.getTemplateId())) {
|
||||
template.setTemplateId(UUID.randomUUID().toString());
|
||||
}
|
||||
template.setCreateTime(now);
|
||||
templateMapper.add(template);
|
||||
log.info("[AiTemplate] 创建模板: templateId={}", template.getTemplateId());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
|
||||
@PostConstruct
|
||||
public void initPresetAlgorithms() {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
for (Map.Entry<String, String[]> entry : PRESET_ALGORITHMS.entrySet()) {
|
||||
String code = entry.getKey();
|
||||
String[] vals = entry.getValue();
|
||||
@@ -72,8 +71,6 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
algo.setDescription(vals[2]);
|
||||
algo.setParamSchema(vals[3]);
|
||||
algo.setIsActive(1);
|
||||
algo.setCreateTime(now);
|
||||
algo.setUpdateTime(now);
|
||||
algorithmMapper.add(algo);
|
||||
log.info("[AI算法] 初始化预置算法: {}", code);
|
||||
} else {
|
||||
@@ -81,7 +78,6 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
existing.setTargetClass(vals[1]);
|
||||
existing.setDescription(vals[2]);
|
||||
existing.setParamSchema(vals[3]);
|
||||
existing.setUpdateTime(now);
|
||||
algorithmMapper.updateByCode(existing);
|
||||
log.info("[AI算法] 校正预置算法数据: {}", code);
|
||||
}
|
||||
@@ -99,7 +95,7 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleActive(Integer id, Integer isActive) {
|
||||
public void toggleActive(Long id, Integer isActive) {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
algorithmMapper.updateActive(id, isActive, now);
|
||||
configLogService.addLog("ALGORITHM", String.valueOf(id),
|
||||
@@ -131,7 +127,6 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
existing.setParamSchema(remote.get("param_schema") != null ? remote.get("param_schema").toString() : null);
|
||||
existing.setDescription((String) remote.get("description"));
|
||||
existing.setSyncTime(now);
|
||||
existing.setUpdateTime(now);
|
||||
algorithmMapper.updateByCode(existing);
|
||||
} else {
|
||||
AiAlgorithm algo = new AiAlgorithm();
|
||||
@@ -142,8 +137,6 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
algo.setDescription((String) remote.get("description"));
|
||||
algo.setIsActive(1);
|
||||
algo.setSyncTime(now);
|
||||
algo.setCreateTime(now);
|
||||
algo.setUpdateTime(now);
|
||||
algorithmMapper.add(algo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.viewsh.module.video.aiot.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.bean.AiConfigLog;
|
||||
import com.viewsh.module.video.aiot.dao.AiConfigLogMapper;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigLogService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,9 +36,9 @@ public class AiConfigLogServiceImpl implements IAiConfigLogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AiConfigLog> queryList(String configType, String configId, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<AiConfigLog> list = configLogMapper.queryList(configType, configId);
|
||||
return new PageInfo<>(list);
|
||||
public PageResult<AiConfigLog> queryList(String configType, String configId, int page, int count) {
|
||||
IPage<AiConfigLog> ipage = new Page<>(page, count);
|
||||
IPage<AiConfigLog> result = configLogMapper.queryList(ipage, configType, configId);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,12 @@ import com.viewsh.module.video.aiot.bean.*;
|
||||
import com.viewsh.module.video.aiot.dao.AiConfigSnapshotMapper;
|
||||
import com.viewsh.module.video.aiot.dao.AiRoiAlgoBindMapper;
|
||||
import com.viewsh.module.video.aiot.dao.AiRoiMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigService;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigSnapshotService;
|
||||
import com.viewsh.module.video.aiot.service.IAiRedisConfigService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -64,10 +65,10 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AiConfigSnapshot> queryVersions(String scopeType, String scopeId, String cameraId, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<AiConfigSnapshot> list = snapshotMapper.queryList(scopeType, scopeId, cameraId);
|
||||
return new PageInfo<>(list);
|
||||
public PageResult<AiConfigSnapshot> queryVersions(String scopeType, String scopeId, String cameraId, int page, int count) {
|
||||
IPage<AiConfigSnapshot> ipage = new Page<>(page, count);
|
||||
IPage<AiConfigSnapshot> result = snapshotMapper.queryList(ipage, scopeType, scopeId, cameraId);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +98,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
}
|
||||
|
||||
// 从快照恢复
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
if (rois != null) {
|
||||
for (int i = 0; i < rois.size(); i++) {
|
||||
JSONObject roiJson = rois.getJSONObject(i);
|
||||
@@ -111,8 +111,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
JSON.toJSONString(roiJson.get("coordinates")) : null);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
roi.setPriority(roiJson.getIntValue("priority"));
|
||||
roi.setCreateTime(now);
|
||||
roi.setUpdateTime(now);
|
||||
roiMapper.add(roi);
|
||||
|
||||
JSONArray algos = roiJson.getJSONArray("algorithms");
|
||||
@@ -130,8 +128,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setPriority(algoJson.getIntValue("priority"));
|
||||
bind.setTemplateId(algoJson.getString("template_id"));
|
||||
bind.setParamOverride(algoJson.getString("param_override"));
|
||||
bind.setCreateTime(now);
|
||||
bind.setUpdateTime(now);
|
||||
bindMapper.add(bind);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +168,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bindMapper.deleteByRoiId(roiId);
|
||||
|
||||
// 更新ROI
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
AiRoi roi = roiMapper.queryByRoiId(roiId);
|
||||
if (roi == null) {
|
||||
roi = new AiRoi();
|
||||
@@ -181,7 +176,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
// 填充 deviceId(新建 ROI 时需要)
|
||||
String deviceId = roiMapper.queryDeviceIdByCameraId(cameraId);
|
||||
roi.setDeviceId(deviceId);
|
||||
roi.setCreateTime(now);
|
||||
}
|
||||
roi.setRoiType(roiJson.getString("roi_type"));
|
||||
roi.setName(roiJson.getString("name"));
|
||||
@@ -189,7 +183,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
JSON.toJSONString(roiJson.get("coordinates")) : null);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
roi.setPriority(roiJson.getIntValue("priority"));
|
||||
roi.setUpdateTime(now);
|
||||
|
||||
if (roi.getId() != null) {
|
||||
roiMapper.update(roi);
|
||||
@@ -213,8 +206,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setPriority(algoJson.getIntValue("priority"));
|
||||
bind.setTemplateId(algoJson.getString("template_id"));
|
||||
bind.setParamOverride(algoJson.getString("param_override"));
|
||||
bind.setCreateTime(now);
|
||||
bind.setUpdateTime(now);
|
||||
bindMapper.add(bind);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +239,6 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
|
||||
JSONObject bindJson = JSON.parseObject(snapshot.getSnapshot());
|
||||
String cameraId = snapshot.getCameraId();
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
|
||||
AiRoiAlgoBind bind = bindMapper.queryByBindId(bindId);
|
||||
if (bind == null) {
|
||||
@@ -256,14 +246,12 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setBindId(bindId);
|
||||
bind.setRoiId(bindJson.getString("roi_id"));
|
||||
bind.setAlgoCode(bindJson.getString("algo_code"));
|
||||
bind.setCreateTime(now);
|
||||
}
|
||||
bind.setParams(bindJson.containsKey("params") ? JSON.toJSONString(bindJson.get("params")) : null);
|
||||
bind.setEnabled(bindJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
bind.setPriority(bindJson.getIntValue("priority"));
|
||||
bind.setTemplateId(bindJson.getString("template_id"));
|
||||
bind.setParamOverride(bindJson.getString("param_override"));
|
||||
bind.setUpdateTime(now);
|
||||
|
||||
if (bind.getId() != null) {
|
||||
bindMapper.updateByBindId(bind);
|
||||
|
||||
@@ -5,8 +5,9 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.viewsh.module.video.aiot.bean.AiEdgeDevice;
|
||||
import com.viewsh.module.video.aiot.dao.AiEdgeDeviceMapper;
|
||||
import com.viewsh.module.video.aiot.service.IAiEdgeDeviceService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@@ -92,10 +93,10 @@ public class AiEdgeDeviceServiceImpl implements IAiEdgeDeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AiEdgeDevice> queryPage(int page, int count, String status) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<AiEdgeDevice> list = deviceMapper.queryPage(status);
|
||||
return new PageInfo<>(list);
|
||||
public PageResult<AiEdgeDevice> queryPage(int page, int count, String status) {
|
||||
IPage<AiEdgeDevice> ipage = new Page<>(page, count);
|
||||
IPage<AiEdgeDevice> result = deviceMapper.queryPage(ipage, status);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,16 +7,15 @@ import com.viewsh.module.video.aiot.dao.AiRoiMapper;
|
||||
import com.viewsh.module.video.aiot.service.IAiConfigLogService;
|
||||
import com.viewsh.module.video.aiot.service.IAiRoiService;
|
||||
import com.viewsh.module.video.streamProxy.dao.StreamProxyMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.viewsh.framework.common.pojo.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -40,13 +39,9 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
@Autowired
|
||||
private IAiConfigLogService configLogService;
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AiRoi roi) {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
roi.setUpdateTime(now);
|
||||
|
||||
// 自动填充 deviceId(边缘设备关联)
|
||||
if (ObjectUtils.isEmpty(roi.getDeviceId()) && !ObjectUtils.isEmpty(roi.getCameraId())) {
|
||||
@@ -68,7 +63,6 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
if (ObjectUtils.isEmpty(roi.getRoiId())) {
|
||||
roi.setRoiId(UUID.randomUUID().toString());
|
||||
}
|
||||
roi.setCreateTime(now);
|
||||
if (roi.getEnabled() == null) {
|
||||
roi.setEnabled(1);
|
||||
}
|
||||
@@ -116,7 +110,7 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiRoiDetail queryDetail(Integer id) {
|
||||
public AiRoiDetail queryDetail(Long id) {
|
||||
AiRoi roi = roiMapper.queryById(id);
|
||||
if (roi == null) {
|
||||
return null;
|
||||
@@ -143,16 +137,15 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<AiRoi> queryList(String cameraId, String deviceId, String query, int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<AiRoi> list = roiMapper.queryList(cameraId, deviceId, query);
|
||||
return new PageInfo<>(list);
|
||||
public PageResult<AiRoi> queryList(String cameraId, String deviceId, String query, int page, int count) {
|
||||
IPage<AiRoi> ipage = new Page<>(page, count);
|
||||
IPage<AiRoi> result = roiMapper.queryList(ipage, cameraId, deviceId, query);
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void bindAlgo(AiRoiAlgoBind bind) {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
AiRoiAlgoBind existing = bindMapper.queryByRoiIdAndAlgoCode(bind.getRoiId(), bind.getAlgoCode());
|
||||
if (existing != null) {
|
||||
throw new IllegalArgumentException("该ROI已绑定此算法");
|
||||
@@ -166,8 +159,6 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
if (bind.getPriority() == null) {
|
||||
bind.setPriority(0);
|
||||
}
|
||||
bind.setCreateTime(now);
|
||||
bind.setUpdateTime(now);
|
||||
bindMapper.add(bind);
|
||||
configLogService.addLog("BIND", bind.getBindId(), null, toJson(bind), null);
|
||||
}
|
||||
@@ -186,7 +177,6 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateAlgoParams(AiRoiAlgoBind bind) {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
AiRoiAlgoBind old = bindMapper.queryByBindId(bind.getBindId());
|
||||
if (old == null) {
|
||||
throw new IllegalArgumentException("绑定关系不存在");
|
||||
@@ -197,7 +187,6 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
if (bind.getEnabled() == null) bind.setEnabled(old.getEnabled());
|
||||
if (bind.getTemplateId() == null) bind.setTemplateId(old.getTemplateId());
|
||||
if (bind.getParamOverride() == null) bind.setParamOverride(old.getParamOverride());
|
||||
bind.setUpdateTime(now);
|
||||
bindMapper.updateByBindId(bind);
|
||||
configLogService.addLog("BIND", bind.getBindId(), toJson(old), toJson(bind), null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user