Ver código fonte

0921 修改如果设备数据为空,抽取异常问题

allen 2 anos atrás
pai
commit
d67f547315

+ 400 - 0
csv/1/1_0.csv

@@ -0,0 +1,400 @@
+DriveMotor_id,DriveMotor_时间
+1,20:19:6
+2,20:19:6
+3,20:19:6
+4,20:19:6
+5,20:19:6
+6,20:19:6
+7,20:19:6
+8,20:19:6
+9,20:19:6
+10,20:19:6
+11,20:19:6
+12,20:19:6
+13,20:19:6
+14,20:19:6
+15,20:19:6
+16,20:19:6
+17,20:19:6
+18,20:19:6
+19,20:19:6
+20,20:19:6
+21,20:19:6
+22,20:19:6
+23,20:19:6
+24,20:19:6
+25,20:19:6
+26,20:19:6
+27,20:19:6
+28,20:19:6
+29,20:19:6
+30,20:19:6
+31,20:19:6
+32,20:19:6
+33,20:19:6
+34,20:19:6
+35,20:19:6
+36,20:19:6
+37,20:19:6
+38,20:19:6
+39,20:19:6
+40,20:19:6
+41,20:19:6
+42,20:19:6
+43,20:19:6
+44,20:19:6
+45,20:19:6
+46,20:19:6
+47,20:19:6
+48,20:19:6
+49,20:19:6
+50,20:19:6
+51,20:19:6
+52,20:19:6
+53,20:19:6
+54,20:19:6
+55,20:19:6
+56,20:19:6
+57,20:19:6
+58,20:19:6
+59,20:19:6
+60,20:19:6
+61,20:19:6
+62,20:19:6
+63,20:19:6
+64,20:19:6
+65,20:19:6
+66,20:19:6
+67,20:19:6
+68,20:19:6
+69,20:19:6
+70,20:19:6
+71,20:19:6
+72,20:19:6
+73,20:19:6
+74,20:19:6
+75,20:19:6
+76,20:19:6
+77,20:19:6
+78,20:19:6
+79,20:19:6
+80,20:19:6
+81,20:19:6
+82,20:19:6
+83,20:19:6
+84,20:19:6
+85,20:19:6
+86,20:19:6
+87,20:19:6
+88,20:19:6
+89,20:19:6
+90,20:19:6
+91,20:19:6
+92,20:19:6
+93,20:19:6
+94,20:19:6
+95,20:19:6
+96,20:19:6
+97,20:19:6
+98,20:19:6
+99,20:19:6
+100,20:19:6
+101,20:19:6
+102,20:19:6
+103,20:19:6
+104,20:19:6
+105,20:19:6
+106,20:19:6
+107,20:19:6
+108,20:19:6
+109,20:19:6
+110,20:19:6
+111,20:19:6
+112,20:19:6
+113,20:19:6
+114,20:19:6
+115,20:19:6
+116,20:19:6
+117,20:19:6
+118,20:19:6
+119,20:19:6
+120,20:19:6
+121,20:19:6
+122,20:19:6
+123,20:19:6
+124,20:19:6
+125,20:19:6
+126,20:19:6
+127,20:19:6
+128,20:19:6
+129,20:19:6
+130,20:19:6
+131,20:19:6
+132,20:19:6
+133,20:19:6
+134,20:19:6
+135,20:19:6
+136,20:19:6
+137,20:19:6
+138,20:19:6
+139,20:19:6
+140,20:19:6
+141,20:19:6
+142,20:19:6
+143,20:19:6
+144,20:19:6
+145,20:19:6
+146,20:19:6
+147,20:19:6
+148,20:19:6
+149,20:19:6
+150,20:19:6
+151,20:19:6
+152,20:19:6
+153,20:19:6
+154,20:19:6
+155,20:19:6
+156,20:19:6
+157,20:19:6
+158,20:19:6
+159,20:19:6
+160,20:19:6
+161,20:19:6
+162,20:19:6
+163,20:19:6
+164,20:19:6
+165,20:19:6
+166,20:19:6
+167,20:19:6
+168,20:19:6
+169,20:19:6
+170,20:19:6
+171,20:19:6
+172,20:19:6
+173,20:19:6
+174,20:19:6
+175,20:19:6
+176,20:19:6
+177,20:19:6
+178,20:19:6
+179,20:19:6
+180,20:19:6
+181,20:19:6
+182,20:19:6
+183,20:19:6
+184,20:19:6
+185,20:19:6
+186,20:19:6
+187,20:19:6
+188,20:19:6
+189,20:19:6
+190,20:19:6
+191,20:19:6
+192,20:19:6
+193,20:19:6
+194,20:19:6
+195,20:19:6
+196,20:19:6
+197,20:19:6
+198,20:19:6
+199,20:19:6
+200,20:19:6
+201,20:19:6
+202,20:19:6
+203,20:19:6
+204,20:19:6
+205,20:19:6
+206,20:19:6
+207,20:19:6
+208,20:19:6
+209,20:19:6
+210,20:19:6
+211,20:19:6
+212,20:19:6
+213,20:19:6
+214,20:19:6
+215,20:19:6
+216,20:19:6
+217,20:19:6
+218,20:19:6
+219,20:19:6
+220,20:19:6
+221,20:19:6
+222,20:19:6
+223,20:19:6
+224,20:19:6
+225,20:19:6
+226,20:19:6
+227,20:19:6
+228,20:19:6
+229,20:19:6
+230,20:19:6
+231,20:19:6
+232,20:19:6
+233,20:19:6
+234,20:19:6
+235,20:19:6
+236,20:19:6
+237,20:19:6
+238,20:19:6
+239,20:19:6
+240,20:19:6
+241,20:19:6
+242,20:19:6
+243,20:19:6
+244,20:19:6
+245,20:19:6
+246,20:19:6
+247,20:19:6
+248,20:19:6
+249,20:19:6
+250,20:19:6
+251,20:19:6
+252,20:19:6
+253,20:19:6
+254,20:19:6
+255,20:19:6
+256,20:19:6
+257,20:19:6
+258,20:19:6
+259,20:19:6
+260,20:19:6
+261,20:19:6
+262,20:19:6
+263,20:19:6
+264,20:19:6
+265,20:19:6
+266,20:19:6
+267,20:19:6
+268,20:19:6
+269,20:19:6
+270,20:19:6
+271,20:19:6
+272,20:19:6
+273,20:19:6
+274,20:19:6
+275,20:19:6
+276,20:19:6
+277,20:19:6
+278,20:19:6
+279,20:19:6
+280,20:19:6
+281,20:19:6
+282,20:19:6
+283,20:19:6
+284,20:19:6
+285,20:19:6
+286,20:19:6
+287,20:19:6
+288,20:19:6
+289,20:19:6
+290,20:19:6
+291,20:19:6
+292,20:19:6
+293,20:19:6
+294,20:19:6
+295,20:19:6
+296,20:19:6
+297,20:19:6
+298,20:19:6
+299,20:19:6
+300,20:19:6
+301,20:19:6
+302,20:19:6
+303,20:19:6
+304,20:19:6
+305,20:19:6
+306,20:19:6
+307,20:19:6
+308,20:19:6
+309,20:19:6
+310,20:19:6
+311,20:19:6
+312,20:19:6
+313,20:19:6
+314,20:19:6
+315,20:19:6
+316,20:19:6
+317,20:19:6
+318,20:19:6
+319,20:19:6
+320,20:19:6
+321,20:19:6
+322,20:19:6
+323,20:19:6
+324,20:19:6
+325,20:19:6
+326,20:19:6
+327,20:19:6
+328,20:19:6
+329,20:19:6
+330,20:19:6
+331,20:19:6
+332,20:19:6
+333,20:19:6
+334,20:19:6
+335,20:19:6
+336,20:19:6
+337,20:19:6
+338,20:19:6
+339,20:19:6
+340,20:19:6
+341,20:19:6
+342,20:19:6
+343,20:19:6
+344,20:19:6
+345,20:19:6
+346,20:19:6
+347,20:19:6
+348,20:19:6
+349,20:19:6
+350,20:19:6
+351,20:19:6
+352,20:19:6
+353,20:19:6
+354,20:19:6
+355,20:19:6
+356,20:19:6
+357,20:19:6
+358,20:19:6
+359,20:19:6
+360,20:19:6
+361,20:19:6
+362,20:19:6
+363,20:19:6
+364,20:19:6
+365,20:19:6
+366,20:19:6
+367,20:19:6
+368,20:19:6
+369,20:19:6
+370,20:19:6
+371,20:19:6
+372,20:19:6
+373,20:19:6
+374,20:19:6
+375,20:19:6
+376,20:19:6
+377,20:19:6
+378,20:19:6
+379,20:19:6
+380,20:19:6
+381,20:19:6
+382,20:19:6
+383,20:19:6
+384,20:19:6
+385,20:19:6
+386,20:19:6
+387,20:19:6
+388,20:19:6
+389,20:19:6
+390,20:19:6
+391,20:19:6
+392,20:19:6
+393,20:19:6
+394,20:19:6
+395,20:19:6
+396,20:19:6
+397,20:19:6
+398,20:19:6
+399,20:19:6

+ 17 - 5
src/main/java/io/renren/modules/dataSet/service/impl/DynamicSystemServiceImpl.java

@@ -320,6 +320,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
         String[] fileds = needFileds;
         final List<Map> equmentAll = getContentTimeLimit(hbaseTableName, limit,start,end);
         Map<String, List<String>> needColumnMap = new HashMap<>();
+        if (equmentAll.size() == 0) return needColumnMap;
         for (String filed : fileds) {
             List<String> needOneLists = new ArrayList();
             for (Map map : equmentAll) {
@@ -371,7 +372,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
             final Map<String, List<String>> equmentOneColumn = getEqumentOneColumn(hbaseTableName, chosedatas, limit);
             for (String chosedata : chosedatas) {
                 final List<String> strings = equmentOneColumn.get(chosedata);
-                for (int i = 0; i < 10; i++) {
+                for (int i = 0; i < 10 && i < strings.size(); i++) {
                     final String s = strings.get(i);
                     final HashMap<String, Object> clumData = new HashMap<>();
                     clumData.put(subEquipmentID + "_" + chosedata, s);
@@ -423,19 +424,28 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
 
     @Override
     public String runSave(Map map) {
-        runSave_coal(map);
+        String s = runSave_coal(map);
         Date date = new Date();
         SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-        String info = ft.format(date) + "  设备名称 :" + (String) map.get("equipment") + "." + map.get("subEquipment")
-                + "  抽取字段:" + map.get("chosedata") + "  抽取成功!!";
+        String info = "";
+        if(s.equals("done")){
+            info  = ft.format(date) + "  设备名称 :" + (String) map.get("equipment") + "." + map.get("subEquipment")
+                    + "  抽取字段:" + map.get("chosedata") + "  抽取成功!!";
+        }else {
+            info = s;
+        }
+
         Map<String, String> redata = new HashMap<>();
         redata.put("info", info);
         return JSON.toJSONString(redata);
     }
 
-    public void runSave_coal(Map map) {
+    public String runSave_coal(Map map) {
+        StringBuilder s = new StringBuilder();
         String hbaseTableName = (String) map.get("hbaseTableName");
+        if (hbaseTableName.length()==0|| "".equals(hbaseTableName)) return "数据源为空!!!";
         List choosedatas = (List<String>) map.get("chosedata");
+        if(choosedatas.size() ==0) return "请选择字段!!!";
         String newFileName = (String) map.get("newFileName");
         String oldFileName = (String) map.get("oldFileName");
 //        System.out.println(oldFileName+"--->"+newFileName);
@@ -453,6 +463,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
         Long start = (Long) map.getOrDefault("start",0l);
         Long end = (Long) map.getOrDefault("end",new Date().getTime());
         final Map<String, List<String>> equmentOneColumn = getEqumentOneColumnTimeLimit(hbaseTableName, chooseDates, 1000,start,end);
+        if (equmentOneColumn.isEmpty()) return "数据为空,请检查数据源中是否有数据!!";
         for (int i = 0; i < choosedatas.size(); i++) {
             filed = (String) choosedatas.get(i);
             // 添加表头
@@ -505,6 +516,7 @@ public class DynamicSystemServiceImpl implements DynamicSystemService {
                 e.printStackTrace();
             }
         }
+        return "done";
     }
 
     // 首次创建csv文件

+ 4 - 4
src/main/resources/application-dev.yml

@@ -5,8 +5,8 @@ spring:
             driver-class-name: com.mysql.cj.jdbc.Driver
             url: jdbc:mysql://localhost:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
             username: root
-#            password: 123456
-            password: root
+            password: 123456
+#            password: root
             initial-size: 10
             max-active: 100
             min-idle: 10
@@ -44,8 +44,8 @@ dynamic:
         url: jdbc:mysql://localhost:3306/hebing?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
         username: root
 #      password: XDUbdm520Mysql
-        password: root
-#        password: 123456
+#        password: root
+        password: 123456
         driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
 server:
     port: 8082