Commit b072e1dc authored by duanruiming's avatar duanruiming

态势检测-统一事件告警监测弹窗服务

parent e10d8984
package net.wanji.web.controller;
import net.wanji.web.common.entity.JsonViewObject;
import net.wanji.web.service.SituationDetectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.wanji.web.common.entity.JsonViewObject;
import net.wanji.web.common.util.StringUtils;
import net.wanji.web.entity.TBaseCrossInfo;
import net.wanji.web.service.SituationDetectionService;
import net.wanji.web.util.HttpRestUtil;
import net.wanji.web.vo.situationDetection.*;
import org.springframework.beans.factory.annotation.Autowired;
import javax.ws.rs.core.MediaType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static net.wanji.web.util.HttpRestUtil.buildHeader;
/**
......@@ -26,7 +34,16 @@ import java.util.Map;
@Api(value = "SituationDetectionController", description = "态势监测")
@RequestMapping("/situationDetection")
@RestController
public class SituationDetectionController extends BaseController{
public class SituationDetectionController extends BaseController {
@Autowired
private HttpRestUtil httpRestUtil;
@Value("${utcServiceUrl}")
private String utcServiceUrl;
@Value("${syncDeviceSatusUrn}")
private String syncDeviceSatusUrl;
@Autowired
SituationDetectionService situationDetectionService;
......@@ -154,4 +171,44 @@ public class SituationDetectionController extends BaseController{
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(list);
}
@ApiOperation(value = "统一事件告警检测", notes = "统一事件告警检测", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON)
@GetMapping(value = "commonEventWarnNotify", produces = MediaType.APPLICATION_JSON)
public JsonViewObject commonEventWarnNotify() {
// 路口报警
// 事件报警
// 信号机故障
Map<String, String> header = buildHeader();
JsonViewObject jsonViewObject = httpRestUtil.doPost(utcServiceUrl.concat(syncDeviceSatusUrl), header, "", JsonViewObject.class);
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("远程服务调用异常".concat(utcServiceUrl.concat(syncDeviceSatusUrl)));
}
LocalDateTime now = LocalDateTime.now();
String formatNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);
List<Map<String, Object>> content = (List<Map<String, Object>>) jsonViewObject.getContent();
Map<String, Object> result = content.get(0);
String signalId = (String) result.get("signalId");
Integer faultType = (Integer) result.get("faultType");
if (Objects.nonNull(faultType) && faultType != 0 && StringUtils.isNotEmpty(signalId)) {
CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
commonEventAlarmOutVo.setEventType(3);
commonEventAlarmOutVo.setEventId(signalId);
commonEventAlarmOutVo.setEventName("信号机故障");// todo 信号机厂商
commonEventAlarmOutVo.setEventDesc("信号机故障");
commonEventAlarmOutVo.setStatus(String.valueOf(faultType));
commonEventAlarmOutVo.setStartTime(formatNow);
TBaseCrossInfo tBaseCrossInfo = situationDetectionService.selectCrossInfoById(signalId);
if (Objects.nonNull(tBaseCrossInfo)) {
commonEventAlarmOutVo.setCoordinate(tBaseCrossInfo.getLocation());
}
jsonViewObject.setContent(commonEventAlarmOutVo);
} else {
jsonViewObject.setContent(null);
jsonViewObject.setMessage("无告警数据");
}
return jsonViewObject;
}
}
package net.wanji.web.service;
import net.wanji.web.po.CrossInfo;
import net.wanji.web.entity.TBaseCrossInfo;
import net.wanji.web.vo.situationDetection.*;
import java.text.ParseException;
......@@ -32,4 +32,6 @@ public interface SituationDetectionService {
List<GreenwaveCrossOutVO> greenwaveCross(String adCode, String currentTime, Integer id);
List<CrossDeviceStatusInfoResultVO> crossDeviceStatusInfo();
TBaseCrossInfo selectCrossInfoById(String signalId);
}
......@@ -5,8 +5,9 @@ import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import net.wanji.web.common.enums.*;
import net.wanji.web.common.util.CrossUtil;
import net.wanji.web.po.*;
import net.wanji.web.entity.TBaseCrossInfo;
import net.wanji.web.mapper.*;
import net.wanji.web.po.*;
import net.wanji.web.service.SituationDetectionService;
import net.wanji.web.vo.situationDetection.*;
import org.springframework.beans.BeanUtils;
......@@ -49,6 +50,9 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
@Autowired
CrossInfoMapper crossInfoMapper;
@Autowired
TBaseCrossInfoMapper tBaseCrossInfoMapper;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
......@@ -387,6 +391,11 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
List<CrossDeviceStatusInfoResultVO> results = crossInfoMapper.listCrossDeviceStatusInfo();
return results;
}
@Override
public TBaseCrossInfo selectCrossInfoById(String signalId) {
return tBaseCrossInfoMapper.selectById(signalId);
}
}
class CrossAlarmComparator implements Comparator<CrossAlarmOutVO> {
......
package net.wanji.web.vo.situationDetection;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/01/04 10:31
*/
@Data
@ApiModel(value = "CommonEventAlarmOutVo", description = "统一事件告警检测返回结果")
public class CommonEventAlarmOutVo {
@ApiModelProperty(value = "事件编号:1:路口报警、2:事件报警、3:信号机故障")
Integer eventType;
@ApiModelProperty(value = "事件id")
String eventId;
@ApiModelProperty(value = "事件名称")
String eventName;
@ApiModelProperty(value = "事件描述")
String eventDesc;
@ApiModelProperty(value = "事件状态:路口报警:状态 0正常 1失衡 2拥堵 3溢出 4死锁;事件报警:1事故 2拥堵 3管制 4施工; 信号机故障:0正常 1检测器故障 2时钟故障 3电源故障 4驱动模块故障 5信号灯故障 6箱门开启 7方案错误 8绿冲突 9红全熄 10行人红熄")
String status;
@ApiModelProperty(value = "发生时间")
String startTime;
@ApiModelProperty(value = "时长(单位:分钟)")
Integer duration;
@ApiModelProperty(value = "事件坐标:经度,纬度;经度,纬度...")
String coordinate;
}
......@@ -58,5 +58,5 @@ spring:
signal:
#远程signalUtcService服务地址
utcServiceUrl: http://10.100.1.59/:32000/utc
utcServiceUrl: http://10.100.1.59:32000/utc
syncDeviceSatusUrn: /signalStatus/runningStatusAlarm
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment