| | |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectAndLogByOrderNo(order.getOrderNo()); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | List<OrderDetl> insertList = new ArrayList<>(); |
| | | |
| | | Double isused = wrkDetl.getWeight(); |
| | | while (isused > 0D) { |
| | | List<NccSaleXsfhmxWms> list = matnrMap.get(wrkDetl.getMatnr()); |
| | | if (!list.isEmpty()) { |
| | | NccSaleXsfhmxWms nccSaleXsfhmxWms = list.get(0); |
| | | BigDecimal orderStock = nccSaleXsfhmxWms.getNastnum(); |
| | | |
| | | BigDecimal diff = orderStock.subtract(BigDecimal.valueOf(isused)); |
| | | if (diff.doubleValue() >= 0) { |
| | | nccSaleXsfhmxWms.setNastnum(diff); |
| | | list.set(0, nccSaleXsfhmxWms); |
| | | matnrMap.put(wrkDetl.getMatnr(), list); |
| | | }else { |
| | | list.remove(0); |
| | | matnrMap.put(wrkDetl.getMatnr(), list); |
| | | } |
| | | |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(wrkDetl); |
| | | orderDetl.setQty(wrkDetl.getAnfme()); |
| | |
| | | orderDetl.setUpdateTime(orderSou.getUpdateTime()); |
| | | orderDetl.setUpdateBy(orderSou.getUpdateBy()); |
| | | orderDetl.setId(null); |
| | | |
| | | List<NccSaleXsfhmxWms> list = matnrMap.get(wrkDetl.getMatnr()); |
| | | if (!list.isEmpty()) { |
| | | NccSaleXsfhmxWms nccSaleXsfhmxWms = list.get(0); |
| | | BigDecimal nastnum = nccSaleXsfhmxWms.getNastnum(); |
| | | BigDecimal subtract = nastnum.subtract(BigDecimal.valueOf(wrkDetl.getWeight())); |
| | | if (subtract.doubleValue() <= 0) { |
| | | list.remove(0); |
| | | }else { |
| | | nccSaleXsfhmxWms.setNastnum(subtract); |
| | | list.set(0, nccSaleXsfhmxWms); |
| | | } |
| | | |
| | | orderDetl.setRemark(JSON.toJSONString(nccSaleXsfhmxWms)); |
| | | insertList.add(orderDetl); |
| | | |
| | | isused -= orderStock.doubleValue(); |
| | | }else { |
| | | throw new CoolException("重整出库订单【orderNo = " + order.getOrderNo() + "】明细失败,ERP原始数据为空"); |
| | | } |
| | | } |
| | | |
| | | for (OrderDetl orderDetl : insertList) { |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("重整出库订单【orderNo = " + order.getOrderNo() + "】明细失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // for (WrkDetl wrkDetl : wrkDetls) { |
| | | // OrderDetl orderDetl = new OrderDetl(); |