| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private AgvLocDetlService agvLocDetlService; |
| | | @Autowired |
| | | private FlowLogService flowLogService; |
| | | |
| | | @GetMapping("/doc/type/list") |
| | | @Transactional |
| | |
| | | @Transactional |
| | | public R formAdd(@RequestBody OrderDomainParam param){ |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | long flowId = snowflakeIdWorker.nextId(); |
| | | if (order != null) { |
| | | return R.error("单据编号已存在"); |
| | | } |
| | |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | Double anfme = item.getAnfme(); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | // 流水 -- 新增订单明细 |
| | | FlowLog flowLog = new FlowLog(); |
| | | flowLog.setFid(String.valueOf(flowId)); |
| | | flowLog.setOpType(2L); |
| | | flowLog.setOrderNo(param.getOrderNo()); |
| | | flowLog.setThreeCode(orderDetl.getThreeCode()); |
| | | flowLog.setMatnr(orderDetl.getMatnr()); |
| | | flowLog.setMaktx(orderDetl.getMaktx()); |
| | | flowLog.setOrderPrevious(anfme); |
| | | flowLog.setOrderCurrent(anfme + orderDetl.getAnfme()); |
| | | flowLog.setOrderChanged(orderDetl.getAnfme()); |
| | | flowLog.setQtyPrevious(orderDetl.getQty()); |
| | | flowLog.setQtyCurrent(orderDetl.getQty()); |
| | | flowLog.setQtyChanged(0.0D); |
| | | flowLog.setUserId(getUserId()); |
| | | flowLog.setAppeTime(now); |
| | | if (!flowLogService.insert(flowLog)) { |
| | | throw new CoolException("同步半成品调拨单流水记录失败"); |
| | | } |
| | | } else { |
| | | list.add(dto); |
| | |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | // 流水 -- 新增订单明细 |
| | | FlowLog flowLog = new FlowLog(); |
| | | flowLog.setFid(String.valueOf(flowId)); |
| | | flowLog.setOpType(1L); |
| | | flowLog.setOrderNo(param.getOrderNo()); |
| | | flowLog.setThreeCode(orderDetl.getThreeCode()); |
| | | flowLog.setMatnr(orderDetl.getMatnr()); |
| | | flowLog.setMaktx(orderDetl.getMaktx()); |
| | | flowLog.setOrderPrevious(0.0D); |
| | | flowLog.setOrderCurrent(orderDetl.getAnfme()); |
| | | flowLog.setOrderChanged(orderDetl.getAnfme()); |
| | | flowLog.setQtyPrevious(0.0D); |
| | | flowLog.setQtyCurrent(0.0D); |
| | | flowLog.setQtyChanged(0.0D); |
| | | flowLog.setUserId(getUserId()); |
| | | flowLog.setAppeTime(now); |
| | | if (!flowLogService.insert(flowLog)) { |
| | | throw new CoolException("同步半成品调拨单流水记录失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成半成品调拨单明细档失败"); |
| | | } |
| | | // 流水 -- 新增订单明细 |
| | | FlowLog flowLog = new FlowLog(); |
| | | flowLog.setFid(String.valueOf(flowId)); |
| | | flowLog.setOpType(1L); |
| | | flowLog.setOrderNo(param.getOrderNo()); |
| | | flowLog.setThreeCode(orderDetl.getThreeCode()); |
| | | flowLog.setMatnr(orderDetl.getMatnr()); |
| | | flowLog.setMaktx(orderDetl.getMaktx()); |
| | | flowLog.setOrderPrevious(0.0D); |
| | | flowLog.setOrderCurrent(orderDetl.getAnfme()); |
| | | flowLog.setOrderChanged(orderDetl.getAnfme()); |
| | | flowLog.setQtyPrevious(0.0D); |
| | | flowLog.setQtyCurrent(0.0D); |
| | | flowLog.setQtyChanged(0.0D); |
| | | flowLog.setUserId(getUserId()); |
| | | flowLog.setAppeTime(now); |
| | | if (!flowLogService.insert(flowLog)) { |
| | | throw new CoolException("同步半成品调拨单流水记录失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | return R.ok("订单添加成功"); |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public R formModify(@RequestBody OrderDomainParam param){ |
| | | Order order = orderService.selectById(param.getOrderId()); |
| | | long flowId = snowflakeIdWorker.nextId(); |
| | | int docType = param.getDocType().intValue(); |
| | | if (order == null || order.getStatus() == 0) { |
| | | return R.error("订单不存在"); |
| | |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getAnfme(), orderDetl.getProcessSts()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | Double anfme = item.getAnfme(); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | // 流水 -- 新增订单明细 |
| | | FlowLog flowLog = new FlowLog(); |
| | | flowLog.setFid(String.valueOf(flowId)); |
| | | flowLog.setOpType(2L); |
| | | flowLog.setOrderNo(param.getOrderNo()); |
| | | flowLog.setThreeCode(orderDetl.getThreeCode()); |
| | | flowLog.setMatnr(orderDetl.getMatnr()); |
| | | flowLog.setMaktx(orderDetl.getMaktx()); |
| | | flowLog.setOrderPrevious(anfme); |
| | | flowLog.setOrderCurrent(anfme + orderDetl.getAnfme()); |
| | | flowLog.setOrderChanged(orderDetl.getAnfme()); |
| | | flowLog.setQtyPrevious(orderDetl.getQty()); |
| | | flowLog.setQtyCurrent(orderDetl.getQty()); |
| | | flowLog.setQtyChanged(0.0D); |
| | | flowLog.setUserId(getUserId()); |
| | | flowLog.setAppeTime(now); |
| | | if (!flowLogService.insert(flowLog)) { |
| | | throw new CoolException("同步半成品调拨单流水记录失败"); |
| | | } |
| | | } else { |
| | | if (docType == 35 && orderDetl.getProcessSts() == 1) { |
| | |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | // 流水 -- 新增订单明细 |
| | | FlowLog flowLog = new FlowLog(); |
| | | flowLog.setFid(String.valueOf(flowId)); |
| | | flowLog.setOpType(2L); |
| | | flowLog.setOrderNo(param.getOrderNo()); |
| | | flowLog.setThreeCode(orderDetl.getThreeCode()); |
| | | flowLog.setMatnr(orderDetl.getMatnr()); |
| | | flowLog.setMaktx(orderDetl.getMaktx()); |
| | | flowLog.setOrderPrevious(0.0D); |
| | | flowLog.setOrderCurrent(orderDetl.getAnfme()); |
| | | flowLog.setOrderChanged(orderDetl.getAnfme()); |
| | | flowLog.setQtyPrevious(orderDetl.getQty()); |
| | | flowLog.setQtyCurrent(orderDetl.getQty()); |
| | | flowLog.setQtyChanged(0.0D); |
| | | flowLog.setUserId(getUserId()); |
| | | flowLog.setAppeTime(now); |
| | | if (!flowLogService.insert(flowLog)) { |
| | | throw new CoolException("同步半成品调拨单流水记录失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("订单修改成功"); |