فهرست منبع

移植新版健康管理后台项目

shilin 1 سال پیش
والد
کامیت
671d7fb8a4

+ 67 - 67
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/config/XxlJobConfig.java

@@ -1,67 +1,67 @@
-package com.gyee.healthmodel.config;
-
-import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.EnvironmentAware;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.env.Environment;
-
-/**
- * xxl-job config
- *
- * @author xuxueli 2017-04-28
- */
-
-
-    @Configuration
-    @PropertySource("classpath:xxl-job-executor.properties")
-    public class XxlJobConfig implements EnvironmentAware {
-        private Environment env;
-
-        @Override
-        public void setEnvironment(Environment environment) {
-            this.env=environment;
-        }
-
-    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
-
-
-
-    @Bean
-    public XxlJobSpringExecutor xxlJobExecutor() {
-        logger.info(">>>>>>>>>>> xxl-job config init.");
-        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
-        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
-        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
-        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
-        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
-        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
-        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
-        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
-
-        return xxlJobSpringExecutor;
-    }
-
-    /**
-     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
-     *
-     *      1、引入依赖:
-     *          <dependency>
-     *             <groupId>org.springframework.cloud</groupId>
-     *             <artifactId>spring-cloud-commons</artifactId>
-     *             <version>${version}</version>
-     *         </dependency>
-     *
-     *      2、配置文件,或者容器启动变量
-     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
-     *
-     *      3、获取IP
-     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
-     */
-
-
-}
+//package com.gyee.healthmodel.config;
+//
+//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.context.EnvironmentAware;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.PropertySource;
+//import org.springframework.core.env.Environment;
+//
+///**
+// * xxl-job config
+// *
+// * @author xuxueli 2017-04-28
+// */
+//
+//
+//    @Configuration
+//    @PropertySource("classpath:xxl-job-executor.properties")
+//    public class XxlJobConfig implements EnvironmentAware {
+//        private Environment env;
+//
+//        @Override
+//        public void setEnvironment(Environment environment) {
+//            this.env=environment;
+//        }
+//
+//    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+//
+//
+//
+//    @Bean
+//    public XxlJobSpringExecutor xxlJobExecutor() {
+//        logger.info(">>>>>>>>>>> xxl-job config init.");
+//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+//        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
+//        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
+//        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
+//        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
+//        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
+//        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
+//        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
+//        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
+//
+//        return xxlJobSpringExecutor;
+//    }
+//
+//    /**
+//     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+//     *
+//     *      1、引入依赖:
+//     *          <dependency>
+//     *             <groupId>org.springframework.cloud</groupId>
+//     *             <artifactId>spring-cloud-commons</artifactId>
+//     *             <version>${version}</version>
+//     *         </dependency>
+//     *
+//     *      2、配置文件,或者容器启动变量
+//     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+//     *
+//     *      3、获取IP
+//     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+//     */
+//
+//
+//}

+ 5 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconHealthReportMain.java

@@ -160,5 +160,10 @@ public class ProEconHealthReportMain extends Model {
      */
     private Double y11mycqxpcl;
 
+    /**
+     * 风机名称
+     */
+    private String name;
+
 
 }

+ 0 - 1
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthJudgeService.java

@@ -363,7 +363,6 @@ public class HealthJudgeService {
                         c.set(Calendar.HOUR_OF_DAY, 0);
                         c.set(Calendar.MINUTE, 0);
                         c.set(Calendar.SECOND, 0);
-                        c.add(Calendar.DAY_OF_MONTH, -1);
                         po.setRecordDate(c.getTime());
                         StringBuilder sb2 = new StringBuilder();
                         if (!descls.isEmpty()) {

+ 42 - 6
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/HealthReportService.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -193,20 +194,43 @@ public class HealthReportService {
 
         }
 
+        QueryWrapper<ProEconHealthReportMain> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",recordDate);
+        //判断是否有重复记录,先删除重复记录
+        List<String> idls = proEconHealthReportMainService.list(queryWrapper).stream()
+                .map(ProEconHealthReportMain::getId)
+                .collect(Collectors.toList());
+
+        if (idls.size() > 0) {
+
+            proEconHealthReportMainService.removeByIds(idls);
+        }
         List<ProEconHealthReportMain> templs=new ArrayList<>();
         for(ProEconHealthReportMain vo:hrmls)
         {
             templs.add(vo);
             if(templs.size()==100)
             {
-                proEconHealthReportMainService.saveOrUpdateBatch(templs);
+                proEconHealthReportMainService.saveBatch(templs);
                 templs=new ArrayList<>();
             }
         }
 
         if(!templs.isEmpty())
         {
-            proEconHealthReportMainService.saveOrUpdateBatch(templs);
+            proEconHealthReportMainService.saveBatch(templs);
+        }
+
+
+        QueryWrapper<ProEconHealthReportTarget> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.eq("record_date",recordDate);
+        //判断是否有重复记录,先删除重复记录
+         idls = proEconHealthReportTargetService.list(queryWrapper2).stream()
+                .map(ProEconHealthReportTarget::getId)
+                .collect(Collectors.toList());
+        if (idls.size() > 0) {
+
+            proEconHealthReportTargetService.removeByIds(idls);
         }
 
         List<ProEconHealthReportTarget> temp2ls=new ArrayList<>();
@@ -215,17 +239,17 @@ public class HealthReportService {
             temp2ls.add(vo);
             if(temp2ls.size()==100)
             {
-                proEconHealthReportTargetService.saveOrUpdateBatch(temp2ls);
+                proEconHealthReportTargetService.saveBatch(temp2ls);
                 temp2ls=new ArrayList<>();
             }
         }
 
         if(!temp2ls.isEmpty())
         {
-            proEconHealthReportTargetService.saveOrUpdateBatch(temp2ls);
+            proEconHealthReportTargetService.saveBatch(temp2ls);
         }
-//        proEconHealthReportMainService.saveOrUpdateBatch(hrmls);
-//        proEconHealthReportTargetService.saveOrUpdateBatch(hrtls);
+//        proEconHealthReportMainService.saveBatch(hrmls);
+//        proEconHealthReportTargetService.saveBatch(hrtls);
     }
 
     /**
@@ -820,6 +844,7 @@ public class HealthReportService {
         po.setWtId(wt.getId());
         po.setRecordDate(recordDate);
         po.setReportCreatedate(new Date());
+        po.setName(wt.getName());
         //健康总分
         PointData jkzpd = realApiUtil.getRealData(ContantXk.JKZT100);
         if (StringUtils.notEmp(jkzpd)) {
@@ -860,6 +885,7 @@ public class HealthReportService {
         int daysDiff = DateUtils.daysDiff(recordDate, firstIntegratedTime);
         po.setRunningDays(daysDiff);
 
+        po.setFirstIntegratedTime(firstIntegratedTime);
 
         //检修间隔月份
         if (whmap.containsKey(wt.getId())) {
@@ -1412,6 +1438,11 @@ public class HealthReportService {
             xdxspo.setName("限电小时");
             xdxspo.setMonthValue(xdxs);
 
+            double slxs = eid2.getYxdxs();
+            ProEconHealthReportTarget slxspo = hrmap.get("slxs");
+            slxspo.setName("受累小时");
+            slxspo.setMonthValue(slxs);
+
         }else
         {
             double ygzxsmx = 0.0;
@@ -1446,6 +1477,11 @@ public class HealthReportService {
             ProEconHealthReportTarget xdxspo = hrmap.get("xdxs");
             xdxspo.setName("限电小时");
             xdxspo.setMonthValue(xdxs);
+
+            double slxs = 0.0;
+            ProEconHealthReportTarget slxspo = hrmap.get("slxs");
+            slxspo.setName("受累小时");
+            slxspo.setMonthValue(slxs);
         }
 
         if (eid2LastMonth1map.containsKey(wt.getId())) {

+ 14 - 12
realtime/healthmodel-server/src/test/java/HealthTest.java

@@ -1,11 +1,10 @@
 import com.gyee.healthmodel.HealthmodelMain;
-import com.gyee.healthmodel.service.HealthJudgeService;
-import com.gyee.healthmodel.service.RecommenmainsService;
+import com.gyee.healthmodel.service.HealthReportService;
 import com.gyee.healthmodel.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
-import java.util.Calendar;
+import java.util.Date;
 
 public class HealthTest {
 
@@ -16,15 +15,18 @@ public class HealthTest {
 
         System.out.println("调度程序执行开始!........");
 
-        HealthJudgeService healthJudgeService= SpringUtils.getBean("healthJudgeService");
-//        healthJudgeService.healthJudge3();
-        healthJudgeService.changeHealthModelValue();
-       RecommenmainsService recommenmainsService= SpringUtils.getBean("recommenmainsService");
-        Calendar cal = Calendar.getInstance();
-//        recommenmainsService.deleteList(cal.getTime());
-//        recommenmainsService.recommenMainWt();
-        healthJudgeService.saveWindturbineBjCount();
- healthJudgeService.savePartbjcount();
+//        HealthJudgeService healthJudgeService= SpringUtils.getBean("healthJudgeService");
+//        healthJudgeService.healthJudge();
+//        healthJudgeService.changeHealthModelValue();
+//       RecommenmainsService recommenmainsService= SpringUtils.getBean("recommenmainsService");
+//        Calendar cal = Calendar.getInstance();
+////        recommenmainsService.deleteList(cal.getTime());
+////        recommenmainsService.recommenMainWt();
+//        healthJudgeService.saveWindturbineBjCount();
+// healthJudgeService.savePartbjcount();
+
+        HealthReportService healthReportService= SpringUtils.getBean("healthReportService");
+        healthReportService.createHealthReport(new Date());
          System.out.println("调度任务处理完成!........");
 
 

+ 10 - 12
realtime/healthmodel-server/src/test/java/WobugeqTest.java

@@ -1,6 +1,4 @@
-
 import com.gyee.healthmodel.HealthmodelMain;
-import com.gyee.healthmodel.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
@@ -11,16 +9,16 @@ public class WobugeqTest {
 
         SpringApplication.run(HealthmodelMain.class, args);
 
-
-
-        WobugeqsService wobugeqsService= SpringUtils.getBean("wobugeqsService");
-
-
-
-        boolean isorno =wobugeqsService.isQueryThreeDayWobugeqs("MG01_01");
-
-
-         System.out.println(isorno);
+//
+//
+//        WobugeqsService wobugeqsService= SpringUtils.getBean("wobugeqsService");
+//
+//
+//
+//        boolean isorno =wobugeqsService.isQueryThreeDayWobugeqs("MG01_01");
+//
+//
+//         System.out.println(isorno);