|
|
|
@ -41,7 +41,7 @@ public class QcPDAController {
|
|
|
|
|
private final IQcInspectionMainService qcInspectionMainService;
|
|
|
|
|
//质检结果子表
|
|
|
|
|
private final IQcInspectionResultService qcInspectionResultService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检测项类别
|
|
|
|
|
private final IQcInspectionItemCategoryService qcInspectionItemCategoryService;
|
|
|
|
|
|
|
|
|
@ -55,124 +55,6 @@ public class QcPDAController {
|
|
|
|
|
private final IQcUnqualifiedRecordService qcUnqualifiedRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取质检任务列表(PDA主页面)
|
|
|
|
|
* 优化:添加用户权限过滤
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/taskList")
|
|
|
|
|
public TableDataInfo<QcInspectionMainVo> getTaskList(QcInspectionMainBo bo, PageQuery pageQuery) {
|
|
|
|
|
// 默认过滤未处理任务
|
|
|
|
|
bo.setStatus(0L);//单据状态(0未处理/1完成)
|
|
|
|
|
return qcInspectionMainService.queryPageUnprocessedTasks(bo, pageQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取质检任务详情(PDA详情页面)
|
|
|
|
|
* 优化:确保返回完整的检测项数据
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/taskDetail/{inspectionId}")
|
|
|
|
|
public R<QcInspectionMainVo> getTaskDetail(@PathVariable Long inspectionId) {
|
|
|
|
|
QcInspectionMainVo result = qcInspectionMainService.queryByIdWithResults(inspectionId);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
return R.fail("质检任务不存在");
|
|
|
|
|
}
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询质检任务历史记录(PDA历史页面)
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/taskHistory")
|
|
|
|
|
public TableDataInfo<QcInspectionMainVo> getTaskHistory(QcInspectionMainBo bo, PageQuery pageQuery) {
|
|
|
|
|
// 添加用户权限过滤 - 只显示当前用户的历史任务
|
|
|
|
|
String currentUser = LoginHelper.getUsername();
|
|
|
|
|
if (bo.getInspector() == null || bo.getInspector().isEmpty()) {
|
|
|
|
|
bo.setInspector(currentUser);
|
|
|
|
|
}
|
|
|
|
|
return qcInspectionMainService.queryPageTaskHistory(bo, pageQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据用户权限查询分派的任务(PDA用户任务页面)
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/userTasks")
|
|
|
|
|
public TableDataInfo<QcInspectionMainVo> getUserTasks(@RequestParam(required = false) String inspector, PageQuery pageQuery) {
|
|
|
|
|
// 如果没有指定检测人员,默认查询当前用户的任务
|
|
|
|
|
if (inspector == null || inspector.isEmpty()) {
|
|
|
|
|
inspector = LoginHelper.getUsername();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return qcInspectionMainService.queryPageUserTasks(inspector, pageQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交质检结果(PDA提交)
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/submitResult")
|
|
|
|
|
public R<Boolean> submitResult(@Valid @RequestBody QcInspectionMainBo bo) {
|
|
|
|
|
// 业务逻辑:更新结果,生成不合格评审如果需要TODO
|
|
|
|
|
return R.ok(qcInspectionMainService.submitInspectionResult(bo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取不合格品待评审任务列表(PDA不合格主页面)
|
|
|
|
|
* TODO优化:添加权限控制
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/unqualifiedReviewList")
|
|
|
|
|
public TableDataInfo<QcUnqualifiedReviewVo> getUnqualifiedReviewList(QcUnqualifiedReviewBo bo, PageQuery pageQuery) {
|
|
|
|
|
return qcUnqualifiedReviewService.queryPagePendingReviews(bo, pageQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取不合格品待评审任务详情(PDA详情页面)
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/unqualifiedReviewDetail/{reviewId}")
|
|
|
|
|
public R<QcUnqualifiedReviewVo> getUnqualifiedReviewDetail(@PathVariable Long reviewId) {
|
|
|
|
|
return R.ok(qcUnqualifiedReviewService.queryByIdWithItems(reviewId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交不合格品评审结果(PDA提交)
|
|
|
|
|
* TODO优化:添加评审结果验证
|
|
|
|
|
* 添加评审权限验证:只有质量工程师可以评审
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/submitReview")
|
|
|
|
|
public R<Boolean> submitReview(@Valid @RequestBody QcUnqualifiedReviewBo bo) {
|
|
|
|
|
|
|
|
|
|
// 验证评审结果是否有效
|
|
|
|
|
if (bo.getReviewResult() == null || bo.getReviewResult().isEmpty()) {
|
|
|
|
|
return R.fail("评审结果不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证评审结果值是否在有效范围内(0报废/1返工/2退货/3让步接收/4流转)
|
|
|
|
|
if (!isValidReviewResult(bo.getReviewResult())) {
|
|
|
|
|
return R.fail("评审结果无效,请选择正确的处置方式");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置评审人
|
|
|
|
|
bo.setReviewer(LoginHelper.getUsername());
|
|
|
|
|
|
|
|
|
|
Boolean result = qcUnqualifiedReviewService.submitReview(bo);
|
|
|
|
|
if (result) {
|
|
|
|
|
return R.ok(true);
|
|
|
|
|
} else {
|
|
|
|
|
return R.fail("评审提交失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取不合格品统计汇总信息(PDA统计页面)
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/unqualifiedSummary")
|
|
|
|
|
public R<Map<String, Object>> getUnqualifiedSummary(@RequestParam(required = false) String dateRange) {
|
|
|
|
|
try {
|
|
|
|
|
Map<String, Object> summary = qcUnqualifiedReviewService.getUnqualifiedSummary(dateRange);
|
|
|
|
|
return R.ok(summary);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("获取不合格品统计信息失败", e);
|
|
|
|
|
return R.fail("获取统计信息失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询不合格品评审记录(PDA查询页面)
|
|
|
|
@ -191,13 +73,12 @@ public class QcPDAController {
|
|
|
|
|
if (reviewResult == null || reviewResult.trim().isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 评审结果的有效值:0报废/1返工/2退货/3让步接收/4流转
|
|
|
|
|
return "0".equals(reviewResult) || // 报废
|
|
|
|
|
"1".equals(reviewResult) || // 返工
|
|
|
|
|
"2".equals(reviewResult) || // 退货
|
|
|
|
|
"3".equals(reviewResult) || // 让步接收
|
|
|
|
|
"4".equals(reviewResult); // 流转
|
|
|
|
|
"4".equals(reviewResult) || // 让步接收
|
|
|
|
|
"3".equals(reviewResult); // 流转
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|