|
@@ -9,6 +9,8 @@ import com.gyee.gaia.cause.entity.StateCause;
|
|
|
import com.gyee.gaia.common.data.alarm.FaultInfo;
|
|
|
import com.gyee.gaia.common.data.point.TestingPoint;
|
|
|
import com.gyee.gaia.common.data.power.ModelPower;
|
|
|
+import com.gyee.gaia.common.data.windturbine.Booststation;
|
|
|
+import com.gyee.gaia.common.data.windturbine.Equipment;
|
|
|
import com.gyee.gaia.init.CacheContext;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -33,8 +35,8 @@ public class CalculateService {
|
|
|
/**
|
|
|
* 设备id,状态点列表
|
|
|
*/
|
|
|
- private Map<String, List<PointData>> stateDatas;
|
|
|
- Map<Double, String> stateMap = CacheContext.stateMap;
|
|
|
+ private Map<String, List<PointData>> stateDatas=new HashMap<>();
|
|
|
+ Map<Double, String> stateMap;
|
|
|
|
|
|
public void refresh(long starttime, long endtime){
|
|
|
log.info("刷新测点值!");
|
|
@@ -42,12 +44,14 @@ public class CalculateService {
|
|
|
List<PointData> rawByKey = adapterApi.getRawByKey(v.getCode(), starttime, endtime);
|
|
|
stateDatas.put(k, rawByKey);
|
|
|
});
|
|
|
+ stateMap = CacheContext.stateMap;
|
|
|
}
|
|
|
|
|
|
//风机的8种原始状态:0-停机、 1-上电、2-待机、3-启动、4-并网、5-故障、6-维护、 7-离线
|
|
|
public void calculate() {
|
|
|
List<StateCause> stateCauseList = new ArrayList<>();
|
|
|
stateDatas.forEach((thingId,value)->{
|
|
|
+ if(value.isEmpty()) return;
|
|
|
//事前状态
|
|
|
double advanceState = value.get(0).getDoubleValue();
|
|
|
//事前时间
|
|
@@ -69,35 +73,35 @@ public class CalculateService {
|
|
|
//TODO 判断限停
|
|
|
}else if(advanceState==2){
|
|
|
if(judgmentStop(stateCauseList,thingId,advanceTime,ts)){
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(thingId),thingId, stateMap.get(8.0),
|
|
|
+ StateCause cause = new StateCause(thingId2StationId(thingId),thingId, stateMap.get(8.0),
|
|
|
new Date(advanceTime),new Date(ts), stateMap.get(2.0),stateMap.get(doubleValue),ts -advanceTime);
|
|
|
stateCauseList.add(cause);
|
|
|
}else {
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(thingId),thingId, stateMap.get(2.0),
|
|
|
+ StateCause cause = new StateCause(thingId2StationId(thingId),thingId, stateMap.get(2.0),
|
|
|
new Date(advanceTime),new Date(ts), stateMap.get(2.0),stateMap.get(doubleValue),ts -advanceTime);
|
|
|
stateCauseList.add(cause);
|
|
|
}
|
|
|
}else if(advanceState==6){
|
|
|
if(isHasFaultEvent(thingId,advanceTime,ts)){
|
|
|
//故障
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(thingId),thingId, stateMap.get(5.0),
|
|
|
+ StateCause cause = new StateCause(thingId2StationId(thingId),thingId, stateMap.get(5.0),
|
|
|
new Date(advanceTime),new Date(ts), stateMap.get(6.0),stateMap.get(doubleValue),ts -advanceTime);
|
|
|
stateCauseList.add(cause);
|
|
|
}else {
|
|
|
//计划检修
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(thingId),thingId, stateMap.get(9.0),
|
|
|
+ StateCause cause = new StateCause(thingId2StationId(thingId),thingId, stateMap.get(9.0),
|
|
|
new Date(advanceTime),new Date(ts), stateMap.get(6.0),stateMap.get(doubleValue),ts -advanceTime);
|
|
|
stateCauseList.add(cause);
|
|
|
}
|
|
|
}else if(advanceState==5){
|
|
|
- if(ts-advanceTime<appConfig.getFaulttime()*60000) continue;
|
|
|
+ if(ts-advanceTime<appConfig.getFaulttime()* 60000L) continue;
|
|
|
//计算受累、故障、计划检修
|
|
|
calcBurdened(stateCauseList,thingId,advanceTime, ts,5,doubleValue);
|
|
|
}else if(advanceState==7){
|
|
|
//计算受累、故障、计划检修
|
|
|
calcBurdened(stateCauseList,thingId,advanceTime, ts,7,doubleValue);
|
|
|
}else if(advanceState==0){
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(thingId),thingId, stateMap.get(0.0),
|
|
|
+ StateCause cause = new StateCause(thingId2StationId(thingId),thingId, stateMap.get(0.0),
|
|
|
new Date(advanceTime),new Date(ts), stateMap.get(2.0),stateMap.get(doubleValue),ts -advanceTime);
|
|
|
stateCauseList.add(cause);
|
|
|
}
|
|
@@ -114,38 +118,95 @@ public class CalculateService {
|
|
|
*/
|
|
|
private boolean judgmentStop(List<StateCause> stateCauseList, String thingId, long start, long end) {
|
|
|
if(isHasFaultEvent(thingId,start,end)) return false;
|
|
|
- String stationid = thingId2Stationid(thingId);
|
|
|
+ Booststation boostStation = thingId2BoostStation(thingId);
|
|
|
+ TestingPoint apsTp = CacheContext.pointMapMap.get("active-power-set").get(boostStation.getId());
|
|
|
+ List<PointData> apsRbk = adapterApi.getValuesByKey(apsTp.getCode(), start, end,30);
|
|
|
+ if(apsRbk.isEmpty()) return false;
|
|
|
+ TestingPoint apTp = CacheContext.pointMapMap.get("apparent-power").get(boostStation.getId());
|
|
|
+ List<PointData> apRbk = adapterApi.getValuesByKey(apTp.getCode(), start, end,30);
|
|
|
+ if(apRbk.isEmpty()) return false;
|
|
|
+ TestingPoint opTp = CacheContext.pointMapMap.get("output-power").get(boostStation.getId());
|
|
|
+ List<PointData> opRbk = adapterApi.getValuesByKey(opTp.getCode(), start, end,30);
|
|
|
+ if(opRbk.isEmpty()) return false;
|
|
|
+ //有功设定
|
|
|
+ double apsDouble = apsRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble()*(apsTp.getRate()==null?1:apsTp.getRate());
|
|
|
+ //应发功率
|
|
|
+ double apDouble = 0;
|
|
|
+ if(boostStation.getId().contains("QS")){
|
|
|
+ TestingPoint apTp2 = CacheContext.pointMapMap.get("apparent-power").get(boostStation.getId()+"2");
|
|
|
+ List<PointData> apRbk2 = adapterApi.getValuesByKey(apTp2.getCode(), start, end,30);
|
|
|
+ if(apRbk2.isEmpty()) return false;
|
|
|
+ apDouble = apRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble()*(apTp.getRate()==null?1:apTp.getRate());
|
|
|
+ apDouble+=apRbk2.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble()*(apTp.getRate()==null?1:apTp.getRate());
|
|
|
|
|
|
- List<PointData> apsRbk = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("active-power-set").get(stationid).getCode(), start, end,30);
|
|
|
- List<PointData> apRbk = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("apparent-power").get(stationid).getCode(), start, end,30);
|
|
|
- List<PointData> opRbk = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("output-power").get(stationid).getCode(), start, end,30);
|
|
|
- double apsDouble = apsRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble();
|
|
|
- double apDouble = apRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble();
|
|
|
- double opDouble = opRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble();
|
|
|
+ }else {
|
|
|
+ apDouble = apRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble()*(apTp.getRate()==null?1:apTp.getRate());
|
|
|
+ }
|
|
|
+ //出线功率
|
|
|
+ double opDouble = opRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble()*(opTp.getRate()==null?1:opTp.getRate());
|
|
|
//有功设定小于出线功率
|
|
|
if(apsDouble<opDouble) return true;
|
|
|
//有功设定小于应发的85% 并且 出线功率大于有功设定94%
|
|
|
if(apsDouble<=apDouble*0.85&&opDouble>=apsDouble*0.94) return true;
|
|
|
|
|
|
- List<StateCause> collect = stateCauseList.stream().filter(sc -> stationid.equals(sc.getStationId()) && stateMap.get(8.0).equals(sc.getEvent())
|
|
|
- && sc.getStartTime().getTime() >= start && sc.getEndTime().getTime() <= end).collect(Collectors.toList());
|
|
|
+ //List<StateCause> collect = stateCauseList.stream().filter(sc -> stationid.equals(sc.getStationId()) && stateMap.get(8.0).equals(sc.getEvent())
|
|
|
+ // && sc.getStartTime().getTime() >= start && sc.getEndTime().getTime() <= end).collect(Collectors.toList());
|
|
|
+
|
|
|
//有功设定小于应发的70% 并且 出线功率大于有功设定80% 并且 当前场站限电台数大于等于3
|
|
|
- if(apsDouble<=apDouble*0.7&&opDouble>=apsDouble*0.8&&collect.size()>=3) return true;
|
|
|
- return false;
|
|
|
+ String stationid = thingId2StationId(thingId);
|
|
|
+ return apsDouble <= apDouble * 0.7 && opDouble >= apsDouble * 0.8 && electricityRationCount(stationid, end) >= 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算风电场当前时刻限电台数
|
|
|
+ */
|
|
|
+ private int electricityRationCount(String stationid, long end) {
|
|
|
+ int count = 0;
|
|
|
+ for (Equipment equipment : CacheContext.stationMap.get(stationid)) {
|
|
|
+ //满发功率和满发最小风速
|
|
|
+ ModelPower modelPower = CacheContext.fullSpeeds.get(equipment.getModelId());
|
|
|
+ //并网时间内的风速列表
|
|
|
+ String speedStr = CacheContext.pointMapMap.get("speed").get(equipment.getId()).getCode();
|
|
|
+ String bladeAngleStr = CacheContext.pointMapMap.get("blade-angle").get(equipment.getId()).getCode();
|
|
|
+ String activePowerStr = CacheContext.pointMapMap.get("active-power").get(equipment.getId()).getCode();
|
|
|
+ String s = new StringBuilder().append(speedStr).append(",").append(bladeAngleStr).append(",").append(activePowerStr).toString();
|
|
|
+ Map<String, PointData> historySection = adapterApi.getHistorySection(s, end);
|
|
|
+
|
|
|
+ if(historySection.size()<3) continue;
|
|
|
+ double speed = historySection.get(speedStr).getDoubleValue();
|
|
|
+ double bladeAngle = historySection.get(bladeAngleStr).getDoubleValue();
|
|
|
+ double activePower = historySection.get(activePowerStr).getDoubleValue();
|
|
|
+
|
|
|
+ //风速小于11并且桨叶角度大于2
|
|
|
+ if (speed <= modelPower.getSpeed() && bladeAngle > 2) {
|
|
|
+ count++;
|
|
|
+ //风速大于11并且有功功率小于满发功率减100
|
|
|
+ } else if (speed > modelPower.getSpeed() && activePower < modelPower.getTheoryPower()-100) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断30分钟内是否有故障
|
|
|
*/
|
|
|
private boolean isHasFaultEvent(String thingId, long start, long end) {
|
|
|
- String stationid = thingId2Stationid(thingId);
|
|
|
- String startStr = DateTime.of(start - 30 * 60 * 1000).toDateStr();
|
|
|
- String endStr = DateTime.of(end).toDateStr();
|
|
|
+ String stationid = thingId2StationId(thingId);
|
|
|
+ String startStr = DateTime.of(start - 30 * 60 * 1000).toStringDefaultTimeZone();
|
|
|
+ String endStr = DateTime.of(end).toStringDefaultTimeZone();
|
|
|
List<FaultInfo> fj = shardingApi.getFaultInfoList("FJ", startStr, endStr, stationid, null,1);
|
|
|
List<FaultInfo> collect = fj.stream().filter(fi -> thingId.equals(fi.getWindturbineId())).collect(Collectors.toList());
|
|
|
if(collect.isEmpty()){
|
|
|
List<FaultInfo> infos = shardingApi.getFaultInfoList("SYZ", startStr, endStr, stationid, "位状态", 1);
|
|
|
- if(infos.isEmpty()) return false;
|
|
|
+ if(infos.isEmpty()){
|
|
|
+ return false;
|
|
|
+ }else {
|
|
|
+ System.out.println("SYZ"+infos.get(0).getAlertText());
|
|
|
+ }
|
|
|
+ //return !infos.isEmpty();
|
|
|
+ }else {
|
|
|
+ System.out.println("FJ"+collect.get(0).getAlertText());
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -153,8 +214,12 @@ public class CalculateService {
|
|
|
/**
|
|
|
* 风机查找返回所属场站
|
|
|
*/
|
|
|
- private String thingId2Stationid(String thingId) {
|
|
|
- return CacheContext.equipPointsMap.get(thingId).getWindpowerstationId();
|
|
|
+ private String thingId2StationId(String thingId) {
|
|
|
+ return CacheContext.equipMap.get(thingId).getWindpowerstationId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Booststation thingId2BoostStation(String thingId) {
|
|
|
+ return CacheContext.boostStationMap.get(CacheContext.equipMap.get(thingId).getProjectId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -174,21 +239,10 @@ public class CalculateService {
|
|
|
});
|
|
|
int size = stationState.get(0).size();
|
|
|
|
|
|
- //是否受累
|
|
|
- boolean isBurdened = false;
|
|
|
- //受累开始时间
|
|
|
- long t1 = 0;
|
|
|
- //是否有故障
|
|
|
- boolean isHasFault = false;
|
|
|
- //故障开始时间
|
|
|
- long t2 = 0;
|
|
|
- //全场故障或离线次数
|
|
|
int k = 0;
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
int finalI = i;
|
|
|
boolean b = stationState.stream().filter(pds -> pds.get(finalI).getDoubleValue() == starteventstate).count() == stationState.size();
|
|
|
- //boolean c = stationState.stream().filter(pds -> pds.get(finalI).getDoubleValue() == 7).count() == stationState.size();
|
|
|
- long ts = stationState.get(0).get(finalI).getTs();
|
|
|
if(b){
|
|
|
k++;
|
|
|
}
|
|
@@ -244,7 +298,7 @@ public class CalculateService {
|
|
|
*/
|
|
|
private void calcElectricityRation(List<StateCause> stateCauseList, String equipment, long start, long end, double endeventstate) {
|
|
|
//满发功率和满发最小风速
|
|
|
- ModelPower modelPower = CacheContext.fullSpeeds.get(CacheContext.equipPointsMap.get(equipment).getModelId());
|
|
|
+ ModelPower modelPower = CacheContext.fullSpeeds.get(CacheContext.equipMap.get(equipment).getModelId());
|
|
|
//并网时间内的风速列表
|
|
|
List<PointData> speedList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("speed").get(equipment).getCode(), start, end, 30);
|
|
|
List<PointData> bladeAngleList = adapterApi.getValuesByKey(CacheContext.pointMapMap.get("blade-angle").get(equipment).getCode(), start, end, 30);
|
|
@@ -258,6 +312,9 @@ public class CalculateService {
|
|
|
long ts = speedList.get(i).getTs();
|
|
|
double speedPd = speedList.get(i).getDoubleValue();
|
|
|
//当前时间戳的桨叶角度
|
|
|
+ if(bladeAngleList==null||bladeAngleList.size()<speedList.size()||bladeAngleList.get(i)==null){
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
double bladeAnglePd = bladeAngleList.get(i).getDoubleValue();
|
|
|
//当前时间戳的有功功率
|
|
|
double activePowerPd = activePowerList.get(i).getDoubleValue();
|
|
@@ -277,15 +334,15 @@ public class CalculateService {
|
|
|
}
|
|
|
isElectricityRation = true;
|
|
|
}else if(isElectricityRation){
|
|
|
+ StateCause cause;
|
|
|
if(i==speedList.size()-1) {
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(equipment),equipment, stateMap.get(8.0),
|
|
|
- new Date(t1),new Date(ts), stateMap.get(4.0),stateMap.get(endeventstate),ts -t1);
|
|
|
- stateCauseList.add(cause);
|
|
|
+ cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
|
|
|
+ new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(endeventstate), ts - t1);
|
|
|
}else {
|
|
|
- StateCause cause = new StateCause(thingId2Stationid(equipment),equipment, stateMap.get(8.0),
|
|
|
- new Date(t1),new Date(ts), stateMap.get(4.0),stateMap.get(4.0),ts -t1);
|
|
|
- stateCauseList.add(cause);
|
|
|
+ cause = new StateCause(thingId2StationId(equipment), equipment, stateMap.get(8.0),
|
|
|
+ new Date(t1), new Date(ts), stateMap.get(4.0), stateMap.get(4.0), ts - t1);
|
|
|
}
|
|
|
+ stateCauseList.add(cause);
|
|
|
isElectricityRation = false;
|
|
|
}
|
|
|
}
|