|
@@ -14,6 +14,7 @@ import com.huaxu.common.StringUtils;
|
|
|
import com.huaxu.dao.AlarmDetailMapper;
|
|
|
import com.huaxu.dto.AlarmDetailsDto;
|
|
|
import com.huaxu.dto.DeviceCheckAlarmDto;
|
|
|
+import com.huaxu.dto.WorkOrderManageByAlarmDto;
|
|
|
import com.huaxu.entity.AlarmDetailsEntity;
|
|
|
import com.huaxu.entity.Message;
|
|
|
import com.huaxu.entity.MonitorDataEntity;
|
|
@@ -30,9 +31,11 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.awt.*;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@@ -76,7 +79,7 @@ public class ReceiveData {
|
|
|
|
|
|
|
|
|
private void send(Message message){
|
|
|
- log.info("消息发送 exchange={} routingkey={} 用户id={}",receiveExchangeName,dispathRoutingKey,message.getUserId());
|
|
|
+ log.debug("消息发送 exchange={} routingkey={} 用户id={}",receiveExchangeName,dispathRoutingKey,message.getUserId());
|
|
|
messageRabbitTemplate.convertAndSend(receiveExchangeName,dispathRoutingKey, JSONObject.toJSONString(message));
|
|
|
}
|
|
|
|
|
@@ -85,7 +88,7 @@ public class ReceiveData {
|
|
|
public void received(byte[] receivedData) {
|
|
|
|
|
|
try {
|
|
|
- log.info("rabbitMq接收消息:"+new String(receivedData));
|
|
|
+ log.debug("rabbitMq接收消息:"+new String(receivedData));
|
|
|
receivedDataHandle(receivedData);
|
|
|
} catch (Exception e) {
|
|
|
log.error(ExceptionUtils.getStackTrace(e));
|
|
@@ -230,7 +233,6 @@ public class ReceiveData {
|
|
|
message.setChannel(0); //渠道
|
|
|
Integer companyOrgId = deviceCheckAlarmDto.getCompanyOrgId();
|
|
|
Integer departmentOrgId = deviceCheckAlarmDto.getDeptOrgId();
|
|
|
- log.info("推送报警消息开始");
|
|
|
try{
|
|
|
List<Integer> taskUsers = userCenterClient.findUserIdsByPermissonOrg(deviceCheckAlarmDto.getTenantId(),companyOrgId,departmentOrgId);
|
|
|
if(taskUsers!=null){
|
|
@@ -248,32 +250,52 @@ public class ReceiveData {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //处理完成后,剩下的标记为历史数据
|
|
|
- for(AlarmDetailsDto alarmDetailsDto:alarmDetailsDtoMap.values()){
|
|
|
- alarmDetailsDto.setState(0);
|
|
|
- alarmDetailsDto.setAlarmEndTime(receiveDateTime);
|
|
|
- alarmDetailsDto.setDateUpdate(new Date());
|
|
|
- alarmDetailMapper.update(alarmDetailsDto);
|
|
|
- }
|
|
|
+
|
|
|
//批量插入新增报警
|
|
|
if(insert.size()>0){
|
|
|
alarmDetailMapper.batchInsert(insert);
|
|
|
}
|
|
|
|
|
|
+ if(alarmDetailsDtoMap.values().size() > 0){
|
|
|
+ //处理完成后,剩下的标记为历史数据
|
|
|
+ List<Long> deviceIds = new ArrayList<>();
|
|
|
+ deviceIds.add(monitorDataEntity.getDeviceId().longValue());
|
|
|
+ List<WorkOrderManageByAlarmDto> workOrders = operationManagerClient.findWorkOrderByDeviceIds(deviceIds);
|
|
|
+ if(workOrders.size()>0){
|
|
|
+ WorkOrderManageByAlarmDto orderManageByAlarmDto = workOrders.get(0);
|
|
|
+ String taskDesc = orderManageByAlarmDto.getTaskDesc();
|
|
|
+ //标记为历史数据 并 修改工单描述
|
|
|
+ for(AlarmDetailsDto alarmDetailsDto : alarmDetailsDtoMap.values()){
|
|
|
+ alarmDetailsDto.setState(0);
|
|
|
+ alarmDetailsDto.setAlarmEndTime(receiveDateTime);
|
|
|
+ alarmDetailsDto.setDateUpdate(new Date());
|
|
|
+ alarmDetailMapper.update(alarmDetailsDto);
|
|
|
+
|
|
|
+ taskDesc = taskDesc.replace(";"+alarmDetailsDto.getAlarmContent(),"")
|
|
|
+ .replace(alarmDetailsDto.getAlarmContent(),"");
|
|
|
+ }
|
|
|
+ orderManageByAlarmDto.setTaskDesc(taskDesc);
|
|
|
+ if(orderManageByAlarmDto != null && orderManageByAlarmDto.getOrderStatus() == 0
|
|
|
+ && StringUtils.isBlank(taskDesc)){
|
|
|
+ //工单未派单且无报警信息,删除工单
|
|
|
+ operationManagerClient.batchDeleteByAlarms(new ArrayList<>(deviceIds));
|
|
|
+ }else{
|
|
|
+ //其他情况修改描述
|
|
|
+ operationManagerClient.updateByAlarms(workOrders);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//报警恢复的删除工单
|
|
|
- Map<Integer,AlarmDetailsEntity> AlarmDtoNewsMap = insert.stream().collect(Collectors.toMap(AlarmDetailsEntity::getDeviceId, a -> a,(k1, k2)->k1));
|
|
|
- Map<Integer,AlarmDetailsEntity> AlarmDtoOldsMap = update.stream().collect(Collectors.toMap(AlarmDetailsEntity::getDeviceId, a -> a,(k1, k2)->k1));
|
|
|
- Set<Long> deviceIds = alarmDetailsDtoMap.values().stream()
|
|
|
- .filter(a -> !(AlarmDtoNewsMap.containsKey(a.getDeviceId())||AlarmDtoOldsMap.containsKey(a.getDeviceId())))
|
|
|
- .map(a -> a.getDeviceId().longValue())
|
|
|
- .collect(Collectors.toSet());
|
|
|
- if(deviceIds.size()>0){
|
|
|
- operationManagerClient.batchDeleteByAlarms(new ArrayList<>(deviceIds));
|
|
|
- }
|
|
|
+// Map<Integer,AlarmDetailsEntity> AlarmDtoOldsMap = update.stream().collect(Collectors.toMap(AlarmDetailsEntity::getDeviceId, a -> a,(k1, k2)->k1));
|
|
|
+// Set<Long> deviceIds = alarmDetailsDtoMap.values().stream()
|
|
|
+// .filter(a -> !AlarmDtoOldsMap.containsKey(a.getDeviceId()))
|
|
|
+// .map(a -> a.getDeviceId().longValue())
|
|
|
+// .collect(Collectors.toSet());
|
|
|
+// if(deviceIds.size()>0){
|
|
|
+// operationManagerClient.batchDeleteByAlarms(new ArrayList<>(deviceIds));
|
|
|
+// }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|