浏览代码

模型预估接口调整

wangchangsheng 3 年之前
父节点
当前提交
781582b8b5

+ 2 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/TrainFileModeController.java

@@ -139,7 +139,7 @@ public class TrainFileModeController {
     }
     }
 
 
 
 
-    @PostMapping("/getHistory")
+    @GetMapping("/getHistory")
     public JSONObject getHistory() {
     public JSONObject getHistory() {
         try {
         try {
             Diagnosetrainhistory d = trainFileModeService.consumeHistory();
             Diagnosetrainhistory d = trainFileModeService.consumeHistory();
@@ -191,6 +191,7 @@ public class TrainFileModeController {
     @PostMapping("/forecasts")
     @PostMapping("/forecasts")
     public JSONObject forecasts(@RequestBody JSONObject jsonObject) {
     public JSONObject forecasts(@RequestBody JSONObject jsonObject) {
         try {
         try {
+            log.warn("预估请求数据:"+jsonObject.toJSONString());
             String resultvalue = trainFileModeService.forecasts(jsonObject);
             String resultvalue = trainFileModeService.forecasts(jsonObject);
             return JsonResult.successData(ResultCode.SUCCESS, resultvalue);
             return JsonResult.successData(ResultCode.SUCCESS, resultvalue);
         } catch (Exception e) {
         } catch (Exception e) {

+ 11 - 8
gyee-sample-impala/src/main/java/com/gyee/impala/service/master/diagnose/TrainFileModeService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.gyee.impala.common.config.GyeeConfig;
 import com.gyee.impala.common.config.GyeeConfig;
 import com.gyee.impala.common.config.jsch.JSchConfig;
 import com.gyee.impala.common.config.jsch.JSchConfig;
 import com.gyee.impala.common.util.DateUtil;
 import com.gyee.impala.common.util.DateUtil;
+import com.gyee.impala.common.util.FileUtil;
 import com.gyee.impala.common.util.JudeSystem;
 import com.gyee.impala.common.util.JudeSystem;
 import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.model.master.diagnose.TrainInfo;
 import com.gyee.impala.model.master.diagnose.TrainInfo;
@@ -188,14 +189,16 @@ public class TrainFileModeService {
         try {
         try {
             String  name = jsonObject.get("name").toString();
             String  name = jsonObject.get("name").toString();
 
 
-            String predict = jsonObject.get("predict").toString();
+//            String predict = jsonObject.get("predict").toString();
+            String filename  = System.currentTimeMillis()+".json";
+            //文件路径
+            String filePath = config.getPath() + filename;
+            fileService.uploadFile(filename, FileUtil.convertStringToInputStream(jsonObject.toJSONString()), "10.155.32.14");
             resultvalue = "";
             resultvalue = "";
-
-
             String cmdPath = gyeeConfig.getDiagnosePath();
             String cmdPath = gyeeConfig.getDiagnosePath();
             String inst = JudeSystem.isWindows() ? "cmd" : "/bin/sh";
             String inst = JudeSystem.isWindows() ? "cmd" : "/bin/sh";
             String c = JudeSystem.isWindows() ? "/c" : "-c";
             String c = JudeSystem.isWindows() ? "/c" : "-c";
-            String[] cmd = {inst, c, "python " + cmdPath + name + ".py " + predict};
+            String[] cmd = {inst, c, "python " + cmdPath + name + ".py " + filePath};
 
 
             Process p;
             Process p;
             System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
             System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
@@ -205,15 +208,13 @@ public class TrainFileModeService {
             String si = null, se = null;
             String si = null, se = null;
             while ((si = bri.readLine()) != null || (se = bre.readLine()) != null) {
             while ((si = bri.readLine()) != null || (se = bre.readLine()) != null) {
                 if (si != null) {
                 if (si != null) {
-                    System.out.println(si);
+                    System.out.println("预估返回信息:"+si);
                     if (si.startsWith("resultvalue:")){
                     if (si.startsWith("resultvalue:")){
                         resultvalue = si.replaceAll("resultvalue:","");
                         resultvalue = si.replaceAll("resultvalue:","");
                     }
                     }
-
-
                 }
                 }
                 if (se != null) {
                 if (se != null) {
-                    System.err.println(se);
+                    System.err.println("预估返回错误信息:"+se);
                 }
                 }
             }
             }
             p.waitFor();
             p.waitFor();
@@ -226,4 +227,6 @@ public class TrainFileModeService {
     }
     }
 
 
 
 
+
+
 }
 }