|
@@ -0,0 +1,276 @@
|
|
|
+package com.gyee.generation.service;//package com.gyee.generation.service;
|
|
|
+
|
|
|
+import com.gyee.common.contant.ContantXk;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.generation.init.CacheContext;
|
|
|
+import com.gyee.generation.model.auto.*;
|
|
|
+import com.gyee.generation.service.auto.*;
|
|
|
+import com.gyee.generation.util.DateUtils;
|
|
|
+import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
+import com.gyee.generation.util.statisticcs.Initial;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class WtAlysisDayService {
|
|
|
+
|
|
|
+// private static final Logger logger = LoggerFactory.getLogger(EquipmentInfo1Service.class);
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconWtAlysisDayService proEconWtAlysisDayService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
|
|
|
+ @Resource
|
|
|
+ private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;
|
|
|
+ @Resource
|
|
|
+ private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
|
|
|
+ @Resource
|
|
|
+ private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service;
|
|
|
+
|
|
|
+
|
|
|
+ private Map<String, ProEconEquipmentInfoDay1> queryEquipmentInfoDay1(Date recordDate) {
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconEquipmentInfoDay1> iostls= proEconEquipmentInfoDay1Service.list()
|
|
|
+ .stream().filter(i-> i.getRecordDate().compareTo(recordDate) == 0
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //List转map
|
|
|
+ Map<String, ProEconEquipmentInfoDay1> iostmap=iostls.stream().
|
|
|
+ collect(Collectors.toMap(ProEconEquipmentInfoDay1::getWindturbineId, Function.identity(), (key1, key2) -> key2));
|
|
|
+ return iostmap;
|
|
|
+ }
|
|
|
+ private Map<String, ProEconEquipmentInfoDay2> queryEquipmentInfoDay2(Date recordDate) {
|
|
|
+
|
|
|
+ List<ProEconEquipmentInfoDay2> iostls= proEconEquipmentInfoDay2Service.list()
|
|
|
+ .stream().filter(i-> i.getRecordDate().compareTo(recordDate) == 0
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //List转map
|
|
|
+ Map<String, ProEconEquipmentInfoDay2> iostmap=iostls.stream().
|
|
|
+ collect(Collectors.toMap(ProEconEquipmentInfoDay2::getWindturbineId, Function.identity(), (key1, key2) -> key2));
|
|
|
+ return iostmap;
|
|
|
+ }
|
|
|
+ private Map<String, ProEconEquipmentInfoDay3> queryEquipmentInfoDay3(Date recordDate) {
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconEquipmentInfoDay3> iostls= proEconEquipmentInfoDay3Service.list()
|
|
|
+ .stream().filter(i-> i.getRecordDate().compareTo(recordDate) == 0
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //List转map
|
|
|
+ Map<String, ProEconEquipmentInfoDay3> iostmap=iostls.stream().
|
|
|
+ collect(Collectors.toMap(ProEconEquipmentInfoDay3::getWindturbineId, Function.identity(), (key1, key2) -> key2));
|
|
|
+ return iostmap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, ProEconEquipmentInfoDay4> queryEquipmentInfoDay4(Date recordDate) {
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconEquipmentInfoDay4> iostls= proEconEquipmentInfoDay4Service.list()
|
|
|
+ .stream().filter(i-> i.getRecordDate().compareTo(recordDate) == 0
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //List转map
|
|
|
+ Map<String, ProEconEquipmentInfoDay4> iostmap=iostls.stream().
|
|
|
+ collect(Collectors.toMap(ProEconEquipmentInfoDay4::getWindturbineId, Function.identity(), (key1, key2) -> key2));
|
|
|
+ return iostmap;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 计算设备日信息
|
|
|
+ */
|
|
|
+ public void calEquipmentInfoDay(Date recordDate) throws Exception {
|
|
|
+ Calendar c=Calendar.getInstance();
|
|
|
+ c.setTime(recordDate);
|
|
|
+
|
|
|
+ Date end=c.getTime();
|
|
|
+
|
|
|
+ Date begin= DateUtils.truncate(c.getTime());
|
|
|
+
|
|
|
+ //判断是否有重复记录,先删除重复记录
|
|
|
+ List<Long> idls = proEconWtAlysisDayService.list().stream()
|
|
|
+ .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
|
|
|
+ && CacheContext.wtmap.containsKey(i.getWindturbineId())).map(ProEconWtAlysisDay::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (idls.size() > 0) {
|
|
|
+
|
|
|
+ proEconWtAlysisDayService.removeByIds(idls);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, ProEconEquipmentInfoDay1> eqday1map = queryEquipmentInfoDay1(recordDate);
|
|
|
+ Map<String, ProEconEquipmentInfoDay2> eqday2map = queryEquipmentInfoDay2(recordDate);
|
|
|
+ Map<String, ProEconEquipmentInfoDay3> eqday3map = queryEquipmentInfoDay3(recordDate);
|
|
|
+ Map<String, ProEconEquipmentInfoDay4> eqday4map = queryEquipmentInfoDay4(recordDate);
|
|
|
+
|
|
|
+ List<ProEconWtAlysisDay> dayls=new ArrayList<>();
|
|
|
+
|
|
|
+ for(ProBasicEquipment wt:CacheContext.wtls)
|
|
|
+ {
|
|
|
+ ProEconWtAlysisDay pewp=new ProEconWtAlysisDay();
|
|
|
+ Initial.initial(pewp);
|
|
|
+ pewp.setRecordDate(DateUtils.truncate(recordDate));
|
|
|
+ pewp.setWindturbineId(wt.getId());
|
|
|
+
|
|
|
+ if(eqday1map.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ ProEconEquipmentInfoDay1 dayinfo= eqday1map.get(wt.getId());
|
|
|
+
|
|
|
+ pewp.setRfdl(dayinfo.getRfdl());
|
|
|
+ pewp.setRpjfs(dayinfo.getRpjfs());
|
|
|
+ pewp.setRpjgl(dayinfo.getRpjgl());
|
|
|
+ pewp.setRyfdl(dayinfo.getRllfdl());
|
|
|
+
|
|
|
+
|
|
|
+ double gzss=dayinfo.getRgzssdl();
|
|
|
+ double jxss=dayinfo.getRjxssdl();
|
|
|
+ double xnss=dayinfo.getRxnssdl();
|
|
|
+ double xdss=dayinfo.getRxdtjssdl()+dayinfo.getRxdjclssdl();
|
|
|
+ double slss=dayinfo.getRcwsltqssdl()+dayinfo.getRcwsldwssdl();
|
|
|
+
|
|
|
+ double ssdl=gzss+jxss+xnss+xdss+slss;
|
|
|
+ pewp.setRssdl(StringUtils.round(ssdl,2));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(eqday2map.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ ProEconEquipmentInfoDay2 dayinfo= eqday2map.get(wt.getId());
|
|
|
+ pewp.setRyxxs(dayinfo.getRyxxs());
|
|
|
+ pewp.setRgzxs(dayinfo.getRgztjxs());
|
|
|
+ pewp.setRjxxs(dayinfo.getRjxtjxs());
|
|
|
+ pewp.setRzdxs(dayinfo.getRxdxs());
|
|
|
+ pewp.setRzdxs(dayinfo.getRtxzdxs());
|
|
|
+
|
|
|
+ int dayTimes=24;
|
|
|
+ double sbklyl = new BigDecimal(dayTimes-dayinfo.getRgztjxs()).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//风机平均设备可利用率
|
|
|
+ pewp.setRsbklyl(StringUtils.round(sbklyl, 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(eqday3map.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ ProEconEquipmentInfoDay3 dayinfo= eqday3map.get(wt.getId());
|
|
|
+ pewp.setRtjcs(dayinfo.getRgztjcs()+dayinfo.getRjxtjcs());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(eqday4map.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ ProEconEquipmentInfoDay4 dayinfo= eqday4map.get(wt.getId());
|
|
|
+ pewp.setRnhyd(dayinfo.getRnhyd());
|
|
|
+ pewp.setRsjbz(dayinfo.getRqxpcbbzsj());
|
|
|
+ pewp.setRyxfs(dayinfo.getRyxfss());
|
|
|
+
|
|
|
+ }
|
|
|
+ //昨日的统计结果
|
|
|
+ List<ProEconWtAlysisDay> pepidls =new ArrayList<>();
|
|
|
+ Calendar cl=Calendar.getInstance();
|
|
|
+ cl.setTime(recordDate);
|
|
|
+ cl.add(Calendar.DAY_OF_MONTH,-1);
|
|
|
+ if(cl.get(Calendar.DAY_OF_MONTH)!=1)
|
|
|
+ {
|
|
|
+ pepidls = proEconWtAlysisDayService.list().stream()
|
|
|
+ .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
|
|
|
+ && i.getWindturbineId().equals(wt.getId())
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ calSimple(pewp, end, begin, wt, pepidls);
|
|
|
+ dayls.add(pewp);
|
|
|
+
|
|
|
+ }
|
|
|
+ proEconWtAlysisDayService.saveBatch(dayls);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void calSimple(ProEconWtAlysisDay pewp, Date end, Date begin, ProBasicEquipment wt, List<ProEconWtAlysisDay> pepidls) throws Exception {
|
|
|
+
|
|
|
+//*******************************************日信息统计*********************************************************/
|
|
|
+
|
|
|
+ double lastState=-1;//上一分钟状态
|
|
|
+
|
|
|
+
|
|
|
+ double bbhcs=0;//不饱和次数
|
|
|
+
|
|
|
+ Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
|
|
|
+ if(aimap.containsKey(ContantXk.SSQFZT))
|
|
|
+ {
|
|
|
+
|
|
|
+ ProBasicEquipmentPoint point=aimap.get(ContantXk.SSQFZT);
|
|
|
+ //按照分钟时间进行统计状态快照值
|
|
|
+ List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
|
|
|
+ if(!pointls.isEmpty()) {
|
|
|
+ for (PointData po : pointls) {
|
|
|
+
|
|
|
+ if (po.getPointValueInDouble() >=3) {
|
|
|
+ if (lastState != po.getPointValueInDouble()) {
|
|
|
+
|
|
|
+ //将当前状态保存到上一分钟状态
|
|
|
+ lastState = po.getPointValueInDouble();
|
|
|
+ //实时欠发大于等于3的次数加1
|
|
|
+ bbhcs++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //日不饱和次数
|
|
|
+ pewp.setRbbhcs(bbhcs);
|
|
|
+
|
|
|
+ //*******************************************日信息统计*********************************************************/
|
|
|
+
|
|
|
+ //*******************************************月信息统计*********************************************************/
|
|
|
+ if(pepidls.isEmpty())
|
|
|
+ {
|
|
|
+ pewp.setYbbhcs(pewp.getRbbhcs());
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ ProEconWtAlysisDay pepid=pepidls.get(0);
|
|
|
+
|
|
|
+ pewp.setYbbhcs(StringUtils.round(pepid.getYbbhcs()+pewp.getRbbhcs(),2));
|
|
|
+
|
|
|
+ }
|
|
|
+ //*******************************************月信息统计*********************************************************/
|
|
|
+
|
|
|
+ //*******************************************年信息统计*********************************************************/
|
|
|
+ if(pepidls.isEmpty())
|
|
|
+ {
|
|
|
+ pewp.setYbbhcs(pewp.getRbbhcs());
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ProEconWtAlysisDay pepid=pepidls.get(0);
|
|
|
+ pewp.setNbbhcs(StringUtils.round(pepid.getNbbhcs()+pewp.getRbbhcs(),2));
|
|
|
+
|
|
|
+ }
|
|
|
+ //*******************************************年信息统计*********************************************************/
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|