| | |
| | | import zy.cloud.wms.common.utils.BarcodeUtils; |
| | | import zy.cloud.wms.common.utils.QrCode; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.Order; |
| | | import zy.cloud.wms.manager.entity.OrderDetl; |
| | | import zy.cloud.wms.manager.entity.Wave; |
| | | import zy.cloud.wms.manager.entity.WaveDetl; |
| | | import zy.cloud.wms.manager.service.OrderDetlService; |
| | | import zy.cloud.wms.manager.service.OrderService; |
| | | import zy.cloud.wms.manager.service.WaveDetlService; |
| | | import zy.cloud.wms.manager.service.WaveService; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.entity.dto.OrderDetlDTO; |
| | | import zy.cloud.wms.manager.entity.param.StockOutParam; |
| | | import zy.cloud.wms.manager.service.*; |
| | | import zy.cloud.wms.manager.utils.AddZero; |
| | | |
| | | import javax.imageio.ImageIO; |
| | |
| | | private WaveService waveService; |
| | | @Autowired |
| | | private WaveDetlService waveDetlService; |
| | | @Autowired |
| | | private PickoutService pickoutService; |
| | | @Autowired |
| | | private PickoutDetlService pickoutDetlService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | |
| | | @RequestMapping(value = "/order/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | Page<OrderDetl> orderDetlPage = orderDetlService.selectPage(new Page<>(curr, limit),orderDetailWrapper); |
| | | return R.ok(orderDetlPage); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 开始播种,更新订单细节,减少库存量 |
| | | * @param orderDetls |
| | | * @return |
| | | */ |
| | | @RequestMapping("/order/waveBack") |
| | | public R waveBack(@RequestBody OrderDetlDTO orderDetls){ |
| | | /** |
| | | * 控管与初始化 |
| | | */ |
| | | if (Cools.isEmpty(orderDetls.getOrderDetls())) { |
| | | |
| | | throw new CoolException("未收到有效播种信息,请联系管理员"); |
| | | } |
| | | |
| | | /** |
| | | * 更新原出库单,根据拣货单来减去库存 |
| | | */ |
| | | for (OrderDetl newOne : orderDetls.getOrderDetls()) { |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>() |
| | | .eq("id", newOne.getOrderId())); |
| | | Pickout pickout = pickoutService.selectOne(new EntityWrapper<Pickout>() |
| | | .eq("wave_no", order.getWaveNo())); |
| | | OrderDetl oldOne = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("id", newOne.getId())); |
| | | /** |
| | | * 计算出差值,减去库存 |
| | | */ |
| | | double diffValue = newOne.getOutQty() - oldOne.getOutQty(); |
| | | if (diffValue !=0) { |
| | | /** |
| | | * 获取拣货单分配的库位 |
| | | */ |
| | | List<PickoutDetl> pickoutDetls = pickoutDetlService.selectList(new EntityWrapper<PickoutDetl>() |
| | | .eq("head_id", pickout.getId()) |
| | | .eq("matnr", newOne.getMatnr())); |
| | | /** |
| | | * 通过拣货单分配的库位,遍历库存, |
| | | */ |
| | | for (PickoutDetl pickoutDetl : pickoutDetls) { |
| | | if (diffValue == 0) break; |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("node_id", pickoutDetl.getNodeId()) |
| | | .eq("matnr",newOne.getMatnr())); |
| | | if (Cools.isEmpty(locDetl) || locDetl.getAnfme() == 0) { |
| | | continue; |
| | | } |
| | | if (locDetl.getAnfme() > diffValue){ |
| | | locDetl.setAnfme(locDetl.getAnfme() - diffValue); |
| | | locDetlService.update(locDetl, new EntityWrapper<LocDetl>() |
| | | .eq("node_id",locDetl.getNodeId() ) |
| | | .eq("matnr",locDetl.getMatnr())); |
| | | break; |
| | | } |
| | | if (locDetl.getAnfme() < diffValue){ |
| | | locDetl.setAnfme(0.0); |
| | | diffValue = diffValue - locDetl.getAnfme(); |
| | | locDetlService.update(locDetl, new EntityWrapper<LocDetl>() |
| | | .eq("node_id",locDetl.getNodeId() ) |
| | | .eq("matnr",locDetl.getMatnr())); |
| | | } |
| | | |
| | | } |
| | | orderDetlService.update(newOne, new EntityWrapper<OrderDetl>() |
| | | .eq("id", newOne.getId() )); |
| | | } |
| | | Boolean result = orderDetlService.checkFinish(order.getId()); |
| | | if (result) { |
| | | orderDetlService.finishOrder(order.getId()); |
| | | } |
| | | } |
| | | return R.ok("播种成功"); |
| | | } |
| | | } |