|
@@ -86,20 +86,10 @@ public class ReceiveDataService {
|
|
|
List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
|
|
|
//按设备请求
|
|
|
for (WeatherStationInfo weatherStationInfo : weatherStationInfoList) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("deviceIds", new String[]{weatherStationInfo.getEquipmentNo()});
|
|
|
- paramMap.put("startTime", startTime);
|
|
|
- paramMap.put("endTime", endTime);
|
|
|
- String body = httpClient(paramMap);
|
|
|
- AnalysisData(body, weatherStationInfo.getId(), weatherStationInfo.getEquipmentType(), electricField);
|
|
|
+ map(electricField, startTime, endTime, weatherStationInfo.getEquipmentNo(), weatherStationInfo.getId(), weatherStationInfo.getEquipmentType());
|
|
|
}
|
|
|
for (InverterInfo inverterInfo : inverterInfoList) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("deviceIds", inverterInfo.getEquipmentNo());
|
|
|
- paramMap.put("startTime", startTime);
|
|
|
- paramMap.put("endTime", endTime);
|
|
|
- String body = httpClient(paramMap);
|
|
|
- AnalysisData(body, inverterInfo.getId(), inverterInfo.getEquipmentType(), electricField);
|
|
|
+ map(electricField, startTime, endTime, inverterInfo.getEquipmentNo(), inverterInfo.getId(), inverterInfo.getEquipmentType());
|
|
|
}
|
|
|
} else {
|
|
|
//测风塔
|
|
@@ -107,20 +97,10 @@ public class ReceiveDataService {
|
|
|
//风机
|
|
|
List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
|
|
|
for (WindTowerInfo windTowerInfo : windTowerInfoList) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("deviceIds", windTowerInfo.getEquipmentNo());
|
|
|
- paramMap.put("startTime", startTime);
|
|
|
- paramMap.put("endTime", endTime);
|
|
|
- String body = httpClient(paramMap);
|
|
|
- AnalysisData(body, windTowerInfo.getId(), windTowerInfo.getEquipmentType(), electricField);
|
|
|
+ map(electricField, startTime, endTime, windTowerInfo.getEquipmentNo(), windTowerInfo.getId(), windTowerInfo.getEquipmentType());
|
|
|
}
|
|
|
for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
|
|
|
- HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
- paramMap.put("deviceIds", windTurbineInfo.getEquipmentNo());
|
|
|
- paramMap.put("startTime", startTime);
|
|
|
- paramMap.put("endTime", endTime);
|
|
|
- String body = httpClient(paramMap);
|
|
|
- AnalysisData(body, windTurbineInfo.getId(), windTurbineInfo.getEquipmentType(), electricField);
|
|
|
+ map(electricField, startTime, endTime, windTurbineInfo.getEquipmentNo(), windTurbineInfo.getId(), windTurbineInfo.getEquipmentType());
|
|
|
}
|
|
|
}
|
|
|
savePowerStationStatusData(electricField);
|
|
@@ -130,6 +110,15 @@ public class ReceiveDataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void map(ElectricField electricField, Long startTime, Long endTime, String equipmentNo, Integer id, EquipmentTypeEnum equipmentType) {
|
|
|
+ HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("deviceIds", equipmentNo);
|
|
|
+ paramMap.put("startTime", startTime);
|
|
|
+ paramMap.put("endTime", endTime);
|
|
|
+ String body = httpClient(paramMap);
|
|
|
+ AnalysisData(body, id, equipmentType, electricField);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 解析数据
|
|
|
*
|
|
@@ -174,77 +163,70 @@ public class ReceiveDataService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- log.info("qxz-" + electricField.getStationCode() + "-" + equipmentId+" "+"该设备没有数据"+"存入-99");
|
|
|
- map.put("stationCode",electricField.getStationCode());
|
|
|
- map.put("equipmentId", equipmentId.toString());
|
|
|
- map.put("time", simpleDateFormat.format(new Date().getTime()));
|
|
|
- for (DataPoint dataPoint : dataPointList) {
|
|
|
- for (Object sensorId : sensorIds) {
|
|
|
- if (dataPoint.getMeasuringPoint().equals(sensorId)) {
|
|
|
- map.put(dataPoint.getEquipmentAttribute().getFieldName(), "-99");
|
|
|
+ switch (map.get("status")) {
|
|
|
+ case "1.00":
|
|
|
+ case "true":
|
|
|
+ //运行
|
|
|
+ map.put("status", "1");
|
|
|
+ break;
|
|
|
+ case "2.00":
|
|
|
+ //待机
|
|
|
+ map.put("status", "2");
|
|
|
+ break;
|
|
|
+ case "3.00":
|
|
|
+ //停用
|
|
|
+ map.put("status", "3");
|
|
|
+ break;
|
|
|
+ case "4.00":
|
|
|
+ case "false":
|
|
|
+ //故障
|
|
|
+ map.put("status", "4");
|
|
|
+ break;
|
|
|
+ case "-99":
|
|
|
+ map.put("status", "5");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch(equipmentType.getCode()){
|
|
|
+ case 1:
|
|
|
+ //气象站
|
|
|
+ redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
+ WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
|
|
|
+ weatherStationStatusDataRepository.save(weatherStationStatusData);
|
|
|
+ log.info("qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //逆变器
|
|
|
+ if (map.get("activePower") != null && map.get("electricalCurrent") != null) {
|
|
|
+ //有功
|
|
|
+ BigDecimal activePower = new BigDecimal(map.get("activePower"));
|
|
|
+ //电流
|
|
|
+ BigDecimal electricalCurrent = new BigDecimal(map.get("electricalCurrent"));
|
|
|
+ //有功/电流=电压
|
|
|
+ BigDecimal voltage = activePower.divide(electricalCurrent, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ map.put("voltage", voltage.toString());
|
|
|
}
|
|
|
- }
|
|
|
+ redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
+ InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
|
|
|
+ inverterStatusDataRepository.save(inverterStatusData);
|
|
|
+ log.info("nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
+ WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
|
|
|
+ windTurbineStatusDataRepository.save(windTurbineStatusData);
|
|
|
+ log.info("fj-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ redisUtils.hmset("cft-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
+ WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
|
|
|
+ windTowerStatusDataRepository.save(windTowerStatusData);
|
|
|
+ log.info("cft-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
+ break;
|
|
|
}
|
|
|
+ }else {
|
|
|
+ log.info(electricField.getStationCode()+ "-" +equipmentType.getMessage() + "-" + equipmentId+"无数据,不进行任何操作");
|
|
|
}
|
|
|
- switch (map.get("status")) {
|
|
|
- case "1.00":
|
|
|
- case "true":
|
|
|
- //运行
|
|
|
- map.put("status", "1");
|
|
|
- break;
|
|
|
- case "2.00":
|
|
|
- //待机
|
|
|
- map.put("status", "2");
|
|
|
- break;
|
|
|
- case "3.00":
|
|
|
- //停用
|
|
|
- map.put("status", "3");
|
|
|
- break;
|
|
|
- case "4.00":
|
|
|
- case "false":
|
|
|
- //故障
|
|
|
- map.put("status", "4");
|
|
|
- break;
|
|
|
- case "-99":
|
|
|
- map.put("status", "5");
|
|
|
- break;
|
|
|
- }
|
|
|
- //光
|
|
|
- if(equipmentType.getCode() == 1){
|
|
|
|
|
|
- //气象站
|
|
|
- redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
- WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
|
|
|
- weatherStationStatusDataRepository.save(weatherStationStatusData);
|
|
|
- log.info("qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
- }else if (equipmentType.getCode() == 2){
|
|
|
- //逆变器
|
|
|
- if (map.get("activePower") != null && map.get("electricalCurrent") != null) {
|
|
|
- //有功
|
|
|
- BigDecimal activePower = new BigDecimal(map.get("activePower"));
|
|
|
- //电流
|
|
|
- BigDecimal electricalCurrent = new BigDecimal(map.get("electricalCurrent"));
|
|
|
- //有功/电流=电压
|
|
|
- BigDecimal voltage = activePower.divide(electricalCurrent, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- map.put("voltage", voltage.toString());
|
|
|
- }
|
|
|
- redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
- InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
|
|
|
- inverterStatusDataRepository.save(inverterStatusData);
|
|
|
- log.info("nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
- }
|
|
|
- if(equipmentType.getCode() == 4){
|
|
|
- redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
- WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
|
|
|
- windTurbineStatusDataRepository.save(windTurbineStatusData);
|
|
|
- log.info("fj-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
- } else if(equipmentType.getCode() == 3){
|
|
|
- redisUtils.hmset("cft-" + electricField.getStationCode() + "-" + equipmentId, map);
|
|
|
- WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
|
|
|
- windTowerStatusDataRepository.save(windTowerStatusData);
|
|
|
- log.info("cft-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
|
|
|
- }
|
|
|
} catch (Exception e) {
|
|
|
log.info("接数程序异常");
|
|
|
e.printStackTrace();
|