From b6a8cc0f2d3ced0b287348eb2a6a5785129f0ffb Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 25 三月 2021 09:12:04 +0800
Subject: [PATCH] #
---
src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java | 121 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 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 891e1e2..f72e187 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
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
/**
@@ -50,6 +51,8 @@
private AsrsService asrsService;
@Autowired
private ErpService erpService;
+ @Autowired
+ private CheckService checkService;
@Override
@Transactional
@@ -412,4 +415,122 @@
return R.error("鏆備笉缂鸿揣锛屼笉闇�瑕佺珛搴撹皟鎷�");
}
+ @Override
+ public R stockCheck(StoCheckParam param, Long userId) {
+ if (Cools.isEmpty(param.getLocNo())) {
+ return R.error("璇烽�夋嫨璐т綅");
+ }
+ Node node = nodeService.selectByUuid(param.getLocNo());
+ if (Cools.isEmpty(node)) {
+ return R.error("璐т綅寮傚父,璇疯仈绯荤鐞嗗憳");
+ }
+ // 鍑嗗鏁版嵁
+ Date now = new Date();
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("node_id", node.getId()));
+ List<String> locDetlMatnrs = new ArrayList<>();
+ locDetls.forEach(locDetl -> locDetlMatnrs.add(locDetl.getMatnr()));
+ Iterator<LocDetl> detlIterator = locDetls.iterator();
+ List<PakinMatDto> dtos = param.getDtos();
+
+ // 1.鐩堜簭 淇敼鏁伴噺
+ while (detlIterator.hasNext()){
+ LocDetl locDetl = detlIterator.next();
+ for (PakinMatDto dto : dtos) {
+ if (locDetl.getMatnr().equals(dto.getMatnr())) {
+ if (!locDetl.getAnfme().equals(dto.getCount())) {
+ Check check = new Check(
+ String.valueOf(snowflakeIdWorker.nextId()), // 鐩樼偣缂栧彿
+ node.getId(), // 鐩樼偣璐т綅
+ node.getUuid(), // 璐т綅缂栧彿
+ node.getName(), // 璐т綅鍚嶇О
+ locDetl.getMatnr(), // 鍟嗗搧缂栧彿
+ locDetl.getMaktx(), // 鍟嗗搧鍚嶇О
+ locDetl.getUnit(), // 鍗曚綅
+ null, // 鍗曟嵁绫诲瀷
+ null, // 鍗曟嵁缂栧彿
+ locDetl.getAnfme(), // 璐﹂潰鏁伴噺
+ dto.getCount(), // 瀹炵洏鏁伴噺
+ dto.getCount() - locDetl.getAnfme(), // 宸��
+ locDetl.getAnfme() < dto.getCount() ? 1 : 2, // 鐩堜簭
+ 1, // 鐘舵��
+ userId, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ userId, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+ if (!checkService.insert(check)) {
+ throw new CoolException("淇濆瓨鐩樼偣璁板綍澶辫触");
+ }
+ }
+ detlIterator.remove();
+ break;
+ }
+ }
+ }
+
+ // 2.鐩樹簭 鍒犻櫎搴撳瓨
+ for (LocDetl locDetl : locDetls) {
+ Check check = new Check(
+ String.valueOf(snowflakeIdWorker.nextId()), // 鐩樼偣缂栧彿
+ node.getId(), // 鐩樼偣璐т綅
+ node.getUuid(), // 璐т綅缂栧彿
+ node.getName(), // 璐т綅鍚嶇О
+ locDetl.getMatnr(), // 鍟嗗搧缂栧彿
+ locDetl.getMaktx(), // 鍟嗗搧鍚嶇О
+ locDetl.getUnit(), // 鍗曚綅
+ null, // 鍗曟嵁绫诲瀷
+ null, // 鍗曟嵁缂栧彿
+ locDetl.getAnfme(), // 璐﹂潰鏁伴噺
+ 0D, // 瀹炵洏鏁伴噺
+ 0D - locDetl.getAnfme(), // 宸��
+ 2, // 鐩堜簭
+ 1, // 鐘舵��
+ userId, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ userId, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+ if (!checkService.insert(check)) {
+ throw new CoolException("淇濆瓨鐩樼偣璁板綍澶辫触");
+ }
+
+ }
+
+ // 3.鐩樼泩 鏂板搴撳瓨
+ for (PakinMatDto dto : dtos) {
+ if (!locDetlMatnrs.contains(dto.getMatnr())) {
+ Mat mat = matService.selectByMatnr(dto.getMatnr());
+ Check check = new Check(
+ String.valueOf(snowflakeIdWorker.nextId()), // 鐩樼偣缂栧彿
+ node.getId(), // 鐩樼偣璐т綅
+ node.getUuid(), // 璐т綅缂栧彿
+ node.getName(), // 璐т綅鍚嶇О
+ mat.getMatnr(), // 鍟嗗搧缂栧彿
+ mat.getMaktx(), // 鍟嗗搧鍚嶇О
+ mat.getUnit(), // 鍗曚綅
+ null, // 鍗曟嵁绫诲瀷
+ null, // 鍗曟嵁缂栧彿
+ 0D, // 璐﹂潰鏁伴噺
+ dto.getCount(), // 瀹炵洏鏁伴噺
+ dto.getCount() - 0D, // 宸��
+ 1, // 鐩堜簭
+ 1, // 鐘舵��
+ userId, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ userId, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+ if (!checkService.insert(check)) {
+ throw new CoolException("淇濆瓨鐩樼偣璁板綍澶辫触");
+ }
+
+ }
+ }
+
+ return R.ok();
+ }
+
}
--
Gitblit v1.9.1