Browse Source

#bug修改

zhongwei
yang_shj 2 years ago
parent
commit
51b036dbc5
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java
  3. 74
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
  4. 82
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java
  6. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java
  7. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  8. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  9. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java
  10. 34
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -10,6 +10,8 @@ public interface AbnormalAlarmConstant {
List<String> TYPE_LIST = Arrays.asList("3","2","5","10","13","14"); List<String> TYPE_LIST = Arrays.asList("3","2","5","10","13","14");
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14");
String LEVEL_TYPE_LIST = "3,2,5,10,13,14"; String LEVEL_TYPE_LIST = "3,2,5,10,13,14";
/**通讯恢复*/ /**通讯恢复*/

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java

@ -156,4 +156,7 @@ public class StationEntity extends TenantEntity implements Serializable {
@ApiModelProperty("实时画面绑定账号秘钥") @ApiModelProperty("实时画面绑定账号秘钥")
private String secretKey; private String secretKey;
@ApiModelProperty("是否发送告警短信: 1-发送短信 0-不发送短信")
private Integer isSendMessage;
} }

74
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -1,8 +1,12 @@
package com.hnac.hzims.operational.alert.service.impl; package com.hnac.hzims.operational.alert.service.impl;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity;
import com.hnac.hzims.operational.alert.mapper.AbnormalAlarmMapper; import com.hnac.hzims.operational.alert.mapper.AbnormalAlarmMapper;
import com.hnac.hzims.operational.alert.service.AbnormalAlarmService; import com.hnac.hzims.operational.alert.service.AbnormalAlarmService;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
@ -18,9 +22,14 @@ 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.mp.base.BaseServiceImpl; 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.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -32,6 +41,7 @@ import java.util.stream.Collectors;
/** /**
* 告警实现类 * 告警实现类
* @author ysj
*/ */
@Slf4j @Slf4j
@Service @Service
@ -42,8 +52,14 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
private final HistoryAbnormalAlarmService historyAbnormalAlarmService; private final HistoryAbnormalAlarmService historyAbnormalAlarmService;
private final ISysClient sysClient;
private final ISoeClient soeClient; private final ISoeClient soeClient;
private final IUserClient userClient;
private final IMessageClient messageClient;
/** /**
* 数据中断数据异常告警 * 数据中断数据异常告警
* @param param * @param param
@ -140,8 +156,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
// 历史数据异常查询 // 历史数据异常查询
HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType()); HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType());
// 数据中断恢复 // 数据中断恢复
// boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType()); boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType());
boolean flag = true;
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null); String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
if(ObjectUtil.isEmpty(queryEntity) || !flag){ if(ObjectUtil.isEmpty(queryEntity) || !flag){
HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity(); HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity();
@ -153,6 +168,8 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
entity.setStartTime(ts); entity.setStartTime(ts);
entity.setStatus(0); entity.setStatus(0);
this.historyAbnormalAlarmService.save(entity); this.historyAbnormalAlarmService.save(entity);
// 消息推送
this.sendAlarmMessage(Collections.singletonList(entity),stations);
return; return;
} }
Random random = new Random(); Random random = new Random();
@ -167,4 +184,57 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
}); });
return "success"; return "success";
} }
/**
* 告警消息推送
* @param entitys
*/
private void sendAlarmMessage(List<HistoryAbnormalAlarmEntity> entitys,List<StationEntity> stations) {
if(CollectionUtil.isEmpty(entitys)){
return;
}
// 告警等级 :事故、数据中断
List<HistoryAbnormalAlarmEntity> alarms = entitys.stream().filter(entity -> AbnormalAlarmConstant.SEND_MESSSAGE_TYPE_LIST.contains(entity.getType())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(alarms)){
return;
}
// 查询站点用户
entitys.forEach(entity->{
if(StringUtil.isEmpty(entity.getStationId())){
return;
}
List<Long> depts = stations.stream().filter(station -> station.getCode().equals(entity.getStationId())).map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(depts)){
return;
}
// 获取站点用户
R<List<User>> result = userClient.userListByDeptId(depts.get(0));
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return;
}
MessagePushRecordDto message = new MessagePushRecordDto();
message.setBusinessClassify("warning");
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription());
message.setTaskId(entity.getId());
message.setTenantId("200000");
message.setContent(entity.getSoeExplain());
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY);
message.setDeptId(depts.get(0));
R<String> deptName = sysClient.getDeptName(depts.get(0));
if (deptName.isSuccess()) {
message.setDeptName(deptName.getData());
}
User admin = userClient.userByAccount("200000", "admin").getData();
message.setCreateDept(admin.getCreateDept());
message.setCreateUser(admin.getCreateUser());
result.getData().forEach(user->{
message.setPusher(String.valueOf(user.getId()));
message.setPusherName(user.getName());
message.setAccount(String.valueOf(user.getId()));
messageClient.sendMessage(message);
});
});
}
} }

82
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java

@ -3,6 +3,9 @@ package com.hnac.hzims.operational.alert.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity;
import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService; import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService;
@ -15,13 +18,20 @@ import com.hnac.hzims.operational.station.service.IStationService;
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.log.exception.ServiceException;
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.core.tool.utils.StringUtil;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,6 +50,12 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
private final HistoryLevelAlarmService historyLevelAlarmService; private final HistoryLevelAlarmService historyLevelAlarmService;
private final IUserClient userClient;
private final ISysClient sysClient;
private final IMessageClient messageClient;
/** /**
* 定时发送消息内容 * 定时发送消息内容
* @return String * @return String
@ -121,13 +137,75 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
historyLevelAlarmService.saveBatch(entitys); historyLevelAlarmService.saveBatch(entitys);
// 消息推送 // 消息推送
this.sendAlarmMessage(entitys); CompletableFuture.runAsync(()->this.sendAlarmMessage(entitys,stations.stream().filter(station -> entitys.stream().filter(stationId -> !StringUtil.isEmpty(stationId)).map(HistoryLevelAlarmEntity::getStationId).collect(Collectors.toList()).contains(station.getCode())).collect(Collectors.toList())));
} }
/** /**
* 告警消息推送 * 告警消息推送
* @param entitys * @param entitys
*/ */
private void sendAlarmMessage(List<HistoryLevelAlarmEntity> entitys) { private void sendAlarmMessage(List<HistoryLevelAlarmEntity> entitys,List<StationEntity> stations) {
if(CollectionUtil.isEmpty(entitys)){
return;
}
// 告警等级 :一级、二级告警发送通知
List<HistoryLevelAlarmEntity> alarms = entitys.stream().filter(entity -> AbnormalAlarmConstant.LEVEL_LIST.contains(entity.getAlarmLevel())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(alarms)){
return;
}
// 查询站点用户
entitys.forEach(entity->{
if(StringUtil.isEmpty(entity.getStationId())){
return;
}
List<Long> depts = stations.stream().filter(station -> station.getCode().equals(entity.getStationId())).map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(depts)){
return;
}
// app,web消息推送
this.sendMessageByWebApp(depts.get(0),entity);
// 短信推送
this.message(depts.get(0),entity);
});
}
private void sendMessageByWebApp(Long dept,HistoryLevelAlarmEntity entity) {
// 获取站点用户
R<List<User>> result = userClient.userListByDeptId(dept);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return;
}
MessagePushRecordDto message = new MessagePushRecordDto();
message.setBusinessClassify("warning");
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription());
message.setTaskId(entity.getId());
message.setTenantId("200000");
message.setContent(entity.getSoeExplain());
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY);
message.setDeptId(dept);
R<String> deptName = sysClient.getDeptName(dept);
if (deptName.isSuccess()) {
message.setDeptName(deptName.getData());
}
User admin = userClient.userByAccount("200000", "admin").getData();
message.setCreateDept(admin.getCreateDept());
message.setCreateUser(admin.getId());
result.getData().forEach(user->{
message.setPusher(String.valueOf(user.getId()));
message.setPusherName(user.getName());
message.setAccount(String.valueOf(user.getId()));
messageClient.sendMessage(message);
});
}
/**
* 发送短信
* @param dept
* @param entity
*/
private void message(Long dept,HistoryLevelAlarmEntity entity) {
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java

@ -29,7 +29,7 @@ public class LevelAlarmRegular{
private LevelAlarmService levelAlarmService; private LevelAlarmService levelAlarmService;
// 定时发送消息 // 定时发送消息
@Scheduled(cron = "0/30 * * * * ?") @Scheduled(cron = "0 0 1 * * ?")
private void regular(){ private void regular(){
// 检查链接存活状态 // 检查链接存活状态
if(ObjectUtil.isNotEmpty(client) && client.isOpen()){ if(ObjectUtil.isNotEmpty(client) && client.isOpen()){

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

@ -237,10 +237,9 @@ public class ScheduledCreateTask {
* 水利-泵组实时加载 * 水利-泵组实时加载
* @return ReturnT<String> * @return ReturnT<String>
*/ */
//@XxlJob(LOAD_WATER_PUMP_REAL) @XxlJob(LOAD_WATER_PUMP_REAL)
@Scheduled(cron = "0/10 * * * * ? ") //@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> loadWaterPumpReal() throws Exception { public ReturnT<String> loadWaterPumpReal(String param) throws Exception {
String param = "";
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
} }
@ -254,7 +253,7 @@ public class ScheduledCreateTask {
* @return ReturnT<String> * @return ReturnT<String>
*/ */
@XxlJob(LOAD_WATER_PUMP_TARGET) @XxlJob(LOAD_WATER_PUMP_TARGET)
//@Scheduled(cron = "0/10 * * * * ? ") //@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterPumpTarget(String param) throws Exception { public ReturnT<String> loadWaterPumpTarget(String param) throws Exception {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");

15
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -154,7 +154,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 装机容量 // 装机容量
real.setInstalledCapacity(device.getInstalledCapacity()); real.setInstalledCapacity(device.getInstalledCapacity());
// 开关机状态 // 开关机状态
real.setState(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0); real.setState(this.hydropowerState(device,map));
// 有功功率 // 有功功率
real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER)); real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER));
// 无功功率 // 无功功率
@ -226,6 +226,19 @@ public class HydropowerServiceImpl implements HydropowerService {
/** /**
* 设备状态
* @param device
* @param map
* @return
*/
private Boolean hydropowerState(EminfoAndEmParamVo device, Map<String, String> map) {
if(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0){
return true;
}
return Math.abs(this.getSignageValue(device, map, HomePageConstant.ACTIVE_POWER)) > 0;
}
/**
* 近年发电量数据 * 近年发电量数据
* *
* @param param 时间 * @param param 时间

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -24,7 +24,6 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.jsoup.helper.DataUtil;
import org.springblade.core.log.exception.ServiceException; 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;
@ -42,7 +41,6 @@ import java.math.BigDecimal;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java

@ -2,19 +2,11 @@ package com.hnac.hzims.operational.maintenance.scheduled;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Lists;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.dto.PlanMsgRecordDto; import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.message.req.PushExtrasReq;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.maintenance.OperationalContants;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper;
@ -23,7 +15,6 @@ import com.hnac.hzims.operational.maintenance.template.service.TemplateService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -31,17 +22,14 @@ import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.system.user.cache.UserCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.*; import java.time.Instant;
import java.time.format.DateTimeFormatter; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;

34
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

@ -176,24 +176,27 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
return; return;
} }
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds); List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
if(CollectionUtil.isEmpty(objects)){ for(int i = 0; i < realIds.size() ;i++){
return;
}
for(int i = 0; i < objects.size() ;i++){
if(ObjectUtil.isEmpty(objects.get(i))){ if(ObjectUtil.isEmpty(objects.get(i))){
Map<String,String> attribute = new ConcurrentHashMap<>();
attribute.put("realId",realIds.get(i));
attribute.put("value","0");
attribute.put("time",DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss.s"));
valueMap.put(realIdArr[i],attribute.get("value"));
keyMap.put(realIdArr[i],attribute);
log.error(realIds.get(i) + "is null"); log.error(realIds.get(i) + "is null");
continue; }else{
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v"));
attribute.put("time",attribute.get("t"));
attribute.remove("v");
attribute.remove("k");
attribute.remove("t");
this.getCheckMap(attribute,switchOnOff);
valueMap.put(realIdArr[i],attribute.get("value"));
keyMap.put(realIdArr[i],attribute);
} }
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v"));
attribute.put("time",attribute.get("t"));
attribute.remove("v");
attribute.remove("k");
attribute.remove("t");
this.getCheckMap(attribute,switchOnOff);
valueMap.put(realIdArr[i],attribute.get("value"));
keyMap.put(realIdArr[i],attribute);
} }
}); });
countDownLatch.countDown(); countDownLatch.countDown();
@ -377,6 +380,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
beginTime = System.currentTimeMillis(); beginTime = System.currentTimeMillis();
// 获取所有设备重点属性 // 获取所有设备重点属性
List<StationAttributeEntity> list = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{ List<StationAttributeEntity> list = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{
isNotNull(StationAttributeEntity::getStationId);
eq(StationAttributeEntity::getIsDeleted, "0"); eq(StationAttributeEntity::getIsDeleted, "0");
orderByAsc(StationAttributeEntity::getSort); orderByAsc(StationAttributeEntity::getSort);
}}); }});

Loading…
Cancel
Save