| | |
| | | public R syncLocsDetl(PageParam<Loc, BaseParam> pageParam, QueryWrapper<Loc> wrapper) { |
| | | Page<Object> page = new Page<>(); |
| | | page.setCurrent(pageParam.getCurrent()).setSize(pageParam.getSize()); |
| | | IPage<LocStockDto> locStocks = locService.getLocDetls(page); |
| | | BaseParam bp = pageParam.getWhere(); |
| | | Map<String, Object> conds = bp != null && bp.getMap() != null ? bp.getMap() : Collections.emptyMap(); |
| | | IPage<LocStockDto> locStocks = locService.getLocDetls(page, conds); |
| | | return R.ok().add(locStocks); |
| | | } |
| | | |
| | |
| | | .eq(WkOrder::getPoCode, syncOrder.getOrderInternalCode())); |
| | | if (!Objects.isNull(order)) { |
| | | assertWkOrderNoLinkedTask(order.getId()); |
| | | assertWkOrderExceStatusUnexecuted(order, "修改"); |
| | | long pakinCount = waitPakinItemService.count(new LambdaQueryWrapper<WaitPakinItem>() |
| | | .eq(WaitPakinItem::getAsnId, order.getId()).eq(WaitPakinItem::getDeleted, 0)); |
| | | if (pakinCount > 0) { |
| | | // 已组托时仍按原规则限制:仅未执行状态可改单 |
| | | assertWkOrderExceStatusUnexecuted(order, "修改"); |
| | | String changeSummary = computeWkOrderModifyChangeSummaryOrNull(order, syncOrder, resolvedOrderType, typeCode, true); |
| | | if (changeSummary == null) { |
| | | return "修改无变化"; |
| | |
| | | if (changeSummary == null) { |
| | | return "修改无变化"; |
| | | } |
| | | updateOrderNoPakin(order, syncOrder, loginUserId); |
| | | // 未组托时允许已收货改单;自动收货场景下同步让完成数量跟计划数量一致 |
| | | boolean alignQtyWithPlan = Objects.equals(order.getExceStatus(), AsnExceStatus.ASN_EXCE_STATUS_RECEIPT_DONE.val); |
| | | updateOrderNoPakin(order, syncOrder, loginUserId, alignQtyWithPlan); |
| | | if (isDirectWaitPakin()) { |
| | | syncReceiptAreaByOrder(order.getId()); |
| | | } |
| | |
| | | /** |
| | | * 未组托单据的修改:在原单上更新主单+明细(按 lineId 匹配),保留 exceStatus、qty、workQty,避免删单重建导致定时任务再次执行。 |
| | | */ |
| | | private void updateOrderNoPakin(WkOrder order, SyncOrderParams syncOrder, Long loginUserId) { |
| | | private void updateOrderNoPakin(WkOrder order, SyncOrderParams syncOrder, Long loginUserId, boolean alignQtyWithPlan) { |
| | | if (syncOrder.getOrderItems() == null || syncOrder.getOrderItems().isEmpty()) { |
| | | throw new CoolException("修改时明细不能为空!!"); |
| | | } |
| | |
| | | SyncOrdersItem inc = incomingByLineId.get(lineId); |
| | | Double newAnfme = QuantityUtils.roundToScale(inc.getAnfme() != null ? inc.getAnfme() : existing.getAnfme()); |
| | | existing.setAnfme(newAnfme); |
| | | if (inc.getQty() != null) { |
| | | if (alignQtyWithPlan) { |
| | | existing.setQty(newAnfme); |
| | | } else if (inc.getQty() != null) { |
| | | existing.setQty(QuantityUtils.roundToScale(inc.getQty())); |
| | | } else { |
| | | Double curQty = existing.getQty() != null ? existing.getQty() : 0.0; |
| | |
| | | map.put("order_code", order.getCode()); |
| | | map.put("matnrCode", e.getValue().getMatnr()); |
| | | map.put("platItemId", e.getKey()); |
| | | if (alignQtyWithPlan) { |
| | | map.put("qty", e.getValue().getAnfme()); |
| | | } |
| | | if (!asnOrderItemService.fieldsSave(map, loginUserId)) { |
| | | throw new CoolException("明细保存失败!!"); |
| | | } |
| | |
| | | Double sum = QuantityUtils.roundToScale(asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, order.getId())) |
| | | .stream().mapToDouble(WkOrderItem::getAnfme).sum()); |
| | | order.setAnfme(sum); |
| | | List<WkOrderItem> afterItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, order.getId())); |
| | | double qtySum = afterItems.stream().mapToDouble(oi -> oi.getQty() != null ? oi.getQty() : 0.0).sum(); |
| | | order.setQty(QuantityUtils.roundToScale(qtySum)); |
| | | if (alignQtyWithPlan) { |
| | | order.setQty(sum); |
| | | } else { |
| | | List<WkOrderItem> afterItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, order.getId())); |
| | | double qtySum = afterItems.stream().mapToDouble(oi -> oi.getQty() != null ? oi.getQty() : 0.0).sum(); |
| | | order.setQty(QuantityUtils.roundToScale(qtySum)); |
| | | } |
| | | asnOrderService.updateById(order); |
| | | } |
| | | |
| | |
| | | if (!Cools.isEmpty(param.getPlanNo())) { |
| | | wrapper.eq(LocItem::getPlatWorkCode, param.getPlanNo()); |
| | | } |
| | | // 仓库、料箱码按库位 id 交集过滤 |
| | | List<Long> allowedLocIds = null; |
| | | if (!Cools.isEmpty(param.getWareHouseId())) { |
| | | Warehouse wh = warehouseService.getOne(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, param.getWareHouseId())); |
| | | if (wh != null) { |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, wh.getId())); |
| | | if (!locs.isEmpty()) { |
| | | wrapper.in(LocItem::getLocId, locs.stream().map(Loc::getId).collect(Collectors.toList())); |
| | | } else { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | } else { |
| | | if (wh == null) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, wh.getId())); |
| | | if (locs.isEmpty()) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | allowedLocIds = locs.stream().map(Loc::getId).collect(Collectors.toList()); |
| | | } |
| | | if (!Cools.isEmpty(param.getBarcode())) { |
| | | LambdaQueryWrapper<Loc> lw = new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, param.getBarcode()); |
| | | if (allowedLocIds != null) { |
| | | lw.in(Loc::getId, allowedLocIds); |
| | | } |
| | | List<Loc> locs = locService.list(lw); |
| | | if (locs.isEmpty()) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | allowedLocIds = locs.stream().map(Loc::getId).collect(Collectors.toList()); |
| | | } |
| | | if (allowedLocIds != null) { |
| | | wrapper.in(LocItem::getLocId, allowedLocIds); |
| | | } |
| | | List<LocItem> list = locItemService.list(wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | |
| | | row.put("wareHouseId", null); |
| | | row.put("wareHouseName", null); |
| | | } |
| | | row.put("barcode", loc != null ? loc.getBarcode() : null); |
| | | row.put("palletId", item.getTrackCode()); |
| | | row.put("matNr", item.getMatnrCode()); |
| | | row.put("makTx", item.getMaktx()); |