xieshengjie 3 years ago
parent
commit
70009f9afd

+ 17 - 0
common/src/main/java/com/gyee/common/util/CommonUtils.java

@@ -0,0 +1,17 @@
+package com.gyee.common.util;
+
+import java.util.UUID;
+
+/**
+ * @ClassName : CommonUtils
+ * @Author : xieshengjie
+ * @Date: 2021/10/5 17:51
+ * @Description : 通用工具类
+ */
+public class CommonUtils {
+
+    public static String getUUID(){
+        String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
+        return uuid;
+    }
+}

+ 87 - 0
common/src/main/java/com/gyee/common/util/DateUtils.java

@@ -0,0 +1,87 @@
+package com.gyee.common.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @ClassName : DateUtils
+ * @Author : xieshengjie
+ * @Date: 2021/10/5 17:35
+ * @Description : 日期工具
+ */
+public class DateUtils  {
+    /**
+     * 获得指定时间的月数
+     *
+     * @param date
+     * @return
+     */
+    public static int getMonth(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.MONTH)+1;
+    }
+
+    /**
+     * 获得指定时间的年数
+     *
+     * @param date
+     * @return
+     */
+    public static int getYear(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.YEAR);
+    }
+
+    /**
+     * 获取某日期的当月最后一天
+     *
+     * @param date
+     *
+     * @return Date
+     */
+    public static Date getMonthLast(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        int month = getMonth(date);
+        int year = getYear(date);
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month-1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        Date currYearFirst = calendar.getTime();
+        return currYearFirst;
+    }
+    /**
+     * 获取某日期的当月第一天
+     *
+     * @param date
+     *
+     * @return Date
+     */
+    public static Date getMonthFirst(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        int month = getMonth(date);
+        int year = getYear(date);
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month-1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+        Date currYearFirst = calendar.getTime();
+        return currYearFirst;
+    }
+
+    /**
+     * 获取昨天日期
+     * @param date
+     * @return
+     */
+    public static Date getYestday(Date date){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, -1);
+        return calendar.getTime();
+
+    }
+}

+ 63 - 1
histroy/healthmanagement-histroy/pom.xml

@@ -11,5 +11,67 @@
 
     <artifactId>healthmanagement-histroy</artifactId>
 
-
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>2.3.28</version>
+        </dependency>
+        <!--mysql-connector-java-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.oracle</groupId>
+            <artifactId>ojdbc6</artifactId>
+            <version>11.2.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.gyee</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 19 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/HealthManagementHistroyMain.java

@@ -0,0 +1,19 @@
+package com.gyee.healthmanagementhistroy;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @ClassName : HealthManagementHistroyMain
+ * @Author : xieshengjie
+ * @Date: 2021/10/5 16:05
+ * @Description :
+ */
+@SpringBootApplication
+@MapperScan("com.gyee.healthmanagementhistroy.mapper")
+public class HealthManagementHistroyMain {
+    public static void main(String[] args) {
+        SpringApplication.run(HealthManagementHistroyMain.class, args);
+    }
+}

+ 152 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/config/GeneratorCodeConfig.java

@@ -0,0 +1,152 @@
+package com.gyee.healthmanagementhistroy.config;
+
+
+import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.*;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
+
+import java.util.Scanner;
+
+/**
+ *@ClassName GeneratorCodeConfig
+ *@Description 自动生成mybatisplus的相关代码
+ *@Author 谢生杰
+ *@Date 2020/9/25 18:26
+ *@Version 1.0
+ **/
+public class GeneratorCodeConfig {
+    public static String scanner(String tip) {
+        Scanner scanner = new Scanner(System.in);
+        StringBuilder help = new StringBuilder();
+        help.append("请输入" + tip + ":");
+        System.out.println(help.toString());
+        if (scanner.hasNext()) {
+            String ipt = scanner.next();
+            if (StringUtils.isNotEmpty(ipt)) {
+                return ipt;
+            }
+        }
+        throw new MybatisPlusException("请输入正确的" + tip + "!");
+    }
+
+    public static void main(String[] args) {
+        // 代码生成器
+        AutoGenerator mpg = new AutoGenerator();
+
+        // 全局配置
+        GlobalConfig gc = new GlobalConfig();
+        String projectPath = System.getProperty("user.dir");
+        gc.setOutputDir(projectPath + "/src/main/java");
+        gc.setAuthor("谢生杰");
+        gc.setOpen(false);
+        //实体属性 Swagger2 注解
+        gc.setSwagger2(false);
+        mpg.setGlobalConfig(gc);
+
+        // 数据源配置
+        DataSourceConfig dsc = new DataSourceConfig();
+
+//        dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true");
+//        dsc.setDriverName("com.mysql.jdbc.Driver");
+//        dsc.setUsername("root");
+//        dsc.setPassword("root");
+//        mpg.setDataSource(dsc);
+
+        dsc.setDriverName("oracle.jdbc.driver.OracleDriver");
+        dsc.setUsername("nxfdprod");
+        dsc.setPassword("gdnxfd123");
+//        dsc.setUrl("jdbc:oracle:thin:@49.4.50.80:1521:gdnxfd");
+        dsc.setUrl("jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd");
+        mpg.setDataSource(dsc);
+
+
+//        dsc.setDriverName("com.cloudera.impala.jdbc41.Driver");
+//        dsc.setUrl("jdbc:impala://192.168.1.67:21050/gyee_test");
+//        mpg.setDataSource(dsc);
+
+
+
+        // 包配置
+        PackageConfig pc = new PackageConfig();
+//        pc.setModuleName(scanner("模块名"));
+        pc.setParent("com.gyee.healthmanagementhistroy");
+        pc.setEntity("model.auto");
+        pc.setMapper("mapper.auto");
+        pc.setService("service.auto");
+        pc.setServiceImpl("service.auto.impl");
+        pc.setController("controller.auto");
+        mpg.setPackageInfo(pc);
+
+        // 自定义配置
+//        InjectionConfig cfg = new InjectionConfig() {
+//            @Override
+//            public void initMap() {
+//                // to do nothing
+//            }
+//        };
+
+        // 如果模板引擎是 freemarker
+//        String templatePath = "/templates/mapper.xml.ftl";
+        // 如果模板引擎是 velocity
+        // String templatePath = "/templates/mapper.xml.vm";
+
+        // 自定义输出配置
+//        List<FileOutConfig> focList = new ArrayList<>();
+        // 自定义配置会被优先输出
+//        focList.add(new FileOutConfig(templatePath) {
+//            @Override
+//            public String outputFile(TableInfo tableInfo) {
+//                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
+//                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
+//                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
+//            }
+//        });
+        /*
+        cfg.setFileCreate(new IFileCreate() {
+            @Override
+            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
+                // 判断自定义文件夹是否需要创建
+                checkDir("调用默认方法创建的目录");
+                return false;
+            }
+        });
+        */
+//        cfg.setFileOutConfigList(focList);
+//        mpg.setCfg(cfg);
+
+        // 配置模板
+        TemplateConfig templateConfig = new TemplateConfig();
+
+        // 配置自定义输出模板
+        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
+        // templateConfig.setEntity("templates/entity2.java");
+        // templateConfig.setService();
+        // templateConfig.setController();
+
+        templateConfig.setXml(null);
+        mpg.setTemplate(templateConfig);
+
+        // 策略配置
+        StrategyConfig strategy = new StrategyConfig();
+        strategy.setNaming(NamingStrategy.underline_to_camel);
+        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+        strategy.setSuperEntityClass("com.baomidou.mybatisplus.extension.activerecord.Model");
+        strategy.setEntityLombokModel(true);
+        strategy.setRestControllerStyle(true);
+
+        strategy.setEntityLombokModel(true);
+        // 公共父类
+//        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
+        // 写于父类中的公共字段
+//        strategy.setSuperEntityColumns("id");
+        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
+        strategy.setControllerMappingHyphenStyle(true);
+        strategy.setTablePrefix(pc.getModuleName() + "_");
+        mpg.setStrategy(strategy);
+        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
+        mpg.execute();
+    }
+}

+ 28 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/mapper/healthreport/PartDangerMapper.java

@@ -0,0 +1,28 @@
+package com.gyee.healthmanagementhistroy.mapper.healthreport;
+
+import com.gyee.healthmanagementhistroy.model.healthreport.PartDanger;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @ClassName : PartDangerMapper
+ * @Author : xieshengjie
+ * @Date: 2021/10/12 11:40
+ * @Description : 部件隐患mapper
+ */
+@Resource
+public interface PartDangerMapper {
+    @Select("select sum(a.count) as count,sum(a.time) time,max(s.stationid) stationid, max(s.windturbineid) windturbineid, max(s.alerttext) alerttext,max(d.name) type\n" +
+            "from alarmcount a left join alarmsnap ss on a.snapid = ss.id\n" +
+            "left join alarmsnap s on a.snapid=s.id\n" +
+            "left join ALERTRULE2 c on s.alerttext=c.name and ss.stationid = c.station\n" +
+            "left join windturbine_parts d on c.relatedparts=d.id\n" +
+            "where  ss.windturbineid is not null  and alarmdate>=#{monthFirst} and alarmdate<=#{monthLast}  \n" +
+            "group by snapid")
+    List<PartDanger> getPartDanger(@Param("monthFirst") Date monthFirst, @Param("monthLast") Date monthLast);
+
+}

+ 23 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/mapper/healthreport/PartPowerMapper.java

@@ -0,0 +1,23 @@
+package com.gyee.healthmanagementhistroy.mapper.healthreport;
+
+import com.gyee.healthmanagementhistroy.model.healthreport.PartPower;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @ClassName : PartPower
+ * @Author : xieshengjie
+ * @Date: 2021/10/12 15:50
+ * @Description : 部件功率mapper
+ */
+@Repository
+public interface PartPowerMapper {
+    @Select("select c.name partname,a.name,avg(a.datavalue) datavalue,a.power,avg(a.earlywarningvalue) earlywarningvalue,b.wtid from PartPowerStatticsSUB a left join PartPowerStatticsmain b on a.tid = b.id\n" +
+            " left join parts c on a.partid=c.id  where a.recodedate>=#{monthFirst} and a.recodedate<=#{monthLast} \n" +
+            " group by c.name,a.name,a.power,b.wtid")
+    List<PartPower> getPartpowers(@Param("monthFirst") Date monthFirst, @Param("monthLast") Date monthLast);
+}

+ 19 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/model/healthreport/PartDanger.java

@@ -0,0 +1,19 @@
+package com.gyee.healthmanagementhistroy.model.healthreport;
+
+import lombok.Data;
+
+/**
+ * @ClassName : PartDanger
+ * @Author : xieshengjie
+ * @Date: 2021/10/12 11:42
+ * @Description : 部件隐患vo
+ */
+@Data
+public class PartDanger {
+    private Integer count;
+    private Double time;
+    private String stationid;
+    private String windturbineid;
+    private String alerttext;
+    private String type;
+}

+ 21 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/model/healthreport/PartPower.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmanagementhistroy.model.healthreport;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @ClassName : PartPower
+ * @Author : xieshengjie
+ * @Date: 2021/10/12 15:52
+ * @Description : 部件功率vo
+ */
+@Data
+public class PartPower {
+    private String partname;
+    private String name;
+    private Double datavalue;
+    private String power;
+    private Double earlywarningvalue;
+    private String wtid;
+}

+ 331 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/service/healthreport/HealthReportService.java

@@ -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 取
+    //全生命周期没做
+
+}

+ 42 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/task/HealthreportTask.java

@@ -0,0 +1,42 @@
+package com.gyee.healthmanagementhistroy.task;
+
+import com.gyee.common.util.DateUtils;
+import com.gyee.healthmanagementhistroy.service.healthreport.HealthReportService;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * @ClassName : HealthreportTask
+ * @Author : xieshengjie
+ * @Date: 2021/10/13 10:27
+ * @Description : 健康报告所需部分表服务
+ */
+@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+@EnableScheduling   // 2.开启定时任务
+public class HealthreportTask {
+    @Resource
+    private HealthReportService healthReportService;
+
+
+    //3.添加定时任务
+    /**
+     * 等级评估调度
+     */
+    @Scheduled(cron = "0 0 8 * * ?")
+    //或直接指定时间间隔,例如:5秒
+    //@Scheduled(fixedRate=5000)
+    private void configureTasks1() {
+        healthReportService.savePowerfitting(null);
+        healthReportService.saveDeviation(null);
+        healthReportService.saveDfpcl(null);
+        healthReportService.saveDfpclWindAndPower(null);
+        healthReportService.saveQrqc(null);
+        healthReportService.savePartdanger(null);
+        healthReportService.saveFaultclassification(null);
+        healthReportService.savePartpower(null);
+    }
+}

+ 90 - 0
histroy/healthmanagement-histroy/src/main/resources/application.yml

@@ -0,0 +1,90 @@
+server:
+  port: 8035
+  servlet:
+    context-path: /
+
+
+spring:
+  main:
+    allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
+  #redis集群
+  redis:
+#    host: 49.4.50.80
+    host: 10.155.32.4
+    port: 6379
+    timeout: 100000
+    #    集群环境打开下面注释,单机不需要打开
+    #    cluster:
+    #      集群信息
+    #      nodes: xxx.xxx.xxx.xxx:xxxx,xxx.xxx.xxx.xxx:xxxx,xxx.xxx.xxx.xxx:xxxx
+    #      #默认值是5 一般当此值设置过大时,容易报:Too many Cluster redirections
+    #      maxRedirects: 3
+    password: gdnxfd123
+    application:
+      name: test
+    jedis:
+      pool:
+        max-active: 8
+        min-idle: 0
+        max-idle: 8
+        max-wait: -1
+    database: 1
+  autoconfigure:
+    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: oracle.jdbc.OracleDriver
+    #外网
+    url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
+#    url: jdbc:oracle:thin:@49.4.50.80:1521:gdnxfd
+    #    url: jdbc:oracle:thin:@172.168.1.14:1521:gdnxfd
+    username: nxfdprod
+    password: gdnxfd123
+    oracle-schema=:
+    #    type: com.alibaba.druid.pool.DruidDataSource
+    #    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC
+    #    username: root
+    #    password: root
+    #    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      max-active: 20
+      initial-size: 1
+      min-idle: 3
+      max-wait: 60000
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+  servlet:
+    multipart:
+      # 开启 multipart 上传功能
+      enabled: true
+      # 文件写入磁盘的阈值
+      file-size-threshold: 2KB
+      # 最大文件大小
+      max-file-size: 200MB
+      # 最大请求大小
+      max-request-size: 215MB
+
+mybatis-plus:
+  configuration:
+    map-underscore-to-camel-case: true
+    auto-mapping-behavior: full
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  global-config:
+    # 逻辑删除配置
+    db-config:
+      id-type: auto
+      # 删除前
+      logic-not-delete-value: 1
+      # 删除后
+      logic-delete-value: 0
+logging:
+  level:
+    root: info
+    com.example: debug
+
+golden:
+  baseURL: http://10.155.32.4:8011/ts

+ 44 - 0
histroy/healthmanagement-histroy/src/test/java/com/gyee/healthmanagementhistroy/HealthManagementHistroyMainTest.java

@@ -0,0 +1,44 @@
+package com.gyee.healthmanagementhistroy;
+
+import com.gyee.healthmanagementhistroy.service.healthreport.HealthReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @ClassName : HealthManagementHistroyMainTest
+ * @Author : xieshengjie
+ * @Date: 2021/10/5 18:01
+ * @Description :
+ */
+@Slf4j
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
+public class HealthManagementHistroyMainTest {
+    @Resource
+    private HealthReportService healthReportService;
+    @Test
+    public void test1() throws ParseException {
+        String string = "2021-08-24";
+                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = sdf.parse(string);
+//        healthReportService.savePowerfitting(null);
+//        healthReportService.saveDeviation(null);
+//        healthReportService.saveDfpcl(null);
+//        healthReportService.saveDfpclWindAndPower(null);
+        healthReportService.saveQrqc(null);
+//        healthReportService.savePartdanger(null);
+//        healthReportService.saveFaultclassification(null);
+//        healthReportService.savePartpower(null);
+    }
+}