|
@@ -10,17 +10,17 @@ import com.gyee.common.util.DateUtils;
|
|
|
import com.gyee.common.util.DoubleUtils;
|
|
|
import com.gyee.common.util.SortUtils;
|
|
|
import com.gyee.ghost.init.CacheContext;
|
|
|
-import com.gyee.ghost.model.auto.Fanoperation;
|
|
|
-import com.gyee.ghost.model.auto.Windturbine;
|
|
|
-import com.gyee.ghost.model.auto.Windturbineinfoday;
|
|
|
-import com.gyee.ghost.model.auto.Windturbineinfoday3;
|
|
|
+import com.gyee.ghost.model.auto.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class GhostService {
|
|
@@ -30,6 +30,12 @@ public class GhostService {
|
|
|
private IWindturbineinfoday3Service windturbineinfoday3Service;
|
|
|
@Resource
|
|
|
private IFanoperationService fanoperationService;
|
|
|
+ @Resource
|
|
|
+ private INatureService natureService;
|
|
|
+ @Resource
|
|
|
+ private IInputoroutputspeedtotalService inputoroutputspeedtotalService;
|
|
|
+ @Resource
|
|
|
+ private IShutdowneventService shutdowneventService;
|
|
|
/**
|
|
|
* 存储fanoperation运行分析表
|
|
|
*/
|
|
@@ -95,6 +101,75 @@ public class GhostService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 存储nature性能分析表
|
|
|
+ */
|
|
|
+ public void saveNature(String beginDate,String endDate){
|
|
|
+ List<String> days = DateUtils.getDays(beginDate, endDate);
|
|
|
+ days.stream().forEach(day->{
|
|
|
+
|
|
|
+ List<Nature> resultList = new ArrayList<>();
|
|
|
+ Date date = DateUtils.parseDate(day);
|
|
|
+
|
|
|
+ QueryWrapper<Nature> delQw = new QueryWrapper<>();
|
|
|
+ delQw.eq("recorddate",date);
|
|
|
+ natureService.remove(delQw);
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<Inputoroutputspeedtotal> inputoroutputspeedtotalQueryWrapper = new QueryWrapper<>();
|
|
|
+ inputoroutputspeedtotalQueryWrapper.eq("recorddate",date);
|
|
|
+ List<Inputoroutputspeedtotal> inputoroutputspeedtotalList = inputoroutputspeedtotalService.list(inputoroutputspeedtotalQueryWrapper);
|
|
|
+
|
|
|
+ QueryWrapper<Windturbineinfoday> windturbineinfodayQueryWrapper = new QueryWrapper<>();
|
|
|
+ windturbineinfodayQueryWrapper.eq("recorddate",date);
|
|
|
+ List<Windturbineinfoday> windturbineinfodayList = windturbineinfodayService.list(windturbineinfodayQueryWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ List<Shutdownevent> shutdowneventList = shutdowneventService.selectByRecordate(date);
|
|
|
+
|
|
|
+
|
|
|
+ List<Windturbine> wtls = CacheContext.wtls;
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
+ Nature nature = new Nature();
|
|
|
+ nature.setId(CommonUtils.getUUID());
|
|
|
+ nature.setWindturbineid(wt.getId());
|
|
|
+ nature.setWindturbinename(wt.getName());
|
|
|
+ nature.setWindpowerstationid(wt.getWindpowerstationid());
|
|
|
+
|
|
|
+ Optional<Windturbineinfoday> optionalWindturbineinfoday = windturbineinfodayList.stream().filter(w -> w.getWindturbineid().equals(wt.getId())).findFirst();
|
|
|
+ Optional<Inputoroutputspeedtotal> optionalInputoroutputspeedtotal = inputoroutputspeedtotalList.stream().filter(w -> w.getWindturbineid().equals(wt.getId())).findFirst();
|
|
|
+ List<Shutdownevent> shutdownevents = shutdowneventList.stream().filter(w -> w.getWindturbineid().equals(wt.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (optionalWindturbineinfoday.isPresent()){
|
|
|
+ Windturbineinfoday windturbineinfoday = optionalWindturbineinfoday.get();
|
|
|
+ nature.setGeneratingcapacity(DoubleUtils.keepPrecision(windturbineinfoday.getGeneratingcapacity(),2));
|
|
|
+ nature.setAvailability(DoubleUtils.keepPrecision(windturbineinfoday.getDaysbklyl(),2));
|
|
|
+ nature.setFaulttime(DoubleUtils.keepPrecision(windturbineinfoday.getFaulttime(),2));
|
|
|
+ }
|
|
|
+ if (optionalInputoroutputspeedtotal.isPresent()){
|
|
|
+ Inputoroutputspeedtotal inputoroutputspeedtotal = optionalInputoroutputspeedtotal.get();
|
|
|
+ nature.setInputsmall(DoubleUtils.keepPrecision(inputoroutputspeedtotal.getInputsmallmin(),2));
|
|
|
+ }
|
|
|
+ int size = 0;
|
|
|
+ if (StringUtils.isNotEmpty(shutdownevents)){
|
|
|
+ size = shutdownevents.size();
|
|
|
+ }
|
|
|
+ nature.setFaultcount(size);
|
|
|
+ nature.setInputsmallspeed("无数据");
|
|
|
+ nature.setEdinputsmallspeed("无数据");
|
|
|
+ nature.setEdinputsavgspeed("无数据");
|
|
|
+ nature.setEdinputavgpower("无数据");
|
|
|
+ nature.setEdinputbigpower("无数据");
|
|
|
+ nature.setRecorddate(date);
|
|
|
+ resultList.add(nature);
|
|
|
+ });
|
|
|
+
|
|
|
+ natureService.saveBatch(resultList);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询运行分析
|
|
|
* @return
|
|
|
* @param beginDate
|
|
@@ -124,10 +199,42 @@ public class GhostService {
|
|
|
List<Fanoperation> hjlist = fanoperationService.list(qw);
|
|
|
if (StringUtils.isNotNull(hjlist)){
|
|
|
Fanoperation fanoperation = hjlist.get(0);
|
|
|
- fanoperation.setWindpowerstationid("合计");
|
|
|
+ fanoperation.setWindturbineid("合计");
|
|
|
fanoperation.setWindturbinename("合计");
|
|
|
resultList.add(fanoperation);
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public List<Nature> listNature(String wpid, String beginDate, String endDate) {
|
|
|
+ List<Nature> resultList = new ArrayList<>();
|
|
|
+ Date begin = DateUtils.parseDate(beginDate);
|
|
|
+ Date end = DateUtils.parseDate(endDate);
|
|
|
+ QueryWrapper<Nature> qw = new QueryWrapper<>();
|
|
|
+ qw.select("windturbineid,windturbinename,sum(generatingcapacity) generatingcapacity,min(inputsmall) inputsmall,max(inputsmallspeed) inputsmallspeed,max(edinputsmallspeed) edinputsmallspeed,max(edinputsavgspeed) edinputsavgspeed,max(edinputbigpower) edinputbigpower,max(edinputavgpower) edinputavgpower,avg(availability) availability,sum(faultcount) faultcount,sum(faulttime) faulttime");
|
|
|
+ qw.ge("recorddate",begin).le("recorddate",end);
|
|
|
+ if (StringUtils.isNotEmpty(wpid)){
|
|
|
+ qw.eq("windpowerstationid",wpid);
|
|
|
+ }
|
|
|
+ qw.groupBy("windturbineid,windturbinename");
|
|
|
+ List<Nature> list = natureService.list(qw);
|
|
|
+ resultList.addAll(list);
|
|
|
+ SortUtils.sort(resultList,"windturbineid",SortUtils.ASC);
|
|
|
+
|
|
|
+ qw.clear();
|
|
|
+ qw.select("windturbineid,windturbinename,sum(generatingcapacity) generatingcapacity,min(inputsmall) inputsmall,max(inputsmallspeed) inputsmallspeed,max(edinputsmallspeed) edinputsmallspeed,max(edinputsavgspeed) edinputsavgspeed,max(edinputbigpower) edinputbigpower,max(edinputavgpower) edinputavgpower,avg(availability) availability,sum(faultcount) faultcount,sum(faulttime) faulttime");
|
|
|
+ qw.ge("recorddate",begin).le("recorddate",end);
|
|
|
+ if (StringUtils.isNotEmpty(wpid)){
|
|
|
+ qw.eq("windpowerstationid",wpid);
|
|
|
+ }
|
|
|
+ List<Nature> hjlist = natureService.list(qw);
|
|
|
+ if (StringUtils.isNotNull(hjlist)){
|
|
|
+ Nature nature = hjlist.get(0);
|
|
|
+ nature.setWindturbineid("合计");
|
|
|
+ nature.setWindturbinename("合计");
|
|
|
+ resultList.add(nature);
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
}
|