Browse Source

模型最大梯度数据获取

wangchangsheng 3 years ago
parent
commit
78c6908301

+ 4 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnosepointController.java

@@ -66,6 +66,10 @@ public class DiagnosepointController {
 
             for (int c = 0; c < codes.size(); c++) {
                 JSONObject code = codes.getJSONObject(c);
+                List<Diagnosepoint> list = diagnosepointService.getDiagnosepointByModelAndUniformcode(station.getId(),modelId,code.get("code").toString());
+               if (null !=list && list.size()>0){
+                   continue;
+               }
                 Diagnosepoint d = new Diagnosepoint();
                 if (code.get("code").toString().equals("AI067")) {
                     System.out.println(code.get("code").toString());
@@ -81,7 +85,6 @@ public class DiagnosepointController {
                 d.setName(code.get("name").toString());
                 d.setOrdernum(Integer.valueOf(code.get("num").toString()));
                 diagnosepointService.insertItem(d);
-
             }
         }
         return JsonResult.success();

+ 16 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/controller/sample/cases/CaseFaultAlgController.java

@@ -94,6 +94,22 @@ public class CaseFaultAlgController {
     }
 
 
+    /**
+     * 更新remark
+     *
+     * @param jsonObject
+     * @return
+     */
+    @PostMapping("/faultalg/editRemark")
+    @ResponseBody
+    public JSONObject faultAlgEditRemark(@RequestBody JSONObject jsonObject) {
+        String id = jsonObject.get("id").toString();
+        String remark = jsonObject.getJSONObject("remark").toJSONString();
+        casefaultalgService.faultAlgEditRemark(id, remark);
+        return JsonResult.success(ResultCode.SUCCESS);
+    }
+
+
 
 
 }

+ 20 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultalgServiceImpl.java

@@ -18,6 +18,7 @@ import com.gyee.impala.service.master.CasefaultalgService;
 import org.apache.kudu.client.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -127,6 +128,25 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
     }
 
 
+    @Transactional
+    @Override
+    public void faultAlgEditRemark(String id, String remark) {
+        Casefaultalg alg = baseMapper.selectById(id);
+        if(null == alg){
+            return;
+        }
+        alg.setRemark(remark);
+        baseMapper.updateById(alg);
+    }
+
+    @Override
+    public List<Casefaultalg> getListRemarkIsNull() {
+        ExcludeQueryWrapper<Casefaultalg> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.isNull("remark");
+        wrapper.or().eq("remark","");
+        return  baseMapper.selectList(wrapper);
+    }
+
     /**
      * 由于mybatis-plus存储的中文乱码
      * 采用原生写法

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

@@ -43,7 +43,14 @@ public class DiagnosepointServiceImpl extends ServiceImpl<DiagnosepointMapper, D
         }
     }
 
-
+    @Override
+    public List<Diagnosepoint> getDiagnosepointByModelAndUniformcode(String stationen,String model, String uniformcode) {
+        QueryWrapper<Diagnosepoint> wrapper = new QueryWrapper<>();
+        wrapper.eq("stationen",stationen);
+        wrapper.eq("model",model);
+        wrapper.eq("uniformcode",uniformcode);
+        return baseMapper.selectList(wrapper);
+    }
 
 
     /**

+ 10 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/master/CasefaultalgService.java

@@ -58,4 +58,14 @@ public interface CasefaultalgService extends IService<Casefaultalg> {
      * @param list
      */
     void confirm(List<Casefaultalg> list);
+
+    /**
+     * 更新remark
+     * @param id
+     * @param remark
+     */
+    void faultAlgEditRemark(String id,String remark);
+
+
+    List<Casefaultalg> getListRemarkIsNull();
 }

+ 2 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/master/diagnose/DiagnosepointService.java

@@ -12,4 +12,6 @@ public interface DiagnosepointService extends IService<Diagnosepoint> {
 
 
     void insertItem(Diagnosepoint obj);
+
+    List<Diagnosepoint> getDiagnosepointByModelAndUniformcode(String stationen,String model,String uniformcode);
 }

+ 65 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/service/task/BigRisingTask.java

@@ -0,0 +1,65 @@
+package com.gyee.impala.service.task;
+
+
+import com.gyee.impala.common.config.GyeeConfig;
+import com.gyee.impala.common.util.JudeSystem;
+import com.gyee.impala.model.master.Casefaultalg;
+import com.gyee.impala.service.master.CasefaultalgService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+
+@Service
+@EnableScheduling
+public class BigRisingTask {
+
+
+    @Autowired
+    private CasefaultalgService casefaultalgService;
+    /**
+     * 保存脚本的位置
+     */
+    @Autowired
+    private GyeeConfig gyeeConfig;
+
+    @Scheduled(cron = "0 0/10 * * * ?")
+//    @Scheduled(fixedRate=1000)
+    private void getBigRisingTasks() {
+
+        List<Casefaultalg> list =  casefaultalgService.getListRemarkIsNull();
+        System.out.println(list.size());
+        list.stream().forEach(l->{
+            System.out.println(l.getId()+"|"+l.getRemark());
+            try {
+                //组装调用脚本命令
+                String name = "grad";
+                String cmdPath = gyeeConfig.getDiagnosePath();
+                String inst = JudeSystem.isWindows() ? "cmd" : "/bin/sh";
+                String c = JudeSystem.isWindows() ? "/c" : "-c";
+                String[] cmd = {inst, c, "python " + cmdPath + name + ".py " + l.getId()};
+                Process p;
+                System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
+                //执行脚本
+                p = Runtime.getRuntime().exec(cmd);
+                p.waitFor();
+                Thread.sleep(100);
+            } catch (IOException e) {
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }finally {
+
+            }
+        });
+
+
+
+    }
+}