From ed4d6474cd902bab8fa99cd00361b42bbfe55ebd Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 13 十一月 2025 22:23:44 +0800
Subject: [PATCH] #新增 1. 单据上报功能优化
---
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java | 63 +++++++++++++++++++++++++++----
1 files changed, 54 insertions(+), 9 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 1d89aaa..a44c07c 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
@@ -12,16 +12,23 @@
import com.vincent.rsf.server.manager.enums.AsnExceStatus;
import com.vincent.rsf.server.manager.enums.TaskStsType;
import com.vincent.rsf.server.manager.service.*;
+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.SerialRuleCode;
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.FieldsItemServiceImpl;
import com.vincent.rsf.server.system.service.impl.FieldsServiceImpl;
+import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import lombok.Synchronized;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
@@ -50,6 +57,10 @@
private FieldsItemService fieldsItemService;
@Autowired
private FieldsService fieldsService;
+ @Autowired
+ private StockService stockService;
+ @Autowired
+ private StockItemServiceImpl stockItemService;
@Override
public R getOutStockTaskItem(String barcode) {
@@ -270,12 +281,41 @@
throw new CoolException("鍑哄簱鍗曟槑缁嗘洿鏂板け璐ワ紒锛�");
}
+ Stock stock = new Stock();
+ String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
+ if (StringUtils.isBlank(ruleCode)) {
+ throw new CoolException("褰撳墠涓氬姟锛�" + SerialRuleCode.SYS_STOCK_CODE + "锛岀紪鐮佽鍒欎笉瀛樺湪锛侊紒");
+ }
+ Double sum = taskItems.stream().mapToDouble(TaskItem::getAnfme).sum();
+ stock.setCode(ruleCode)
+ .setUpdateBy(SystemAuthUtils.getLoginUserId())
+ .setBarcode(task.getBarcode())
+ .setLocCode(task.getOrgLoc())
+ .setType(order.getType())
+ .setWkType(Short.parseShort(order.getWkType()))
+ .setSourceId(orderItem.getOrderId())
+ .setSourceCode(orderItem.getOrderCode())
+ .setUpdateTime(new Date())
+ .setAnfme(sum);
+
+ if (!stockService.save(stock)) {
+ throw new CoolException("鍑哄叆搴撳巻鍙蹭繚瀛樺け璐ワ紒锛�");
+ }
+
+ List<StockItem> stockItems = new ArrayList<>();
items.forEach(taskItem -> {
- taskItem.setQty(taskItem.getAnfme());
+ taskItem.setQty(taskItem.getAnfme()).setOrderId(order.getId()).setOrderItemId(orderItem.getId());
if (!taskItemService.updateById(taskItem)) {
throw new CoolException("鐘舵�佸畬鎴愬け璐ワ紒锛�");
}
+ StockItem stockItem = new StockItem();
+ BeanUtils.copyProperties(taskItem, stockItem);
+ stockItem.setStockId(stock.getId()).setStockCode(stock.getCode()).setSourceItemId(orderItem.getId());
+ stockItems.add(stockItem);
});
+ if (!stockItemService.saveBatch(stockItems)) {
+ throw new CoolException("鍑哄叆搴撳巻鍙叉槑缁嗕繚瀛樺け璐ワ紒锛�");
+ }
});
List<WkOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, params.getOrderId()));
@@ -292,8 +332,13 @@
throw new CoolException("鍑哄簱鍗曟洿鏂扮姸鎬佸け璐�");
}
}
-
return R.ok();
+ }
+
+
+ private void saveOrderToStock(Order order) {
+
+
}
/**
@@ -329,13 +374,13 @@
}
});
- orderItems.forEach(orderItem -> {
- try {
- taskService.saveOutStockItem(taskItems, orderItem, null, null, SystemAuthUtils.getLoginUserId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- });
+// orderItems.forEach(orderItem -> {
+// try {
+// taskService.saveOutStockItem(taskItems, orderItem, null, null, SystemAuthUtils.getLoginUserId());
+// } catch (Exception e) {
+// throw new RuntimeException(e);
+// }
+// });
// containerWaveParam.getOrderItems().forEach(orderItem -> {
//
--
Gitblit v1.9.1