|
@@ -0,0 +1,331 @@
|
|
|
+package com.gyee.healthmanagementhistroy.service.healthreport;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.common.util.CommonUtils;
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
+import com.gyee.healthmanagementhistroy.mapper.healthreport.PartDangerMapper;
|
|
|
+import com.gyee.healthmanagementhistroy.mapper.healthreport.PartPowerMapper;
|
|
|
+import com.gyee.healthmanagementhistroy.model.auto.*;
|
|
|
+import com.gyee.healthmanagementhistroy.model.healthreport.PartDanger;
|
|
|
+import com.gyee.healthmanagementhistroy.model.healthreport.PartPower;
|
|
|
+import com.gyee.healthmanagementhistroy.service.auto.*;
|
|
|
+import org.springframework.stereotype.Repository;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.*;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : HealthReportService
|
|
|
+ * @Author : xieshengjie
|
|
|
+ * @Date: 2021/10/5 17:19
|
|
|
+ * @Description : 健康报告service
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class HealthReportService {
|
|
|
+ @Resource
|
|
|
+ private IReportpowerfittingService reportpowerfittingService;
|
|
|
+ @Resource
|
|
|
+ private IReportdeviationService reportdeviationService;
|
|
|
+ @Resource
|
|
|
+ private IWindturbinecurvefittingmonthService windturbinecurvefittingmonthService;
|
|
|
+ @Resource
|
|
|
+ private ICurvefittingsubService curvefittingsubService;
|
|
|
+ @Resource
|
|
|
+ private IWindturbinepoweryawService windturbinepoweryawService;
|
|
|
+ @Resource
|
|
|
+ private IWinddeviationrateService winddeviationrateService;
|
|
|
+ @Resource
|
|
|
+ private IWindpowerdeviationrateService windpowerdeviationrateService;
|
|
|
+ @Resource
|
|
|
+ private IWindturbinewindyawService windturbinewindyawService;
|
|
|
+ @Resource
|
|
|
+ private IInputoroutputspeedtotalService inputoroutputspeedtotalService;
|
|
|
+ @Resource
|
|
|
+ private IReportcutinoutService reportcutinoutService;
|
|
|
+ @Resource
|
|
|
+ private PartDangerMapper partDangerMapper;
|
|
|
+ @Resource
|
|
|
+ private IReportdangerService reportdangerService;
|
|
|
+ @Resource
|
|
|
+ private IFaultstatisticwindturbineService faultstatisticwindturbineService;
|
|
|
+ @Resource
|
|
|
+ private IReportfaultclassService reportfaultclassService;
|
|
|
+ @Resource
|
|
|
+ private PartPowerMapper partPowerMapper;
|
|
|
+ @Resource
|
|
|
+ private IReportpowerpartweatherService reportpowerpartweatherService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存曲线拟合
|
|
|
+ */
|
|
|
+ public void savePowerfitting(Date date){
|
|
|
+
|
|
|
+ List<Reportpowerfitting> resultList = new ArrayList<>();
|
|
|
+ if (date == null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Integer year = DateUtils.getYear(date);
|
|
|
+ Integer month = DateUtils.getMonth(date);
|
|
|
+ Map<String,Object> delMap = new HashMap<>();
|
|
|
+ delMap.put("year",year);
|
|
|
+ delMap.put("month",month);
|
|
|
+ reportpowerfittingService.removeByMap(delMap);
|
|
|
+ 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->{
|
|
|
+ Reportpowerfitting reportpowerfitting = new Reportpowerfitting();
|
|
|
+ reportpowerfitting.setId(CommonUtils.getUUID());
|
|
|
+ reportpowerfitting.setWtid(i.getWindturbineid());
|
|
|
+ reportpowerfitting.setSpeed(i.getSpeed());
|
|
|
+ reportpowerfitting.setYear(i.getYear());
|
|
|
+ reportpowerfitting.setMonth(i.getMonth());
|
|
|
+ reportpowerfitting.setNhgl(i.getActualpower());
|
|
|
+ reportpowerfitting.setBzgl(i.getOptimalpower());
|
|
|
+ resultList.add(reportpowerfitting);
|
|
|
+ });
|
|
|
+ reportpowerfittingService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存曲线偏差率
|
|
|
+ */
|
|
|
+ public void saveDeviation(Date date){
|
|
|
+ List<Reportdeviation> resultList = new ArrayList<>();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
+ QueryWrapper<Reportdeviation> delquery = new QueryWrapper<>();
|
|
|
+ delquery.ge("recorddate",monthFirst).le("recorddate",monthLast);
|
|
|
+ reportdeviationService.remove(delquery);
|
|
|
+
|
|
|
+ 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->{
|
|
|
+ Reportdeviation reportdeviation = new Reportdeviation();
|
|
|
+ reportdeviation.setId(CommonUtils.getUUID());
|
|
|
+ reportdeviation.setRecorddate(i.getRecorddate());
|
|
|
+ reportdeviation.setWtid(i.getWindturbineid());
|
|
|
+ reportdeviation.setPcl(i.getDeviationrate2());
|
|
|
+ reportdeviation.setJzz(i.getStandarddeviationrate());
|
|
|
+ resultList.add(reportdeviation);
|
|
|
+ });
|
|
|
+ reportdeviationService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存对风偏差率(奶嘴图)
|
|
|
+ */
|
|
|
+ public void saveDfpcl(Date date){
|
|
|
+ List<Winddeviationrate> resultList = new ArrayList<>();
|
|
|
+ winddeviationrateService.clear();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存对风偏差率(风速图,功率图)
|
|
|
+ */
|
|
|
+ public void saveDfpclWindAndPower(Date date){
|
|
|
+ windpowerdeviationrateService.clear();
|
|
|
+ List<Windpowerdeviationrate> resultList = new ArrayList<>();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
+ //获取功率偏差
|
|
|
+ List<Windturbinepoweryaw> windturbinepoweryawList = windturbinepoweryawService.getdfpclpower(monthFirst, monthLast);
|
|
|
+ windturbinepoweryawList.stream().forEach(i->{
|
|
|
+ Windpowerdeviationrate windpowerdeviationrate = new Windpowerdeviationrate();
|
|
|
+ windpowerdeviationrate.setId(CommonUtils.getUUID());
|
|
|
+ windpowerdeviationrate.setWtid(i.getWindturbineid());
|
|
|
+ windpowerdeviationrate.setType(2);
|
|
|
+ Double qualified = i.getQualified();
|
|
|
+ Double unqualified = i.getUnqualified();
|
|
|
+ windpowerdeviationrate.setTypevalue((int) (i.getPower()*100));
|
|
|
+ windpowerdeviationrate.setValue((qualified+unqualified)!=0?(unqualified/(qualified+unqualified)*100):0);
|
|
|
+ resultList.add(windpowerdeviationrate);
|
|
|
+ });
|
|
|
+ //获取风速偏差
|
|
|
+ List<Windturbinewindyaw> windturbinewindyawList = windturbinewindyawService.getdfpclwind(monthFirst, monthLast);
|
|
|
+ windturbinewindyawList.stream().forEach(i->{
|
|
|
+ Windpowerdeviationrate windpowerdeviationrate = new Windpowerdeviationrate();
|
|
|
+ windpowerdeviationrate.setId(CommonUtils.getUUID());
|
|
|
+ windpowerdeviationrate.setWtid(i.getWindturbineid());
|
|
|
+ windpowerdeviationrate.setType(1);
|
|
|
+ Double qualified = i.getQualified();
|
|
|
+ Double unqualified = i.getUnqualified();
|
|
|
+ windpowerdeviationrate.setTypevalue(i.getSpeed());
|
|
|
+ windpowerdeviationrate.setValue((qualified+unqualified)!=0?(unqualified/(qualified+unqualified)*100):0);
|
|
|
+ resultList.add(windpowerdeviationrate);
|
|
|
+ });
|
|
|
+ windpowerdeviationrateService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存切入切出(没用)
|
|
|
+ */
|
|
|
+ public void saveQrqc(Date date){
|
|
|
+ reportcutinoutService.clear();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Date yestoday = DateUtils.getYestday(date);
|
|
|
+ List<Reportcutinout> resultList = new ArrayList<>();
|
|
|
+ QueryWrapper<Inputoroutputspeedtotal> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("recorddate",yestoday);
|
|
|
+ List<Inputoroutputspeedtotal> list = inputoroutputspeedtotalService.list(qw);
|
|
|
+ list.stream().forEach(i->{
|
|
|
+ Reportcutinout reportcutinout = new Reportcutinout();
|
|
|
+ reportcutinout.setId(CommonUtils.getUUID());
|
|
|
+ reportcutinout.setWtid(i.getWindturbineid());
|
|
|
+ reportcutinout.setMincutin(i.getMonthinputsmall());
|
|
|
+ reportcutinout.setMincutout(i.getMonthoutputsmall());
|
|
|
+ reportcutinout.setMaxcutin(i.getMonthinputbig());
|
|
|
+ reportcutinout.setMaxcutout(i.getMonthoutputbig());
|
|
|
+ reportcutinout.setWpid(i.getWindpowerstationid());
|
|
|
+ resultList.add(reportcutinout);
|
|
|
+ });
|
|
|
+ reportcutinoutService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存部件隐患
|
|
|
+ * @param date
|
|
|
+ */
|
|
|
+ public void savePartdanger(Date date){
|
|
|
+ reportdangerService.clear();
|
|
|
+ List<Reportdanger> resultList = new ArrayList<>();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
+ List<PartDanger> partDangerList = partDangerMapper.getPartDanger(monthFirst, monthLast);
|
|
|
+ partDangerList.stream().forEach(i->{
|
|
|
+ Reportdanger reportdanger = new Reportdanger();
|
|
|
+ reportdanger.setId(CommonUtils.getUUID());
|
|
|
+ reportdanger.setWtid(i.getWindturbineid());
|
|
|
+ reportdanger.setWpid(i.getStationid());
|
|
|
+ reportdanger.setPart(i.getType());
|
|
|
+ reportdanger.setDanger(i.getAlerttext());
|
|
|
+ reportdanger.setCount(i.getCount());
|
|
|
+ reportdanger.setTimes(i.getTime());
|
|
|
+ List<PartDanger> partDangers = partDangerList.stream().filter(j -> j.getStationid().equals(i.getStationid()) && j.getAlerttext().equals(i.getAlerttext())).collect(Collectors.toList());
|
|
|
+ double avgcount=0;
|
|
|
+ double avgtime=0;
|
|
|
+ if (partDangers!=null) {
|
|
|
+ avgcount=partDangers.stream().mapToDouble(PartDanger::getCount).average().getAsDouble();
|
|
|
+ avgtime= partDangers.stream().mapToDouble(PartDanger::getTime).average().getAsDouble();
|
|
|
+ }
|
|
|
+ reportdanger.setCountavg((int) avgcount);
|
|
|
+ reportdanger.setTimesavg(avgtime);
|
|
|
+ resultList.add(reportdanger);
|
|
|
+ });
|
|
|
+ reportdangerService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存故障分类(暂时没用)
|
|
|
+ * @param date
|
|
|
+ */
|
|
|
+ public void saveFaultclassification(Date date){
|
|
|
+ reportfaultclassService.clear();
|
|
|
+ List<Reportfaultclass> resultList = new ArrayList<>();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ int month = DateUtils.getMonth(date);
|
|
|
+ int year = DateUtils.getYear(date);
|
|
|
+ QueryWrapper<Faultstatisticwindturbine> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("year",year);
|
|
|
+ qw.eq("month",month);
|
|
|
+ List<Faultstatisticwindturbine> faultstatisticwindturbines = faultstatisticwindturbineService.list(qw);
|
|
|
+ faultstatisticwindturbines.stream().forEach(i->{
|
|
|
+ Reportfaultclass reportfaultclass = new Reportfaultclass();
|
|
|
+ reportfaultclass.setId(CommonUtils.getUUID());
|
|
|
+ reportfaultclass.setWtid(i.getWindturbineid());
|
|
|
+ reportfaultclass.setWpid(i.getWindpowerstationid());
|
|
|
+ reportfaultclass.setType(i.getWarningtype());
|
|
|
+ reportfaultclass.setDcount(i.getMonthwarningnum());
|
|
|
+ reportfaultclass.setScount(i.getMonthonmonthnum());
|
|
|
+ reportfaultclass.setTcount(i.getYearoveryearnum());
|
|
|
+ reportfaultclass.setDtime(i.getMonthwarningtime());
|
|
|
+ reportfaultclass.setStime(i.getMonthonmonthtime());
|
|
|
+ reportfaultclass.setTtime(i.getYearoveryeartime());
|
|
|
+ resultList.add(reportfaultclass);
|
|
|
+ });
|
|
|
+ reportfaultclassService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存部件功率
|
|
|
+ * @param date
|
|
|
+ */
|
|
|
+ public void savePartpower(Date date){
|
|
|
+ reportpowerpartweatherService.clear();
|
|
|
+ List<Reportpowerpartweather> resultList = new ArrayList<>();
|
|
|
+ if (date ==null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ Date monthFirst = DateUtils.getMonthFirst(date);
|
|
|
+ Date monthLast = DateUtils.getMonthLast(date);
|
|
|
+ List<PartPower> partpowers = partPowerMapper.getPartpowers(monthFirst, monthLast);
|
|
|
+ partpowers.stream().forEach(i->{
|
|
|
+ Reportpowerpartweather reportpowerpartweather = new Reportpowerpartweather();
|
|
|
+ reportpowerpartweather.setId(CommonUtils.getUUID());
|
|
|
+ reportpowerpartweather.setWtid(i.getWtid());
|
|
|
+ reportpowerpartweather.setPartname(i.getPartname());
|
|
|
+ reportpowerpartweather.setName(i.getName());
|
|
|
+ reportpowerpartweather.setPower(i.getPower());
|
|
|
+ reportpowerpartweather.setDatavalue(i.getDatavalue());
|
|
|
+ reportpowerpartweather.setEarlywarningvalue(i.getEarlywarningvalue());
|
|
|
+ resultList.add(reportpowerpartweather);
|
|
|
+ });
|
|
|
+ reportpowerpartweatherService.saveBatch(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //部件从WTTRAGETREPORTCHART 取
|
|
|
+ //全生命周期没做
|
|
|
+
|
|
|
+}
|