xushili 2 年 前
コミット
7ec7e048d1

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/KuduDataSourceConfig.java

@@ -34,7 +34,7 @@ public class KuduDataSourceConfig {
     public void initKuDu(){
         if (kuduClient == null)
             kuduClient = new KuduClient
-                    .KuduClientBuilder(gyeeConfig.getKuduHost() + ":7051")//7051,21050
+                    .KuduClientBuilder(gyeeConfig.getKuduHost() )//7051,21050
                     .defaultOperationTimeoutMs(6000)
                     .build();
     }

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/common/config/datasource/SlaveDataSourceConfig.java

@@ -51,7 +51,7 @@ public class SlaveDataSourceConfig {
     @Bean
     public PaginationInterceptor paginationInterceptor() {
         PaginationInterceptor page = new PaginationInterceptor();
-        page.setDbType(DbType.ORACLE);
+        page.setDbType(DbType.POSTGRE_SQL);
         return page;
     }
 }

+ 1 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/custom/diagnose/AutoCmdService.java

@@ -32,6 +32,7 @@ public class AutoCmdService {
         System.out.println(new Date() + "开始执行脚本...");
         Process p;
         String cmdPath = gyeeConfig.getDiagnosePath();
+        if(InitialRunner.historyModelMap.size()<1) return;
         try {
             Diagnosetrainhistory history = InitialRunner.historyModelMap.get(fi.getStationId() + "_" + fi.getModelId()).get(0);
             System.out.println("脚本调用成功: " + history.toString());

+ 35 - 28
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/WindspeedforecastshorttermServiceImpl.java

@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author gfhd
@@ -42,6 +42,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     /**
      * 由于mybatis-plus存储的中文乱码
      * 采用原生写法
+     *
      * @param list
      * @return
      */
@@ -50,13 +51,13 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
         KuduTable kuduTable = kuduConfig.kuduClient.openTable("impala::gyee_sample_kudu.windspeedforecastshortterm");
         KuduSession kuduSession = kuduConfig.kuduSession();
         int i = 0;
-        for (Windspeedforecastshortterm boj : list){
+        for (Windspeedforecastshortterm boj : list) {
             Insert insert = kuduTable.newInsert();
             // 获取Row对象,设置插入的值
             PartialRow row = insert.getRow();
             row.addObject("id", SnowFlakeUtil.generateIdL());
-            long time = boj.getCalctime().getTime()+28800000;
-            row.addObject("calctime", time*1000);
+            long time = boj.getCalctime().getTime() + 28800000;
+            row.addObject("calctime", time * 1000);
             row.addObject("forecasttype", boj.getForecasttype());
             row.addObject("stationid", boj.getStationid());
             row.addObject("projectid", boj.getProjectid());
@@ -74,7 +75,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
 
             // 先不提交kudu
             kuduSession.apply(insert);
-            i ++;
+            i++;
             if (i % kuduConfig.getCount() == 0)
                 kuduSession.flush(); //批量写入kudu
         }
@@ -94,16 +95,16 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
 
     @Override
     public JSONObject getContrast(String stationid, Date starttime, Date endtime, int timescale) {
-        Date dateStartQntq = DateUtil.dateTimeAddYear(starttime,-1);
-        Date dateEndQntq = DateUtil.dateTimeAddYear(endtime,-1);
+        Date dateStartQntq = DateUtil.dateTimeAddYear(starttime, -1);
+        Date dateEndQntq = DateUtil.dateTimeAddYear(endtime, -1);
 
         //list1短期 list2超短期 list3去年同期短期 list4去年同期超短期
-        List<Windspeedforecastshortterm> list1 = getShortterm(stationid,starttime,endtime);
-        List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid,starttime,endtime,timescale);
-        List<Windspeedforecastshortterm> list3 = getShortterm(stationid,dateStartQntq,dateEndQntq);
-        List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid,dateStartQntq,dateEndQntq,timescale);
+        List<Windspeedforecastshortterm> list1 = getShortterm(stationid, starttime, endtime);
+        List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid, starttime, endtime, timescale);
+        List<Windspeedforecastshortterm> list3 = getShortterm(stationid, dateStartQntq, dateEndQntq);
+        List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid, dateStartQntq, dateEndQntq, timescale);
         List<WindspeedforecastContrast> windspeedforecastContrasts = new ArrayList<>();
-        list1.forEach(l->{
+        list1.forEach(l -> {
             WindspeedforecastContrast wsfcc = new WindspeedforecastContrast();
             wsfcc.setCalctime(l.getCalctime());
             wsfcc.setActualpower(l.getActualpower());
@@ -112,25 +113,31 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
             wsfcc.setForecastwindspeed(l.getForecastwindspeed());
             windspeedforecastContrasts.add(wsfcc);
         });
-        Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(),(key1,key2)->key2));
+        Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(), (key1, key2) -> key2));
 
-        list2.forEach(l-> {
+        list2.forEach(l -> {
             WindspeedforecastContrast wsfcc = contrastMap.get(l.getCalctime());
-            wsfcc.setForecastpowersp(l.getForecastpower());
-            wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
+            if (wsfcc != null) {
+                wsfcc.setForecastpowersp(l.getForecastpower());
+                wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
+            }
         });
         //给年份加一年,然后匹配
-        list3.forEach(l-> {
-            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
-            wsfcc.setActualpowertq(l.getActualpower());
-            wsfcc.setForecastpowertq(l.getForecastpower());
-            wsfcc.setActualwindspeedtq(l.getActualwindspeed());
-            wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
+        list3.forEach(l -> {
+            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
+            if (wsfcc != null) {
+                wsfcc.setActualpowertq(l.getActualpower());
+                wsfcc.setForecastpowertq(l.getForecastpower());
+                wsfcc.setActualwindspeedtq(l.getActualwindspeed());
+                wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
+            }
         });
-        list4.forEach(l-> {
-            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
-            wsfcc.setForecastpowersptq(l.getForecastpower());
-            wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
+        list4.forEach(l -> {
+            WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
+            if (wsfcc != null) {
+                wsfcc.setForecastpowersptq(l.getForecastpower());
+                wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
+            }
         });
 
         //根据时间排序
@@ -145,7 +152,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     private List<Windspeedforecastshortterm> getShortterm(String stationid, Date dateStart, Date dateEnd) {
         QueryWrapper<Windspeedforecastshortterm> wrapper = new QueryWrapper<>();
         wrapper.eq("stationid", stationid)
-                .eq("algorithmmodel","风电_极限学习机_功率_中国大陆")
+                .eq("algorithmmodel", "风电_极限学习机_功率_中国大陆")
                 .between("calctime", dateStart, dateEnd).orderByDesc("calctime");
         return baseMapper.selectList(wrapper);
     }
@@ -153,7 +160,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
     /**
      * 超短期功率
      */
-    private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd,int timescale) {
+    private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd, int timescale) {
         QueryWrapper<Windspeedforecastspshortterm> wrapper = new QueryWrapper<>();
         wrapper.eq("stationid", stationid)
                 .between("calctime", dateStart, dateEnd)

+ 5 - 5
gyee-sample-impala/src/main/resources/application.yaml

@@ -1,15 +1,15 @@
 gyee:
   # golden实时适配器的url
-  golden-url: http://18.6.30.71:8011
+  golden-url: http://18.6.30.63:8011
   # 报警url
-  alert-url: http://18.6.30.71:8075
+  alert-url: http://18.6.30.53:8075
   # 样本数据统计开始时间
   init-time: 2022-01-01 00:00:00
   # 故障样本数据导入模板路径
   template-path-window: D://java//kudu//template/
   template-path-linux: /home/gyee/fault_digonsis/services/template/
   # kudu的host
-  kudu-host: 18.6.30.73
+  kudu-host: 18.6.30.73:21050
   # 故障诊断脚本路径
   diagnose-path-window: D://test//
   diagnose-path-linux: /home/gyee/fault_digonsis/scripts/
@@ -71,13 +71,13 @@ spring:
 ####################三区大数据服务器 SFTP  hive 配置####################
 hiveconfig:
   protocols: sftp
-  host: 18.6.30.73
+  host: 18.6.30.70
   port: 22
   username: root
   password: Admin@2019
   path: /home/gyee/kudu/dataprocess/
   driver: org.apache.hive.jdbc.HiveDriver
-  url: jdbc:hive2://18.6.30.73:10000/default
+  url: jdbc:hive2://18.6.30.70:10000/default
 ####################三区大数据服务器 SFTP EXEC 配置####################