Browse Source

#光伏首页

zhongwei
yang_shj 2 years ago
parent
commit
3d5e2d6ac6
  1. 19
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  2. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java
  3. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java
  4. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java
  5. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  6. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java
  7. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java
  8. 65
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  9. 71
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java
  10. 299
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  11. 41
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

19
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -61,7 +61,8 @@ public interface HomePageConstant {
List<String> SIGNAGES = Arrays.asList(HomePageConstant.JOINT_RELAY,HomePageConstant.SWITCH_ON_OFF,HomePageConstant.ELECTRICITY_CONSUMPTION, List<String> SIGNAGES = Arrays.asList(HomePageConstant.JOINT_RELAY,HomePageConstant.SWITCH_ON_OFF,HomePageConstant.ELECTRICITY_CONSUMPTION,
HomePageConstant.ACTIVE_POWER,HomePageConstant.REACTIVE_POWER,HomePageConstant.POWER_FACTOR,HomePageConstant.VOLTAGE,HomePageConstant.CURRENT, HomePageConstant.ACTIVE_POWER,HomePageConstant.REACTIVE_POWER,HomePageConstant.POWER_FACTOR,HomePageConstant.VOLTAGE,HomePageConstant.CURRENT,
HomePageConstant.HYDROPOWER_GENERATE_POWER,HomePageConstant.HYDROPOWER_POWERFACTOR,HomePageConstant.HYDROPOWER_FREQUENCY,HomePageConstant.HYDROPOWER_GUIDEOPEN, HomePageConstant.HYDROPOWER_GENERATE_POWER,HomePageConstant.HYDROPOWER_POWERFACTOR,HomePageConstant.HYDROPOWER_FREQUENCY,HomePageConstant.HYDROPOWER_GUIDEOPEN,
HomePageConstant.HYDROPOWER_VOLTAGE,HomePageConstant.HYDROPOWER_CURRENT,HomePageConstant.UNIT_SPEED,HomePageConstant.ACTIVE_POWER_GIVEN,HomePageConstant.REACTIVE_POWER_GIVEN); HomePageConstant.HYDROPOWER_VOLTAGE,HomePageConstant.HYDROPOWER_CURRENT,HomePageConstant.UNIT_SPEED,HomePageConstant.ACTIVE_POWER_GIVEN,HomePageConstant.REACTIVE_POWER_GIVEN,
HomePageConstant.PV_GENERATION_DAY);
/** /**
* 站点类型 运维服务 * 站点类型 运维服务
@ -168,16 +169,24 @@ public interface HomePageConstant {
String P_ATTRIBUTES = "P"; String P_ATTRIBUTES = "P";
/*==========================================================================================*/ /*==========================================================================================*/
// 光伏电站-电表-物模型监测点标识 // 光伏电站-电表-物模型监测点标识
/**开关机状态**/
String PV_JOINT_RELAY = "joint_relay";
/**总有功电度**/ /**总有功电度**/
String PV_GENERATION_CAPACITY = "generation_capacity"; String PV_GENERATION_CAPACITY = "generation_capacity";
/**日发电量**/
String PV_GENERATION_DAY = "generate_day";
/**有功功率**/
String PV_LOAD = "active_power";
/**正向无功**/ /**正向无功**/
String PV_REACTIVE_POWER = "reactive_power"; String PV_REACTIVE_POWER = "reactive_power";
/**遥信1**/ /**电压**/
String PV_JOINT_RELAY = "joint_relay"; String PV_VOLTAGE = "voltage";
/**电流**/
String PV_CURRENT = "current";
/*==========================================================================================*/ /*==========================================================================================*/
// 光伏指标属性 // 光伏指标属性
String PHOTOVOLTAIC_GENERATE = "generation_capacity"; // 发电量 String PHOTOVOLTAIC_OFF = "1.0"; // 开机
String PHOTOVOLTAIC_LOAD = "active_power"; // 功率
String PHOTOVOLTAIC_LOAD_TARGET = "0"; String PHOTOVOLTAIC_LOAD_TARGET = "0";
/*==========================================================================================*/ /*==========================================================================================*/

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java

@ -10,7 +10,7 @@ import lombok.Data;
public class PhotovoltaicPowerVo { public class PhotovoltaicPowerVo {
@ApiModelProperty(value = "小时") @ApiModelProperty(value = "小时")
private String hour; private Integer hour;
@ApiModelProperty(value = "有功功率") @ApiModelProperty(value = "有功功率")
private String activePower; private String activePower;

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.Now;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -50,8 +51,8 @@ public class PhotovoltaicStationAppVo {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate; private Double generate;
@ApiModelProperty(value = "站点实时温度") @ApiModelProperty(value = "天气")
private String temp; private Now now;
@ApiModelProperty(value = "站点收益") @ApiModelProperty(value = "站点收益")
private Double income; private Double income;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java

@ -3,7 +3,7 @@ package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Now;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -25,8 +25,8 @@ public class PhotovoltaicSubordinateAppVo {
@ApiModelProperty(value = "机构名称") @ApiModelProperty(value = "机构名称")
private String deptName; private String deptName;
@ApiModelProperty(value = "温度") @ApiModelProperty(value = "天气")
private String temp; private Now now;
@ApiModelProperty(value = "地址") @ApiModelProperty(value = "地址")
private String address; private String address;

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

@ -270,6 +270,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
return record; return record;
}).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) }).sorted(Comparator.comparing(AlarmDataVo::getIsHandle)
.thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); .thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList());
response.setCount(datas.size()); response.setCount(datas.size());
response.setSoeList(datas); response.setSoeList(datas);
response.setTotal(result.getData().getTotal()); response.setTotal(result.getData().getTotal());

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

@ -175,7 +175,7 @@ public class ScheduledCreateTask {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
} }
homePageService.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),SERVE_TYPE,2); homePageService.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),SERVE_TYPE,3);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
@ -292,30 +292,30 @@ public class ScheduledCreateTask {
} }
/** /**
* 光伏站-逆变器指标加载 * 光伏站-逆变器实时加载
* @return ReturnT<String> * @return ReturnT<String>
*/ */
@XxlJob(LOAD_PHOTOVOLTAIC_TARGET) @XxlJob(LOAD_PHOTOVOLTAIC_REAL)
//@Scheduled(cron = "0/40 * * * * ? ") //@Scheduled(cron = "0/50 * * * * ? ")
public ReturnT<String> loadPhotovoltaicTarget(String param) throws Exception { public ReturnT<String> loadPhotovoltaicReal(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");
} }
photovoltaicService.loadPhotovoltaicTarget(param); photovoltaicService.loadPhotovoltaicReal(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/** /**
* 光伏站-逆变器实时加载 * 光伏站-逆变器指标加载
* @return ReturnT<String> * @return ReturnT<String>
*/ */
@XxlJob(LOAD_PHOTOVOLTAIC_REAL) @XxlJob(LOAD_PHOTOVOLTAIC_TARGET)
//@Scheduled(cron = "0/50 * * * * ? ") //@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadPhotovoltaicReal(String param) throws Exception { public ReturnT<String> loadPhotovoltaicTarget(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");
} }
photovoltaicService.loadPhotovoltaicReal(param); photovoltaicService.loadPhotovoltaicTarget(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
} }

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

@ -18,4 +18,5 @@ public interface IAnalyseDataService {
List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages);
Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages);
} }

65
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.main.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
@ -14,6 +15,8 @@ import lombok.AllArgsConstructor;
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;
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.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -21,6 +24,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -45,12 +49,13 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
} }
/*** /***
* 指标数据查询 * 指标数据列表查询
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param cycleType * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param deviceCode * @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param signages * @param deviceCode 设备编号
* @param signages 指标
* @return * @return
*/ */
@Override @Override
@ -61,9 +66,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
analyzeDataConditionPO.setFull(1); analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode); po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages); analyzeDataConditionPO.setSignages(signages);
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
analyzeDataConditionPO.setAccessRules(accessRules); analyzeDataConditionPO.setAccessRules(accessRules);
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
analyzeDataConditionPO.setSaveTimeType(cycleType); analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔 // 间隔
analyzeDataConditionPO.setTimeInterval(1); analyzeDataConditionPO.setTimeInterval(1);
@ -78,5 +81,55 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
return result.getData().get(0).getList(); return result.getData().get(0).getList();
} }
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param cycleType 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param deviceCode 设备编号
* @param ride 配电比
* @param signages 指标
* @return
*/
@Override
public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return 0f;
}
List<AnalyzeDataConditionVO> records = result.getData();
if(CollectionUtil.isEmpty(records)){
return 0f;
}
AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0);
if (ObjectUtil.isEmpty(analyzeDataConditionVO)) {
return 0f;
}
List<AnalyseDataTaosVO> analyseDataTaosVOList = analyzeDataConditionVO.getList();
if (CollectionUtil.isEmpty(analyseDataTaosVOList)) {
return 0f;
}
AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0);
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) {
return 0f;
}
return Float.parseFloat(analyseDataTaosVO.getVal()) * ride;
}
} }

71
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java

@ -11,6 +11,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.monitor.utils.DateUtils;
import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.fill.entity.*;
import com.hnac.hzims.operational.fill.service.*; import com.hnac.hzims.operational.fill.service.*;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzims.operational.main.service.IHomePageService; import com.hnac.hzims.operational.main.service.IHomePageService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; import com.hnac.hzims.operational.main.service.IMainTaskStatisticService;
@ -69,7 +70,8 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class HomePageServiceImpl implements IHomePageService { public class HomePageServiceImpl implements IHomePageService {
private final IAnalyseDataSearchClient analyseDataSearchClient;
private final IAnalyseDataService analyseDataService;
private final IPlanGenertionClient planGenertionClient; private final IPlanGenertionClient planGenertionClient;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final IMainTaskStatisticService mainTaskStatisticService; private final IMainTaskStatisticService mainTaskStatisticService;
@ -219,41 +221,70 @@ public class HomePageServiceImpl implements IHomePageService {
* *
* @param param 时间 * @param param 时间
* @param serveType 站点类型 * @param serveType 站点类型
* @param yearCount 近几年 * @param year 近几年
*/ */
@Override @Override
public void loadPowerData(String param,List<Integer> types, Integer serveType, int yearCount) { public void loadPowerData(String param,List<Integer> types, Integer serveType, int year) {
// 站点查询 // 站点查询
List<StationEntity> stationList = stationService.getStationType(serveType, types, null); List<StationEntity> stationList = stationService.getStationType(serveType, types, null);
// 设备信息 // 设备信息
List<EminfoAndEmParamVo> equipmentInfoList = maintenanceTaskService.getEmInfoList(); List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
// 开始事件
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>> // 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new HashMap<>(); Map<Long, Map<String, Float>> powerMap = new HashMap<>();
// 获取需要遍历月份
List<String> monList = this.getMonthList(yearCount, 12,true);
Random random = new Random();
stationList.forEach(station -> { stationList.forEach(station -> {
Long departId = station.getRefDept(); // 站点设备集合
// 获取对应站点设备 List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
List<EminfoAndEmParamVo> effEmInfoList = equipmentInfoList.stream().filter(o -> departId.equals(o.getCreateDept())).collect(Collectors.toList()); if(CollectionUtil.isEmpty(stationDevices)){
if (CollectionUtil.isEmpty(effEmInfoList)) {
return; return;
} }
Map<String, Float> floatMap = new HashMap<>(); Map<String, Float> generateMap = this.getGenerateYear(stationDevices,start,end);
for (int i = 0; i < monList.size() - 1; i++) { if(MapUtils.isEmpty(generateMap)){
if (this.compareDate(monList.get(i))) { return;
floatMap.put(monList.get(i), 0f);
continue;
}
float power = getPowerGeneration(effEmInfoList, monList.get(i) + " 00:00:00", monList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType());
floatMap.put(monList.get(i), power);
} }
powerMap.put(station.getId(), floatMap); powerMap.put(station.getId(),generateMap);
}); });
redisTemplate.opsForValue().set(RECENT_YEAR_POWER_DATA, powerMap); redisTemplate.opsForValue().set(RECENT_YEAR_POWER_DATA, powerMap);
} }
/** /**
* 获取年发电量
* @param devices
* @param start
* @param end
* @return
*/
private Map<String, Float> getGenerateYear(List<EminfoAndEmParamVo> devices, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>();
devices.forEach(device->{
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return;
}
datas.addAll(records.stream().map(record -> {
PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate;
}).collect(Collectors.toList()));
});
if(CollectionUtil.isEmpty(datas)){
return null;
}
return datas.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth, Collectors.collectingAndThen(
Collectors.mapping(PowerMonthVo::getPower, Collectors.reducing(Float::sum)),Optional::get)));
}
/**
* @param stationList * @param stationList
* @return * @return
*/ */

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

@ -22,6 +22,7 @@ import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.sdk.core.response.HzPage; 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 net.sf.jsqlparser.expression.StringValue;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
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;
@ -87,8 +88,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final static String recent_year_power_data = "hzims:operation:key:power:data"; private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String recent_year_load_data = "hzims:operation:key:load:data";
@Value("${hzims.operation.realIdKey}") @Value("${hzims.operation.realIdKey}")
public String real_id_key; public String real_id_key;
@ -109,28 +108,33 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
// 取redis实时数据 // 取redis实时数据
Map<String, String> map = this.getRealData(); Map<String, String> map = this.getRealData();
List<PhotovoltaicRealVo> list = new ArrayList<>(); if(MapUtils.isEmpty(map)){
Random random = new Random(); return;
devices.forEach(device -> { }
// redis缓存设备实时数据
List<PhotovoltaicRealVo> history = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 设备实时数据
List<PhotovoltaicRealVo> list = devices.stream().map(device -> {
PhotovoltaicRealVo real = new PhotovoltaicRealVo(); PhotovoltaicRealVo real = new PhotovoltaicRealVo();
real.setDeptId(device.getCreateDept()); real.setDeptId(device.getCreateDept());
real.setDeviceCode(device.getEmCode()); real.setDeviceCode(device.getEmCode());
real.setDeviceName(device.getName()); real.setDeviceName(device.getName());
real.setState(random.nextInt(2) - 1); real.setState(this.getPhotovoltaicState(device,map));
// 容量 // 容量
real.setCapacity(device.getInstalledCapacity()); real.setCapacity(device.getInstalledCapacity());
// 发电量 // 发电量
real.setGenerate(random.nextDouble() * 25000 * 300 * 2); real.setGenerate(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_GENERATION_CAPACITY)));
// 功率
real.setLoad(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_LOAD)));
// 电压 // 电压
real.setVoltage(random.nextDouble() * 300); real.setVoltage(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_VOLTAGE)));
// 电流 // 电流
real.setCurrent(random.nextDouble() * 300); real.setCurrent(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_CURRENT)));
// 功率
real.setLoad(random.nextDouble() * 300);
// 上次功率 // 上次功率
real.setLastLoad(random.nextDouble() * 300); real.setLastLoad(this.getLastLoad(device,history));
list.add(real); return real;
}); }).collect(Collectors.toList());
// 存储redis
redisTemplate.opsForValue().set(load_photovoltaic_real_key, list); redisTemplate.opsForValue().set(load_photovoltaic_real_key, list);
} }
@ -147,7 +151,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return; return;
} }
List<PhotovoltaicTargetVo> list = new ArrayList<>(); List<PhotovoltaicTargetVo> list = new ArrayList<>();
Random random = new Random();
devices.forEach(device -> { devices.forEach(device -> {
PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); PhotovoltaicTargetVo target = new PhotovoltaicTargetVo();
target.setDeptId(device.getCreateDept()); target.setDeptId(device.getCreateDept());
@ -155,53 +158,189 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
target.setDeviceName(device.getName()); target.setDeviceName(device.getName());
target.setDeptName(device.getName()); target.setDeptName(device.getName());
// 当日运行时长 // 当日运行时长
// target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY))); //target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY)));
// 当天有功功率
// List<ActivePowerVo> activePowerVoList = waterService.getActivePowerVoList(device);
// FIXME 测试数据
// 当天运行时长
target.setRunHours(new Random().nextDouble() * 24);
// 年发电量 // 年发电量
target.setGenerationYear(random.nextDouble() * 25000 * 360); target.setGenerationYear((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"0"));
// 月发电量 // 月发电量
target.setGenerationMon(random.nextDouble() * 25000 * 30); target.setGenerationMon((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"1"));
// 日发电量 // 日发电量
target.setGenerationDay(random.nextDouble() * 25000); target.setGenerationDay((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"2"));
// 昨日发电量
target.setGenerationYesterday((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"3"));
// 收益 // 收益
target.setIncome(target.getGenerationDay() * 0.34); target.setIncome(target.getGenerationDay() * 0.34);
// 昨日发电量
target.setGenerationYesterday(random.nextDouble() * 25000);
// 节约标准煤 // 节约标准煤
target.setTec(target.getGenerationMon() * 0.0001229); target.setTec(target.getGenerationMon() * 0.0001229);
// 二氧化碳减排 // 二氧化碳减排
target.setCo2(target.getGenerationMon() * 0.000997); target.setCo2(target.getGenerationMon() * 0.000997);
// 减少森林砍伐 // 减少森林砍伐
target.setDeforest(target.getGenerationMon() * 0.000553); target.setDeforest(target.getGenerationMon() * 0.000553);
// FIXME 测试模拟数据30天功率 // 当天有功功率
List<PhotovoltaicPowerVo> photovoltaicPowers = this.activePowerVoList(device); target.setActivePowerVoList(this.getLoadsByDay(device));
target.setActivePowerVoList(photovoltaicPowers);
// 30天发电量 // 30天发电量
List<GenerationPowerVo> generationPowerVoList = this.getGenerationPowerList(device); target.setGenerationPowerVoList(this.getGenerateByMon(device));
target.setGenerationPowerVoList(generationPowerVoList);
list.add(target); list.add(target);
}); });
redisTemplate.opsForValue().set(load_photovoltaic_target_key, list); redisTemplate.opsForValue().set(load_photovoltaic_target_key, list);
} }
// FIXME 测试模拟 /**
private List<PhotovoltaicPowerVo> activePowerVoList(EminfoAndEmParamVo device) { * 当天有功功率
List<String> hours = getTestDay(); * @param device
Random random = new Random(); * @return
return hours.stream().map(hour -> { */
PhotovoltaicPowerVo power = new PhotovoltaicPowerVo(); private List<PhotovoltaicPowerVo> getLoadsByDay(EminfoAndEmParamVo device) {
power.setHour(hour); String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00";
power.setActivePower(String.valueOf(random.nextDouble() * 500)); String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
return power; List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,1,2,device.getEmCode(),HomePageConstant.PV_LOAD);
}).collect(Collectors.toList()); if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(time.getHours());
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());
}
/**
* 近30天发电量
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerateByMon(EminfoAndEmParamVo device) {
Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH, -29);
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.PV_GENERATION_CAPACITY);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record -> {
GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")));
return generate;
}).sorted(Comparator.comparing(GenerationPowerVo::getDate)).collect(Collectors.toList());
} }
/** /**
* 根据事件查询数据值
* @param deviceCode
* @param rideCount
* @param type
* @return
*/
private float sumValueByTime(String deviceCode, int rideCount,String type) {
Calendar calendar = Calendar.getInstance();
String start = null,end = null;
Integer cycleType = 3;
switch (type){
//年
case "0":
calendar.add(Calendar.HOUR_OF_DAY, + 1);
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DAY_OF_MONTH, -calendar.get(Calendar.DATE) + 1);
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
cycleType = 6;
break;
//月
case "1":
start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00";
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
cycleType = 5;
break;
//日
case "2":
start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00";
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
break;
//昨日
case "3":
calendar.add(Calendar.DAY_OF_MONTH, - 1);
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
end = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00";
break;
}
return analyseDataService.periodTargetFloat(start,end,5,cycleType,deviceCode,rideCount,HomePageConstant.PV_GENERATION_CAPACITY);
}
/**
* 获取上一次功率
* @param device
* @param history
* @return
*/
private Double getLastLoad(EminfoAndEmParamVo device, List<PhotovoltaicRealVo> history) {
if(CollectionUtil.isEmpty(history)){
return 0.0;
}
List<PhotovoltaicRealVo> historyDevice = history.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(historyDevice)){
return 0.0;
}
return historyDevice.get(0).getLoad();
}
/**
* 获取开机状态
* @param device
* @return
*/
private int getPhotovoltaicState(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取开关机监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.PV_JOINT_RELAY);
// 开机状态
if (HomePageConstant.OFF.equals(value)) {
return 0;
}
return 1;
}
/**
* 获取监测点实时数据
* @param em
* @param map
* @param targets
* @return
*/
private String getSignageValue(EminfoAndEmParamVo em,Map<String,String> map, String targets) {
if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){
return "0";
}
Map<String,String> point = em.getPoint();
if(MapUtils.isEmpty(point)){
return "0";
}
String realId = point.get(targets);
if(StringUtil.isEmpty(realId)){
return "0";
}
String value = map.get(realId);
if(StringUtil.isEmpty(realId)){
return "0";
}
// 获取value
return value;
}
/**
* 当天运行时长 * 当天运行时长
* *
* @param realId * @param realId
@ -297,7 +436,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private long runTime(List<PointData> result, Date startDate, Date endDate) { private long runTime(List<PointData> result, Date startDate, Date endDate) {
if (result.size() == 1) { if (result.size() == 1) {
// 一直开机 // 一直开机
if (HomePageConstant.OFF.equals(result.get(0).getValue())) { if (HomePageConstant.PHOTOVOLTAIC_OFF.equals(result.get(0).getValue())) {
return endDate.getTime() - startDate.getTime(); return endDate.getTime() - startDate.getTime();
} }
// 一直关机 // 一直关机
@ -365,56 +504,10 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
default: default:
throw new IllegalStateException("Unexpected value: " + scope); throw new IllegalStateException("Unexpected value: " + scope);
} }
return homePageService.getAnalyzeCodeAndSignages(device, startTime, endTime, cycle, HomePageConstant.PHOTOVOLTAIC_GENERATE); return homePageService.getAnalyzeCodeAndSignages(device, startTime, endTime, cycle, HomePageConstant.PV_GENERATION_CAPACITY);
} }
/** /**
* 近30天发电量
*
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
List<GenerationPowerVo> generationPowerVoList = new ArrayList<>();
// 近30天日期集合
Random random = new Random();
List<String> dayList = this.getRecent30Day();
for (int i = 0; i < dayList.size() - 1; i++) {
GenerationPowerVo generationPowerVo = new GenerationPowerVo();
generationPowerVo.setDate(dayList.get(i));
// 某天发电量
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE);
generationPowerVo.setGenerate(power);
generationPowerVo.setLoad((float) (random.nextDouble() * 500));
generationPowerVoList.add(generationPowerVo);
}
return generationPowerVoList;
}
/**
* 近7天发电量
*
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerationPowerWeek(EminfoAndEmParamVo device) {
List<GenerationPowerVo> generationPowerVoList = new ArrayList<>();
// 近一周日期集合
List<String> dayList = this.getRecentWeek();
SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
for (int i = 0; i < dayList.size() - 1; i++) {
GenerationPowerVo generationPowerVo = new GenerationPowerVo();
generationPowerVo.setDate(sdf.format(DateUtil.parse(dayList.get(i), DateUtil.PATTERN_DATE)));
// 某天发电量
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE);
generationPowerVo.setGenerate(power);
generationPowerVoList.add(generationPowerVo);
}
return generationPowerVoList;
}
/**
* 当天功率 * 当天功率
* *
* @return * @return
@ -462,30 +555,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
/** /**
* 获取近30天集合
*
* @return
*/
private List<String> getRecent30Day() {
// 日期格式化yyyy-mm-dd
SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE);
List<String> list = new ArrayList<>();
// 开始日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, +1);
list.add(df.format(calendar.getTime()));
// 获取日期之间的月
int i = 0;
while (i < 30) {
calendar.add(Calendar.DATE, -1);
list.add(df.format(calendar.getTime()));
i++;
}
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
}
/**
* 获取实时数据 * 获取实时数据
* *
* @return * @return
@ -922,7 +991,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 获取实时天气 // 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode())); Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode()));
if (MapUtils.isNotEmpty(nowWeather)) { if (MapUtils.isNotEmpty(nowWeather)) {
subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp()); subordinate.setNow(nowWeather.get(station.getCode()).getNow());
} }
// 容量、实时功率、今日发电量 // 容量、实时功率、今日发电量
this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets); this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets);
@ -1049,7 +1118,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
photovoltaic.setStationCode(station.getCode()); photovoltaic.setStationCode(station.getCode());
photovoltaic.setDeptId(station.getRefDept()); photovoltaic.setDeptId(station.getRefDept());
photovoltaic.setDeptName(station.getName()); photovoltaic.setDeptName(station.getName());
photovoltaic.setTemp(this.temp(weather, station.getCode())); photovoltaic.setNow(weather.get(station.getCode()).getNow());
photovoltaic.setAddress(station.getAddress()); photovoltaic.setAddress(station.getAddress());
// 站点实时数据: 设备状态统计、实时功率、总发电量 、 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐 // 站点实时数据: 设备状态统计、实时功率、总发电量 、 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐
this.app_data(photovoltaic); this.app_data(photovoltaic);

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

@ -16,11 +16,11 @@ import com.hnac.hzims.operational.config.service.StAlamRecordService;
import com.hnac.hzims.operational.config.service.StFocusPropertiesService; import com.hnac.hzims.operational.config.service.StFocusPropertiesService;
import com.hnac.hzims.operational.config.vo.MessageParamVo; import com.hnac.hzims.operational.config.vo.MessageParamVo;
import com.hnac.hzims.operational.config.vo.StationRealVo; import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWeatherService; import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.JointRelayVo; import com.hnac.hzims.operational.main.vo.JointRelayVo;
import com.hnac.hzims.operational.main.vo.WaterLevelVo; import com.hnac.hzims.operational.main.vo.WaterLevelVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IRealMonitorService; import com.hnac.hzims.operational.station.service.IRealMonitorService;
@ -31,6 +31,7 @@ import com.hnac.hzims.operational.station.vo.RealAttributeVo;
import com.hnac.hzims.operational.station.vo.RealDeviceVo; import com.hnac.hzims.operational.station.vo.RealDeviceVo;
import com.hnac.hzims.operational.station.vo.RealStationVo; import com.hnac.hzims.operational.station.vo.RealStationVo;
import com.hnac.hzims.operational.station.vo.WeatherVo; import com.hnac.hzims.operational.station.vo.WeatherVo;
import com.hnac.hzinfo.sdk.v5.redis.RedisClient;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -88,6 +89,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
@NotNull @NotNull
private final AbnormalAlarmService abnormalAlarmService; private final AbnormalAlarmService abnormalAlarmService;
private final RedisClient redisClient;
@NotNull @NotNull
private final ISysClient sysClient; private final ISysClient sysClient;
@ -131,8 +134,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key";
private final static String redis_real_prefix_key = "iot:real:data:";
@Override @Override
public void realTimeData(String param) { public void realTimeData(String param) {
@ -146,10 +147,14 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
return ""; return "";
} }
String jointRelay = points.get(HomePageConstant.JOINT_RELAY); String jointRelay = points.get(HomePageConstant.JOINT_RELAY);
if(StringUtil.isBlank(jointRelay)){ if(!StringUtil.isEmpty(jointRelay)){
return ""; return jointRelay;
}
String onOff = points.get(HomePageConstant.SWITCH_ON_OFF);
if(!StringUtil.isEmpty(onOff)){
return onOff;
} }
return jointRelay; return "";
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 获取站点缓存数据 // 获取站点缓存数据
List<StationRealVo> stationRealVos = (List<StationRealVo>) redisTemplate.opsForValue().get(moniter_realId_key); List<StationRealVo> stationRealVos = (List<StationRealVo>) redisTemplate.opsForValue().get(moniter_realId_key);
@ -169,11 +174,11 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
list.forEach(stations -> { list.forEach(stations -> {
stations.forEach(stationReal -> { stations.forEach(stationReal -> {
String[] realIdArr = stationReal.getRealId(); String[] realIdArr = stationReal.getRealId();
List<String> realIds = Stream.of(realIdArr).map(o-> redis_real_prefix_key + stationReal.getStation() + ":" + o).collect(Collectors.toList()); List<String> realIds = Stream.of(realIdArr).collect(Collectors.toList());
if(CollectionUtil.isEmpty(realIds)){ if(CollectionUtil.isEmpty(realIds)){
return; return;
} }
List<Object> objects = redisTemplate.opsForValue().multiGet(realIds); List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
if(CollectionUtil.isEmpty(objects)){ if(CollectionUtil.isEmpty(objects)){
return; return;
} }
@ -182,11 +187,12 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
log.error(realIds.get(i) + "is null"); log.error(realIds.get(i) + "is null");
continue; continue;
} }
Map<String,String> attribute = (Map<String, String>) objects.get(i); Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",realIdArr[i]); attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v")); attribute.put("value",attribute.get("v"));
attribute.put("time",attribute.get("t")); attribute.put("time",attribute.get("t"));
attribute.remove("v"); attribute.remove("v");
attribute.remove("k");
attribute.remove("t"); attribute.remove("t");
this.getCheckMap(attribute,switchOnOff); this.getCheckMap(attribute,switchOnOff);
valueMap.put(realIdArr[i],attribute.get("value")); valueMap.put(realIdArr[i],attribute.get("value"));
@ -217,15 +223,15 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
* @param value * @param value
* @return * @return
*/ */
private Map<String, String> getCheckMap(Map<String, String> value,List<String> switchOnOff){ private void getCheckMap(Map<String, String> value,List<String> switchOnOff){
try{ try{
String time = value.get("time");
if(StringUtil.isEmpty(time)){
return value;
}
// 不处理开机状态监测点 // 不处理开机状态监测点
if(switchOnOff.contains(value.get("realId"))){ if(switchOnOff.contains(value.get("realId"))){
return value; return;
}
String time = value.get("time");
if(StringUtil.isEmpty(time)){
return;
} }
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DateUtil.PATTERN_DATETIME);
Date date = simpleDateFormat.parse(time); Date date = simpleDateFormat.parse(time);
@ -234,9 +240,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
value.put("value","0"); value.put("value","0");
} }
}catch (ParseException e){ }catch (ParseException e){
return value; return;
} }
return value;
} }
/** /**

Loading…
Cancel
Save