|
|
@ -6,21 +6,25 @@ import com.hnac.hzims.alarm.constants.AlarmConstants; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.show.service.AlarmService; |
|
|
|
import com.hnac.hzims.alarm.show.service.AlarmService; |
|
|
|
import com.hnac.hzims.alarm.show.service.VideoAlarmService; |
|
|
|
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.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.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
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.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
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 org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -33,35 +37,48 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class VideoAlarmServiceImpl implements VideoAlarmService { |
|
|
|
public class VideoAlarmServiceImpl implements VideoAlarmService { |
|
|
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IMessageClient messageClient; |
|
|
|
private final IMessageClient messageClient; |
|
|
|
private final AlarmService alarmService; |
|
|
|
private final AlarmService alarmService; |
|
|
|
|
|
|
|
private final ISoeClient iSoeClient; |
|
|
|
private final IStationClient stationClient; |
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
private final IEmInfoClient emInfoClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 定时查询告警信息 |
|
|
|
* 定时查询告警信息 |
|
|
|
|
|
|
|
* |
|
|
|
* @return String |
|
|
|
* @return String |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<AlarmEntity> sendMessage() { |
|
|
|
public List<AlarmEntity> sendMessage() { |
|
|
|
R<List<StationEntity>> listAll = stationClient.getListAll(); |
|
|
|
String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); |
|
|
|
if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { |
|
|
|
String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
throw new ServiceException("暂无站点信息"); |
|
|
|
// 根据海康摄像头的字段查询所有设备
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
List<StationEntity> stations = listAll.getData(); |
|
|
|
return alarmEntities; |
|
|
|
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<>(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,7 +89,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<AlarmEntity> receiveMessage(String message) { |
|
|
|
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)) { |
|
|
|
if (CollectionUtil.isEmpty(alarms)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -83,16 +100,16 @@ public class VideoAlarmServiceImpl implements VideoAlarmService { |
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AlarmEntity getAlarmEntity(SystemAlarmVo item) { |
|
|
|
private AlarmEntity getAlarmEntity(DeviceSoeVO item) { |
|
|
|
AlarmEntity entity = new AlarmEntity(); |
|
|
|
AlarmEntity entity = new AlarmEntity(); |
|
|
|
entity.setAlarmId(item.getId()); |
|
|
|
entity.setAlarmId(item.getId()); |
|
|
|
entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); |
|
|
|
entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); |
|
|
|
entity.setAlarmContext(item.getSoeExplain()); |
|
|
|
entity.setAlarmContext(item.getSoeExplain()); |
|
|
|
entity.setAlarmType(item.getSoeAlarmType()); |
|
|
|
entity.setAlarmType(AbnormalAlarmConstant.VIDEO_ALARM); |
|
|
|
entity.setAlarmStatus(item.getSoeStatus()); |
|
|
|
entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus())); |
|
|
|
entity.setAlarmValue(item.getOptionvals()); |
|
|
|
entity.setRealId(item.getRealId()); |
|
|
|
entity.setStationId(item.getStation()); |
|
|
|
entity.setStationId(item.getStation()); |
|
|
|
entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); |
|
|
|
entity.setAlarmSource(AlarmConstants.VIDEO_WARNING); |
|
|
|
entity.setTenantId("200000"); |
|
|
|
entity.setTenantId("200000"); |
|
|
|
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation()); |
|
|
|
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation()); |
|
|
|
if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { |
|
|
|
if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { |
|
|
|