|
@@ -21,10 +21,13 @@ import com.gyee.ghost.service.auto.IProEconStatusmxService;
|
|
|
import com.gyee.ghost.service.auto.IProEconWindturbineStatus2Service;
|
|
|
import com.gyee.ghost.util.realtimesource.IEdosUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import oracle.sql.Datum;
|
|
|
import org.apache.ibatis.annotations.Update;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -42,6 +45,7 @@ public class RealtimeService {
|
|
|
public void saveWindturbineStatus2() {
|
|
|
|
|
|
List<ProEconWindturbineStatus2> resultList = new ArrayList<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
|
List<Windturbine> wtls = CacheContext.wtls;
|
|
|
Map<Integer, String> statusmxMap = CacheContext.statusmxMap;
|
|
@@ -53,26 +57,32 @@ public class RealtimeService {
|
|
|
// Date befroeDate = DateUtils.addSeconds(currentDate, -1);
|
|
|
Date befroeDate = DateUtils.addMinutes(currentDate,-5);
|
|
|
|
|
|
+ Date startOfDay = DateUtils.getStartOfDay(currentDate);
|
|
|
+ Date endOfDay = DateUtils.getEndOfDay(currentDate);
|
|
|
+
|
|
|
wtls.stream().forEach(wt->{
|
|
|
|
|
|
Map<String, Windturbinetestingpointai> stringWindturbinetestingpointaiMap = wtpAimap.get(wt.getId());
|
|
|
Windturbinetestingpointai windturbinetestingpointai = stringWindturbinetestingpointaiMap.get(Contant.ZTMX);
|
|
|
Windturbinetestingpointai windturbinetestingpointaifs = stringWindturbinetestingpointaiMap.get(Contant.AI022);
|
|
|
+
|
|
|
try {
|
|
|
- PointData realData = edosUtil.getRealData(windturbinetestingpointai);
|
|
|
+ PointData realData = edosUtil.getSectionData(windturbinetestingpointai,currentDate.getTime());
|
|
|
|
|
|
double aDouble = realData.getPointValueInDouble();
|
|
|
|
|
|
PointData sectionData = edosUtil.getSectionData(windturbinetestingpointai, befroeDate.getTime());
|
|
|
double tempDouble = sectionData.getPointValueInDouble();
|
|
|
double speed = edosUtil.getRealData(windturbinetestingpointaifs).getPointValueInDouble();
|
|
|
- if (aDouble != tempDouble){
|
|
|
+
|
|
|
+ if (isEq(DateUtils.toDate(currentDate),DateUtils.toDate(startOfDay)) || aDouble != tempDouble){
|
|
|
ProEconWindturbineStatus2 proEconWindturbineStatus2 = new ProEconWindturbineStatus2();
|
|
|
proEconWindturbineStatus2.setId(CommonUtils.getUUID());
|
|
|
proEconWindturbineStatus2.setWindpowerstationId(wt.getWindpowerstationid());
|
|
|
proEconWindturbineStatus2.setWindturbineId(wt.getId());
|
|
|
- proEconWindturbineStatus2.setStopTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
- proEconWindturbineStatus2.setStartTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
+
|
|
|
+ proEconWindturbineStatus2.setStopTime(DateUtils.parseLongToDate(sdf.parse(DateUtils.toDate1(currentDate)).getTime()));
|
|
|
+ proEconWindturbineStatus2.setStartTime(DateUtils.parseLongToDate(sdf.parse(DateUtils.toDate1(currentDate)).getTime()));
|
|
|
proEconWindturbineStatus2.setStopHours(DateUtils.hoursDiff2(proEconWindturbineStatus2.getStopTime(), proEconWindturbineStatus2.getStartTime()));
|
|
|
proEconWindturbineStatus2.setLossPower(0.0);
|
|
|
proEconWindturbineStatus2.setShutdownEventId("");
|
|
@@ -82,39 +92,51 @@ public class RealtimeService {
|
|
|
proEconWindturbineStatus2.setAvgSpeed(0.0);
|
|
|
String statusName = statusmxMap.get(new Double(aDouble).intValue());
|
|
|
proEconWindturbineStatus2.setStatusDesc(statusName);
|
|
|
- resultList.add(proEconWindturbineStatus2);
|
|
|
+// resultList.add(proEconWindturbineStatus2);
|
|
|
+ proEconWindturbineStatus2Service.save(proEconWindturbineStatus2);
|
|
|
|
|
|
QueryWrapper<ProEconWindturbineStatus2> qw = new QueryWrapper<>();
|
|
|
qw.eq("windTurbine_Id",wt.getId());
|
|
|
- qw.orderByDesc("start_Time");
|
|
|
- ProEconWindturbineStatus2 proEconWindturbineStatus21 = proEconWindturbineStatus2Service.getBaseMapper().selectOne(qw);
|
|
|
- if (StringUtils.isNotNull(proEconWindturbineStatus21)){
|
|
|
- proEconWindturbineStatus21.setStopTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
- proEconWindturbineStatus21.setLossPower(0.0);
|
|
|
- proEconWindturbineStatus21.setSpeed(speed);
|
|
|
- proEconWindturbineStatus21.setAvgSpeed(0.0);
|
|
|
- resultList.add(proEconWindturbineStatus21);
|
|
|
+ Date beforeFive = DateUtils.addMinutes(sdf.parse(DateUtils.toDate1(currentDate)), -5);
|
|
|
+// String toDate = DateUtils.toDate(beforeFive);
|
|
|
+// Date parse = sdf.parse(toDate);
|
|
|
+ qw.eq("stop_Time",beforeFive);
|
|
|
+ Optional<ProEconWindturbineStatus2> first = proEconWindturbineStatus2Service.list(qw).stream().findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ ProEconWindturbineStatus2 proEconWindturbineStatus = first.get();
|
|
|
+ proEconWindturbineStatus.setStopTime(DateUtils.parseLongToDate(currentDate.getTime()));
|
|
|
+ proEconWindturbineStatus.setStopHours(DateUtils.hoursDiff2(proEconWindturbineStatus.getStopTime(), proEconWindturbineStatus.getStartTime()));
|
|
|
+ proEconWindturbineStatus.setLossPower(0.0);
|
|
|
+ proEconWindturbineStatus.setSpeed(speed);
|
|
|
+ proEconWindturbineStatus.setAvgSpeed(0.0);
|
|
|
+// resultList.add(proEconWindturbineStatus2);
|
|
|
+ proEconWindturbineStatus2Service.updateById(proEconWindturbineStatus2);
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
QueryWrapper<ProEconWindturbineStatus2> qw = new QueryWrapper<>();
|
|
|
qw.eq("windTurbine_Id",wt.getId());
|
|
|
- qw.orderByDesc("start_Time");
|
|
|
- ProEconWindturbineStatus2 proEconWindturbineStatus21 = proEconWindturbineStatus2Service.getBaseMapper().selectOne(qw);
|
|
|
- if (StringUtils.isNotNull(proEconWindturbineStatus21)){
|
|
|
- proEconWindturbineStatus21.setStopTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
- proEconWindturbineStatus21.setStopHours(DateUtils.hoursDiff2(proEconWindturbineStatus21.getStopTime(), proEconWindturbineStatus21.getStartTime()));
|
|
|
- proEconWindturbineStatus21.setLossPower(0.0);
|
|
|
- proEconWindturbineStatus21.setSpeed(speed);
|
|
|
- proEconWindturbineStatus21.setAvgSpeed(0.0);
|
|
|
- resultList.add(proEconWindturbineStatus21);
|
|
|
- }else{
|
|
|
+ Date beforeFive = DateUtils.addMinutes(sdf.parse(DateUtils.toDate1(currentDate)), -5);
|
|
|
+// String toDate = DateUtils.toDate(beforeFive);
|
|
|
+// Date parse = sdf.parse(toDate);
|
|
|
+ qw.eq("stop_Time",beforeFive);
|
|
|
+ Optional<ProEconWindturbineStatus2> first = proEconWindturbineStatus2Service.list(qw).stream().findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ ProEconWindturbineStatus2 proEconWindturbineStatus2 = first.get();
|
|
|
+ proEconWindturbineStatus2.setStopTime(DateUtils.parseLongToDate(sdf.parse(DateUtils.toDate1(currentDate)).getTime()));
|
|
|
+ proEconWindturbineStatus2.setStopHours(DateUtils.hoursDiff2(proEconWindturbineStatus2.getStopTime(), proEconWindturbineStatus2.getStartTime()));
|
|
|
+ proEconWindturbineStatus2.setLossPower(0.0);
|
|
|
+ proEconWindturbineStatus2.setSpeed(speed);
|
|
|
+ proEconWindturbineStatus2.setAvgSpeed(0.0);
|
|
|
+ proEconWindturbineStatus2Service.updateById(proEconWindturbineStatus2);
|
|
|
+// resultList.add(proEconWindturbineStatus2);
|
|
|
+ }else {
|
|
|
ProEconWindturbineStatus2 proEconWindturbineStatus2 = new ProEconWindturbineStatus2();
|
|
|
proEconWindturbineStatus2.setId(CommonUtils.getUUID());
|
|
|
proEconWindturbineStatus2.setWindpowerstationId(wt.getWindpowerstationid());
|
|
|
proEconWindturbineStatus2.setWindturbineId(wt.getId());
|
|
|
- proEconWindturbineStatus2.setStopTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
- proEconWindturbineStatus2.setStartTime(DateUtils.parseLongToDate(realData.getPointTime()*1000));
|
|
|
+ proEconWindturbineStatus2.setStopTime(DateUtils.parseLongToDate(sdf.parse(DateUtils.toDate1(currentDate)).getTime()));
|
|
|
+ proEconWindturbineStatus2.setStartTime(DateUtils.parseLongToDate(sdf.parse(DateUtils.toDate1(currentDate)).getTime()));
|
|
|
proEconWindturbineStatus2.setStopHours(DateUtils.hoursDiff2(proEconWindturbineStatus2.getStopTime(), proEconWindturbineStatus2.getStartTime()));
|
|
|
proEconWindturbineStatus2.setLossPower(0.0);
|
|
|
proEconWindturbineStatus2.setShutdownEventId("");
|
|
@@ -124,24 +146,115 @@ public class RealtimeService {
|
|
|
proEconWindturbineStatus2.setAvgSpeed(0.0);
|
|
|
String statusName = statusmxMap.get(new Double(aDouble).intValue());
|
|
|
proEconWindturbineStatus2.setStatusDesc(statusName);
|
|
|
- resultList.add(proEconWindturbineStatus2);
|
|
|
+// resultList.add(proEconWindturbineStatus2);
|
|
|
+ proEconWindturbineStatus2Service.save(proEconWindturbineStatus2);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
- proEconWindturbineStatus2Service.saveOrUpdateBatch(resultList);
|
|
|
+// proEconWindturbineStatus2Service.saveOrUpdateBatch(resultList);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void saveWindstationStatus(String beginDate,String endDate) {
|
|
|
+
|
|
|
+ List<ProEconStationStatusmx> resultList = new ArrayList<>();
|
|
|
+ List<String> days = DateUtils.getDays(beginDate, endDate);
|
|
|
+ List<Windturbine> wtls = CacheContext.wtls;
|
|
|
+ Map<Integer, String> statusmxMap = CacheContext.statusmxMap;
|
|
|
+ Set<Integer> status = statusmxMap.keySet();
|
|
|
+
|
|
|
+ days.stream().forEach(day->{
|
|
|
+ Date date = DateUtils.parseDate1(day);
|
|
|
+ Date addDays = DateUtils.addDays(date, 1);
|
|
|
+ Map<String,Object> delMap = new HashMap<>();
|
|
|
+ delMap.put("recorddate",date);
|
|
|
+ proEconStationStatusmxService.removeByMap(delMap);
|
|
|
+
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
+ QueryWrapper<ProEconWindturbineStatus2> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("windTurbine_Id",wt.getId());
|
|
|
+ qw.le("stop_Time",addDays).ge("start_Time",date);
|
|
|
+ List<ProEconWindturbineStatus2> windturbineStatus2s = proEconWindturbineStatus2Service.list(qw);
|
|
|
+ status.stream().forEach(sta->{
|
|
|
+ ProEconStationStatusmx proEconStationStatusmx = new ProEconStationStatusmx();
|
|
|
+ proEconStationStatusmx.setId(CommonUtils.getUUID());
|
|
|
+ proEconStationStatusmx.setProjectId(wt.getProjectid());
|
|
|
+ proEconStationStatusmx.setWindpowerstationId(wt.getWindpowerstationid());
|
|
|
+ proEconStationStatusmx.setWindturbineId(wt.getId());
|
|
|
+ proEconStationStatusmx.setRecorddate(date);
|
|
|
+ proEconStationStatusmx.setStopHours(windturbineStatus2s.stream().filter(i->i.getSatusCode().equals(sta)).mapToDouble(ProEconWindturbineStatus2::getStopHours).sum());
|
|
|
+ proEconStationStatusmx.setLossPower(0.0);
|
|
|
+ proEconStationStatusmx.setSatusCode(sta);
|
|
|
+ proEconStationStatusmx.setStatusDesc(statusmxMap.get(sta));
|
|
|
+ proEconStationStatusmx.setAvgSpeed(0.0);
|
|
|
+ resultList.add(proEconStationStatusmx);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ proEconStationStatusmxService.saveBatch(resultList);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// List<ProEconStationStatusmx> resultList = new ArrayList<>();
|
|
|
+// List<String> days = DateUtils.getDays(beginDate, endDate);
|
|
|
+// List<Windturbine> wtls = CacheContext.wtls;
|
|
|
+// Map<Integer, String> statusmxMap = CacheContext.statusmxMap;
|
|
|
+// Set<Integer> status = statusmxMap.keySet();
|
|
|
+//
|
|
|
+// Map<String, Map<String, Windturbinetestingpointai>> wtpAimap = CacheContext.wtpAimap;
|
|
|
+//
|
|
|
+// Date samedayZero = DateUtils.getSamedayZero();
|
|
|
+// Date currentDate = DateUtils.getCurrentDate();
|
|
|
+//// Date befroeDate = DateUtils.addSeconds(currentDate,-1);
|
|
|
+//// Date befroeDate = DateUtils.addMinutes(currentDate,-5);
|
|
|
+// days.forEach(day->{
|
|
|
+// Date date = DateUtils.parseDate(day);
|
|
|
+// Date addday = DateUtils.addDays(date, 1);
|
|
|
+// wtls.stream().forEach(wt->{
|
|
|
+// Map<String, Windturbinetestingpointai> stringWindturbinetestingpointaiMap = wtpAimap.get(wt.getId());
|
|
|
+// Windturbinetestingpointai windturbinetestingpointai = stringWindturbinetestingpointaiMap.get(Contant.ZTMX);
|
|
|
+// Windturbinetestingpointai windturbinetestingpointaifs = stringWindturbinetestingpointaiMap.get(Contant.AI022);
|
|
|
+// try {
|
|
|
+// List<PointData> historyDatasSnap = edosUtil.getHistoryDatasSnap(windturbinetestingpointai, date.getTime() / 1000, addday.getTime() / 1000, null, 60l);
|
|
|
+// status.stream().forEach(sta->{
|
|
|
+// int minutes = historyDatasSnap.stream().filter(i -> i.getPointValueInDouble() == sta).collect(Collectors.toList()).size();
|
|
|
+// ProEconStationStatusmx proEconStationStatusmx = new ProEconStationStatusmx();
|
|
|
+// proEconStationStatusmx.setId(CommonUtils.getUUID());
|
|
|
+// proEconStationStatusmx.setProjectId(wt.getProjectid());
|
|
|
+// proEconStationStatusmx.setWindpowerstationId(wt.getWindpowerstationid());
|
|
|
+// proEconStationStatusmx.setWindturbineId(wt.getId());
|
|
|
+// proEconStationStatusmx.setRecorddate(date);
|
|
|
+// proEconStationStatusmx.setStopHours(DoubleUtils.keepPrecision(new Double(minutes)/60,2));
|
|
|
+// proEconStationStatusmx.setLossPower(0.0);
|
|
|
+// proEconStationStatusmx.setSatusCode(sta);
|
|
|
+// proEconStationStatusmx.setStatusDesc(statusmxMap.get(sta));
|
|
|
+// proEconStationStatusmx.setAvgSpeed(0.0);
|
|
|
+//// proEconStationStatusmxService.save(proEconStationStatusmx);
|
|
|
+// resultList.add(proEconStationStatusmx);
|
|
|
+// });
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+// });
|
|
|
+//
|
|
|
+// proEconStationStatusmxService.saveBatch(resultList);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveWindstationStatus1(String beginDate,String endDate) {
|
|
|
+
|
|
|
List<ProEconStationStatusmx> resultList = new ArrayList<>();
|
|
|
List<String> days = DateUtils.getDays(beginDate, endDate);
|
|
|
List<Windturbine> wtls = CacheContext.wtls;
|
|
@@ -189,63 +302,9 @@ public class RealtimeService {
|
|
|
proEconStationStatusmxService.saveBatch(resultList);
|
|
|
|
|
|
|
|
|
-
|
|
|
-// List<Windturbine> wtls = CacheContext.wtls;
|
|
|
-// Map<Integer, String> statusmxMap = CacheContext.statusmxMap;
|
|
|
-// Set<Integer> status = statusmxMap.keySet();
|
|
|
-// List<String> days = DateUtils.getDays(beginDate, endDate);
|
|
|
-// days.forEach(day->{
|
|
|
-// Date date = DateUtils.parseDate1(day);
|
|
|
-// Date addDay = DateUtils.addDays(date, 1);
|
|
|
-//
|
|
|
-// wtls.stream().forEach(wt->{
|
|
|
-// QueryWrapper<ProEconWindturbineStatus2> qw = new QueryWrapper<>();
|
|
|
-// qw.eq("windTurbine_Id",wt.getId());
|
|
|
-// qw.ge("start_Time",date).lt("start_Time",addDay);
|
|
|
-// List<ProEconWindturbineStatus2> proEconWindturbineStatus2s = proEconWindturbineStatus2Service.list(qw);
|
|
|
-// if (StringUtils.isNotNull(proEconWindturbineStatus2s)){
|
|
|
-// status.stream().forEach(sta->{
|
|
|
-// List<ProEconWindturbineStatus2> collect = proEconWindturbineStatus2s.stream().filter(i -> i.getSatusCode() == sta).collect(Collectors.toList());
|
|
|
-// if (StringUtils.isNotNull(collect)){
|
|
|
-// double sum = collect.stream().mapToDouble(ProEconWindturbineStatus2::getStopHours).sum();
|
|
|
-// ProEconStationStatusmx proEconStationStatusmx = new ProEconStationStatusmx();
|
|
|
-// proEconStationStatusmx.setId(CommonUtils.getUUID());
|
|
|
-// proEconStationStatusmx.setProjectId(wt.getProjectid());
|
|
|
-// proEconStationStatusmx.setWindpowerstationId(wt.getWindpowerstationid());
|
|
|
-// proEconStationStatusmx.setWindturbineId(wt.getId());
|
|
|
-// proEconStationStatusmx.setRecorddate(date);
|
|
|
-// proEconStationStatusmx.setStopHours(sum);
|
|
|
-// proEconStationStatusmx.setLossPower(0.0);
|
|
|
-// proEconStationStatusmx.setSatusCode(sta);
|
|
|
-// proEconStationStatusmx.setStatusDesc(statusmxMap.get(sta));
|
|
|
-// proEconStationStatusmx.setAvgSpeed(0.0);
|
|
|
-// }else{
|
|
|
-//
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }else{
|
|
|
-//
|
|
|
-// }
|
|
|
-// qw.clear();
|
|
|
-// qw.eq("windTurbine_Id",wt.getId());
|
|
|
-// qw.ge("stop_Time",date).lt("start_Time",addDay);
|
|
|
-//
|
|
|
-// proEconWindturbineStatus2s.stream().forEach(data->{
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-// });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取两日期间日期list
|
|
|
*
|
|
@@ -253,14 +312,21 @@ public class RealtimeService {
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<String> getDays(String beginDate, String endDate) {
|
|
|
- List<String> days = null;
|
|
|
- if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate)) {
|
|
|
- days = DateUtils.getDays(beginDate, endDate);
|
|
|
- } else {
|
|
|
- days = new ArrayList<>();
|
|
|
- days.add(DateUtils.getYesterdayStr("yyyy-MM-dd"));
|
|
|
+ private boolean isEq(String beginDate, String endDate) throws ParseException {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Date date1 = sdf.parse(beginDate);
|
|
|
+
|
|
|
+ Date date2 = sdf.parse(endDate);
|
|
|
+
|
|
|
+ if(date1.equals(date2)) {
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
}
|
|
|
- return days;
|
|
|
}
|
|
|
}
|