From 1060d645b41edf14d57266015008b41c56edacea Mon Sep 17 00:00:00 2001
From: zc <zyzc>
Date: 星期二, 18 十一月 2025 20:54:25 +0800
Subject: [PATCH] 11
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java | 75 +++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
index 4fb6bc9..00b16df 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java
@@ -13,6 +13,7 @@
import com.vincent.rsf.server.system.constant.SerialRuleCode;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -62,9 +63,26 @@
// List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
.eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
- if (!Objects.isNull(pakin)) {
- throw new CoolException("鎵樼洏鐮侊細" + waitPakin.getBarcode() + "宸茶缁勬墭鍗曪細" + pakin.getCode() + "浣跨敤锛侊紒");
+
+ List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
+ if (!tasks.isEmpty()) {
+ throw new CoolException("褰撳墠鎵樼洏宸叉湁浠诲姟妗e湪鎵ц锛屼笉鑳藉啀娆$粍鎵橈紒锛�");
}
+ if (!Objects.isNull(pakin)) {
+ List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(!Objects.isNull(pakin.getId()) ,WaitPakinItem::getPakinId, pakin.getId()));
+ waitPakinItems.forEach(item -> {
+ for (PakinItem pakinItem : waitPakin.getItems()) {
+ WarehouseAreasItem warehouseAreasItems = warehouseAreasItemService.getById(pakinItem.getId());
+ if (Objects.isNull(warehouseAreasItems)) {
+ throw new CoolException("鐗╂枡鏈�佽嚦鏀惰揣鍖烘垨宸茬粍鎵樺畬鎴愮Щ鍑烘敹璐у尯锛侊紒");
+ }
+ if (item.getFieldsIndex().equals(warehouseAreasItems.getFieldsIndex())) {
+ throw new CoolException("绁ㄥ彿锛�" + item.getExtendFields().get("crushNo") + "宸茬粍鎵橈紝涓嶅彲閲嶅缁勬墭锛侊紒");
+ }
+ }
+ });
+ }
+
List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
if (!locs.isEmpty()) {
List<String> locCodes = locs.stream().map(Loc::getCode).collect(Collectors.toList());
@@ -74,31 +92,25 @@
double sum = waitPakin.getItems().stream().mapToDouble(PakinItem::getReceiptQty).sum();
WaitPakin waitPakin1 = new WaitPakin();
- String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_WAIT_PAKIN_CODE, null);
- if (StringUtils.isBlank(ruleCode)) {
- throw new CoolException("缂栫爜瑙勫垯閿欒锛� 缂栫爜瑙勫垯銆孲YS_WAIT_PAKIN_CODE銆嶈鍒欐槸涓嶅瓨鍦�");
+ if (Objects.isNull(pakin)) {
+ String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_WAIT_PAKIN_CODE, null);
+ if (StringUtils.isBlank(ruleCode)) {
+ throw new CoolException("缂栫爜瑙勫垯閿欒锛� 缂栫爜瑙勫垯銆孲YS_WAIT_PAKIN_CODE銆嶈鍒欐槸涓嶅瓨鍦�");
+ }
+ waitPakin1.setCode(ruleCode)
+ //鐘舵�佷慨鏀逛负鍏ュ簱涓�
+ .setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
+ .setAnfme(sum)
+ .setUpdateBy(userId)
+ .setCreateBy(userId)
+ .setBarcode(waitPakin.getBarcode());
+ if (!this.save(waitPakin1)) {
+ throw new CoolException("涓诲崟淇濆瓨澶辫触锛侊紒");
+ }
+ } else {
+ BeanUtils.copyProperties(pakin, waitPakin1);
}
- waitPakin1.setCode(ruleCode)
- //鐘舵�佷慨鏀逛负鍏ュ簱涓�
- .setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
- .setAnfme(sum)
- .setUpdateBy(userId)
- .setCreateBy(userId)
- .setBarcode(waitPakin.getBarcode());
- if (!this.save(waitPakin1)) {
- throw new CoolException("涓诲崟淇濆瓨澶辫触锛侊紒");
- }
-// /**鐗╂枡璺熻釜鐮�*/
-// List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>()
-// .eq(WaitPakinItem::getPakinId, waitPakin1.getId()))
-// ;
-// if (!pakinItems.isEmpty()) {
-// if (!waitPakinItemService.remove(new LambdaQueryWrapper<WaitPakinItem>()
-// .eq(WaitPakinItem::getPakinId, waitPakin1.getId())
-// )) {
-// throw new CoolException("鍘熷崟鎹竻闄ゅけ璐ワ紒锛�");
-// }
-// }
+
List<WaitPakinItem> items = new ArrayList<>();
for (PakinItem pakinItem1 : waitPakin.getItems()) {
//涓嶈壇鏍囩缁勬墭
@@ -144,11 +156,16 @@
items.add(pakinItem);
}
- Double sum1 = items.stream().mapToDouble(WaitPakinItem::getAnfme).sum();
-
if (!waitPakinItemService.saveBatch(items)) {
throw new CoolException("缁勬墭鏄庣粏淇濆瓨澶辫触锛侊紒");
}
+
+ List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, waitPakin1.getId()));
+ Double waitSum = 0.0;
+ if (!pakinItems.isEmpty()) {
+ waitSum = pakinItems.stream().mapToDouble(WaitPakinItem::getAnfme).sum();
+ }
+// Double total = Math.round((sum + waitSum) * 100) / 100.0;
for (WaitPakinItem pakinItem : items) {
WarehouseAreasItem one = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
@@ -167,7 +184,7 @@
}
}
- waitPakin1.setAnfme(sum1);
+ waitPakin1.setAnfme(waitSum);
if (!this.updateById(waitPakin1)) {
throw new CoolException("缁勬墭鏁伴噺淇敼澶辫触锛侊紒");
}
--
Gitblit v1.9.1