From 28191aeb9b6da1a90e63f5d7722d9ed51b15cbe7 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期三, 26 十一月 2025 13:11:07 +0800
Subject: [PATCH] 添加是否允许超收配置
---
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java | 54 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
index b9a4f10..52a5c8c 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
@@ -17,11 +17,14 @@
import com.vincent.rsf.server.manager.service.impl.LocItemWorkingServiceImpl;
import com.vincent.rsf.server.manager.service.impl.StockItemServiceImpl;
import com.vincent.rsf.server.manager.service.impl.StockServiceImpl;
+import com.vincent.rsf.server.system.constant.GlobalConfigCode;
import com.vincent.rsf.server.system.constant.SerialRuleCode;
+import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.entity.Fields;
import com.vincent.rsf.server.system.entity.FieldsItem;
import com.vincent.rsf.server.system.service.FieldsItemService;
import com.vincent.rsf.server.system.service.FieldsService;
+import com.vincent.rsf.server.system.service.impl.ConfigServiceImpl;
import com.vincent.rsf.server.system.service.impl.FieldsItemServiceImpl;
import com.vincent.rsf.server.system.service.impl.FieldsServiceImpl;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
@@ -68,6 +71,8 @@
private LocItemService locItemService;
@Autowired
private LocItemWorkingService locItemWorkingService;
+ @Autowired
+ private ConfigServiceImpl configService;
@Override
public R getOutStockTaskItem(String barcode) {
@@ -275,12 +280,20 @@
if (Objects.isNull(orderItem)) {
throw new CoolException("鏁版嵁閿欒锛屾嫞鏂欎笉鍦ㄥ崟鎹渶姹備腑锛侊紒");
}
+
Double summed = items.stream().mapToDouble(TaskItem::getAnfme).sum();
//鍔犱笂鍘嗗彶鎷f枡鏁伴噺
Double pickQty = Math.round((orderItem.getQty() + summed) * 100) / 100.0;
- if (pickQty.compareTo(orderItem.getAnfme()) > 0.0) {
- throw new CoolException("鎾鏁伴噺涓嶈兘瓒呭嚭璁㈠崟闇�姹傛暟閲�");
+ Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_OVER_CHANGE));
+ //鍒ゆ柇鏄惁鍏佽瓒呮敹锛屼笉鍏佽瓒呮敹娣诲姞鎷掓敹鍒ゆ柇
+ if (!Objects.isNull(config)) {
+ if (!Boolean.parseBoolean(config.getVal())) {
+ if (pickQty.compareTo(orderItem.getAnfme()) > 0.0) {
+ throw new CoolException("鎾鏁伴噺涓嶈兘瓒呭嚭璁㈠崟闇�姹傛暟閲�");
+ }
+ }
}
+
orderItem.setQty(pickQty);
if (!asnOrderItemService.updateById(orderItem)) {
@@ -310,8 +323,18 @@
List<StockItem> stockItems = new ArrayList<>();
items.forEach(taskItem -> {
- taskItem.setQty(taskItem.getAnfme()).setOrderId(order.getId()).setOrderItemId(orderItem.getId());
- if (!taskItemService.updateById(taskItem)) {
+ TaskItem item = taskItemService.getById(taskItem.getId());
+ //鍒ゆ柇鏄惁鍏佽瓒呮敹锛屼笉鍏佽瓒呮敹娣诲姞鎷掓敹鍒ゆ柇
+ if (!Objects.isNull(config)) {
+ if (!Boolean.parseBoolean(config.getVal())) {
+ if (item.getAnfme().compareTo(item.getQty() + taskItem.getAnfme()) < 0.0) {
+ throw new CoolException("鍓嶅綋鐗╂枡宸茶秴鍑哄彲鎷h寖鍥达紝璇锋牳瀵瑰悗鍐嶆搷浣滐紒锛�");
+ }
+ }
+ }
+
+ item.setQty(item.getQty() + taskItem.getAnfme()).setOrderId(order.getId()).setOrderItemId(orderItem.getId());
+ if (!taskItemService.updateById(item)) {
throw new CoolException("鐘舵�佸畬鎴愬け璐ワ紒锛�");
}
StockItem stockItem = new StockItem();
@@ -326,8 +349,8 @@
List<WkOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, params.getOrderId()));
double total = orderItems.stream().mapToDouble(WkOrderItem::getQty).sum();
- double wkQty = orderItems.stream().mapToDouble(WkOrderItem::getWorkQty).sum();
- order.setQty(total).setWorkQty(order.getWorkQty() - wkQty);
+ Double wkQty = orderItems.stream().mapToDouble(WkOrderItem::getWorkQty).sum();
+ order.setQty(total).setWorkQty(order.getWorkQty().compareTo(wkQty) < 0 ? 0.0 : (total - wkQty));
if (!asnOrderService.updateById(order)) {
throw new CoolException("璁㈠崟鏁伴噺鏇存柊澶辫触锛侊紒");
}
@@ -454,12 +477,19 @@
return R.error("浠诲姟鐘舵�佷笉鏄緟鎻�鐙�鎱�");
}
- List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
- taskItems.forEach(taskItem -> {
- if (!(taskItem.getQty().compareTo(taskItem.getAnfme()) == 0)) {
- throw new CoolException("鏈夊崟鎹墿鏂欐湭鎷o紝璇锋嫞瀹屽悗鍐嶇‘璁わ紒锛�");
- }
- });
+ Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_OVER_CHANGE));
+ //鍒ゆ柇鏄惁鍏佽瓒呮敹锛屼笉鍏佽瓒呮敹娣诲姞鎷掓敹鍒ゆ柇
+ if (!Objects.isNull(config)) {
+ if (!Boolean.parseBoolean(config.getVal())) {
+ List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ taskItems.forEach(taskItem -> {
+ if ((taskItem.getQty().compareTo(taskItem.getAnfme()) < 0)) {
+ throw new CoolException("鏈夊崟鎹墿鏂欐湭鎷o紝璇锋嫞瀹屽悗鍐嶇‘璁わ紒锛�");
+ }
+ });
+ }
+ }
+
try {
if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
--
Gitblit v1.9.1