|
|
@@ -54,7 +54,7 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
/** 算法表路径列只允许这些功能编号,避免把请求参数拼进列名。 */
|
|
|
private static final Set<String> FUNCTION_CODES = new HashSet<>(Arrays.asList(
|
|
|
"A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10", "A11", "A12",
|
|
|
- "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20", "A21", "A22", "Y01", "Y02"));
|
|
|
+ "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20", "A21", "A22", "A23", "Y01", "Y02"));
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> projectFunction(String fieldCode, String machineTypeCode,
|
|
|
@@ -112,15 +112,37 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
}
|
|
|
List<Map<String, Object>> criteria = new ArrayList<>();
|
|
|
List<Map<String, Object>> turbines = new ArrayList<>();
|
|
|
- resp.put("metrics", loadTurbineMetrics(fieldCode, machineTypeCode, month, functionCode, criteria, turbines));
|
|
|
+ List<Map<String, Object>> reviewClues = new ArrayList<>();
|
|
|
+ resp.put("metrics", loadTurbineMetrics(fieldCode, machineTypeCode, month, functionCode, criteria, turbines, reviewClues));
|
|
|
Map<String, Object> table = new LinkedHashMap<>();
|
|
|
table.put("id", "project_criteria_row");
|
|
|
+ table.put("columns", criteriaColumns());
|
|
|
table.put("rows", criteria);
|
|
|
resp.put("tables", Collections.singletonList(table));
|
|
|
resp.put("turbines", turbines);
|
|
|
+ resp.put("reviewClues", reviewClues);
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ /** 逐机判据表显示列(机组/机型/检测结果/实际情况/判断标准/说明) */
|
|
|
+ private List<Map<String, Object>> criteriaColumns() {
|
|
|
+ List<Map<String, Object>> cols = new ArrayList<>();
|
|
|
+ cols.add(col("engine_name", "机组"));
|
|
|
+ cols.add(col("machine_type_code", "机型"));
|
|
|
+ cols.add(col("status_label", "检测结果"));
|
|
|
+ cols.add(col("actual", "实际情况"));
|
|
|
+ cols.add(col("criterion", "判断标准"));
|
|
|
+ cols.add(col("explanation", "说明"));
|
|
|
+ return cols;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> col(String key, String label) {
|
|
|
+ Map<String, Object> c = new LinkedHashMap<>();
|
|
|
+ c.put("key", key);
|
|
|
+ c.put("label", label);
|
|
|
+ return c;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> turbineFunction(String fieldCode, String machineTypeCode,
|
|
|
String month, String functionCode, String engineCode) {
|
|
|
@@ -379,7 +401,8 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
private List<Map<String, Object>> loadTurbineMetrics(String fieldCode, String machineTypeCode,
|
|
|
String month, String functionCode,
|
|
|
List<Map<String, Object>> criteria,
|
|
|
- List<Map<String, Object>> turbines) {
|
|
|
+ List<Map<String, Object>> turbines,
|
|
|
+ List<Map<String, Object>> reviewClues) {
|
|
|
List<Map<String, Object>> out = new ArrayList<>();
|
|
|
String func = functionCode == null ? "" : functionCode.trim().toUpperCase();
|
|
|
if (!FUNCTION_CODES.contains(func) || month == null || !month.matches("\\d{4}-\\d{2}")) {
|
|
|
@@ -388,20 +411,25 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
String col = func.toLowerCase() + "_conclusion_txt_path";
|
|
|
try {
|
|
|
List<Map<String, Object>> rows = analyseJdbcTemplate.queryForList(
|
|
|
- "SELECT engine_code, " + col + " AS txt_path FROM turbine_monthly_result " +
|
|
|
+ "SELECT engine_code, engine_name, " + col + " AS txt_path FROM turbine_monthly_result " +
|
|
|
"WHERE field_code = ? AND machine_type_code = ? AND period_start = ?",
|
|
|
fieldCode, machineTypeCode, month + "-01");
|
|
|
for (Map<String, Object> row : rows) {
|
|
|
Object ec = row.get("engine_code");
|
|
|
+ Object en = row.get("engine_name");
|
|
|
Object path = row.get("txt_path");
|
|
|
if (ec == null || path == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+ String engineName = en == null ? null : String.valueOf(en);
|
|
|
Map<String, Object> txt = GzlyTxtParser.parse(readByFullPath(String.valueOf(path)));
|
|
|
Map<String, Object> result = (Map<String, Object>) txt.get("result");
|
|
|
Map<String, Object> status = (Map<String, Object>) txt.get("status");
|
|
|
Map<String, Object> m = new LinkedHashMap<>();
|
|
|
m.put("engineCode", String.valueOf(ec));
|
|
|
+ if (engineName != null) {
|
|
|
+ m.put("engineName", engineName);
|
|
|
+ }
|
|
|
m.put("value", result == null ? null : result.get("value"));
|
|
|
m.put("unit", result == null ? null : result.get("unit"));
|
|
|
m.put("status", status == null ? null : status.get("source_status"));
|
|
|
@@ -410,7 +438,7 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
m.put("metric", display.get("metric"));
|
|
|
}
|
|
|
out.add(m);
|
|
|
- Map<String, Object> one = criteriaRow(txt, machineTypeCode, String.valueOf(ec));
|
|
|
+ Map<String, Object> one = criteriaRow(txt, machineTypeCode, String.valueOf(ec), engineName);
|
|
|
if (criteria != null && one != null) {
|
|
|
criteria.add(one);
|
|
|
}
|
|
|
@@ -419,11 +447,15 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
collectChannels(txt, channels, String.valueOf(ec));
|
|
|
Map<String, Object> turbine = new LinkedHashMap<>();
|
|
|
turbine.put("engineCode", String.valueOf(ec));
|
|
|
+ if (engineName != null) {
|
|
|
+ turbine.put("engineName", engineName);
|
|
|
+ }
|
|
|
turbine.put("machineTypeCode", machineTypeCode);
|
|
|
turbine.put("criteria", one);
|
|
|
turbine.put("channels", channels);
|
|
|
turbines.add(turbine);
|
|
|
}
|
|
|
+ collectReviewClues(txt, String.valueOf(ec), engineName, reviewClues);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.warn("loadTurbineMetrics failed for {} {} {}: {}",
|
|
|
@@ -432,6 +464,32 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
+ /** 从风机结论 TXT 的 result.review_clues 收集异常线索,并附上数据库 engine_code/engine_name。 */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private void collectReviewClues(Map<String, Object> txt, String engineCode, String engineName,
|
|
|
+ List<Map<String, Object>> out) {
|
|
|
+ if (txt == null || out == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, Object> result = (Map<String, Object>) txt.get("result");
|
|
|
+ if (result == null || !(result.get("review_clues") instanceof List)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Object item : (List<?>) result.get("review_clues")) {
|
|
|
+ if (!(item instanceof Map)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, Object> clue = new LinkedHashMap<>((Map<String, Object>) item);
|
|
|
+ if (clue.get("engine_code") == null) {
|
|
|
+ clue.put("engine_code", engineCode);
|
|
|
+ }
|
|
|
+ if (clue.get("engine_name") == null) {
|
|
|
+ clue.put("engine_name", engineName);
|
|
|
+ }
|
|
|
+ out.add(clue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 从风机 TXT 收集温度矩阵单元格。行对象、按通道代码嵌套的对象、列式数组都收。 */
|
|
|
private void collectChannels(Object node, List<Map<String, Object>> out, String engine) {
|
|
|
if (node instanceof Map) {
|
|
|
@@ -592,7 +650,7 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
}
|
|
|
|
|
|
/** 一台风机的结论 TXT 收成逐机表的一行。没有检测结果和实际情况时不造行。 */
|
|
|
- private Map<String, Object> criteriaRow(Map<String, Object> parsed, String machineTypeCode, String engineCode) {
|
|
|
+ private Map<String, Object> criteriaRow(Map<String, Object> parsed, String machineTypeCode, String engineCode, String engineName) {
|
|
|
if (parsed == null || parsed.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -604,12 +662,30 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
String actualLabel = firstString(parsed, "actual_label");
|
|
|
String criterion = firstString(parsed, "criterion");
|
|
|
String explanation = firstString(parsed, "explanation");
|
|
|
+ // 对齐机组详情「本机结论」展示:实际情况取「名称:数值」,判断标准取 result.display.threshold,说明取 result.reason / conclusion.text
|
|
|
+ if (actual == null) {
|
|
|
+ actual = joinLabelValue(
|
|
|
+ nestedString(parsed, "result", "display", "metric_label"),
|
|
|
+ nestedString(parsed, "result", "display", "metric"));
|
|
|
+ }
|
|
|
+ if (criterion == null) {
|
|
|
+ criterion = nestedString(parsed, "result", "display", "threshold");
|
|
|
+ }
|
|
|
+ if (explanation == null) {
|
|
|
+ explanation = nestedString(parsed, "result", "reason");
|
|
|
+ if (explanation == null) {
|
|
|
+ explanation = nestedString(parsed, "conclusion", "text");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (status == null && actual == null && criterion == null && explanation == null) {
|
|
|
return null;
|
|
|
}
|
|
|
Map<String, Object> row = new LinkedHashMap<>();
|
|
|
String engine = firstString(parsed, "engine_code");
|
|
|
row.put("engine_code", engine != null ? engine : engineCode);
|
|
|
+ if (engineName != null) {
|
|
|
+ row.put("engine_name", engineName);
|
|
|
+ }
|
|
|
String model = firstString(parsed, "machine_type_code");
|
|
|
row.put("machine_type_code", model != null ? model : machineTypeCode);
|
|
|
row.put("status_label", status);
|
|
|
@@ -650,6 +726,33 @@ public class DiagnosisServiceImpl implements DiagnosisService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /** 按固定路径读取嵌套字段(如 result -> display -> metric),返回字符串或 null。 */
|
|
|
+ private String nestedString(Object node, String... path) {
|
|
|
+ Object cur = node;
|
|
|
+ for (String key : path) {
|
|
|
+ if (!(cur instanceof Map)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ cur = ((Map<String, Object>) cur).get(key);
|
|
|
+ }
|
|
|
+ if (cur instanceof String || cur instanceof Number || cur instanceof Boolean) {
|
|
|
+ String text = String.valueOf(cur).trim();
|
|
|
+ return text.isEmpty() ? null : text;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 把「名称」与「数值」拼成一行(如 需要复查的电气柜测点数:0测点)。 */
|
|
|
+ private String joinLabelValue(String label, String value) {
|
|
|
+ if (label == null || label.isEmpty()) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ if (value == null || value.isEmpty()) {
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ return label + ":" + value;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 拼出浏览器可直接读取的完整地址。
|
|
|
* 本机和内网访问使用 http://192.168.50.233:6900,外网访问使用 http://106.120.102.238:26900。
|