Merge remote-tracking branch '惠信/qms/develop' into qms/develop
This commit is contained in:
commit
59bbb396c3
|
|
@ -88,7 +88,7 @@ public class QmsPdiTaskRecordController extends BaseController {
|
|||
*/
|
||||
@GetMapping("summary")
|
||||
public ApiResult<QmsPdiTaskRecordSummaryVO> summary(
|
||||
@NotNull(message = "任务ID不能为空") @RequestParam Long taskId) {
|
||||
return ApiResult.success(taskRecordControllerService.summary(taskId));
|
||||
@NotNull(message = "任务ID不能为空") @RequestParam Long id) {
|
||||
return ApiResult.success(taskRecordControllerService.summary(id));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,13 @@ public class QmsInspectionItemAddQO {
|
|||
private Integer detectionType;
|
||||
|
||||
/**
|
||||
* 检测项名称(必传)
|
||||
* 检测项名称(后端根据物料类别全路径自动生成,无需传入)
|
||||
*/
|
||||
@NotBlank(message = "检测项名称不能为空")
|
||||
private String inspectionItemName;
|
||||
|
||||
/**
|
||||
* 检测项编号(必传)
|
||||
* 检测项编号(后端自动生成:CATD_ + 类别码,无需传入)
|
||||
*/
|
||||
@NotBlank(message = "检测项编号不能为空")
|
||||
private String inspectionNo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
|
@ -56,12 +58,20 @@ public class QmsInspectionItemServiceImpl extends ServiceImpl<QmsInspectionItemM
|
|||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 根据物料类别ID生成编号和名称
|
||||
QmsQcMaterialCategory category = materialCategoryService.getById(qo.getMaterialTypeId());
|
||||
if (category == null) {
|
||||
throw new NflgException(STATE.BusinessError, "物料类别不存在");
|
||||
}
|
||||
String inspectionNo = "CATD_" + category.getCategoryCode();
|
||||
String inspectionItemName = buildCategoryFullPath(qo.getMaterialTypeId());
|
||||
|
||||
// 保存主表
|
||||
QmsInspectionItem item = new QmsInspectionItem()
|
||||
.setMaterialTypeId(qo.getMaterialTypeId())
|
||||
.setDetectionType(qo.getDetectionType())
|
||||
.setInspectionItemName(qo.getInspectionItemName())
|
||||
.setInspectionNo(qo.getInspectionNo())
|
||||
.setInspectionItemName(inspectionItemName)
|
||||
.setInspectionNo(inspectionNo)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
|
|
@ -162,8 +172,15 @@ public class QmsInspectionItemServiceImpl extends ServiceImpl<QmsInspectionItemM
|
|||
throw new NflgException(STATE.BusinessError, "开始时间不能晚于结束时间");
|
||||
}
|
||||
|
||||
// 如果传了物料类别,收集该类别及所有子孙类别ID
|
||||
List<Long> categoryIds = null;
|
||||
if (Objects.nonNull(qo.getMaterialTypeId())) {
|
||||
categoryIds = collectDescendantIds(qo.getMaterialTypeId());
|
||||
}
|
||||
|
||||
List<Long> finalCategoryIds = categoryIds;
|
||||
IPage<QmsInspectionItem> page = lambdaQuery()
|
||||
.eq(Objects.nonNull(qo.getMaterialTypeId()), QmsInspectionItem::getMaterialTypeId, qo.getMaterialTypeId())
|
||||
.in(finalCategoryIds != null && !finalCategoryIds.isEmpty(), QmsInspectionItem::getMaterialTypeId, finalCategoryIds)
|
||||
.like(StrUtil.isNotBlank(qo.getInspectionItemName()), QmsInspectionItem::getInspectionItemName, qo.getInspectionItemName())
|
||||
.ge(Objects.nonNull(start), QmsInspectionItem::getCreateTime, Objects.nonNull(start) ? start.atStartOfDay() : null)
|
||||
.le(Objects.nonNull(end), QmsInspectionItem::getCreateTime, Objects.nonNull(end) ? end.atTime(LocalTime.MAX) : null)
|
||||
|
|
@ -327,4 +344,47 @@ public class QmsInspectionItemServiceImpl extends ServiceImpl<QmsInspectionItemM
|
|||
vo.setDeterminationType(d.getDeterminationType());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建物料类别全路径名称(如:采购物料/原材料/板材/普通钢板)
|
||||
*/
|
||||
private String buildCategoryFullPath(Long categoryId) {
|
||||
List<String> names = new ArrayList<>();
|
||||
Long currentId = categoryId;
|
||||
while (currentId != null) {
|
||||
QmsQcMaterialCategory cat = materialCategoryService.getById(currentId);
|
||||
if (cat == null) break;
|
||||
names.add(cat.getCategoryName());
|
||||
currentId = cat.getParentCategoryRowId();
|
||||
}
|
||||
Collections.reverse(names);
|
||||
return String.join("/", names);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集指定类别及其所有子孙类别的ID集合
|
||||
*/
|
||||
private List<Long> collectDescendantIds(Long categoryId) {
|
||||
List<QmsQcMaterialCategory> all = materialCategoryService.list();
|
||||
// 构建 parentId -> children 映射
|
||||
Map<Long, List<QmsQcMaterialCategory>> childrenMap = all.stream()
|
||||
.filter(c -> c.getParentCategoryRowId() != null && c.getParentCategoryRowId() > 0)
|
||||
.collect(Collectors.groupingBy(QmsQcMaterialCategory::getParentCategoryRowId));
|
||||
|
||||
List<Long> result = new ArrayList<>();
|
||||
// BFS 收集所有后代
|
||||
java.util.Deque<Long> queue = new java.util.ArrayDeque<>();
|
||||
queue.add(categoryId);
|
||||
while (!queue.isEmpty()) {
|
||||
Long current = queue.poll();
|
||||
result.add(current);
|
||||
List<QmsQcMaterialCategory> children = childrenMap.get(current);
|
||||
if (children != null) {
|
||||
for (QmsQcMaterialCategory child : children) {
|
||||
queue.add(child.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue