Browse Source

#AI告警

zhongwei
yang_shj 12 months ago
parent
commit
4a9e4985e9
  1. 40
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/VideoEnumConstants.java
  2. 24
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/VideoAlarmVO.java
  3. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java
  4. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  5. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AiAlarmController.java
  6. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AiAlarmService.java
  7. 82
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AiAlarmServiceImpl.java

40
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/VideoEnumConstants.java

@ -0,0 +1,40 @@
package com.hnac.hzims.operational.main.constant;
import lombok.Getter;
/**
* @author ysj
* @version 4.0.0
* @create 2023-11-07-14:31
*/
public interface VideoEnumConstants {
@Getter
enum SoeKindEnum{
/**
* 视频告警类型
*/
MOTION_DETECTION("131331","移动侦测"),
REGIONAL_INTRUSION("131588","区域入侵"),
CROSS_BORDER_DETECTION("131585","越界侦测"),
SMOKE_FIRE_DETECTION("192514","烟火检测"),
OTHER_FLOATING_OBJECTS("42200047146001","其他漂浮物"),
PLANT_FLOATING_OBJECTS("42200047146000","植物类漂浮物"),
PLASTIC_FLOATING_OBJECTS("42200047146002","塑料类漂浮物");
private final String instance;
private final String name;
SoeKindEnum(String instance,String name){
this.instance = instance;
this.name = name;
}
public static String getValueByKey(String key) {
for (SoeKindEnum kind : SoeKindEnum.values()) {
if (kind.instance.equals(key)) {
return kind.getName();
}
}
throw new IllegalArgumentException("Invalid key: " + key);
}
}
}

24
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/VideoAlarmVO.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.main.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class VideoAlarmVO {
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("开始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
}

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java

@ -55,10 +55,9 @@ public class MonitorScheduledTask {
* 集中监控数据处理
* @return ReturnT<String>
*/
//@XxlJob(CENTRALIZED_MONITORING)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadMonitoring() {
String param = "";
@XxlJob(CENTRALIZED_MONITORING)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadMonitoring(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -451,7 +451,7 @@ public class MonitorServiceImpl implements MonitorService {
return;
}
item.setStationName(station.getName());
item.setWaterLevelMax(station.getLimitWaterLevel());
item.setWaterLevelMax(Optional.ofNullable(station.getLimitWaterLevel()).orElse(0.0));
item.setServerType(station.getServeType());
item.setStationDeptId(station.getRefDept());
item.setSort(9999);

38
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AiAlarmController.java

@ -0,0 +1,38 @@
package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.AiAlarmService;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@RequestMapping("/ai")
@Api(value = "ai视频告警", tags = "ai视频告警")
@AllArgsConstructor
public class AiAlarmController extends BladeController {
private final AiAlarmService aiAlarmService;
@ApiLog
@GetMapping("/video/alarm_page")
@ApiOperationSupport(order = 15)
@ApiOperation(value = "视频告警数据查询接口", notes = "station")
public R<HzPage<DeviceSoeVO>> alarmPage(VideoAlarmVO videoAlarm, Query query) {
return R.data(aiAlarmService.alarmPage(videoAlarm, Condition.getPage(query)));
}
}

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AiAlarmService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.operational.main.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
/**
* @author ysj
*/
public interface AiAlarmService {
HzPage<DeviceSoeVO> alarmPage(VideoAlarmVO videoAlarm, IPage<DeviceSoeVO> page);
}

82
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AiAlarmServiceImpl.java

@ -0,0 +1,82 @@
package com.hnac.hzims.operational.main.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.constant.VideoEnumConstants;
import com.hnac.hzims.operational.main.service.AiAlarmService;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class AiAlarmServiceImpl implements AiAlarmService {
private final ISoeClient alarmClient;
/**
* 设备告警列表查询
* @param videoAlarm
* @param page
* @return
*/
@Override
public HzPage<DeviceSoeVO> alarmPage(VideoAlarmVO videoAlarm, IPage<DeviceSoeVO> page) {
String startTime,endTime;
if(StringUtils.isEmpty(videoAlarm.getStartTime())){
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
}else{
startTime = videoAlarm.getStartTime();
}
if(StringUtils.isEmpty(videoAlarm.getEndTime())){
endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
}else{
endTime = videoAlarm.getEndTime();
}
// 查询视频告警数据
Result<HzPage<DeviceSoeVO>> soe = alarmClient.getDeviceCodeByTaosSoe(startTime,endTime,videoAlarm.getDeviceCode(),(int) page.getCurrent(), String.valueOf(page.getSize()));
if(!soe.isSuccess() || CollectionUtil.isEmpty(soe.getData().getRecords())){
return new HzPage<>();
}
List<DeviceSoeVO> records = soe.getData().getRecords();
soe.getData().setRecords(records.stream().peek(record -> {
record.setSoeType(videoAlarm.getDeviceName() + "_" + VideoEnumConstants.SoeKindEnum.getValueByKey(record.getInstanceFieldName()) + "_触发告警");
if(!StringUtil.isEmpty(record.getSoeExplain())) {
String soeExplain = StringUtils.strip(record.getSoeExplain(), "[]");
StringBuilder sb = new StringBuilder();
if(record.getSoeExplain().contains("http")){
String[] imgs = soeExplain.split(",");
for (String img : imgs){
sb.append(img).append(",");
}
}else{
String[] imgs = soeExplain.split(",");
for (String img : imgs){
sb.append("https://172.30.100.204").append(img).append(",");
}
}
record.setSoeAlarmType(sb.substring(0, sb.length() - 1).replace("\"", ""));
}
}).collect(Collectors.toList()));
return soe.getData();
}
}
Loading…
Cancel
Save