|
@@ -0,0 +1,326 @@
|
|
|
|
+package com.gyee.healthmanagementhistroy.service.healthreport;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.gyee.common.model.StringUtils;
|
|
|
|
+import com.gyee.common.util.CommonUtils;
|
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
|
+import com.gyee.healthmanagementhistroy.init.CacheContext;
|
|
|
|
+import com.gyee.healthmanagementhistroy.model.auto.*;
|
|
|
|
+import com.gyee.healthmanagementhistroy.service.auto.*;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class HealthReportNewService {
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport1Service healthwtreport1Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport2Service healthwtreport2Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport3Service healthwtreport3Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport4Service healthwtreport4Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport5Service healthwtreport5Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport6Service healthwtreport6Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private IHealthwtreport7Service healthwtreport7Service;
|
|
|
|
+ @Resource
|
|
|
|
+ private ICurvefittingmonthsubService curvefittingmonthsubService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ICurvefittingsubService curvefittingsubService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IWindturbinecurvefittingmonthService windturbinecurvefittingmonthService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IWindturbinewindyawService windturbinewindyawService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IWindturbinepoweryawService windturbinepoweryawService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private IWinddeviationrateService winddeviationrateService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IInputoroutputspeedtotalService inputoroutputspeedtotalService;
|
|
|
|
+ /**
|
|
|
|
+ * 保存性能描述表
|
|
|
|
+ * @param stringdate
|
|
|
|
+ */
|
|
|
|
+ public void saveHealthwtreport1(String stringdate){
|
|
|
|
+ healthwtreport1Service.remove(new QueryWrapper<>());
|
|
|
|
+
|
|
|
|
+ List<Healthwtreport1> resultList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Windturbine> wtls = CacheContext.wtls;
|
|
|
|
+
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ int month = DateUtils.getMonth(date);
|
|
|
|
+ int year = DateUtils.getYear(date);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Curvefittingmonthsub> curvefittingsubQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ curvefittingsubQueryWrapper.ge("month",String.valueOf(month));
|
|
|
|
+ curvefittingsubQueryWrapper.ge("year",String.valueOf(year));
|
|
|
|
+ List<Curvefittingmonthsub> curvefittingmonthsubs = curvefittingmonthsubService.list(curvefittingsubQueryWrapper);
|
|
|
|
+ if (StringUtils.isNotEmpty(curvefittingmonthsubs)){
|
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
|
+ //过滤此台风机的偏差率数据
|
|
|
|
+ List<Curvefittingmonthsub> collect = curvefittingmonthsubs.stream().filter(curve -> curve.getWindturbineid().equals(wt.getId())).collect(Collectors.toList());
|
|
|
|
+ Healthwtreport1 healthwtreport1 = new Healthwtreport1();
|
|
|
|
+ healthwtreport1.setId(CommonUtils.getUUID());
|
|
|
|
+ double qxpcl = collect.stream().mapToDouble(Curvefittingmonthsub::getDeviationrate2).average().orElse(0d);
|
|
|
|
+ double jzz = collect.stream().mapToDouble(Curvefittingmonthsub::getStandarddeviationrate).average().orElse(0d);
|
|
|
|
+ healthwtreport1.setQxpcl(qxpcl);
|
|
|
|
+ healthwtreport1.setThreeqxpcl(collect.stream().filter(i->Double.parseDouble(i.getSpeed())>=3 && Double.parseDouble(i.getSpeed())<5).mapToDouble(Curvefittingmonthsub::getDeviationrate2).average().orElse(0d));
|
|
|
|
+ healthwtreport1.setFiveqxpcl(collect.stream().filter(i->Double.parseDouble(i.getSpeed())>=5 && Double.parseDouble(i.getSpeed())<11).mapToDouble(Curvefittingmonthsub::getDeviationrate2).average().orElse(0d));
|
|
|
|
+ healthwtreport1.setElevenqxpcl(collect.stream().filter(i->Double.parseDouble(i.getSpeed())>=11).mapToDouble(Curvefittingmonthsub::getDeviationrate2).average().orElse(0d));
|
|
|
|
+ if (qxpcl>=jzz){
|
|
|
|
+ healthwtreport1.setCompareqxpclname("高于");
|
|
|
|
+ }else {
|
|
|
|
+ healthwtreport1.setCompareqxpclname("低于");
|
|
|
|
+ }
|
|
|
|
+ healthwtreport1.setCompareqxpcl(Math.abs(qxpcl-jzz));
|
|
|
|
+ healthwtreport1.setType(1);
|
|
|
|
+ resultList.add(healthwtreport1);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ healthwtreport1Service.saveBatch(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存功率曲线
|
|
|
|
+ * @param stringdate
|
|
|
|
+ */
|
|
|
|
+ public void saveHealthwtreport2(String stringdate){
|
|
|
|
+ healthwtreport2Service.remove(new QueryWrapper<>());
|
|
|
|
+ List<Healthwtreport2> resultList = new ArrayList<>();
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ int month = DateUtils.getMonth(date);
|
|
|
|
+ int year = DateUtils.getYear(date);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Windturbinecurvefittingmonth> windturbinecurvefittingmonthQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ windturbinecurvefittingmonthQueryWrapper.eq("year",year);
|
|
|
|
+ windturbinecurvefittingmonthQueryWrapper.eq("month",month);
|
|
|
|
+ windturbinecurvefittingmonthQueryWrapper.in("speed",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);
|
|
|
|
+ List<Windturbinecurvefittingmonth> windturbinecurvefittingmonthList = windturbinecurvefittingmonthService.list(windturbinecurvefittingmonthQueryWrapper);
|
|
|
|
+ windturbinecurvefittingmonthList.stream().forEach(i->{
|
|
|
|
+ Healthwtreport2 healthwtreport2 = new Healthwtreport2();
|
|
|
|
+ healthwtreport2.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport2.setWtid(i.getWindturbineid());
|
|
|
|
+ healthwtreport2.setSpeed(i.getSpeed());
|
|
|
|
+ healthwtreport2.setBzgl(i.getOptimalpower());
|
|
|
|
+ healthwtreport2.setNhgl(i.getActualpower());
|
|
|
|
+
|
|
|
|
+ resultList.add(healthwtreport2);
|
|
|
|
+ });
|
|
|
|
+ healthwtreport2Service.saveBatch(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存曲线偏差率曲线
|
|
|
|
+ * @param stringdate
|
|
|
|
+ */
|
|
|
|
+ public void saveHealthwtreport3(String stringdate){
|
|
|
|
+ healthwtreport3Service.remove(new QueryWrapper<>());
|
|
|
|
+ List<Healthwtreport3> resultList = new ArrayList<>();
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Curvefittingsub> curvefittingsubQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ curvefittingsubQueryWrapper.select("windturbineid,recorddate,avg(standarddeviationrate) standarddeviationrate,avg(deviationrate2) deviationrate2");
|
|
|
|
+ curvefittingsubQueryWrapper.ge("recorddate",monthFirst).le("recorddate",monthLast);
|
|
|
|
+ curvefittingsubQueryWrapper.groupBy("windturbineid","recorddate");
|
|
|
|
+ List<Curvefittingsub> curvefittingsubList = curvefittingsubService.list(curvefittingsubQueryWrapper);
|
|
|
|
+ curvefittingsubList.stream().forEach(i->{
|
|
|
|
+ Healthwtreport3 healthwtreport3 = new Healthwtreport3();
|
|
|
|
+
|
|
|
|
+ healthwtreport3.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport3.setDate(i.getRecorddate());
|
|
|
|
+ healthwtreport3.setWtid(i.getWindturbineid());
|
|
|
|
+ healthwtreport3.setQxpcl(i.getDeviationrate2());
|
|
|
|
+ healthwtreport3.setJzz(i.getStandarddeviationrate());
|
|
|
|
+ resultList.add(healthwtreport3);
|
|
|
|
+ });
|
|
|
|
+ healthwtreport3Service.saveBatch(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存对风偏差率描述
|
|
|
|
+ * @param stringdate
|
|
|
|
+ */
|
|
|
|
+ public void saveHealthwtreport456(String stringdate){
|
|
|
|
+ healthwtreport4Service.remove(new QueryWrapper<>());
|
|
|
|
+ healthwtreport5Service.remove(new QueryWrapper<>());
|
|
|
|
+ healthwtreport6Service.remove(new QueryWrapper<>());
|
|
|
|
+
|
|
|
|
+ List<Windturbine> wtls = CacheContext.wtls;
|
|
|
|
+ List<Healthwtreport4> resultList = new ArrayList<>();
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Windturbinewindyaw> windqueryWrapper = new QueryWrapper<>();
|
|
|
|
+ windqueryWrapper.le("recorddate",monthLast);
|
|
|
|
+ windqueryWrapper.ge("recorddate",monthFirst);
|
|
|
|
+ List<Windturbinewindyaw> windturbinewindyaws = windturbinewindyawService.list(windqueryWrapper);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Windturbinepoweryaw> powerqueryWrapper = new QueryWrapper<>();
|
|
|
|
+ powerqueryWrapper.le("recorddate",monthLast);
|
|
|
|
+ powerqueryWrapper.ge("recorddate",monthFirst);
|
|
|
|
+ List<Windturbinepoweryaw> powerturbinewindyaws = windturbinepoweryawService.list(powerqueryWrapper);
|
|
|
|
+
|
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
|
+ Healthwtreport4 healthwtreport4 = new Healthwtreport4();
|
|
|
|
+ healthwtreport4.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport4.setWtid(wt.getId());
|
|
|
|
+ List<Windturbinewindyaw> collect = windturbinewindyaws.stream().filter(i -> i.getWindturbineid().equals(wt.getId())).collect(Collectors.toList());
|
|
|
|
+ List<Windturbinepoweryaw> collect1 = powerturbinewindyaws.stream().filter(i -> i.getWindturbineid().equals(wt.getId())).collect(Collectors.toList());
|
|
|
|
+ int hg = collect.stream().mapToInt(Windturbinewindyaw::getQualified).sum();
|
|
|
|
+ int bhg = collect.stream().mapToInt(Windturbinewindyaw::getUnqualified).sum();
|
|
|
|
+ healthwtreport4.setWithincount(hg);
|
|
|
|
+ healthwtreport4.setBeyondcount(bhg);
|
|
|
|
+ int sum = hg+bhg;
|
|
|
|
+ healthwtreport4.setDfpcl(sum!=0?(double)bhg/sum*100:0);
|
|
|
|
+
|
|
|
|
+ int threehg = collect.stream().filter(i->i.getSpeed() >= 3 && i.getSpeed() < 5).mapToInt(Windturbinewindyaw::getQualified).sum();
|
|
|
|
+ int threebhg = collect.stream().filter(i->i.getSpeed() >= 3 && i.getSpeed() < 5).mapToInt(Windturbinewindyaw::getUnqualified).sum();
|
|
|
|
+ int threesum = threehg+threebhg;
|
|
|
|
+ healthwtreport4.setThreedfpcl(threesum!=0?(double)threebhg/threesum*100:0);
|
|
|
|
+
|
|
|
|
+ int fivehg = collect.stream().filter(i->i.getSpeed() >= 5 && i.getSpeed() < 11).mapToInt(Windturbinewindyaw::getQualified).sum();
|
|
|
|
+ int fivebhg = collect.stream().filter(i->i.getSpeed() >= 5 && i.getSpeed() < 11).mapToInt(Windturbinewindyaw::getUnqualified).sum();
|
|
|
|
+ int fivesum = fivehg+fivebhg;
|
|
|
|
+ healthwtreport4.setFivedfpcl(fivesum!=0?(double)fivebhg/fivesum*100:0);
|
|
|
|
+
|
|
|
|
+ int elehg = collect.stream().filter(i->i.getSpeed() >= 11).mapToInt(Windturbinewindyaw::getQualified).sum();
|
|
|
|
+ int elebhg = collect.stream().filter(i->i.getSpeed() >= 11).mapToInt(Windturbinewindyaw::getUnqualified).sum();
|
|
|
|
+ int elesum = elehg+elebhg;
|
|
|
|
+ healthwtreport4.setElevendfpcl(elesum!=0?(double)elebhg/elesum*100:0);
|
|
|
|
+ List<Healthwtreport6> powerresultList = new ArrayList<>();
|
|
|
|
+ List<Healthwtreport5> speedresultList = new ArrayList<>();
|
|
|
|
+ healthwtreport4.setGlfw("1500");
|
|
|
|
+ if (collect1!=null && collect1.size()>0){
|
|
|
|
+ List<Double> powercollect = collect1.stream().map(i -> i.getPower()).distinct().collect(Collectors.toList());
|
|
|
|
+ Collections.sort(powercollect);
|
|
|
|
+ String descriptiondfpcl="";
|
|
|
|
+ for (Double aDouble : powercollect) {
|
|
|
|
+ Healthwtreport6 healthwtreport6 = new Healthwtreport6();
|
|
|
|
+ healthwtreport6.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport6.setWtid(wt.getId());
|
|
|
|
+ healthwtreport6.setPower(aDouble);
|
|
|
|
+
|
|
|
|
+ int xhg = collect1.stream().filter(i->i.getPower()==aDouble).mapToInt(Windturbinepoweryaw::getQualified).sum();
|
|
|
|
+ int xbhg= collect1.stream().filter(i->i.getPower()==aDouble).mapToInt(Windturbinepoweryaw::getUnqualified).sum();
|
|
|
|
+ int xsum = xhg + xbhg;
|
|
|
|
+ healthwtreport6.setDfpcl(xsum!=0?(double)xbhg/xsum*100:0);
|
|
|
|
+ powerresultList.add(healthwtreport6);
|
|
|
|
+ descriptiondfpcl += ((xsum!=0?xbhg/xsum*100:0)+"%,");
|
|
|
|
+ }
|
|
|
|
+ healthwtreport4.setDescriptiondfpcl(descriptiondfpcl);
|
|
|
|
+ }
|
|
|
|
+ if (collect!=null && collect.size()>0){
|
|
|
|
+ List<Double> speedcollect = collect.stream().map(i -> i.getSpeed()).distinct().collect(Collectors.toList());
|
|
|
|
+ Collections.sort(speedcollect);
|
|
|
|
+ for (Double aDouble : speedcollect) {
|
|
|
|
+ Healthwtreport5 healthwtreport5 = new Healthwtreport5();
|
|
|
|
+ healthwtreport5.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport5.setWtid(wt.getId());
|
|
|
|
+ healthwtreport5.setSpeed(aDouble);
|
|
|
|
+
|
|
|
|
+ int xhg = collect.stream().filter(i->i.getSpeed()==aDouble).mapToInt(Windturbinewindyaw::getQualified).sum();
|
|
|
|
+ int xbhg= collect.stream().filter(i->i.getSpeed()==aDouble).mapToInt(Windturbinewindyaw::getUnqualified).sum();
|
|
|
|
+ int xsum = xhg + xbhg;
|
|
|
|
+ healthwtreport5.setDfpcl(xsum!=0?(double)xbhg/xsum*100:0);
|
|
|
|
+ speedresultList.add(healthwtreport5);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ resultList.add(healthwtreport4);
|
|
|
|
+ healthwtreport6Service.saveBatch(powerresultList);
|
|
|
|
+ healthwtreport5Service.saveBatch(speedresultList);
|
|
|
|
+ });
|
|
|
|
+ healthwtreport4Service.saveBatch(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存对风偏差率(奶嘴图)
|
|
|
|
+ */
|
|
|
|
+ public void saveDfpcl(String stringdate){
|
|
|
|
+ List<Winddeviationrate> resultList = new ArrayList<>();
|
|
|
|
+ winddeviationrateService.clear();
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
|
+ List<Windturbinepoweryaw> windturbinepoweryawList = windturbinepoweryawService.getDfpcl(monthFirst,monthLast);
|
|
|
|
+ windturbinepoweryawList.stream().forEach(i->{
|
|
|
|
+ Field[] fields = i.getClass().getDeclaredFields();
|
|
|
|
+ Arrays.stream(fields).forEach(j->{
|
|
|
|
+ Winddeviationrate winddeviationrate = new Winddeviationrate();
|
|
|
|
+ winddeviationrate.setId(CommonUtils.getUUID());
|
|
|
|
+ winddeviationrate.setWtid(i.getWindturbineid());
|
|
|
|
+ winddeviationrate.setType(j.getName().replace("Rf","R-"));
|
|
|
|
+ try {
|
|
|
|
+ Field field = i.getClass().getDeclaredField(j.getName());
|
|
|
|
+ if (field.getGenericType().toString().equals("class java.lang.Integer")){
|
|
|
|
+ field.setAccessible(true);
|
|
|
|
+ Integer count = (Integer) field.get(i);
|
|
|
|
+ winddeviationrate.setCount(count);
|
|
|
|
+ resultList.add(winddeviationrate);
|
|
|
|
+ }
|
|
|
|
+ } catch (NoSuchFieldException | IllegalAccessException e) {
|
|
|
|
+ winddeviationrate.setCount(0);
|
|
|
|
+ resultList.add(winddeviationrate);
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ winddeviationrateService.saveBatch(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存切入切出
|
|
|
|
+ * @param stringdate
|
|
|
|
+ */
|
|
|
|
+ public void saveHealthwtreport7(String stringdate){
|
|
|
|
+ healthwtreport7Service.remove(new QueryWrapper<>());
|
|
|
|
+
|
|
|
|
+ Date date = DateUtils.parseDate1(stringdate);
|
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<Inputoroutputspeedtotal> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.le("recorddate",monthLast);
|
|
|
|
+ queryWrapper.ge("recorddate",monthFirst);
|
|
|
|
+ List<Inputoroutputspeedtotal> inputoroutputspeedtotals = inputoroutputspeedtotalService.list(queryWrapper);
|
|
|
|
+
|
|
|
|
+ List<Healthwtreport7> resultList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Windturbine> wtls = CacheContext.wtls;
|
|
|
|
+ wtls.stream().forEach(wt->{
|
|
|
|
+ List<Inputoroutputspeedtotal> collect = inputoroutputspeedtotals.stream().filter(in -> in.getWindturbineid().equals(wt.getId())).collect(Collectors.toList());
|
|
|
|
+ Healthwtreport7 healthwtreport7 = new Healthwtreport7();
|
|
|
|
+ healthwtreport7.setId(CommonUtils.getUUID());
|
|
|
|
+ healthwtreport7.setWtid(wt.getId());
|
|
|
|
+ double xfqr = collect.stream().mapToDouble(Inputoroutputspeedtotal::getInputsmall).average().orElse(0d);
|
|
|
|
+ double dfqr = collect.stream().mapToDouble(Inputoroutputspeedtotal::getInputbig).average().orElse(0d);
|
|
|
|
+ double xfqc = collect.stream().mapToDouble(Inputoroutputspeedtotal::getOutputsmall).average().orElse(0d);
|
|
|
|
+ double dfqc = collect.stream().mapToDouble(Inputoroutputspeedtotal::getOutputbig).average().orElse(0d);
|
|
|
|
+ healthwtreport7.setDfqc(dfqc);
|
|
|
|
+ healthwtreport7.setDfqr(dfqr);
|
|
|
|
+ healthwtreport7.setXfqc(xfqc);
|
|
|
|
+ healthwtreport7.setXfqr(xfqr);
|
|
|
|
+ resultList.add(healthwtreport7);
|
|
|
|
+ });
|
|
|
|
+ healthwtreport7Service.saveBatch(resultList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|