fix:需求单下发取消工单验证
This commit is contained in:
@@ -317,49 +317,54 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
if (CollectionUtils.isEmpty(pmDemandDtos)) {
|
||||
throw new BadRequestException("下推失败,请求数据不能为空");
|
||||
}
|
||||
List<PmDemand> disList = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList()))
|
||||
.eq(PmDemand::getStatus, DemandStatus.DIS.getValue())
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (disList.size() < pmDemandDtos.size()) {
|
||||
String collect = pmDemandDtos.stream()
|
||||
.map(PmDemandDto::getWorkOrder)
|
||||
.filter(workOrder -> disList.stream()
|
||||
.noneMatch(i -> Objects.equals(i.getWork_order(), workOrder)))
|
||||
.collect(Collectors.joining(","));
|
||||
throw new BadRequestException("下推失败,单据" + collect + "状态不为已分配不能下推");
|
||||
}
|
||||
List<PmDemand> allWorkDemand = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
.in(PmDemand::getWork_order, pmDemandDtos.stream()
|
||||
.map(PmDemandDto::getWorkOrder)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
.ne(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
// 统计 allWorkDemand 中每个工单的数量
|
||||
Map<String, Long> sourceCountMap = allWorkDemand.stream()
|
||||
.collect(Collectors.groupingBy(PmDemand::getWork_order, Collectors.counting()));
|
||||
|
||||
// 统计 pmDemandDtos 中每个工单的数量
|
||||
Map<String, Long> targetCountMap = pmDemandDtos.stream()
|
||||
.collect(Collectors.groupingBy(PmDemandDto::getWorkOrder, Collectors.counting()));
|
||||
|
||||
// 找出数量不一致的工单
|
||||
String collect = sourceCountMap.entrySet().stream()
|
||||
.filter(entry -> {
|
||||
Long targetCount = targetCountMap.getOrDefault(entry.getKey(), 0L);
|
||||
return !entry.getValue().equals(targetCount);
|
||||
})
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.joining(","));
|
||||
// throw new BadRequestException("存在未勾选完全的工单" + collect);
|
||||
pmDemandDtos.forEach(item -> {
|
||||
if (collect.contains(item.getWorkOrder())) {
|
||||
item.setWorkOrder(item.getWorkOrder() + item.getPriority());
|
||||
}
|
||||
});
|
||||
}
|
||||
pmDemandDtos.forEach(item -> {
|
||||
if (!Objects.equals(item.getStatus(), DemandStatus.DIS.getValue())){
|
||||
throw new BadRequestException("下推失败,单据状态不是已分配:" + item.getWorkOrder());
|
||||
}
|
||||
item.setWorkOrder(item.getWorkOrder() + item.getPriority());
|
||||
});
|
||||
// List<PmDemand> disList = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
// .in(PmDemand::getId, pmDemandDtos.stream().map(PmDemandDto::getId).collect(Collectors.toList()))
|
||||
// .eq(PmDemand::getStatus, DemandStatus.DIS.getValue())
|
||||
// .ne(PmDemand::getIs_deleted, 1));
|
||||
// if (disList.size() < pmDemandDtos.size()) {
|
||||
// String collect = pmDemandDtos.stream()
|
||||
// .map(PmDemandDto::getWorkOrder)
|
||||
// .filter(workOrder -> disList.stream()
|
||||
// .noneMatch(i -> Objects.equals(i.getWork_order(), workOrder)))
|
||||
// .collect(Collectors.joining(","));
|
||||
// throw new BadRequestException("下推失败,单据" + collect + "状态不为已分配不能下推");
|
||||
// }
|
||||
// List<PmDemand> allWorkDemand = this.list(new LambdaQueryWrapper<PmDemand>()
|
||||
// .in(PmDemand::getWork_order, pmDemandDtos.stream()
|
||||
// .map(PmDemandDto::getWorkOrder)
|
||||
// .distinct()
|
||||
// .collect(Collectors.toList()))
|
||||
// .ne(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
// .ne(PmDemand::getIs_deleted, 1));
|
||||
// if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
// // 统计 allWorkDemand 中每个工单的数量
|
||||
// Map<String, Long> sourceCountMap = allWorkDemand.stream()
|
||||
// .collect(Collectors.groupingBy(PmDemand::getWork_order, Collectors.counting()));
|
||||
//
|
||||
// // 统计 pmDemandDtos 中每个工单的数量
|
||||
// Map<String, Long> targetCountMap = pmDemandDtos.stream()
|
||||
// .collect(Collectors.groupingBy(PmDemandDto::getWorkOrder, Collectors.counting()));
|
||||
//
|
||||
// // 找出数量不一致的工单
|
||||
// String collect = sourceCountMap.entrySet().stream()
|
||||
// .filter(entry -> {
|
||||
// Long targetCount = targetCountMap.getOrDefault(entry.getKey(), 0L);
|
||||
// return !entry.getValue().equals(targetCount);
|
||||
// })
|
||||
// .map(Map.Entry::getKey)
|
||||
// .collect(Collectors.joining(","));
|
||||
// pmDemandDtos.forEach(item -> {
|
||||
// if (collect.contains(item.getWorkOrder())) {
|
||||
// item.setWorkOrder(item.getWorkOrder() + item.getPriority());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
|
||||
Reference in New Issue
Block a user