feat(qms-pdi-task-record): 添加发货前检测项详情接口
- 在QmsPdiTaskRecordController中新增deliveryDetail接口 - 实现QmsPdiTaskRecordControllerService的deliveryDetail方法 - 查询任务下所有inspectionItemType为2的检测项及其图片URL列表 - 批量获取发货检查项规则并返回对应的检查项目checklist - 定义DeliveryItemDetailVO用于返回发货前检测项明细结构 - 图片字段inspectionItemImage按逗号拆分为URL字符串列表返回
This commit is contained in:
parent
402b6159ba
commit
43de593cb0
|
|
@ -91,4 +91,13 @@ public class QmsPdiTaskRecordController extends BaseController {
|
||||||
@NotNull(message = "任务ID不能为空") @RequestParam Long id) {
|
@NotNull(message = "任务ID不能为空") @RequestParam Long id) {
|
||||||
return ApiResult.success(taskRecordControllerService.summary(id));
|
return ApiResult.success(taskRecordControllerService.summary(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发货前检测项详情(inspectionItemType=2),图片直接返回URL列表
|
||||||
|
*/
|
||||||
|
@GetMapping("deliveryDetail")
|
||||||
|
public ApiResult<List<QmsPdiTaskRecordDetailVO.DeliveryItemDetailVO>> deliveryDetail(
|
||||||
|
@NotNull(message = "任务ID不能为空") @RequestParam Long id) {
|
||||||
|
return ApiResult.success(taskRecordControllerService.deliveryDetail(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,63 @@ public class QmsPdiTaskRecordControllerService {
|
||||||
return convertImageIdsToVO(result.getInspectionItemImage());
|
return convertImageIdsToVO(result.getInspectionItemImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========================= 发货前检测项详情 =========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询发货前检测项(inspectionItemType=2),图片直接返回URL列表
|
||||||
|
*/
|
||||||
|
public List<QmsPdiTaskRecordDetailVO.DeliveryItemDetailVO> deliveryDetail(Long taskId) {
|
||||||
|
// 查询该任务下所有 type=2 的记录
|
||||||
|
List<QmsPdiInspectionResults> results = inspectionResultsService.lambdaQuery()
|
||||||
|
.eq(QmsPdiInspectionResults::getTaskId, taskId)
|
||||||
|
.eq(QmsPdiInspectionResults::getInspectionItemType, 2)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
if (results.isEmpty()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查 delivery_item 获取 checklist
|
||||||
|
Set<Long> deliveryItemIds = results.stream()
|
||||||
|
.map(QmsPdiInspectionResults::getInspectionItemId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<Long, QmsPdiDetectionRulesDeliveryItem> deliveryItemMap = Map.of();
|
||||||
|
if (!deliveryItemIds.isEmpty()) {
|
||||||
|
List<QmsPdiDetectionRulesDeliveryItem> deliveryItems = deliveryItemService.listByIds(deliveryItemIds);
|
||||||
|
deliveryItemMap = deliveryItems.stream()
|
||||||
|
.collect(Collectors.toMap(QmsPdiDetectionRulesDeliveryItem::getId, di -> di, (a, b) -> a));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建返回列表
|
||||||
|
Map<Long, QmsPdiDetectionRulesDeliveryItem> finalMap = deliveryItemMap;
|
||||||
|
List<QmsPdiTaskRecordDetailVO.DeliveryItemDetailVO> detailList = new ArrayList<>();
|
||||||
|
for (QmsPdiInspectionResults r : results) {
|
||||||
|
QmsPdiTaskRecordDetailVO.DeliveryItemDetailVO vo = new QmsPdiTaskRecordDetailVO.DeliveryItemDetailVO();
|
||||||
|
vo.setDeliveryItemId(r.getInspectionItemId());
|
||||||
|
|
||||||
|
// checklist 从 delivery_item 获取
|
||||||
|
QmsPdiDetectionRulesDeliveryItem di = finalMap.get(r.getInspectionItemId());
|
||||||
|
if (di != null) {
|
||||||
|
vo.setChecklist(di.getChecklist());
|
||||||
|
}
|
||||||
|
|
||||||
|
// inspectionItemImage 按逗号拆分,直接返回URL列表
|
||||||
|
String imageStr = r.getInspectionItemImage();
|
||||||
|
if (imageStr != null && !imageStr.isEmpty()) {
|
||||||
|
vo.setInspectionItemImage(Arrays.stream(imageStr.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(s -> !s.isEmpty())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
} else {
|
||||||
|
vo.setInspectionItemImage(List.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
detailList.add(vo);
|
||||||
|
}
|
||||||
|
return detailList;
|
||||||
|
}
|
||||||
|
|
||||||
// ========================= 任务概要 =========================
|
// ========================= 任务概要 =========================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -110,4 +110,26 @@ public class QmsPdiTaskRecordDetailVO {
|
||||||
*/
|
*/
|
||||||
private List<FileDetailVO> inspectionItemImage;
|
private List<FileDetailVO> inspectionItemImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发货前检测项明细VO(图片直接返回URL列表)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class DeliveryItemDetailVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发货检查项ID
|
||||||
|
*/
|
||||||
|
private Long deliveryItemId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查项目
|
||||||
|
*/
|
||||||
|
private String checklist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 现场图片/视频URL列表
|
||||||
|
*/
|
||||||
|
private List<String> inspectionItemImage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue