修改追加物料功能
This commit is contained in:
parent
514080a0f9
commit
ba473a6215
|
|
@ -38,9 +38,6 @@ public class QmsCoaTaskController extends BaseController {
|
|||
@Resource
|
||||
private IQmsCoaTaskService coaTaskService;
|
||||
|
||||
@Resource
|
||||
private List<ISendMessageService> sendMessageServices;
|
||||
|
||||
@Resource
|
||||
private IQmsTodoItemService todoItemService;
|
||||
|
||||
|
|
|
|||
|
|
@ -221,16 +221,28 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
if (Objects.isNull(inspector)) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||
}
|
||||
Long inspectorId = inspector.getUserId();
|
||||
Long inspectorId = inspector.getId();
|
||||
Integer inspectionType = inspector.getInspectionType();
|
||||
|
||||
// 追加物料
|
||||
if (!CollectionUtils.isEmpty(request.getAddMaterialIds())) {
|
||||
// 校验这些物料是否已被任意质检员绑定(含自己)
|
||||
// 校验这些物料是否已被相同 inspectionType 的质检员绑定
|
||||
List<QmsInspectorMaterialItem> conflictMaterials = materialItemService.lambdaQuery()
|
||||
.in(QmsInspectorMaterialItem::getMaterialId, request.getAddMaterialIds())
|
||||
.list();
|
||||
if (!conflictMaterials.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料中存在已被质检员绑定的物料,不允许重复追加");
|
||||
// 查冲突记录对应的质检员 inspectionType
|
||||
List<Long> conflictInspectorIds = conflictMaterials.stream()
|
||||
.map(QmsInspectorMaterialItem::getInspectorId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
boolean sameTypeConflict = lambdaQuery()
|
||||
.in(QmsQualityInspector::getId, conflictInspectorIds)
|
||||
.eq(QmsQualityInspector::getInspectionType, inspectionType)
|
||||
.exists();
|
||||
if (sameTypeConflict) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料中存在已被相同质检类型的质检员绑定的物料,不允许重复追加");
|
||||
}
|
||||
}
|
||||
List<QmsInspectorMaterialItem> toAdd = request.getAddMaterialIds().stream()
|
||||
.map(materialId -> new QmsInspectorMaterialItem()
|
||||
|
|
@ -256,13 +268,23 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
if (!CollectionUtils.isEmpty(request.getAddMaterialCategoryCodes())) {
|
||||
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getAddMaterialCategoryCodes());
|
||||
List<Long> addCategoryIds = new ArrayList<>(codeToIdMap.values());
|
||||
// 校验这些物料类别是否已被任意质检员绑定(含自己)
|
||||
// 校验这些物料类别是否已被相同 inspectionType 的质检员绑定
|
||||
if (!addCategoryIds.isEmpty()) {
|
||||
List<QmsInspectorMaterialCategoryItem> conflictCategories = materialCategoryItemService.lambdaQuery()
|
||||
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, addCategoryIds)
|
||||
.list();
|
||||
if (!conflictCategories.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料类别中存在已被质检员绑定的类别,不允许重复追加");
|
||||
List<Long> conflictInspectorIds = conflictCategories.stream()
|
||||
.map(QmsInspectorMaterialCategoryItem::getInspectorId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
boolean sameTypeConflict = lambdaQuery()
|
||||
.in(QmsQualityInspector::getId, conflictInspectorIds)
|
||||
.eq(QmsQualityInspector::getInspectionType, inspectionType)
|
||||
.exists();
|
||||
if (sameTypeConflict) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料类别中存在已被相同质检类型的质检员绑定的类别,不允许重复追加");
|
||||
}
|
||||
}
|
||||
}
|
||||
List<QmsInspectorMaterialCategoryItem> toAdd = new ArrayList<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue