Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
517a4bdc36
  1. 3
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/constants/AlarmConstants.java
  2. 4
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java
  3. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  4. 7
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java
  5. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  6. 14
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  7. 73
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/VideoAlarmServiceImpl.java
  8. 19
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/task/VideoScheduledTask.java

3
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<Integer> ALARAM_SOURCE = Arrays.asList(HZ3000_ALARM,LEVEL_ALARM,CONDITION_ALARM,EARLY_WARNING);
// 子类告警

4
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<List<String>> getChildrenByEmCode(@RequestParam("emCode") String emCode);
@GetMapping(value = GET_VIDEO_DEVICE_BY_EM_CODE)
List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo);
}

6
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<String> 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;
}

7
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<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo) {
return service.getVideoDeviceByEmCode(emInfo);
}
@PostMapping(GET_EM_CREATE_TABLE)
@Override
public List<CreateTableVO> getEmCreateTable(List<String> tableNames) {

4
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<EmInfoEntity> {
* @return 设备信息列表
*/
List<JSONObject> getEmTreeByDeptAndParentCode(Long deptId, String parentCode);
List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo);
}

14
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<EmInfoMapper, EmInfoEntit
return resultList;
}
@Override
public List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo){
LambdaQueryWrapper<EmInfoEntity> emTreeWrapper = new LambdaQueryWrapper();
emTreeWrapper.eq(EmInfoEntity::getEmType, emInfo.getEmType());
emTreeWrapper.eq(EmInfoEntity::getIsDeleted, "0");
List<EmInfoEntity> emInfoEntities = baseMapper.selectList(emTreeWrapper);
return emInfoEntities;
}
private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, String modelSignage, List<EmTreeIdsDTO> treeIds) {
List<ProjectDTO> projectDTOList = new ArrayList<>();
LambdaQueryWrapper<EmTreeEntity> wrapper = new LambdaQueryWrapper();

73
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<AlarmEntity> sendMessage() {
R<List<StationEntity>> 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<EmInfoEntity> infoEntityList = emInfoClient.getVideoDeviceByEmCode(emInfoEntity);
// 拿到所有设备后,掉平台预警信息的接口
List<List<DeviceSoeVO>> collect = infoEntityList.stream()
.map(s -> {
List<DeviceSoeVO> records = new ArrayList<>();
Result<HzPage<DeviceSoeVO>> deviceCodeByTaosSoe = iSoeClient.getDeviceCodeByTaosSoe(startTime, endTime, s.getNumber(), 1, "999");
if (deviceCodeByTaosSoe.isSuccess() && ObjectUtils.isNotEmpty(deviceCodeByTaosSoe.getData())) {
HzPage<DeviceSoeVO> data = deviceCodeByTaosSoe.getData();
records = data.getRecords();
return records;
}
List<StationEntity> stations = listAll.getData();
List<String> 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 records;
}).filter(s -> CollectionUtil.isNotEmpty(s)).collect(Collectors.toList());
List<DeviceSoeVO> res =new ArrayList<>();
if (CollectionUtil.isNotEmpty(collect)) {
res= collect.stream().flatMap(List::stream).collect(Collectors.toList());
}
// 转换平台视频预警信息
List<AlarmEntity> alarmEntities =new ArrayList<>();
if (CollectionUtil.isNotEmpty(res)) {
alarmEntities= res.stream().filter(s->ObjectUtils.isNotEmpty(s)).map(s -> getAlarmEntity(s)).collect(Collectors.toList());
}
return alarmEntities;
}
@ -72,7 +89,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
@Override
public List<AlarmEntity> receiveMessage(String message) {
// 对象转换
List<SystemAlarmVo> alarms = JSONObject.parseArray(message, SystemAlarmVo.class);
List<DeviceSoeVO> 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<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation());
if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) {

19
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<String> loadEmInfo(String param) {
service.sendMessage();
// public ReturnT<String> loadVideoInfo(String param) {
public ReturnT<String> loadVideoInfo() {
// //获取报警信息
List<AlarmEntity> alarmEntities = service.sendMessage();
//获取消息
// List<AlarmEntity> alarmEntities = service.receiveMessage(param);
alarmService.dealAlarmEntities(alarmEntities);
return new ReturnT<>("SUCCESS");
}

Loading…
Cancel
Save