diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java index 76b9947..17e9d45 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java @@ -28,11 +28,12 @@ public interface AlarmConstants { Integer IS_WX_MESSAGE = 8; - // 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 + // 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 Integer HZ3000_ALARM = 0; Integer LEVEL_ALARM = 1; Integer CONDITION_ALARM = 2; Integer EARLY_WARNING = 3; + Integer VIDEO_WARNING = 4; List ALARAM_SOURCE = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING); // 子类告警 diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 7c99354..235ccdc 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -80,6 +80,7 @@ public interface IEmInfoClient { String UPDATE_BATCH_EM_STATE = API_PREFIX + "/updateBachEmState"; String GET_CHILDREN_BY_EM_CODE = API_PREFIX + "/getChildrenByEmCode"; String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable"; + String GET_VIDEO_DEVICE_BY_EM_CODE = API_PREFIX + "/getVideoDeviceByEmCode"; @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -157,4 +158,7 @@ public interface IEmInfoClient { */ @GetMapping(GET_CHILDREN_BY_EM_CODE) R> getChildrenByEmCode(@RequestParam("emCode") String emCode); + + @GetMapping(value = GET_VIDEO_DEVICE_BY_EM_CODE) + List getVideoDeviceByEmCode(EmInfoEntity emInfo); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index 094df95..3bf7e4f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -49,7 +49,7 @@ public interface AbnormalAlarmConstant { List LEVEL_LIST = Arrays.asList("0","1"); /** - * 告警类型: 智能告警 + * 告警类型: HZ3000告警 */ Integer SYSTEM_ALARM = 0; @@ -57,4 +57,8 @@ public interface AbnormalAlarmConstant { * 告警类型: 智能告警 */ Integer INTELLIGENCE_ALARM = 1; + /** + * 告警类型: 视频告警 + */ + Integer VIDEO_ALARM = 4; } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index cb2ac6e..fbbef97 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -9,7 +9,6 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.vo.CreateTableVO; import org.springframework.beans.factory.annotation.Autowired; @@ -127,7 +126,11 @@ public class EmInfoClient implements IEmInfoClient { service.updateBachEmState(boot, shutdown); return R.success("修改成功"); } - + @GetMapping(value = GET_VIDEO_DEVICE_BY_EM_CODE) + @Override + public List getVideoDeviceByEmCode(EmInfoEntity emInfo) { + return service.getVideoDeviceByEmCode(emInfo); + } @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index b607902..5decdcc 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -5,11 +5,9 @@ import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.*; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; -import io.swagger.annotations.ApiParam; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; -import org.springframework.web.bind.annotation.RequestParam; import javax.validation.Valid; import java.util.List; @@ -89,4 +87,6 @@ public interface IEmInfoService extends BaseService { * @return 设备信息列表 */ List getEmTreeByDeptAndParentCode(Long deptId, String parentCode); + + List getVideoDeviceByEmCode(EmInfoEntity emInfo); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index fa5a04f..5b9ecef 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -16,7 +16,6 @@ import com.hnac.hzims.equipment.mapper.EmInfoMapper; import com.hnac.hzims.equipment.mapper.EmInfoNoScopeMapper; import com.hnac.hzims.equipment.service.*; import com.hnac.hzims.equipment.vo.*; -import com.hnac.hzims.equipment.wrapper.EmInfoWrapper; import com.hnac.hzims.fdp.service.IFdpQuestionService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -24,7 +23,6 @@ import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.util.TableJsonUtils; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; -import com.hnac.hzinfo.datasearch.device.IDeviceClient; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; @@ -39,12 +37,10 @@ import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.dto.DeviceChildrenDTO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceChildrenVO; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; @@ -784,6 +780,16 @@ public class EmInfoServiceImpl extends BaseServiceImpl getVideoDeviceByEmCode(EmInfoEntity emInfo){ + LambdaQueryWrapper emTreeWrapper = new LambdaQueryWrapper(); + emTreeWrapper.eq(EmInfoEntity::getEmType, emInfo.getEmType()); + emTreeWrapper.eq(EmInfoEntity::getIsDeleted, "0"); + List emInfoEntities = baseMapper.selectList(emTreeWrapper); + return emInfoEntities; + } + private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, String modelSignage, List treeIds) { List projectDTOList = new ArrayList<>(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java index 4c3b235..e9edfb2 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java @@ -6,21 +6,25 @@ import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.VideoAlarmService; -import com.hnac.hzims.alarm.vo.SystemAlarmVo; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +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.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; -import org.springblade.system.feign.ISysClient; -import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -33,35 +37,48 @@ import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class VideoAlarmServiceImpl implements VideoAlarmService { - - private final IUserClient userClient; - - private final ISysClient sysClient; - private final IMessageClient messageClient; private final AlarmService alarmService; + private final ISoeClient iSoeClient; private final IStationClient stationClient; + private final IEmInfoClient emInfoClient; /** * 定时查询告警信息 + * * @return String */ @Override public List sendMessage() { - R> listAll = stationClient.getListAll(); - if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { - throw new ServiceException("暂无站点信息"); + String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); + String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); +// 根据海康摄像头的字段查询所有设备 + EmInfoEntity emInfoEntity = new EmInfoEntity(); +// 字典配的deviceType,4是海康视频 + emInfoEntity.setEmType("4"); + List infoEntityList = emInfoClient.getVideoDeviceByEmCode(emInfoEntity); + // 拿到所有设备后,掉平台预警信息的接口 + List> collect = infoEntityList.stream() + .map(s -> { + List records = new ArrayList<>(); + Result> deviceCodeByTaosSoe = iSoeClient.getDeviceCodeByTaosSoe(startTime, endTime, s.getNumber(), 1, "999"); + if (deviceCodeByTaosSoe.isSuccess() && ObjectUtils.isNotEmpty(deviceCodeByTaosSoe.getData())) { + HzPage data = deviceCodeByTaosSoe.getData(); + records = data.getRecords(); + return records; + } + return records; + }).filter(s -> CollectionUtil.isNotEmpty(s)).collect(Collectors.toList()); + List res =new ArrayList<>(); + if (CollectionUtil.isNotEmpty(collect)) { + res= collect.stream().flatMap(List::stream).collect(Collectors.toList()); + } +// 转换平台视频预警信息 + List alarmEntities =new ArrayList<>(); + if (CollectionUtil.isNotEmpty(res)) { + alarmEntities= res.stream().filter(s->ObjectUtils.isNotEmpty(s)).map(s -> getAlarmEntity(s)).collect(Collectors.toList()); } - List stations = listAll.getData(); - List collect = stations.stream().map(StationEntity::getCode).collect(Collectors.toList()); -// em_infoService -// collect -// -// -// -// map.put("soe_type", AbnormalAlarmConstant.SYSTEM_TYPE_LIST); -// return JSONObject.toJSONString(map); - return new ArrayList<>(); + return alarmEntities; } @@ -72,7 +89,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { @Override public List receiveMessage(String message) { // 对象转换 - List alarms = JSONObject.parseArray(message, SystemAlarmVo.class); + List alarms = JSONObject.parseArray(message, DeviceSoeVO.class); if (CollectionUtil.isEmpty(alarms)) { return new ArrayList<>(); } @@ -83,16 +100,16 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { return res; } - private AlarmEntity getAlarmEntity(SystemAlarmVo item) { + private AlarmEntity getAlarmEntity(DeviceSoeVO item) { AlarmEntity entity = new AlarmEntity(); entity.setAlarmId(item.getId()); entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); entity.setAlarmContext(item.getSoeExplain()); - entity.setAlarmType(item.getSoeAlarmType()); - entity.setAlarmStatus(item.getSoeStatus()); - entity.setAlarmValue(item.getOptionvals()); + entity.setAlarmType(AbnormalAlarmConstant.VIDEO_ALARM); + entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus())); + entity.setRealId(item.getRealId()); entity.setStationId(item.getStation()); - entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); + entity.setAlarmSource(AlarmConstants.VIDEO_WARNING); entity.setTenantId("200000"); R stationByCode = stationClient.getStationByCode(item.getStation()); if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java index 126e897..2d1fa0b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java @@ -1,13 +1,14 @@ package com.hnac.hzims.alarm.task; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.VideoAlarmService; import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import static com.hnac.hzims.alarm.constants.AlarmConstants.VIDEO_SCHEDULED_TASK; +import java.util.List; /** @@ -20,17 +21,23 @@ public class VideoScheduledTask { @Autowired private VideoAlarmService service; + @Autowired + private AlarmService alarmService; /** * 设备信息缓存 * @return * @throws Exception */ - @XxlJob(VIDEO_SCHEDULED_TASK) +// @XxlJob(VIDEO_SCHEDULED_TASK) //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadEmInfo(String param) { - service.sendMessage(); - +// public ReturnT loadVideoInfo(String param) { + public ReturnT loadVideoInfo() { +// //获取报警信息 + List alarmEntities = service.sendMessage(); + //获取消息 +// List alarmEntities = service.receiveMessage(param); + alarmService.dealAlarmEntities(alarmEntities); return new ReturnT<>("SUCCESS"); }