Browse Source

fix:设备绑定其它站点(集控中心)的厂信息点查不到数据

show
luyie 4 weeks ago
parent
commit
32e6d5b459
  1. 40
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  2. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StFocusPropertiesController.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/StFocusPropertiesService.java
  4. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StFocusPropertiesServiceImpl.java
  5. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  6. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

40
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -48,6 +48,7 @@ import java.util.stream.Stream;
/**
* 集中监控数据获取实现类
*
* @author ysj
*/
@Service
@ -108,7 +109,8 @@ public class MonitorServiceImpl implements MonitorService {
}
// 设备监测点list
Object json = redisTemplate.opsForValue().get(device_cache_final);
List<EminfoAndEmParamVo> eminfoAndEmParams = JSONObject.parseObject(json.toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
List<EminfoAndEmParamVo> eminfoAndEmParams = JSONObject.parseObject(json.toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
});
// 厂房监测点list
List<AnalyzeCodeBySignagesVO> wsMonitorList = this.getRealIdByWsCodeAndSign();
// 实时监控监测点list
@ -149,7 +151,9 @@ public class MonitorServiceImpl implements MonitorService {
@Override
public void loadRealData(String param) {
// 获取设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});;
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
});
;
// 设备开关机集合监测点
List<String> switchOnOff = devices.stream().map(o -> {
Map<String, String> points = o.getPoint();
@ -187,11 +191,11 @@ public class MonitorServiceImpl implements MonitorService {
if (CollectionUtil.isEmpty(realIds)) {
return;
}
log.error("real_time_data: {},{}",stationReal.getStation(),realIds);
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(), realIds);
List<String> emptyIds = new ArrayList<>();
for (int i = 0; i < realIds.size(); i++) {
if (ObjectUtil.isEmpty(objects.get(i))) {
log.error(realIds.get(i) + "is null");
emptyIds.add(realIds.get(i));
} else {
Map<String, String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId", attribute.get("k"));
@ -205,6 +209,25 @@ public class MonitorServiceImpl implements MonitorService {
keyMap.put(realIdArr[i], attribute);
}
}
if (CollectionUtil.isNotEmpty(emptyIds)) {
List<String> restList = redisClient.getBatchRealDataByRealId("901200000034", emptyIds);
for (int i = 0; i < emptyIds.size(); i++) {
if (ObjectUtil.isEmpty(restList.get(i))) {
log.error("获取数据失败:{}", emptyIds.get(i));
} else {
Map<String, String> attribute = (Map<String, String>) JSONObject.parse(restList.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(emptyIds.get(i), attribute.get("value"));
keyMap.put(emptyIds.get(i), attribute);
}
}
}
});
countDownLatch.countDown();
}));
@ -230,6 +253,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 监测点过期数据检查
*
* @param value
* @return
*/
@ -251,6 +275,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 集中监控数据处理
*
* @param param
*/
@Override
@ -284,7 +309,8 @@ public class MonitorServiceImpl implements MonitorService {
// 所有设备分类
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final);
// 所有设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
});
// 根据站点分组
Map<String, List<StationAttributeEntity>> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId));
// 获取站点列表
@ -385,6 +411,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 获取站点属性
*
* @param stationEntityList
* @param item
*/
@ -646,6 +673,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 设置站点状态
*
* @param alarmList
* @param station
* @param key
@ -705,6 +733,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 获取厂房监测点
*
* @return
*/
private List<AnalyzeCodeBySignagesVO> getRealIdByWsCodeAndSign() {
@ -725,6 +754,7 @@ public class MonitorServiceImpl implements MonitorService {
/**
* 获取站点realId
*
* @param refDept
* @param eminfoAndEmParams
* @return

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StFocusPropertiesController.java

@ -7,6 +7,7 @@ import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.config.entity.StFocusPropertiesEntity;
import com.hnac.hzims.operational.config.service.StFocusPropertiesService;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.log.annotation.ApiLog;
@ -81,4 +82,10 @@ public class StFocusPropertiesController {
public R remove(@RequestParam("ids") String ids){
return R.data(stFocusPropertiesService.removeByIds(Func.toLongList(ids)));
}
@ApiOperation(value = "获取站点实时ID")
@GetMapping(value = "/getStationRealIds")
public R<List<StationRealVo>> getStationRealIds(@RequestParam(value = "params", required = false) String params){ ;
return R.data(stFocusPropertiesService.getStationRealIds(params));
}
}

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

@ -11,7 +11,7 @@ public interface StFocusPropertiesService extends BaseService<StFocusPropertiesE
String getRealIds();
void getStationRealIds(String param);
List<StationRealVo> getStationRealIds(String param);
List<AnalyzeCodeBySignagesVO> getRealIdByEmCodeAndSign();

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StFocusPropertiesServiceImpl.java

@ -22,6 +22,7 @@ import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.base.BaseServiceImpl;
@ -41,6 +42,7 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
public class StFocusPropertiesServiceImpl extends BaseServiceImpl<StFocusPropertiesMapper, StFocusPropertiesEntity> implements StFocusPropertiesService {
private final IStationService stationService;
@ -73,11 +75,12 @@ public class StFocusPropertiesServiceImpl extends BaseServiceImpl<StFocusPropert
}
@Override
public void getStationRealIds(String param) {
public List<StationRealVo> getStationRealIds(String param) {
// 所有站点
List<StationEntity> stationList = stationService.getAll();
log.error("所有站点:{}", JSONObject.toJSONString(stationList));
if(CollectionUtil.isEmpty(stationList)){
return;
return Lists.newArrayList();
}
// 设备监测点list
Object json = redisTemplate.opsForValue().get(em_info_list_path);
@ -116,7 +119,9 @@ public class StFocusPropertiesServiceImpl extends BaseServiceImpl<StFocusPropert
stationRealVo.setRealId(realArr);
list.add(stationRealVo);
});
log.error("实时监控站点实时设备:{}", JSONObject.toJSONString(list));
redisTemplate.opsForValue().set(moniter_realId_key,list);
return list;
}
/**

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

@ -1539,6 +1539,7 @@ public class HydropowerServiceImpl implements HydropowerService {
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 实时监测点数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
log.error("实时数据:{}",JSONObject.toJSONString(reals));
/**
* 水位
*/

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

@ -170,11 +170,11 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
if(CollectionUtil.isEmpty(realIds)){
return;
}
log.error("real_time_data: {},{}",stationReal.getStation(),realIds);
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
List<String> emptyIds = new ArrayList<>();
for(int i = 0; i < realIds.size() ;i++){
if(ObjectUtil.isEmpty(objects.get(i))){
log.error(realIds.get(i) + "is null");
emptyIds.add(realIds.get(i));
}else{
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k"));
@ -188,6 +188,25 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
keyMap.put(realIdArr[i],attribute);
}
}
if (CollectionUtil.isNotEmpty(emptyIds)) {
List<String> restList = redisClient.getBatchRealDataByRealId("901200000034", emptyIds);
for (int i = 0; i < emptyIds.size(); i++) {
if (ObjectUtil.isEmpty(restList.get(i))) {
log.error("获取数据失败:{}", emptyIds.get(i));
} else {
Map<String, String> attribute = (Map<String, String>) JSONObject.parse(restList.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(emptyIds.get(i), attribute.get("value"));
keyMap.put(emptyIds.get(i), attribute);
}
}
}
});
countDownLatch.countDown();
}));
@ -195,7 +214,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
log.error("线程等待异常",e);
Thread.currentThread().interrupt();
}
pool.shutdown();
@ -204,7 +223,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
redisTemplate.opsForValue().set(real_id_key_gather_path,JSONObject.toJSONString(keyMap));
Long endTime = System.currentTimeMillis();
Long time = endTime - beginTime;
log.error("处理redis实时数据 耗时 : {}",time);
}
/**

Loading…
Cancel
Save