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 | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 166 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 2f266cc..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
@@ -9,9 +9,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import zy.cloud.wms.common.model.BillDto;
import zy.cloud.wms.common.model.OrderStoDto;
import zy.cloud.wms.common.service.MainService;
import zy.cloud.wms.common.service.asrs.AsrsService;
+import zy.cloud.wms.common.service.erp.ErpService;
import zy.cloud.wms.common.utils.VersionUtils;
import zy.cloud.wms.manager.entity.*;
import zy.cloud.wms.manager.entity.param.*;
@@ -20,6 +22,7 @@
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
/**
@@ -46,6 +49,10 @@
private MatService matService;
@Autowired
private AsrsService asrsService;
+ @Autowired
+ private ErpService erpService;
+ @Autowired
+ private CheckService checkService;
@Override
@Transactional
@@ -59,6 +66,17 @@
return R.error("鐗╂枡涓嶅瓨鍦�");
}
Date now = new Date();
+ String docNum = String.valueOf(snowflakeIdWorker.nextId());
+ switch (param.getDocType()) {
+ case 34: // 閲囪喘鍗�
+ docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15);
+ break;
+ case 45: // 閿�鍞��璐у崟
+ docNum = "SR-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15);
+ break;
+ default:
+ break;
+ }
for (Comb comb : combs) {
// 鏀瑰彉缁勬墭妗g姸鎬�
comb.setIoStatus(4);
@@ -77,6 +95,8 @@
locDetl.setZpallet(param.getZpallet());
locDetl.setAnfme(comb.getAnfme());
VersionUtils.setLocDetl(locDetl, comb);
+ locDetl.setDocId(param.getDocType().longValue());
+ locDetl.setDocNum(docNum);
locDetl.setStatus(1);
locDetl.setCreateBy(userId);
locDetl.setCreateTime(now);
@@ -94,6 +114,19 @@
}
}
+
+ // 涓婃姤缁檈rp
+ List<BillDto> dtos = new ArrayList<>();
+ for (Comb comb : combs) {
+ BillDto billDto = new BillDto();
+ billDto.setMatnr(comb.getMatnr());
+ billDto.setQty(comb.getAnfme());
+ dtos.add(billDto);
+ }
+ if (!erpService.uploadBill(dtos, param.getDocType(), docNum)) {
+ throw new CoolException("鏃犳硶涓婃姤鑷砮rp");
+ }
+
return R.ok();
}
@@ -174,6 +207,21 @@
// 淇敼鍗曟嵁鐘舵��
if (!custOrderService.updateStatus(param.getNumber(), 4)) {
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");
+ }
+
}
return R.ok();
}
@@ -367,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