From d80dd0abcb56aacf30bc32e424ff398f7ccce730 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 26 三月 2021 13:17:00 +0800 Subject: [PATCH] # --- src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 96 insertions(+), 13 deletions(-) diff --git a/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java b/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java index 1c8556f..c610d49 100644 --- a/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java +++ b/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java @@ -209,20 +209,23 @@ throw new CoolException("淇敼鍗曟嵁鐘舵�佸け璐�"); } // 閲囪喘閫�璐у崟 - if (param.getNumber().startsWith("PR-")) { - List<BillDto> dtos = new ArrayList<>(); - for (Pakout pakout : pakouts) { - BillDto billDto = new BillDto(); - billDto.setMatnr(pakout.getMatnr()); - billDto.setQty(pakout.getAnfme()); - dtos.add(billDto); - } - // erp鍗曟嵁涓婁紶 -- 閲囪喘閫�璐у崟 - if (!erpService.uploadBill(dtos, 6, pakouts.get(0).getDocNum())) { - throw new CoolException("鏃犳硶涓婃姤鑷砮rp"); +// if (param.getNumber().startsWith("PR-")) { + // erp鍗曟嵁涓婁紶 + Long docId = pakouts.get(0).getDocId(); + if (null != docId) { + List<BillDto> dtos = new ArrayList<>(); + for (Pakout pakout : pakouts) { + BillDto billDto = new BillDto(); + billDto.setMatnr(pakout.getMatnr()); + billDto.setQty(pakout.getAnfme()); + dtos.add(billDto); + } + if (!erpService.uploadBill(dtos, docId.intValue() , pakouts.get(0).getDocNum())) { + throw new CoolException("鏃犳硶涓婃姤鑷砮rp"); + } } - } +// } return R.ok(); } @@ -529,14 +532,94 @@ } } - return R.ok(); } @Override + @Transactional public R stockCheckAuditing(Long checkId, Long userId) { + Check check = checkService.selectById(checkId); + if (null == check) { + return R.error("鐩樼偣璁板綍宸插け鏁�"); + } + Date now = new Date(); + // 1.淇敼搴撳瓨鏁伴噺 + if (check.getOriQty() != 0 && check.getCekQty() != 0) { + // 鏇存柊搴撳瓨鏄庣粏 + if (check.getSettle() == 1) { + if (!locDetlService.incrementStock(check.getNodeId(), check.getMatnr(), Math.abs(check.getDiffQty()))) { + throw new CoolException("淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触"); + } + } else if (check.getSettle() == 2) { + if (!locDetlService.reduceStock(check.getNodeId(), check.getMatnr(), Math.abs(check.getDiffQty()))) { + throw new CoolException("淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触"); + } + } + } + // 2.鍒犻櫎搴撳瓨 + if (check.getOriQty() != 0 && check.getCekQty() == 0) { + if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("node_id", check.getNodeId()).eq("matnr", check.getMatnr()))) { + throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏鏁伴噺澶辫触"); + } + } + // 3.鏂板搴撳瓨 + if (check.getOriQty() == 0 && check.getCekQty() != 0) { + Mat mat = matService.selectByMatnr(check.getMatnr()); + if (mat == null) { + throw new CoolException("鍟嗗搧鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�"); + } + // 鏇存柊璐т綅搴撳瓨鏄庣粏 + LocDetl locDetl = new LocDetl(); + locDetl.setLocNo(check.getLocNo()); + locDetl.setNodeId(check.getNodeId()); +// locDetl.setZpallet(param.getZpallet()); + locDetl.setAnfme(check.getCekQty()); + VersionUtils.setLocDetl(locDetl, mat); + locDetl.setStatus(1); + locDetl.setCreateBy(userId); + locDetl.setCreateTime(now); + locDetl.setUpdateBy(userId); + locDetl.setUpdateTime(now); + if (!locDetlService.insert(locDetl)) { + throw new CoolException("鏂板搴撳瓨鏄庣粏澶辫触"); + } + } + + // 淇敼鐩樼偣璁板綍 + String docNum = null; + Long docId = null; + switch (check.getSettle()) { + case 1: // 鐩樼泩 + docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); + docId = 14L; // 鎶ユ孩鍗� + break; + case 2: // 鐩樹簭 + docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); + docId = 9L; // 鎶ユ崯鍗� + break; + default: + throw new CoolException("鐩樼偣璁板綍鐩堜簭鎯呭喌寮傚父"); + } + check.setStatus(2); + check.setDocId(docId); + check.setDocNum(docNum); + check.setUpdateBy(userId); + check.setUpdateTime(now); + if (!checkService.updateById(check)) { + throw new CoolException("淇敼鐩樼偣璁板綍鐘舵�佸け璐�"); + } + + // 涓婃姤缁檈rp + List<BillDto> dtos = new ArrayList<>(); + BillDto billDto = new BillDto(); + billDto.setMatnr(check.getMatnr()); + billDto.setQty(Math.abs(check.getDiffQty())); + dtos.add(billDto); + if (!erpService.uploadBill(dtos, docId.intValue(), docNum)) { + throw new CoolException("鏃犳硶涓婃姤鑷砮rp"); + } return R.ok(); } -- Gitblit v1.9.1