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