Add submit report API
This commit is contained in:
parent
00b7251435
commit
c354e9e74e
|
|
@ -14,7 +14,7 @@
|
|||
| 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` | ✅ 已修正 | 返回 `ocr_result.API核验/org_exists/cma_exists`,并附带 `pages/history` 与 `status` |
|
||||
| 10 | POST | `/api/tasks` | 创建识别任务 | `src/api/report.js` | ✅ 已修正 | 支持 `product_name/testing_date/contact_phone` 等表单字段 |
|
||||
| 11 | POST | `/api/reports/{id}/submit` | 用户确认提交 | `src/api/report.js` | | |
|
||||
| 11 | POST | `/api/reports/{id}/submit` | 用户确认提交 | `src/api/report.js` | ✅ 已修正 | OCR 通过后将状态置为 `pending` 并记录历史 |
|
||||
| 12 | POST | `/api/reports/{id}/audit` | 审核提交 | `src/api/report.js` | | |
|
||||
| 13 | DELETE | `/api/reports/{id}` | 删除报告 | `src/api/report.js` | | |
|
||||
| 14 | POST | `/api/validate-cma` | CMA 校验 | `src/api/report.js` | | |
|
||||
|
|
|
|||
|
|
@ -187,6 +187,28 @@ public class TaskController {
|
|||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@PostMapping("/reports/{id}/submit")
|
||||
@SaCheckRole(value = { "ADMIN", "USER" }, mode = SaMode.OR)
|
||||
public ResponseEntity<?> submitReport(@PathVariable("id") String id) {
|
||||
try {
|
||||
taskService.submitReport(id);
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 0);
|
||||
resp.put("msg", "Submitted");
|
||||
return ResponseEntity.ok(resp);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 1);
|
||||
resp.put("msg", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(resp);
|
||||
} catch (IllegalStateException e) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 2);
|
||||
resp.put("msg", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@SaCheckRole(value = { "ADMIN", "AUDITOR", "USER" }, mode = SaMode.OR)
|
||||
public ResponseEntity<?> getStatistics() {
|
||||
|
|
|
|||
|
|
@ -531,6 +531,34 @@ public class TaskService {
|
|||
return preview;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void submitReport(String approvalId) {
|
||||
if (approvalId == null || approvalId.isBlank()) {
|
||||
throw new IllegalArgumentException("approval_id is required");
|
||||
}
|
||||
Task task = taskRepository.findByApprovalId(approvalId);
|
||||
if (task == null) {
|
||||
throw new IllegalArgumentException("Report not found");
|
||||
}
|
||||
OCRResult ocr = task.getOcrResult();
|
||||
if (ocr == null || !"PASS".equalsIgnoreCase(ocr.getApiStatus())) {
|
||||
throw new IllegalStateException("OCR validation not passed");
|
||||
}
|
||||
task.setStatus("pending");
|
||||
if (task.getSubmitTime() == null) {
|
||||
task.setSubmitTime(new Date());
|
||||
}
|
||||
AuditHistory history = new AuditHistory();
|
||||
history.setAction("用户确认提交");
|
||||
history.setOpinion("");
|
||||
history.setTask(task);
|
||||
if (task.getHistories() == null) {
|
||||
task.setHistories(new java.util.ArrayList<>());
|
||||
}
|
||||
task.getHistories().add(history);
|
||||
taskRepository.save(task);
|
||||
}
|
||||
|
||||
public Map<String, Object> getStatistics() {
|
||||
List<String> pendingStatuses = List.of("pending", "ocr_completed");
|
||||
List<String> auditedStatuses = List.of("compliant", "non-compliant");
|
||||
|
|
|
|||
Loading…
Reference in New Issue