|
@@ -1,10 +1,15 @@
|
|
|
package com.gyee.generation.service;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.gyee.common.contant.Contant;
|
|
|
import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.common.util.CommonUtils;
|
|
|
import com.gyee.common.util.DateUtils;
|
|
|
import com.gyee.generation.init.CacheContext;
|
|
|
import com.gyee.generation.model.auto.*;
|
|
|
+import com.gyee.generation.service.auto.IShutdowneventService;
|
|
|
import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -35,6 +40,8 @@ public class FiveLossesService {
|
|
|
private Map<String, Map<String, Windpowerstationpointnew>> wppointmap;
|
|
|
private Map<String, Map<String, Windpowerstationpointnew>> linepointmap;
|
|
|
private Map<String, Map<String, Windpowerstationpointnew>> propointmap;
|
|
|
+ @Resource
|
|
|
+ private IShutdowneventService shutdowneventService;
|
|
|
|
|
|
private void init(){
|
|
|
wpls = CacheContext.wpls;
|
|
@@ -60,6 +67,154 @@ public class FiveLossesService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 存储shutdownevent
|
|
|
+ */
|
|
|
+ public void saveShutdownevent(){
|
|
|
+ init();
|
|
|
+ List<PointData> resultList = new ArrayList<>();
|
|
|
+ QueryWrapper<Shutdownevent> qw = new QueryWrapper<>();
|
|
|
+ qw.isNull("starttime");
|
|
|
+ qw.isNotNull("stoptime");
|
|
|
+ //查出有故障但没恢复的事件
|
|
|
+ List<Shutdownevent> shutdownevents = shutdowneventService.list(qw);
|
|
|
+ List<String> faultWinturbines = null;
|
|
|
+ List<String> mainWinturbines = null;
|
|
|
+ if (StringUtils.isNotEmpty(shutdownevents)){
|
|
|
+ faultWinturbines = shutdownevents.stream().filter(i->i.getStatuscode()==2).map(s -> s.getWindturbineid()).collect(Collectors.toList());
|
|
|
+ mainWinturbines = shutdownevents.stream().filter(i->i.getStatuscode()==4).map(s -> s.getWindturbineid()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> finalFaultWinturbines = faultWinturbines;
|
|
|
+ List<String> finalMainWinturbines = mainWinturbines;
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
+ Map<String, Windturbinetestingpointnew> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
|
|
|
+ Windturbinetestingpointnew ztmxPoint = windturbinetestingpointnewMap.get(Contant.ZTMX);
|
|
|
+ Windturbinetestingpointnew bzglPoint = windturbinetestingpointnewMap.get(Contant.BZGL);
|
|
|
+ Windturbinetestingpointnew zsglPoint = windturbinetestingpointnewMap.get(Contant.ZSGL);
|
|
|
+ Windturbinetestingpointnew powerPoint = windturbinetestingpointnewMap.get(Contant.AI130);
|
|
|
+ PointData sectionData = null;
|
|
|
+ try {
|
|
|
+ sectionData = edosUtil.getSectionData(ztmxPoint, tomorrow.getTime());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ double fjzt = sectionData.getPointValueInDouble();
|
|
|
+ if (StringUtils.isNotEmpty(finalFaultWinturbines)){ //故障不为空
|
|
|
+
|
|
|
+ if (finalFaultWinturbines.contains(wt.getId())){ //此风机在之前故障未恢复列表
|
|
|
+ if (fjzt!=6){
|
|
|
+ //将时间存储到结束时间,算时间与电量
|
|
|
+ Optional<Shutdownevent> first = shutdownevents.stream().filter(i -> i.getWindturbineid().equals(wt.getId())).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ Shutdownevent shutdownevent = first.get();
|
|
|
+ Date starttime = new Date(sectionData.getPointTime());
|
|
|
+ shutdownevent.setStarttime(starttime);
|
|
|
+ Date stoptime = shutdownevent.getStoptime();
|
|
|
+ double hour = DateUtils.hoursDiff1(stoptime, starttime);
|
|
|
+ shutdownevent.setStophours(hour);
|
|
|
+
|
|
|
+ List<PointData> ztmxDatasSnap = null;
|
|
|
+ List<PointData> bzglDatasSnap = null;
|
|
|
+ List<PointData> zsglDatasSnap = null;
|
|
|
+ List<PointData> powerDatasSnap = null;
|
|
|
+ try {
|
|
|
+ ztmxDatasSnap = edosUtil.getHistoryDatasSnap(ztmxPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ bzglDatasSnap = edosUtil.getHistoryDatasSnap(bzglPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ zsglDatasSnap = edosUtil.getHistoryDatasSnap(zsglPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ powerDatasSnap = edosUtil.getHistoryDatasSnap(powerPoint, samedayZero.getTime() / 1000, currentDate.getTime() / 1000, null, 60l);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (ztmxDatasSnap.size() == zsglDatasSnap.size()){
|
|
|
+ //故障
|
|
|
+ double gzss = generalLoss(ztmxDatasSnap, bzglDatasSnap, zsglDatasSnap, powerDatasSnap, 6.0, resultList, windturbinetestingpointnewMap.get(Contant.WTRGZSSDL));
|
|
|
+ shutdownevent.setLosspower(gzss);
|
|
|
+ }
|
|
|
+ shutdowneventService.saveOrUpdate(shutdownevent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else { //此风机不在故障列表中
|
|
|
+ if (fjzt==6 || fjzt==8){
|
|
|
+ Shutdownevent shutdownevent = new Shutdownevent();
|
|
|
+ shutdownevent.setId(CommonUtils.getUUID());
|
|
|
+ shutdownevent.setWindpowerstationid(wt.getWindpowerstationid());
|
|
|
+ shutdownevent.setWindturbineid(wt.getId());
|
|
|
+ shutdownevent.setStoptime(new Date(sectionData.getPointTime()));
|
|
|
+ shutdownevent.setProjectid(wt.getProjectid());
|
|
|
+ if (fjzt == 2){
|
|
|
+ shutdownevent.setStatuscode(2);
|
|
|
+ }else {
|
|
|
+ shutdownevent.setStatuscode(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(StringUtils.isNotEmpty(finalMainWinturbines)){ //维护不为空
|
|
|
+ if (finalMainWinturbines.contains(wt.getId())){ //此风机在之前故障未恢复列表
|
|
|
+ if (fjzt!=8){
|
|
|
+ //将时间存储到结束时间,算时间与电量
|
|
|
+ Optional<Shutdownevent> first = shutdownevents.stream().filter(i -> i.getWindturbineid().equals(wt.getId())).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ Shutdownevent shutdownevent = first.get();
|
|
|
+ Date starttime = new Date(sectionData.getPointTime());
|
|
|
+ shutdownevent.setStarttime(starttime);
|
|
|
+ Date stoptime = shutdownevent.getStoptime();
|
|
|
+ double hour = DateUtils.hoursDiff1(stoptime, starttime);
|
|
|
+ shutdownevent.setStophours(hour);
|
|
|
+
|
|
|
+ List<PointData> ztmxDatasSnap = null;
|
|
|
+ List<PointData> bzglDatasSnap = null;
|
|
|
+ List<PointData> zsglDatasSnap = null;
|
|
|
+ List<PointData> powerDatasSnap = null;
|
|
|
+ try {
|
|
|
+ ztmxDatasSnap = edosUtil.getHistoryDatasSnap(ztmxPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ bzglDatasSnap = edosUtil.getHistoryDatasSnap(bzglPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ zsglDatasSnap = edosUtil.getHistoryDatasSnap(zsglPoint,stoptime.getTime()/1000,starttime.getTime()/1000,null,60l);
|
|
|
+ powerDatasSnap = edosUtil.getHistoryDatasSnap(powerPoint, samedayZero.getTime() / 1000, currentDate.getTime() / 1000, null, 60l);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (ztmxDatasSnap.size() == zsglDatasSnap.size()){
|
|
|
+ //维护
|
|
|
+ double jxss = generalLoss(ztmxDatasSnap, bzglDatasSnap, zsglDatasSnap, powerDatasSnap, 8.0, resultList, windturbinetestingpointnewMap.get(Contant.WTRJXSSDL));
|
|
|
+ shutdownevent.setLosspower(jxss);
|
|
|
+ }
|
|
|
+ shutdowneventService.saveOrUpdate(shutdownevent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else { //此风机不在故障列表中
|
|
|
+ if (fjzt==6 || fjzt==8){
|
|
|
+ Shutdownevent shutdownevent = new Shutdownevent();
|
|
|
+ shutdownevent.setId(CommonUtils.getUUID());
|
|
|
+ shutdownevent.setWindpowerstationid(wt.getWindpowerstationid());
|
|
|
+ shutdownevent.setWindturbineid(wt.getId());
|
|
|
+ shutdownevent.setStoptime(new Date(sectionData.getPointTime()));
|
|
|
+ shutdownevent.setProjectid(wt.getProjectid());
|
|
|
+ if (fjzt == 2){
|
|
|
+ shutdownevent.setStatuscode(2);
|
|
|
+ }else {
|
|
|
+ shutdownevent.setStatuscode(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else { //没有没结束的故障维护事件
|
|
|
+ if (fjzt==6 || fjzt==8){
|
|
|
+ Shutdownevent shutdownevent = new Shutdownevent();
|
|
|
+ shutdownevent.setId(CommonUtils.getUUID());
|
|
|
+ shutdownevent.setWindpowerstationid(wt.getWindpowerstationid());
|
|
|
+ shutdownevent.setWindturbineid(wt.getId());
|
|
|
+ shutdownevent.setStoptime(new Date(sectionData.getPointTime()));
|
|
|
+ shutdownevent.setProjectid(wt.getProjectid());
|
|
|
+ if (fjzt == 2){
|
|
|
+ shutdownevent.setStatuscode(2);
|
|
|
+ }else {
|
|
|
+ shutdownevent.setStatuscode(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 场站五损,欠发电量
|
|
|
*/
|
|
|
private void wpDaylossesReal() throws Exception {
|