fix(文件中心):修复冷数据访问问题彻底修复,设备中心查询航线文件空指针异常问题修复
This commit is contained in:
+73
-5
@@ -13,7 +13,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Wayline file information
|
||||
@@ -48,8 +51,16 @@ public class LineFileController {
|
||||
@Operation(summary = "查询")
|
||||
@GetMapping("/{id}")
|
||||
public Result findById(@PathVariable String id) {
|
||||
LineFile model = lineFileService.findLineFileByWaylineId(id);
|
||||
return Result.succeed(model, "查询成功");
|
||||
try {
|
||||
LineFile model = lineFileService.findLineFileByWaylineId(id);
|
||||
if (model == null) {
|
||||
return Result.failed("未找到对应的航线文件信息");
|
||||
}
|
||||
return Result.succeed(model, "查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询航线文件失败,id: {}", id, e);
|
||||
return Result.failed("查询航线文件失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +68,17 @@ public class LineFileController {
|
||||
*/
|
||||
@Operation(summary = "查询")
|
||||
@GetMapping("/sign/{id}")
|
||||
public String findLineSignById(@PathVariable String id) {
|
||||
LineFile model = lineFileService.findLineFileByWaylineId(id);
|
||||
return model.getSign();
|
||||
public Result findLineSignById(@PathVariable String id) {
|
||||
try {
|
||||
LineFile model = lineFileService.findLineFileByWaylineId(id);
|
||||
if (model == null) {
|
||||
return Result.failed("未找到对应的航线文件信息");
|
||||
}
|
||||
return Result.succeed(model.getSign(), "查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询航线文件签名失败,id: {}", id, e);
|
||||
return Result.failed("查询航线文件签名失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,4 +101,53 @@ public class LineFileController {
|
||||
lineFileService.removeById(id);
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊断航线文件数据
|
||||
*/
|
||||
@Operation(summary = "诊断航线文件数据")
|
||||
@GetMapping("/diagnose")
|
||||
public Result diagnoseLineFileData() {
|
||||
try {
|
||||
// 查询所有航线文件
|
||||
List<LineFile> allLineFiles = lineFileService.list();
|
||||
|
||||
Map<String, Object> diagnosis = new HashMap<>();
|
||||
diagnosis.put("totalCount", allLineFiles.size());
|
||||
|
||||
// 按waylineId分组统计
|
||||
Map<String, Long> waylineIdStats = allLineFiles.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
f -> f.getWaylineId() == null ? "NULL_WAYLINE_ID" : f.getWaylineId(),
|
||||
Collectors.counting()
|
||||
));
|
||||
diagnosis.put("waylineIdStats", waylineIdStats);
|
||||
|
||||
// 检查有sign字段的文件
|
||||
List<LineFile> filesWithSign = allLineFiles.stream()
|
||||
.filter(f -> f.getSign() != null && !f.getSign().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
diagnosis.put("filesWithSign", filesWithSign.size());
|
||||
|
||||
// 最近的文件示例
|
||||
List<Map<String, Object>> recentFiles = allLineFiles.stream()
|
||||
.limit(10)
|
||||
.map(f -> {
|
||||
Map<String, Object> fileInfo = new HashMap<>();
|
||||
fileInfo.put("id", f.getId());
|
||||
fileInfo.put("name", f.getName());
|
||||
fileInfo.put("waylineId", f.getWaylineId());
|
||||
fileInfo.put("sign", f.getSign());
|
||||
fileInfo.put("createTime", f.getCreateTime());
|
||||
return fileInfo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
diagnosis.put("recentFiles", recentFiles);
|
||||
|
||||
return Result.succeed(diagnosis, "诊断完成");
|
||||
} catch (Exception e) {
|
||||
log.error("诊断航线文件数据失败", e);
|
||||
return Result.failed("诊断失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user