Showing
1 changed file
with
61 additions
and
0 deletions
| ... | ... | @@ -360,6 +360,67 @@ public class ScSelectorController extends DefaultBaseController { |
| 360 | 360 | return InvokeResultBuilder.success(result); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | + /** | |
| 364 | + * 根据ID加载订货单数据(补货单专用) | |
| 365 | + */ | |
| 366 | + @ApiOperation("根据ID加载订货单数据") | |
| 367 | + @PostMapping("/replenishment/order/load") | |
| 368 | + public InvokeResult<List<GetPurchaseOrderInfoBo>> loadReplenishmentOrderInfo(@RequestBody(required = false) List<String> ids) { | |
| 369 | + if (CollectionUtil.isEmpty(ids)) { | |
| 370 | + return InvokeResultBuilder.success(CollectionUtil.emptyList()); | |
| 371 | + } | |
| 372 | + List<PurchaseOrderInfo> orderInfoList = orderInfoService.findById(ids); | |
| 373 | + if (CollectionUtils.isEmpty(orderInfoList)) { | |
| 374 | + return new InvokeResult<>(); | |
| 375 | + } | |
| 376 | + List<GetPurchaseOrderInfoBo> result = new ArrayList<>(); | |
| 377 | + List<String> orderIds = new ArrayList<>(); | |
| 378 | + for (PurchaseOrderInfo orderInfo : orderInfoList) { | |
| 379 | + GetPurchaseOrderInfoBo orderInfoBo = new GetPurchaseOrderInfoBo(orderInfo); | |
| 380 | + result.add(orderInfoBo); | |
| 381 | + | |
| 382 | + orderIds.add(orderInfo.getId()); | |
| 383 | + } | |
| 384 | + // 获取物料行数据 | |
| 385 | + List<PurchaseOrderLine> orderLineList = orderLineService.listByOrderIds(orderIds, true); | |
| 386 | + if (CollectionUtils.isEmpty(orderLineList)) { | |
| 387 | + return InvokeResultBuilder.success(result); | |
| 388 | + } | |
| 389 | + List<String> orderSpecIds = new ArrayList<>(); | |
| 390 | + Map<String, List<PurchaseOrderLine>> orderLineMap = new HashMap<>(); | |
| 391 | + for (PurchaseOrderLine orderLine : orderLineList) { | |
| 392 | + String orderId = orderLine.getPurchaseOrderId(); | |
| 393 | + List<PurchaseOrderLine> list = orderLineMap.computeIfAbsent(orderId, k -> new ArrayList<>()); | |
| 394 | + list.add(orderLine); | |
| 395 | + | |
| 396 | + orderSpecIds.add(orderLine.getId()); | |
| 397 | + } | |
| 398 | + // 获取发货明细数据 | |
| 399 | + Map<String, ShipmentsPlanDetail> shipmentsDetailMap = new HashMap<>(); | |
| 400 | + List<ShipmentsPlanDetail> shipmentsDetails = shipmentsPlanDetailService.listBySpecIds(orderSpecIds); | |
| 401 | + if (CollectionUtils.isNotEmpty(shipmentsDetails)) { | |
| 402 | + shipmentsDetailMap = shipmentsDetails.stream().collect(Collectors.toMap(ShipmentsPlanDetail::getOrderSpecId | |
| 403 | + , Function.identity(), (v1, v2) -> v1)); | |
| 404 | + } | |
| 405 | + for (GetPurchaseOrderInfoBo orderInfoBo : result) { | |
| 406 | + String orderId = orderInfoBo.getId(); | |
| 407 | + List<PurchaseOrderLine> lineList = orderLineMap.get(orderId); | |
| 408 | + //生产人员不展示价格 | |
| 409 | + processPrice(lineList); | |
| 410 | + // 实发数 | |
| 411 | + if (CollectionUtils.isNotEmpty(lineList)) { | |
| 412 | + for (PurchaseOrderLine orderLine : lineList) { | |
| 413 | + ShipmentsPlanDetail detail = shipmentsDetailMap.get(orderLine.getId()); | |
| 414 | + if (detail != null) { | |
| 415 | + orderLine.setActualShipmentQuantity(detail.getActualShipmentQuantity()); | |
| 416 | + } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + orderInfoBo.setPurchaseOrderLineList(lineList); | |
| 420 | + } | |
| 421 | + return InvokeResultBuilder.success(result); | |
| 422 | + } | |
| 423 | + | |
| 363 | 424 | //生产人员不展示价格,根据部门判断(生产管理科、精轧一车间、精轧车间、品质管理科),需要生产的控制价格 |
| 364 | 425 | public void processPrice(List<PurchaseOrderLine> purchaseOrderLineList) { |
| 365 | 426 | if (CollectionUtils.isEmpty(purchaseOrderLineList)) { | ... | ... |