华安泰推送过来ai报警数据
This commit is contained in:
parent
7fe5c2df3f
commit
0c45ba97ec
@ -1452,72 +1452,42 @@ public class ParamEnum {
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum RainAlarmTypeEnum implements BaseEnum {
|
||||
/**
|
||||
* 风力
|
||||
*/
|
||||
/**
|
||||
* 风力
|
||||
*/
|
||||
WIND_FORCE(1, "风力"),
|
||||
/**
|
||||
* 风速
|
||||
*/
|
||||
/**
|
||||
* 风速
|
||||
*/
|
||||
WIND_SPEED(2, "风速"),
|
||||
/**
|
||||
* 风向
|
||||
*/
|
||||
/**
|
||||
* 风向
|
||||
*/
|
||||
WIND_DIRECTION(3, "风向"),
|
||||
/**
|
||||
* 累计雨量
|
||||
*/
|
||||
/**
|
||||
* 累计雨量
|
||||
*/
|
||||
ACCUMULATED_RAINFALL(4, "累计雨量"),
|
||||
/**
|
||||
* 瞬时雨量
|
||||
*/
|
||||
/**
|
||||
* 瞬时雨量
|
||||
*/
|
||||
INSTANTANEOUS_RAINFALL(5, "瞬时雨量"),
|
||||
/**
|
||||
* 当前雨量
|
||||
*/
|
||||
/**
|
||||
* 当前雨量
|
||||
*/
|
||||
CURRENT_RAINFALL(6, "当前雨量"),
|
||||
/**
|
||||
* 日雨量
|
||||
*/
|
||||
/**
|
||||
* 日雨量
|
||||
*/
|
||||
DAILY_RAINFALL(7, "日雨量"),
|
||||
/**
|
||||
* 空气温度
|
||||
*/
|
||||
/**
|
||||
* 空气温度
|
||||
*/
|
||||
AIR_TEMPERATURE(8, "空气温度"),
|
||||
/**
|
||||
* 空气湿度
|
||||
*/
|
||||
/**
|
||||
* 空气湿度
|
||||
*/
|
||||
AIR_HUMIDITY(9, "空气湿度"),
|
||||
/**
|
||||
* 大气压
|
||||
*/
|
||||
/**
|
||||
* 大气压
|
||||
*/
|
||||
@ -1553,5 +1523,42 @@ public class ParamEnum {
|
||||
}
|
||||
}
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum QualityProblemTechnologyEnum implements BaseEnum {
|
||||
ENUM0(1, "土建"),
|
||||
ENUM1(2, "管道"),
|
||||
ENUM2(3, "设备"),
|
||||
ENUM3(4, "电气"),
|
||||
ENUM4(5, "仪表"),
|
||||
ENUM5(6, "其他");
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
||||
QualityProblemTechnologyEnum(Integer value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,8 +27,11 @@ public interface IDictionaryItemService extends IService<DictionaryItem> {
|
||||
*/
|
||||
DictionaryItem getDict(String dictionaryEncoding, String data, String projectSn);
|
||||
|
||||
DictionaryItem getDictByRemark(String dictionaryEncoding, String remarks, String projectSn);
|
||||
|
||||
/**
|
||||
* 添加基础字典信息
|
||||
*
|
||||
* @param dictionaryItem
|
||||
*/
|
||||
void add(DictionaryItem dictionaryItem);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -70,6 +69,22 @@ public class DictionaryItemServiceImpl extends ServiceImpl<DictionaryItemMapper,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictionaryItem getDictByRemark(String dictionaryEncoding, String remarks, String projectSn) {
|
||||
String newCode = dictionaryEncoding + "_" + projectSn;
|
||||
LambdaQueryWrapper<DictionaryItem> queryWrapper = new LambdaQueryWrapper<DictionaryItem>()
|
||||
.and(w -> w.eq(DictionaryItem::getDictionaryEncoding, dictionaryEncoding).or().eq(DictionaryItem::getDictionaryEncoding, newCode))
|
||||
.eq(DictionaryItem::getIsEnable, 1)
|
||||
.eq(DictionaryItem::getRemarks, remarks);
|
||||
List<DictionaryItem> dictionaryItems = dictionaryItemMapper.selectList(queryWrapper);
|
||||
Map<String, DictionaryItem> map = dictionaryItems.stream().collect(Collectors.toMap(DictionaryItem::getDictionaryEncoding, dictionaryItem -> dictionaryItem, (o1, o2) -> o1));
|
||||
if (map.containsKey(newCode)) {
|
||||
return map.get(newCode);
|
||||
} else {
|
||||
return map.get(dictionaryEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(DictionaryItem dictionaryItem) {
|
||||
Long dictionaryId = dictionaryItem.getDictionaryId();
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
package com.zhgd.xmgl.modules.video.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.async.AsyncAiAnalyse;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.DictionaryItem;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.DictionaryItemServiceImpl;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareRecord;
|
||||
import com.zhgd.xmgl.modules.video.entity.VideoItem;
|
||||
import com.zhgd.xmgl.modules.video.mapper.AiAnalyseHardWareAlarmRecordMapper;
|
||||
import com.zhgd.xmgl.modules.video.mapper.AiAnalyseHardWareRecordMapper;
|
||||
import com.zhgd.xmgl.modules.video.service.IVideoItemService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import com.zhgd.xmgl.util.PathUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 华安泰
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/hat")
|
||||
public class HatAlarmServerController {
|
||||
@Lazy
|
||||
@Autowired
|
||||
AiAnalyseHardWareAlarmRecordMapper aiAnalyseHardWareAlarmRecordMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private AiAnalyseHardWareRecordMapper aiAnalyseHardWareRecordMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private AsyncAiAnalyse asyncAiAnalyse;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DictionaryItemServiceImpl dictionaryItemService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IVideoItemService videoItemService;
|
||||
|
||||
/**
|
||||
* http报警上报用例
|
||||
* 设备根据用例url配置http报警服务器后,demo作为http服务器可以接收设备推送的报警数据
|
||||
*
|
||||
* @param deviceSn 设备sn
|
||||
* @param alarmInfo 报警消息
|
||||
* @param pics 报警图片
|
||||
*/
|
||||
@PostMapping("/httpAlarmServer")
|
||||
public Result httpAlarmServer(@RequestParam("sn") String deviceSn, @RequestParam("alarm_info") JSONObject alarmInfo, @RequestPart(value = "picture", required = false) MultipartFile[] pics) throws IOException {
|
||||
log.info("华安泰获取ai报警数据 receive alarm from {}, alarm_info: {}", deviceSn, alarmInfo);
|
||||
FileOutputStream fos = null;
|
||||
if (pics == null) {
|
||||
return Result.error("报警图片是空的");
|
||||
}
|
||||
QueryWrapper<AiAnalyseHardWareRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AiAnalyseHardWareRecord::getHardwareId, deviceSn);
|
||||
AiAnalyseHardWareRecord dev = aiAnalyseHardWareRecordMapper.selectOne(queryWrapper);
|
||||
if (dev == null) {
|
||||
throw new OpenAlertException(MessageUtil.get("EquipmentNumIncorrectErr"));
|
||||
}
|
||||
JSONObject additional = alarmInfo.getJSONObject("additional");
|
||||
AiAnalyseHardWareAlarmRecord aiAnalyseHardWareAlarmRecord = new AiAnalyseHardWareAlarmRecord();
|
||||
aiAnalyseHardWareAlarmRecord.setCreateTime(DateUtil.formatDateTime(new Date(additional.getLong("alarm_time"))));
|
||||
DictionaryItem dict = dictionaryItemService.getDictByRemark("ai_analyse_hard_ware_alarm_record_type", additional.getString("alarm_minor"), dev.getProjectSn());
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmType(Optional.ofNullable(dict).map(m -> Integer.valueOf(m.getData())).orElse(null));
|
||||
aiAnalyseHardWareAlarmRecord.setHardwareId(dev.getHardwareId());
|
||||
aiAnalyseHardWareAlarmRecord.setHardwareName(dev.getHardwareName());
|
||||
List<VideoItem> videoItems = videoItemService.list(new LambdaQueryWrapper<VideoItem>()
|
||||
.eq(VideoItem::getHatAiVideoId, additional.getInt("stream_id"))
|
||||
.eq(VideoItem::getAiHardwareId, deviceSn)
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(videoItems)) {
|
||||
aiAnalyseHardWareAlarmRecord.setLocation(videoItems.get(0).getVideoName());
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmDesc(videoItems.get(0).getVideoName());
|
||||
}
|
||||
aiAnalyseHardWareAlarmRecord.setProjectSn(dev.getProjectSn());
|
||||
aiAnalyseHardWareAlarmRecord.setStatus(1);
|
||||
byte[] data = pics[1].getBytes();
|
||||
String uuid = alarmInfo.getJSONObject("global_info").getString("data_uuid");
|
||||
String fileName = uuid.replace(':', '_');
|
||||
File dir = new File(PathUtil.getBasePath(), "/hat_ai_http_alarm");
|
||||
dir.mkdir();
|
||||
String name = "/" + fileName + "_" + 1 + ".jpg";
|
||||
try {
|
||||
fos = new FileOutputStream(dir + name, false);
|
||||
fos.write(data);
|
||||
aiAnalyseHardWareAlarmRecord.setImageUrl("hat_ai_http_alarm" + name);
|
||||
|
||||
aiAnalyseHardWareAlarmRecordMapper.insert(aiAnalyseHardWareAlarmRecord);
|
||||
//将数据通过MQTT转发到前台
|
||||
asyncAiAnalyse.sendAiAnalyse(aiAnalyseHardWareAlarmRecord, Cts.PROJECT_LEVEL);
|
||||
} catch (Exception e) {
|
||||
log.error("华安泰获取ai报警错误", e);
|
||||
} finally {
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
@ -141,6 +141,16 @@ public class VideoItem implements Serializable {
|
||||
private String parentObj;
|
||||
@ApiModelProperty(value = "工作流是否通过(1是0否)工作流吊装通过显示图标")
|
||||
private Integer isFlowPass;
|
||||
/**
|
||||
* 华安泰的ai盒子的摄像头的设备id
|
||||
*/
|
||||
@ApiModelProperty(value = "华安泰的ai盒子的摄像头的设备id")
|
||||
private String hatAiVideoId;
|
||||
/**
|
||||
* AI分析硬件设备id
|
||||
*/
|
||||
@ApiModelProperty(value = "AI分析硬件设备id")
|
||||
private String aiHardwareId;
|
||||
/**
|
||||
* 项目sn
|
||||
*/
|
||||
|
||||
@ -80,6 +80,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/xmgl/hat/httpAlarmServer").permitAll()
|
||||
.antMatchers("/xmgl/mlHoist/flow/add/transpond").permitAll()
|
||||
.antMatchers("/xmgl/mlHoist/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/videoItem/camera/search").permitAll()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user