|
@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.gyee.impala.common.base.ExcludeQueryWrapper;
|
|
|
+import com.gyee.impala.common.config.GyeeConfig;
|
|
|
import com.gyee.impala.common.config.datasource.KuduDataSourceConfig;
|
|
|
import com.gyee.impala.common.exception.CustomException;
|
|
|
import com.gyee.impala.common.result.ResultCode;
|
|
|
import com.gyee.impala.common.spring.InitialRunner;
|
|
|
import com.gyee.impala.common.util.DateUtil;
|
|
|
+import com.gyee.impala.common.util.JudeSystem;
|
|
|
import com.gyee.impala.common.util.SnowFlakeUtil;
|
|
|
import com.gyee.impala.mapper.master.diagnose.DiagnosereportMapper;
|
|
|
import com.gyee.impala.model.custom.diagnose.DataInfo;
|
|
@@ -21,6 +23,9 @@ import org.apache.kudu.client.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
@@ -37,6 +42,12 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
|
|
|
@Autowired
|
|
|
private DataPointService dataPointService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存脚本的位置
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ private GyeeConfig gyeeConfig;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<Diagnosereport> getAll(String wtId, String model, String modelName, String trainingTimes) {
|
|
@@ -123,6 +134,45 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
|
|
|
return pairs;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getbigRising(String id) {
|
|
|
+
|
|
|
+ String bigrising = null;
|
|
|
+ try {
|
|
|
+ //组装调用脚本命令
|
|
|
+ String name = "";
|
|
|
+ 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 " + id};
|
|
|
+ Process p;
|
|
|
+ System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
|
|
|
+ //执行脚本
|
|
|
+ p = Runtime.getRuntime().exec(cmd);
|
|
|
+ //脚本输出信息
|
|
|
+ BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
|
+ BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream()));
|
|
|
+ String si = null, se = null;
|
|
|
+ while ((si = bri.readLine()) != null || (se = bre.readLine()) != null) {
|
|
|
+ if (si != null) {
|
|
|
+ System.out.println("获取故障前测点最大攀升值:" + si);
|
|
|
+ if (si.startsWith("bigrising:")) {
|
|
|
+ bigrising = si.replaceAll("bigrising:", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (se != null) {
|
|
|
+ System.err.println("获取故障前测点最大攀升值返回错误信息:" + se);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.waitFor();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return bigrising;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
|
|
|
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
|