From 3799e9f3fc8abaafa95094c8c987a8d9da3eb2a9 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期二, 06 五月 2025 13:11:19 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 127 ++++++++++++++++++++++++++++++++----------
1 files changed, 96 insertions(+), 31 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
index 3943f40..c255752 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -2,11 +2,13 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.server.api.entity.enums.OrderType;
import com.vincent.rsf.server.api.entity.enums.TaskStsType;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.api.entity.enums.TaskType;
+import com.vincent.rsf.server.api.utils.LocUtils;
import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.PakinIOStatus;
@@ -52,15 +54,15 @@
private StockItemService stockItemService;
@Autowired
private DeviceSiteService deviceSiteService;
-
- @Autowired
- private OrderService orderService;
-
- @Autowired
- private OrderItemService orderItemService;
-
@Autowired
private LocItemService locItemService;
+ @Autowired
+ private DeviceBindService deviceBindService;
+ @Autowired
+ private WarehouseAreasService warehouseAreasService;
+
+ @Autowired
+ private WarehouseAreasItemService warehouseAreasItemService;
/**
@@ -82,6 +84,15 @@
if (Objects.isNull(deviceSite)) {
throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
}
+ DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(Integer.valueOf(deviceSite.getSite())));
+ if (Cools.isEmpty(deviceBind)) {
+ throw new CoolException("搴撲綅瑙勫垯鏈煡");
+ }
+ WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
+ if (Cools.isEmpty(warehouseArea)) {
+ throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+ }
+
/**鑾峰彇缁勬嫋*/
List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
@@ -91,6 +102,12 @@
throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
}
waitPakins.forEach(pakin -> {
+ /**鑾峰彇搴撲綅*/
+ String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId());
+ if (Cools.isEmpty(targetLoc)) {
+ throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
+ }
+
List<TaskItem> taskItems = new ArrayList<>();
String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
if (StringUtils.isBlank(ruleCode)) {
@@ -100,28 +117,28 @@
task.setTaskCode(ruleCode)
.setTaskStatus(TaskStsType.GENERATE_IN.id.shortValue())
.setTaskType(TaskType.TASK_TYPE_IN.type.shortValue())
- .setTargLoc(LocManageUtil.getTargetLoc())
+ .setTargLoc(targetLoc)
.setBarcode(pakin.getBarcode())
- .setTargSite(deviceSite.getDeviceCode())
+ .setOrgSite(deviceSite.getSite())
+ .setTargSite(deviceSite.getDeviceSite())
.setCreateBy(loginUserId)
.setUpdateBy(loginUserId);
-
- if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) {
- DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId());
- task.setTargSite(site.getSite() + "");
- } else {
- task.setTargSite(LocManageUtil.getTargetSite());
- }
- if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) {
- List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode()));
-// if (!locs.isEmpty()) {
-// throw new CoolException("搴撲綅閿欒锛氱浉鍚屽簱浣嶅簲鍙竴鏉�")
-// }
- Loc loc = locs.stream().findFirst().get();
- task.setTargSite(loc.getCode());
- } else {
- task.setTargSite(LocManageUtil.getTargetSite());
- }
+// if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) {
+// DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId());
+// task.setTargSite(site.getSite() + "");
+// } else {
+// task.setTargSite(LocManageUtil.getTargetSite());
+// }
+// if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) {
+// List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode()));
+//// if (!locs.isEmpty()) {
+//// throw new CoolException("搴撲綅閿欒锛氱浉鍚屽簱浣嶅簲鍙竴鏉�")
+//// }
+// Loc loc = locs.stream().findFirst().get();
+// task.setTargSite(loc.getCode());
+// } else {
+// task.setTargSite(LocManageUtil.getTargetSite());
+// }
if (!this.save(task)) {
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
@@ -155,6 +172,13 @@
if (!taskItemService.saveBatch(taskItems)) {
throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
}
+ waitPakinItems.forEach(item -> {
+ if (! waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
+ .set(WaitPakinItem::getWorkQty, item.getAnfme())
+ .eq(WaitPakinItem::getId, item.getId()))) {
+ throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
+ }
+ });
});
if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -188,8 +212,8 @@
/**瀵逛换鍔℃槑缁嗘寜浠诲姟涓诲崟杩涜鍒嗙粍*/
listMap.keySet().forEach(key -> {
List<TaskItem> items = listMap.get(key);
- //鏇存柊搴撲綅鏄庣粏
try {
+ //鏇存柊搴撲綅鏄庣粏
saveLocItem(items, key);
} catch (Exception e) {
throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
@@ -207,9 +231,11 @@
throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨暟鎹笉瀛樺湪锛岃鑱旂郴绠$悊鍛橈紒锛�");
}
List<TaskItem> items = orderMap.get(key);
- //淇濆瓨搴撳瓨鏄庣粏
try {
+ //淇濆瓨搴撳瓨鏄庣粏
saveStockItems(items, pakinItem);
+ //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵��
+ removeReceiptStock(pakinItem);
} catch (Exception e) {
throw new CoolException("搴撳瓨绠$悊淇濆瓨鏇存柊澶辫触锛侊紒");
}
@@ -225,13 +251,49 @@
/**
* @author Ryan
+ * @description 绉婚櫎鏀惰揣鍖哄簱瀛�
+ * @param
+ * @return
+ * @time 2025/4/30 16:32
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void removeReceiptStock(WaitPakinItem pakinItem) {
+ WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
+ .eq(WarehouseAreasItem::getTrackCode, pakinItem.getTrackCode())
+ .eq(WarehouseAreasItem::getSplrBatch, pakinItem.getBatch()));
+ if (Objects.isNull(itemServiceOne)) {
+ throw new CoolException("鏁版嵁閿欒锛岃鏌ョ湅璇疯揣鍖哄簱瀛樻槸鍚﹀瓨鍦紒锛�");
+ }
+ Double workQty = itemServiceOne.getWorkQty() - pakinItem.getAnfme();
+ Double qty = itemServiceOne.getQty() + pakinItem.getAnfme();
+ itemServiceOne.setWorkQty(workQty).setQty(qty);
+
+ if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
+ .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
+ .eq(WaitPakin::getId, pakinItem.getPakinId()))) {
+ throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+
+ if (qty.compareTo(itemServiceOne.getAnfme()) == 0.00) {
+ if (!warehouseAreasItemService.removeById(itemServiceOne.getId())) {
+ throw new CoolException("鏀惰揣鍖虹墿鏂欏垹闄ゅけ璐ワ紒锛�");
+ }
+ } else {
+ if (!warehouseAreasItemService.updateById(itemServiceOne)) {
+ throw new CoolException("鏀惰揣鍖哄簱瀹屾垚鏁伴噺淇敼澶辫触锛侊紒");
+ }
+ }
+ }
+
+ /**
+ * @author Ryan
* @description 鏇存柊搴撲綅鏄庣粏
* @param
* @return
* @time 2025/4/15 15:28
*/
@Transactional(rollbackFor = Exception.class)
- void saveLocItem(List<TaskItem> items, Long taskId) throws Exception {
+ public void saveLocItem(List<TaskItem> items, Long taskId) throws Exception {
Task task = this.getById(taskId);
if (Objects.isNull(task)) {
throw new CoolException("浠诲姟涓嶅瓨鍦�!!");
@@ -241,7 +303,10 @@
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()), false);
LocItem item = new LocItem();
BeanUtils.copyProperties(taskItem, item);
- item.setLocCode(loc.getCode()).setId(null).setLocId(loc.getId()).setType(taskItem.getOrderType());
+ item.setLocCode(loc.getCode()).setId(null)
+ .setLocId(loc.getId())
+ .setWkType(taskItem.getWkType())
+ .setType(taskItem.getOrderType());
locItems.add(item);
});
if (!locItemService.saveBatch(locItems)) {
@@ -255,7 +320,7 @@
* @return
*/
@Transactional(rollbackFor = Exception.class)
- void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception {
+ public void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception {
Stock stock = new Stock();
// if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) {
// Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode()));
--
Gitblit v1.9.1