Add report detail API
This commit is contained in:
parent
90eba91756
commit
4e9ecdae9a
|
|
@ -11,7 +11,7 @@
|
|||
| 5 | POST | `/api/auditor/switch-institution` | 切换机构 | `src/api/user.js` | ✅ 已核对 | 后端存在并接收 `{ institutionId }` |
|
||||
| 6 | GET | `/api/statistics` | 报告统计 | `src/api/report.js` | ✅ 已修正 | 新增接口并返回 `{待审核报告, 已通过报告, 驳回报告, 本月审核量}` |
|
||||
| 7 | GET | `/api/reports` | 报告列表 | `src/api/report.js` | ✅ 已修正 | 支持 `status` 过滤并返回前端表格字段(含 `approval_id`、`报告编号`、`检测机构`、`提交时间`、`状态`) |
|
||||
| 8 | GET | `/api/reports/{id}` | 报告详情 | `src/api/report.js` | | |
|
||||
| 8 | GET | `/api/reports/{id}` | 报告详情 | `src/api/report.js` | ✅ 已修正 | 返回 `status(0/1/2/3)`、`report_id`、`report_type`、`institution`、`submit_time`、`testing_date`、`audit_opinion`、`ocr_result`、`attachments`、`history` |
|
||||
| 9 | GET | `/api/reports/{id}/preview` | 报告预览(图片/历史) | `src/api/report.js` | | |
|
||||
| 10 | POST | `/api/tasks` | 创建识别任务 | `src/api/report.js` | | |
|
||||
| 11 | POST | `/api/reports/{id}/submit` | 用户确认提交 | `src/api/report.js` | | |
|
||||
|
|
|
|||
|
|
@ -142,6 +142,23 @@ public class TaskController {
|
|||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@GetMapping("/reports/{id}")
|
||||
@SaCheckRole(value = { "ADMIN", "AUDITOR", "USER" }, mode = SaMode.OR)
|
||||
public ResponseEntity<?> getReportDetail(@PathVariable("id") String id) {
|
||||
Map<String, Object> detail = taskService.getReportDetail(id);
|
||||
if (detail == null) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 1);
|
||||
resp.put("msg", "Report not found");
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(resp);
|
||||
}
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 0);
|
||||
resp.put("data", detail);
|
||||
resp.put("msg", "Success");
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@SaCheckRole(value = { "ADMIN", "AUDITOR", "USER" }, mode = SaMode.OR)
|
||||
public ResponseEntity<?> getStatistics() {
|
||||
|
|
|
|||
|
|
@ -371,6 +371,68 @@ public class TaskService {
|
|||
return row;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Map<String, Object> getReportDetail(String approvalId) {
|
||||
if (approvalId == null || approvalId.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
Task task = taskRepository.findByApprovalId(approvalId);
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> detail = new HashMap<>();
|
||||
detail.put("approval_id", task.getApprovalId());
|
||||
detail.put("report_id", task.getReportId());
|
||||
detail.put("report_type", task.getReportType());
|
||||
detail.put("institution", task.getInstitution());
|
||||
detail.put("submit_time", task.getSubmitTime());
|
||||
detail.put("testing_date", task.getTestingDate());
|
||||
detail.put("audit_opinion", task.getAuditOpinion());
|
||||
detail.put("status", mapStatusForList(task.getStatus()));
|
||||
|
||||
OCRResult ocr = task.getOcrResult();
|
||||
if (ocr != null) {
|
||||
Map<String, Object> ocrMap = new HashMap<>();
|
||||
ocrMap.put("extracted_org", ocr.getExtractedOrg());
|
||||
ocrMap.put("extracted_cma", ocr.getExtractedCma());
|
||||
ocrMap.put("api_status", ocr.getApiStatus());
|
||||
detail.put("ocr_result", ocrMap);
|
||||
} else {
|
||||
detail.put("ocr_result", null);
|
||||
}
|
||||
|
||||
if (task.getAttachments() != null) {
|
||||
List<Map<String, Object>> attachments = task.getAttachments().stream().map(att -> {
|
||||
Map<String, Object> a = new HashMap<>();
|
||||
a.put("id", att.getId());
|
||||
a.put("filename", att.getFilename());
|
||||
a.put("upload_time", att.getUploadTime());
|
||||
if (att.getId() != null) {
|
||||
a.put("url", "/report-detect-api/api/reports/" + approvalId + "/attachments/" + att.getId());
|
||||
}
|
||||
return a;
|
||||
}).collect(Collectors.toList());
|
||||
detail.put("attachments", attachments);
|
||||
} else {
|
||||
detail.put("attachments", List.of());
|
||||
}
|
||||
|
||||
if (task.getHistories() != null) {
|
||||
List<Map<String, Object>> history = task.getHistories().stream().map(h -> {
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("action", h.getAction());
|
||||
m.put("timestamp", h.getTimestamp());
|
||||
m.put("opinion", h.getOpinion());
|
||||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
detail.put("history", history);
|
||||
} else {
|
||||
detail.put("history", List.of());
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
private Set<String> mapStatusFilter(String statusParam) {
|
||||
String status = statusParam.trim();
|
||||
return switch (status) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue