|
|
|
@ -18,6 +18,7 @@ import com.hnac.hzims.alarm.show.vo.AlarmHistoryParamVo;
|
|
|
|
|
import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; |
|
|
|
|
import com.hnac.hzims.alarm.show.vo.ShowQueryVo; |
|
|
|
|
import com.hnac.hzims.alarm.source.service.MessageService; |
|
|
|
|
import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; |
|
|
|
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
|
|
|
|
import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; |
|
|
|
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
|
|
|
@ -35,12 +36,14 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
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.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.message.dto.MailMessageDTO; |
|
|
|
|
import org.springblade.message.fegin.IMessageClient; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -108,9 +111,6 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
if(!StringUtil.isEmpty(showQuery.getAlarmType())){ |
|
|
|
|
wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); |
|
|
|
|
} |
|
|
|
|
if(!StringUtil.isEmpty(showQuery.getContent())){ |
|
|
|
|
wrapper.like("alarmContext",showQuery.getContent()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 处理告警过滤 :当天处理告警
|
|
|
|
|
List<String> handles = alarmHandleService.handles(); |
|
|
|
@ -140,18 +140,6 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取权限站点 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<StationEntity> stationsByCodes(List<String> stations) { |
|
|
|
|
R<List<StationEntity>> result = stationClient.querySatationByCodes(stations); |
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return result.getData(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询告警数量 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -203,9 +191,6 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 播报告警 |
|
|
|
|
* @param startTime |
|
|
|
@ -233,25 +218,26 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 弹框告警 |
|
|
|
|
* @param codes |
|
|
|
|
* @param param |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public TextMessage majorAlarm(List<String> codes) { |
|
|
|
|
public TextMessage majorAlarm(AlartParamVo param) { |
|
|
|
|
// 站点查询
|
|
|
|
|
List<StationEntity> stations = this.stationsByCodes(codes); |
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
List<StationEntity> stations = this.stations(param.getServeType()); |
|
|
|
|
if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ |
|
|
|
|
return new TextMessage(new ArrayList().toString()); |
|
|
|
|
} |
|
|
|
|
List<String> effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(effectives)){ |
|
|
|
|
return new TextMessage(new ArrayList().toString()); |
|
|
|
|
} |
|
|
|
|
// 条件过滤
|
|
|
|
|
QueryWrapper<AlarmEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.lambda().in(AlarmEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
queryWrapper.lambda().in(AlarmEntity::getAlarmType, AlarmConstants.WHOLE_ALARM_TYPE); |
|
|
|
|
queryWrapper.lambda().eq(AlarmEntity::getIsRightTabulation,0); |
|
|
|
|
queryWrapper.lambda().ge(AlarmEntity::getAlarmTime, DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"); |
|
|
|
|
queryWrapper.lambda().le(AlarmEntity::getAlarmTime,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
queryWrapper.lambda().orderByDesc(AlarmEntity::getAlarmTime); |
|
|
|
|
//queryWrapper.lambda().eq(AlarmEntity::getStatus,0);
|
|
|
|
|
queryWrapper.lambda().in(AlarmEntity::getStationId,effectives); |
|
|
|
|
queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.FAULT,AlarmConstants.EARLY)); |
|
|
|
|
queryWrapper.lambda().eq(AlarmEntity::getIsShowAlert,0); |
|
|
|
|
queryWrapper.lambda().eq(AlarmEntity::getStatus,0); |
|
|
|
|
// 处理告警过滤 :当天处理告警
|
|
|
|
|
List<String> handles = alarmHandleService.handles(); |
|
|
|
|
if(!CollectionUtil.isEmpty(handles)){ |
|
|
|
@ -261,9 +247,10 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
if(CollectionUtil.isEmpty(alarms)){ |
|
|
|
|
return new TextMessage(new ArrayList().toString()); |
|
|
|
|
} |
|
|
|
|
return new TextMessage(JSONObject.toJSONString(alarms.stream().skip(0).limit(1000).collect(Collectors.toList()))); |
|
|
|
|
return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 验证设备编号是否绑定视频 |
|
|
|
|
* @param emInfo 设备信息 |
|
|
|
@ -387,6 +374,35 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* websocket断联发送邮件 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
public void sendMailByNum(Integer num,Integer maxConnent,String name) { |
|
|
|
|
if (num>=maxConnent){ |
|
|
|
|
MailMessageDTO mailMessageDTO = new MailMessageDTO(); |
|
|
|
|
mailMessageDTO.setDeptId(200000L); |
|
|
|
|
mailMessageDTO.setDeptName("华自科技"); |
|
|
|
|
mailMessageDTO.setBusinessClassify("system"); |
|
|
|
|
mailMessageDTO.setBusinessKey("Mail"); |
|
|
|
|
mailMessageDTO.setSubject("邮件发送"); |
|
|
|
|
|
|
|
|
|
mailMessageDTO.setContent(name+"websocket链接失败;"+"链接失败次数:"+num); |
|
|
|
|
R<List<User>> res = userClient.userListByRoleAlias("200000", "sendMail"); |
|
|
|
|
if (!res.isSuccess()||CollectionUtil.isEmpty(res.getData())){ |
|
|
|
|
log.error("消息发送失败:无对应用户"); |
|
|
|
|
} |
|
|
|
|
String userIds = res.getData().stream().map(s -> s.getId().toString()).collect(Collectors.joining(",")); |
|
|
|
|
mailMessageDTO.setUserIds(userIds); |
|
|
|
|
mailMessageDTO.setIsHtml(false); |
|
|
|
|
R<Boolean> booleanR = messageClient.sendMailMsgByUsers(mailMessageDTO); |
|
|
|
|
if (!booleanR.isSuccess()){ |
|
|
|
|
log.error("消息发送失败:"+mailMessageDTO.getUserIds()+"--->"+booleanR.getMsg()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取告警视频信息 |
|
|
|
|
* @param stationCode |
|
|
|
|
* @param deviceCode |
|
|
|
@ -419,7 +435,6 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
|
|
|
|
|
throw new ServiceException("未查询到告警视频信息!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
*查询站点绑定视频信息 |
|
|
|
|
* @param stationCode |
|
|
|
|