| | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean batchMergeOrders(BatchMergeOrdersParam ordersParam) {
|
| | | Loc locServiceOne = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, ordersParam.getMergeNo()), false);
|
| | | if (!Objects.isNull(locServiceOne)) {
|
| | | throw new CoolException("托盘已入库,不能再组托!!");
|
| | | }
|
| | |
|
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, ordersParam.getOrderNo()));
|
| | | if (Objects.isNull(order)) {
|
| | | throw new CoolException("订单不存在!!");
|
| | |
| | | if (!locService.updateById(loc)) {
|
| | | throw new CoolException("库位更新失败!!");
|
| | | }
|
| | |
|
| | | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode()));
|
| | | if (waitPakins.isEmpty()) {
|
| | | throw new CoolException("当前拖盘没有组拖档!!");
|
| | |
| | | }
|
| | | //修改状态为入库中
|
| | | pakin.setIoStatus(1);
|
| | |
|
| | | OrderDetl detl = orderDetlService.getById(pakin.getDetlId());
|
| | | if (Objects.isNull(detl)) {
|
| | | throw new CoolException("数据错误:单据明细不存在!!");
|
| | | }
|
| | | Double qty = Math.round((detl.getQty() + pakin.getAnfme()) * 1000) / 1000.0;
|
| | | detl.setQty(qty);
|
| | | if (!orderDetlService.updateById(detl)) {
|
| | | throw new CoolException("单据明细修改失败!!");
|
| | | }
|
| | | });
|
| | |
|
| | | //删除组拖档,加入历史组拖档
|
| | |
| | | WaitPakinLog pakinLog = new WaitPakinLog();
|
| | | BeanUtils.copyProperties(waitPakin, pakinLog);
|
| | | pakinLog.setIoStatus(1);
|
| | | pakinLog.setId(null);
|
| | | if (!waitPakinLogService.saveOrUpdate(pakinLog)) {
|
| | | throw new CoolException("组拖历史档更新失败");
|
| | | }
|
| | | });
|
| | |
|
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | throw new CoolException("组拖档删除失败!!");
|
| | | }
|
| | | //通过组拖订单ID获取订单,并删除原单据,加入单据历史档
|
| | | Set<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toSet());
|
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getId, list));
|
| | | //订单入历史档
|
| | | orders.forEach(order -> {
|
| | | if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
|
| | | throw new CoolException("当前订单类型:" + order.getOrderType() + ",不可做平库上架操作!!");
|
| | | }
|
| | | //修改订单状态为已完成
|
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | OrderLog orderLog = new OrderLog();
|
| | | BeanUtils.copyProperties(order, orderLog);
|
| | | if (!orderLogService.save(orderLog)) {
|
| | | throw new CoolException("历史单据更新失败!!");
|
| | | List<OrderDetl> detls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()));
|
| | | Double sum = detls.stream().mapToDouble(OrderDetl::getQty).sum();
|
| | | Double summed = detls.stream().mapToDouble(OrderDetl::getWorkQty).sum();
|
| | | Double v = Math.round((sum + summed) * 1000) / 1000.0;
|
| | | Double anfme = detls.stream().mapToDouble(OrderDetl::getAnfme).sum();
|
| | | if (v.compareTo(anfme) == 0.0) {
|
| | | order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | if (! orderService.updateById(order)) {
|
| | | throw new CoolException("单据状态修改失败!!");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | //删除订单数据
|
| | | if (!orderService.removeBatchByIds(orders)) {
|
| | | throw new CoolException("订单删除失败!!");
|
| | | // //订单入历史档
|
| | | // orders.forEach(order -> {
|
| | | //// if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
|
| | | //// throw new CoolException("当前订单类型:" + order.getOrderType() + ",不可做平库上架操作!!");
|
| | | //// }
|
| | | // //修改订单状态为已完成
|
| | | // order.setOrderSettle(OrderSettleType.COMPLETE.val());
|
| | | // OrderLog orderLog = new OrderLog();
|
| | | // BeanUtils.copyProperties(order, orderLog);
|
| | | // orderLog.setId(null);
|
| | | // if (!orderLogService.save(orderLog)) {
|
| | | // throw new CoolException("历史单据更新失败!!");
|
| | | // }
|
| | | // });
|
| | | // //删除订单数据
|
| | | // if (!orderService.removeBatchByIds(orders)) {
|
| | | // throw new CoolException("订单删除失败!!");
|
| | | // }
|
| | | // List<OrderDetl> detls = orderDetlMapper.selectList(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list));
|
| | | // List<OrderDetlLog> detlLogs = new ArrayList<>();
|
| | | // detls.forEach(delt ->{
|
| | | // OrderDetlLog detlLog = new OrderDetlLog();
|
| | | // BeanUtils.copyProperties(delt, detlLog);
|
| | | // detlLog.setQty(delt.getWorkQty());
|
| | | // detlLog.setWorkQty(0.0);
|
| | | // detlLog.setId(null);
|
| | | // detlLogs.add(detlLog);
|
| | | // });
|
| | | // //订单明细转历史档
|
| | | // if (!orderDetlLogService.saveBatch(detlLogs)) {
|
| | | // throw new CoolException("订单明细转历史失败!!");
|
| | | // }
|
| | | //
|
| | | // //删除订单明细数据
|
| | | // if (!orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list))) {
|
| | | // throw new CoolException("订单明细删除失败!!");
|
| | | // }
|
| | | if (!waitPakinService.removeBatchByIds(waitPakins)) {
|
| | | throw new CoolException("组拖档删除失败!!");
|
| | | }
|
| | |
|
| | | List<OrderDetl> detls = orderDetlMapper.selectList(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list));
|
| | | List<OrderDetlLog> detlLogs = new ArrayList<>();
|
| | | detls.forEach(delt ->{
|
| | | OrderDetlLog detlLog = new OrderDetlLog();
|
| | | BeanUtils.copyProperties(delt, detlLog);
|
| | | detlLog.setQty(delt.getWorkQty());
|
| | | detlLog.setWorkQty(0.0);
|
| | | detlLogs.add(detlLog);
|
| | | });
|
| | |
|
| | | //订单明细转历史档
|
| | | if (!orderDetlLogService.saveBatch(detlLogs)) {
|
| | | throw new CoolException("订单明细转历史失败!!");
|
| | | }
|
| | |
|
| | | //删除订单明细数据
|
| | | if (!orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list))) {
|
| | | throw new CoolException("订单明细删除失败!!");
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | if (Objects.isNull(order)) {
|
| | | throw new CoolException("绑定订单不存在!!");
|
| | | }
|
| | | siteNo.setOrderNo(order.getOrderNo()).setOrderId(order.getId()).setSiteStatus(CacheSiteStatusType.R.id).setBarcode(param.get("barcode").toString());
|
| | | siteNo.setOrderNo(order.getOrderNo())
|
| | | .setOrderId(order.getId())
|
| | | .setSiteStatus(CacheSiteStatusType.R.id)
|
| | | .setBarcode(param.get("barcode").toString());
|
| | | if (cacheSiteMapper.updateById(siteNo) < 1) {
|
| | | throw new CoolException("订单播种位绑定失败!!" );
|
| | | }
|
| | |
| | | if (StringUtil.isNullOrEmpty(siteNo.getOrderNo())) {
|
| | | throw new CoolException("当前播种站点未绑定订单!!");
|
| | | }
|
| | | siteNo.setOrderId(null).setOrderNo(null).setSiteNo("0");
|
| | | siteNo.setOrderId(null).setOrderNo(null).setBarcode(null).setSiteNo("0");
|
| | | if (cacheSiteMapper.updateById(siteNo) < 1) {
|
| | | throw new CoolException("订单与播种位解绑失败!!" );
|
| | | }
|
| | |
| | | return R.ok("发货完成!!");
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Ryan
|
| | | * @date 2025/6/28
|
| | | * @description: 获取平库推荐库位
|
| | | * @version 1.0
|
| | | */
|
| | | @Override
|
| | | public R getRecommendLocs() {
|
| | | return locService.getRecommengLocs();
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Ryan
|
| | | * @date 2025/6/28
|
| | | * @description: 查询物料信息
|
| | | * @version 1.0
|
| | | */
|
| | | @Override
|
| | | public R getMatsByCode(String matnr) {
|
| | | return R.ok().add(matService.list(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, matnr)));
|
| | | }
|
| | |
|
| | | }
|