| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private AgvLocDetlService agvLocDetlService; |
| | | @Autowired |
| | | private FlowLogService flowLogService; |
| | | |
| | | @GetMapping("/doc/type/list") |
| | | @Transactional |
| | | @ManagerAuth(memo = "单据类型") |
| | | @ManagerAuth(memo = "入库单据类型") |
| | | @Synchronized |
| | | public R docTypeList(){ |
| | | List<DocType> result = new ArrayList<>(); |
| | |
| | | unDocIds.add(30L); |
| | | unDocIds.add(32L); |
| | | unDocIds.add(36L); |
| | | for (DocType pakin : pakins) { |
| | | if (!unDocIds.contains(pakin.getDocId())) { |
| | | result.add(pakin); |
| | | } |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | @GetMapping("/doc/type/out/list") |
| | | @Transactional |
| | | @ManagerAuth(memo = "出库单据类型") |
| | | @Synchronized |
| | | public R docTypeOutList(){ |
| | | List<DocType> result = new ArrayList<>(); |
| | | List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); |
| | | List<Long> unDocIds = new ArrayList<>(); |
| | | unDocIds.add(18L); |
| | | unDocIds.add(31L); |
| | | unDocIds.add(33L); |
| | | unDocIds.add(34L); |
| | | unDocIds.add(35L); |
| | | unDocIds.add(37L); |
| | | for (DocType pakin : pakins) { |
| | | if (!unDocIds.contains(pakin.getDocId())) { |
| | | result.add(pakin); |
| | |
| | | @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("订单不存在"); |
| | | } |
| | |
| | | // 2.重组数据 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | 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) { |
| | | List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>() |
| | | .eq("matnr", orderDetl.getMatnr()) |
| | | .eq("order_no", orderDetl.getOrderNo()) |
| | | .eq("process_sts", 3)); |
| | | for (AgvLocDetl agvLocDetl : agvLocDetls) { |
| | | agvLocDetl.setProcessSts(1); |
| | | agvLocDetlService.updateById(agvLocDetl); |
| | | } |
| | | } |
| | | list.add(dto); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setSource(param.getDocType().intValue()); |
| | | orderDetl.setSource(docType); |
| | | orderDetl.setCreateBy(getUserId()); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(getUserId()); |
| | |
| | | orderDetl.setQty(0.0D); |
| | | 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("同步半成品调拨单流水记录失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | proSts = 3; |
| | | } |
| | | |
| | | |
| | | String odNo = uuid; |
| | | if(docType.getPakin() == 1){ |
| | | uuid += "_I"; |
| | | odNo += "_I"; |
| | | }else { |
| | | uuid += "_O"; |
| | | odNo += "_O"; |
| | | } |
| | | |
| | | Order order = orderService.selectByNo(uuid); |
| | | Order order = orderService.selectByNo(odNo); |
| | | if (null == order) { |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | uuid, // 订单编号 |
| | | odNo, // 订单编号 |
| | | null, // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | |
| | | throw new CoolException("生成单据主档失败,请重新导入!"); |
| | | } |
| | | }else { |
| | | // 有原订单在的情况 |
| | | DocType orderType = docTypeService.selectById(order.getDocType()); |
| | | if (!orderType.getDocName().equals(docName)) { |
| | | throw new CoolException("新订单:" + uuid + " 与系统内的订单号相同,单据类型不同。请确认新订单单据类型!"); |
| | | } |
| | | order.setSettle(order.getSettle() == 1L ? 1L : 2L ); |
| | | orderService.updateById(order); |
| | | } |
| | |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | | } else { |
| | | if (anfme < 0) { |
| | | throw new CoolException("订单数量不允许为负数!"); |
| | | } |
| | | if(!orderDetlService.increaseAnfme(order.getId(), matnr, null, anfme,csocode,isocode)) { |
| | | throw new CoolException("生成单据明细失败,请重新导入!"); |
| | | } |
| | | } |
| | | // 生成调拨单 |
| | | if (docType.getDocId().intValue() == 32) { |
| | | String dbUuid = "DB" + uuid; |
| | | String dbUuid = "DB" + odNo; |
| | | Order order2 = orderService.selectByNo(dbUuid); |
| | | if (null == order2) { |
| | | order2 = new Order( |
| | |
| | | // 工序为1:待加工 生成加工单 |
| | | if (proSts == 1) { |
| | | if (docType.getDocId().intValue() == 32) { |
| | | String dbUuid = "JG" + uuid; |
| | | String dbUuid = "JG" + odNo; |
| | | Order order3 = orderService.selectByNo(dbUuid); |
| | | if (null == order3) { |
| | | order3 = new Order( |