新增AI预警设置
This commit is contained in:
parent
d14da94715
commit
86aabebb80
|
|
@ -0,0 +1,71 @@
|
|||
package com.multictrl.modules.business.controller;
|
||||
|
||||
import com.multictrl.common.annotation.ApiOrder;
|
||||
import com.multictrl.common.annotation.LogOperation;
|
||||
import com.multictrl.common.utils.Result;
|
||||
import com.multictrl.common.validator.ValidatorUtils;
|
||||
import com.multictrl.common.validator.group.AddGroup;
|
||||
import com.multictrl.common.validator.group.DefaultGroup;
|
||||
import com.multictrl.common.validator.group.UpdateGroup;
|
||||
import com.multictrl.modules.business.dto.AiWarningDTO;
|
||||
import com.multictrl.modules.business.service.AiWarningService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("business/ai/warning")
|
||||
@Tag(name = "AI识别预警")
|
||||
@ApiOrder(26)
|
||||
@RequiredArgsConstructor
|
||||
public class AiWarningController {
|
||||
private final AiWarningService aiWarningService;
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "设置ai预警")
|
||||
@LogOperation("设置ai预警")
|
||||
@RequiresPermissions("bus:ai:warning:save")
|
||||
public Result<Object> save(@RequestBody AiWarningDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class);
|
||||
aiWarningService.save(dto);
|
||||
|
||||
return new Result<>();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改ai预警")
|
||||
@LogOperation("修改ai预警")
|
||||
@RequiresPermissions("bus:ai:warning:update")
|
||||
public Result<Object> update(@RequestBody AiWarningDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class);
|
||||
aiWarningService.update(dto);
|
||||
|
||||
return new Result<>();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "获取预警信息")
|
||||
@RequiresPermissions("bus:ai:warning:get")
|
||||
public Result<List<AiWarningDTO>> get() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("status", "1");
|
||||
List<AiWarningDTO> list = aiWarningService.list(map);
|
||||
|
||||
return new Result<List<AiWarningDTO>>().ok(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.multictrl.modules.business.dao;
|
||||
|
||||
import com.multictrl.common.dao.BaseDao;
|
||||
import com.multictrl.modules.business.entity.AiWarningEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiWarningDao extends BaseDao<AiWarningEntity> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.multictrl.modules.business.dto;
|
||||
|
||||
import com.multictrl.common.validator.group.AddGroup;
|
||||
import com.multictrl.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
@Data
|
||||
@Schema(name = "AI识别预警")
|
||||
public class AiWarningDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Null(message = "标识必须为空", groups = AddGroup.class)
|
||||
@NotNull(message = "标识不能为空", groups = UpdateGroup.class)
|
||||
@Schema(description = "标识")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "应用标识不能为空", groups = AddGroup.class)
|
||||
@Schema(description = "应用id")
|
||||
private String appId;
|
||||
|
||||
@NotBlank(message = "应用名称不能为空", groups = AddGroup.class)
|
||||
@Schema(description = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@NotBlank(message = "规则标识不能为空", groups = AddGroup.class)
|
||||
@Schema(description = "规则id")
|
||||
private String ruleId;
|
||||
|
||||
@NotBlank(message = "规则名称不能为空", groups = AddGroup.class)
|
||||
@Schema(description = "规则名称")
|
||||
private String ruleName;
|
||||
|
||||
@NotBlank(message = "状态不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
@Schema(description = "状态 0关闭 1开启")
|
||||
private String status;
|
||||
|
||||
@NotBlank(message = "预警等级不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
@Schema(description = "预警等级 高 中 低")
|
||||
private String warningLevel;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.multictrl.modules.business.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.multictrl.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("bus_ai_warning")
|
||||
public class AiWarningEntity extends BaseEntity {
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
private String appName;
|
||||
/**
|
||||
* 规则id
|
||||
*/
|
||||
private String ruleId;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String ruleName;
|
||||
/**
|
||||
* 状态 0关闭 1开启
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 预警等级 高 中 低
|
||||
*/
|
||||
private String warningLevel;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.multictrl.modules.business.service;
|
||||
|
||||
import com.multictrl.common.service.CrudService;
|
||||
import com.multictrl.modules.business.dto.AiWarningDTO;
|
||||
import com.multictrl.modules.business.entity.AiWarningEntity;
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
public interface AiWarningService extends CrudService<AiWarningEntity, AiWarningDTO> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.multictrl.modules.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.multictrl.common.service.impl.CrudServiceImpl;
|
||||
import com.multictrl.modules.business.dao.AiWarningDao;
|
||||
import com.multictrl.modules.business.dto.AiWarningDTO;
|
||||
import com.multictrl.modules.business.entity.AiWarningEntity;
|
||||
import com.multictrl.modules.business.service.AiWarningService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AI识别预警
|
||||
*
|
||||
* @author Sdy
|
||||
* @since 1.0.0 2026-06-18
|
||||
*/
|
||||
@Service
|
||||
public class AiWarningServiceImpl extends CrudServiceImpl<AiWarningDao, AiWarningEntity, AiWarningDTO> implements AiWarningService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<AiWarningEntity> getWrapper(Map<String, Object> params) {
|
||||
String id = (String) params.get("id");
|
||||
String status = (String) params.get("status");
|
||||
|
||||
QueryWrapper<AiWarningEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||
wrapper.eq(StrUtil.isNotBlank(status), "status", status);
|
||||
wrapper.orderByDesc("create_date");
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -19,8 +19,10 @@ import com.multictrl.common.utils.CacheUtils;
|
|||
import com.multictrl.common.utils.Result;
|
||||
import com.multictrl.common.utils.Utils;
|
||||
import com.multictrl.modules.business.dao.ZhimouCallbackDao;
|
||||
import com.multictrl.modules.business.dto.AiWarningDTO;
|
||||
import com.multictrl.modules.business.dto.zhimou.*;
|
||||
import com.multictrl.modules.business.entity.ZhimouCallbackEntity;
|
||||
import com.multictrl.modules.business.service.AiWarningService;
|
||||
import com.multictrl.modules.business.service.SrsService;
|
||||
import com.multictrl.modules.business.service.ZhiMouService;
|
||||
import com.multictrl.modules.sys.dao.SysParamsDao;
|
||||
|
|
@ -52,6 +54,7 @@ public class ZhiMouServiceImpl implements ZhiMouService {
|
|||
private final SrsService srsService;
|
||||
private final MqttConfig mqttConfig;
|
||||
private final SysConfig sysConfig;
|
||||
private final AiWarningService aiWarningService;
|
||||
private final ZhimouCallbackDao zhimouCallbackDao;
|
||||
private static final String APP_KEY = "appkey";
|
||||
private static final String APP_SECRET = "appsecret";
|
||||
|
|
@ -173,9 +176,9 @@ public class ZhiMouServiceImpl implements ZhiMouService {
|
|||
.header(AUTHORIZATION, BEARER + zhiMouInfo.getToken()).execute().body();
|
||||
log.debug("invoke zhiMou getApp result: {}", result);
|
||||
if (StrUtil.isNotBlank(result)) {
|
||||
// List<UavAiWarningDTO> aiList = aiWarningService.list(new HashMap<>());
|
||||
List<AiWarningDTO> aiList = aiWarningService.list(new HashMap<>());
|
||||
JSONObject data = JSONObject.parse(result);
|
||||
/*JSONArray apps = data.getJSONObject("data").getJSONArray("apps");
|
||||
JSONArray apps = data.getJSONObject("data").getJSONArray("apps");
|
||||
for (Object app : apps) {
|
||||
JSONObject appObj = (JSONObject) app;
|
||||
String appId = appObj.getString("app_id");
|
||||
|
|
@ -186,7 +189,7 @@ public class ZhiMouServiceImpl implements ZhiMouService {
|
|||
ruleObj.put("ai_id", null);
|
||||
ruleObj.put("ai_status", null);
|
||||
ruleObj.put("ai_warning_level", null);
|
||||
for (UavAiWarningDTO dto : aiList) {
|
||||
for (AiWarningDTO dto : aiList) {
|
||||
if (dto.getAppId().equals(appId) && dto.getRuleId().equals(ruleId)) {
|
||||
ruleObj.put("ai_id", dto.getId());
|
||||
ruleObj.put("ai_status", dto.getStatus());
|
||||
|
|
@ -194,7 +197,7 @@ public class ZhiMouServiceImpl implements ZhiMouService {
|
|||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -2461,4 +2461,41 @@ ON COLUMN public.bus_route_ai.creator IS '创建人';
|
|||
COMMENT
|
||||
ON COLUMN public.bus_route_ai.create_date IS '创建时间';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_route_ai.zhimou_child_id IS '智眸应用子类编号';
|
||||
ON COLUMN public.bus_route_ai.zhimou_child_id IS '智眸应用子类编号';
|
||||
|
||||
-- public.bus_ai_warning definition
|
||||
|
||||
-- Drop table
|
||||
|
||||
-- DROP TABLE public.bus_ai_warning;
|
||||
|
||||
CREATE TABLE public.bus_ai_warning
|
||||
(
|
||||
id int8 NOT NULL,
|
||||
app_id varchar(50) NULL, -- 应用id
|
||||
app_name varchar(255) NULL, -- 应用名称
|
||||
rule_id varchar(50) NULL, -- 规则id
|
||||
rule_name varchar(255) NULL, -- 规则名称
|
||||
status bpchar(1) NULL, -- 状态 0关闭 1开启
|
||||
warning_level varchar(10) NULL, -- 预警等级 高 中 低
|
||||
create_date timestamp(6) NULL,
|
||||
creator int8 NULL,
|
||||
CONSTRAINT uav_ai_warning_pkey PRIMARY KEY (id)
|
||||
);
|
||||
COMMENT
|
||||
ON TABLE public.bus_ai_warning IS 'AI识别预警';
|
||||
|
||||
-- Column comments
|
||||
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.app_id IS '应用id';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.app_name IS '应用名称';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.rule_id IS '规则id';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.rule_name IS '规则名称';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.status IS '状态 0关闭 1开启';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.warning_level IS '预警等级 高 中 低';
|
||||
Loading…
Reference in New Issue