Browse Source

调整保存修改模型方法

wangchangsheng 2 years ago
parent
commit
b5a29d93dd

+ 15 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnosetrainhistoryController.java

@@ -53,7 +53,7 @@ public class DiagnosetrainhistoryController {
 
 
     /**
-     * 编辑最终
+     * 编辑模型
      *
      * @param history
      * @return
@@ -64,4 +64,18 @@ public class DiagnosetrainhistoryController {
         diagnosetrainhistoryService.editDiagnosetrainhistory(update);
         return JsonResult.success(ResultCode.SUCCESS);
     }
+
+
+    /**
+     * 保存模型
+     *
+     * @param history
+     * @return
+     */
+    @PostMapping("/addHistory")
+    public JSONObject addDiagnosetrainhistory(@RequestBody String history) {
+        Diagnosetrainhistory add = JSONObject.parseObject(history, Diagnosetrainhistory.class);
+        diagnosetrainhistoryService.insertItem(add);
+        return JsonResult.success(ResultCode.SUCCESS);
+    }
 }

+ 15 - 13
gyee-sample-impala/src/main/java/com/gyee/impala/service/custom/diagnose/TrainFileModeService.java

@@ -58,7 +58,16 @@ public class TrainFileModeService {
     //控制太输出信息队列
     BlockingQueue<TrainInfo> infoQueue = new LinkedBlockingQueue<TrainInfo>();
     //零时保存模型队列
-    BlockingQueue<Diagnosetrainhistory> historyQueue = new LinkedBlockingQueue<Diagnosetrainhistory>();
+//    BlockingQueue<Diagnosetrainhistory> historyQueue = new LinkedBlockingQueue<Diagnosetrainhistory>();
+    private Diagnosetrainhistory historyQueue =null;
+
+    public Diagnosetrainhistory getHistoryQueue() {
+        return historyQueue;
+    }
+
+    public void setHistoryQueue(Diagnosetrainhistory historyQueue) {
+        this.historyQueue = historyQueue;
+    }
 
     public void exec(String name, String forecastLabel, String[] inputLabel, String host, MultipartFile file) {
 
@@ -144,16 +153,11 @@ public class TrainFileModeService {
      * @param history
      * @throws Exception
      */
-    public void putDiagnosetrainhistory(String history) throws Exception {
-
+    public void putDiagnosetrainhistory(String history){
         String body = JSONObject.toJSONString(history);
         Object historys = JSONObject.parse(body);
-        Diagnosetrainhistory d = JSONObject.parseObject(historys.toString(), Diagnosetrainhistory.class);
-        d.setEnable(false);
-        diagnosetrainhistoryService.insertItem(d);
-        Diagnosetrainhistory dbhistory = diagnosetrainhistoryService.getHistoryByCode(d.getCode());
-        historyQueue.put(dbhistory);
-
+        historyQueue= JSONObject.parseObject(historys.toString(), Diagnosetrainhistory.class);
+        historyQueue.setEnable(false);
     }
 
     /**
@@ -165,10 +169,8 @@ public class TrainFileModeService {
     public Diagnosetrainhistory consumeHistory() throws Exception {
         Diagnosetrainhistory d = null;
         try {
-            if (historyQueue.size() > 0) {
-                d = historyQueue.take();
-            }
-        } catch (InterruptedException e) {
+                d = historyQueue;
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return d;

+ 4 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/diagnose/DiagnosereportServiceImpl.java

@@ -91,7 +91,10 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
             if(importance<1){
                 continue;
             }
-            newpoint.add(map.get(pointname));
+            //System.out.println(pointname+"|"+map.get(pointname));
+            if (null !=map.get(pointname) ){
+                newpoint.add(map.get(pointname));
+            }
         }
         dataPointService.formatUniformcode(newpoint);
         Map<String, List<PointData>> pairs = dataPointService.getData(info);