From 11514b301466eb7598073d0126c6d9781daaa3ba Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期一, 09 三月 2026 14:00:40 +0800
Subject: [PATCH] 盘点流程
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 371 insertions(+), 18 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 1daacaa..bc755ee 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
@@ -8,7 +8,6 @@
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.vincent.rsf.framework.common.Cools;
-import com.vincent.rsf.framework.common.DateUtils;
import com.vincent.rsf.server.api.config.RemotesInfoProperties;
import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
import com.vincent.rsf.server.api.entity.CommonResponse;
@@ -34,7 +33,6 @@
import com.vincent.rsf.server.manager.enums.LocStsType;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
-import com.vincent.rsf.server.system.service.impl.ConfigServiceImpl;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import lombok.Synchronized;
@@ -150,11 +148,11 @@
}
Task task = new Task();
task.setTaskCode(ruleCode)
- .setTaskStatus(TaskStsType.GENERATE_IN.id)
+ .setTaskStatus(TaskStsType.MISSION_INITIAL.id)
.setTaskType(TaskType.TASK_TYPE_IN.type)
.setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)
.setTargLoc(targetLoc)
- .setTargSite(targSite)
+ //.setTargSite(targSite)//鍏ュ簱娌℃湁鐩爣绔欑偣
.setOrgSite(orgSta)
.setBarcode(pakin.getBarcode())
.setCreateBy(loginUserId)
@@ -494,12 +492,13 @@
throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
}
- List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
- if (!areaList.contains(area)) {
+ if (!basStation.getCrossZoneArea().contains(Integer.parseInt(area))) {
throw new CoolException("褰撳墠绔欑偣涓嶆敮鎸佺洰鏍囧簱鍖�");
}
if (!Cools.isEmpty(basStation.getContainerType())) {
- List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
+ List<Long> longs1 = basStation.getContainerType().stream()
+ .map(Integer::longValue)
+ .collect(Collectors.toList());
List<BasContainer> containers = basContainerService.list(
new LambdaQueryWrapper<BasContainer>()
.in(BasContainer::getContainerType, longs1)
@@ -558,7 +557,9 @@
throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
}
if (!Cools.isEmpty(basStation.getContainerType())) {
- List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
+ List<Long> longs1 = basStation.getContainerType().stream()
+ .map(Integer::longValue)
+ .collect(Collectors.toList());
List<BasContainer> containers = basContainerService.list(
new LambdaQueryWrapper<BasContainer>()
.in(BasContainer::getContainerType, longs1)
@@ -612,7 +613,9 @@
}
warehouseAreasList.add(warehouseArea);
} else {
- List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
+ List<Long> areaList = basStation.getCrossZoneArea().stream()
+ .map(Integer::longValue)
+ .collect(Collectors.toList());
if (areaList.isEmpty()) {
throw new CoolException("褰撳墠绔欑偣搴撳尯鏈厤缃�");
}
@@ -664,7 +667,7 @@
}
Task task = new Task();
task.setTaskCode(ruleCode)
- .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
+ .setTaskStatus(TaskStsType.MISSION_INITIAL.id)
.setTaskType(TaskType.TASK_TYPE_IN.type)
.setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
.setTargLoc(targetLoc)
@@ -761,6 +764,9 @@
} else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) {
//绉诲簱
complateInstockE(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) {
+ //瓒婂簱
+ complateInstockDocking(task, loginUserId);
}
}
}
@@ -984,6 +990,17 @@
if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) {
//110.绌烘澘鍑哄簱
complateOutStockEmpty(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) {
+ //109.澶囪揣
+ complateOutStockDocking(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
+ //107.鐩�
+// pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_CHECK);
+ complateOutStock2(task, loginUserId);
+// } else if () {
+// //103.鎷i��
+//// pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_PICK);
+// complateOutStock2(task, loginUserId);
} else {
complateOutStock(task, loginUserId);
}
@@ -1032,7 +1049,7 @@
.eq(LocItemWorking::getTaskId, taskItem.getTaskId())
.eq(LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex())
.eq(StringUtils.isNotEmpty(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
- .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()));
+ .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()).last("limit 1"));
if (Objects.isNull(locWorking)) {
continue;
}
@@ -1059,6 +1076,95 @@
throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
+ }
+
+ /**
+ * 瓒婂簱鍥炲簱
+ *
+ * @param task
+ * @param loginUserId
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void complateInstockDocking(Task task, Long loginUserId) {
+ if (Objects.isNull(task)) {
+ return;
+ }
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()));
+ if (Objects.isNull(loc)) {
+ throw new CoolException("搴撳瓨涓嶅瓨鍦紒锛�");
+ }
+// if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
+// throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
+// }
+ loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
+ .setBarcode(task.getBarcode())
+ .setUpdateBy(loginUserId).setUpdateTime(new Date());
+
+ if (!locService.updateById(loc)) {
+ throw new CoolException("搴撲綅淇℃伅鏇存柊澶辫触锛侊紒");
+ }
+
+
+
+ List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ if (taskItems.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocItem> list = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
+ list.forEach(item -> {
+ item.setOrderId(taskItems.get(0).getSourceId());
+ item.setType(taskItems.get(0).getOrderType());
+ item.setOrderItemId(taskItems.get(0).getSource());
+ item.setPlatOrderCode(taskItems.get(0).getSourceCode());
+ item.setWkType(taskItems.get(0).getWkType());
+ });
+
+ locItemService.updateBatchById(list);
+
+ TaskItem taskItem = taskItems.stream().findFirst().get();
+ //淇濆瓨鍏ュ嚭搴撴祦姘�
+ saveStockItems(taskItems, task, null, null, taskItem.getWkType(), OrderType.ORDER_IN.type, loginUserId);
+
+ locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
+
+ task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(new Date()).setUpdateBy(loginUserId);
+ if (!taskService.updateById(task)) {
+ throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ // 鐩樼偣鍐嶅叆搴撲换鍔$粨鏉燂細灏嗗叧鑱旂殑鐩樼偣宸紓鍗曠疆涓哄凡瀹℃牳
+ if (TaskType.TASK_TYPE_CHECK_IN.type.equals(task.getTaskType())) {
+ markCheckDiffApprovedWhenCheckInDone(task);
+ }
+ }
+
+ /**
+ * 鐩樼偣鍐嶅叆搴撳畬鎴愬悗锛屽皢鍏宠仈鐨勭洏鐐瑰樊寮傚崟缃负宸插鏍革紙鏈夊崟鎸� orderId锛屾棤鍗曟寜 鍑哄簱浠诲姟鍙� orderCode锛�
+ */
+ @Override
+ public void markCheckDiffApprovedWhenCheckInDone(Task checkInTask) {
+ List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, checkInTask.getId()).last("limit 1"));
+ Long orderId = items.isEmpty() ? null : items.get(0).getOrderId();
+ CheckDiff checkDiff = null;
+ if (orderId != null && !orderId.equals(0L)) {
+ checkDiff = checkDiffService.getOne(new LambdaQueryWrapper<CheckDiff>().eq(CheckDiff::getOrderId, orderId).last("limit 1"));
+ } else {
+ Task outTask = taskService.getOne(new LambdaQueryWrapper<Task>()
+ .eq(Task::getBarcode, checkInTask.getBarcode())
+ .eq(Task::getTaskType, TaskType.TASK_TYPE_CHECK_OUT.type)
+ .last("limit 1"));
+ if (outTask != null) {
+ checkDiff = checkDiffService.getOne(new LambdaQueryWrapper<CheckDiff>()
+ .eq(CheckDiff::getOrderCode, outTask.getTaskCode())
+ .and(w -> w.isNull(CheckDiff::getOrderId).or().eq(CheckDiff::getOrderId, 0))
+ .last("limit 1"));
+ }
+ }
+ if (checkDiff != null && !CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_END.val.equals(checkDiff.getExceStatus())) {
+ checkDiffService.update(new LambdaUpdateWrapper<CheckDiff>()
+ .eq(CheckDiff::getId, checkDiff.getId())
+ .set(CheckDiff::getExceStatus, CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_END.val));
+ }
}
/**
@@ -1281,7 +1387,7 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public Task pickOrCheckTask(Long id, String oType) throws Exception {
+ public synchronized Task pickOrCheckTask(Long id, String oType) throws Exception {
Task task = this.getById(id);
if (Objects.isNull(task)) {
throw new CoolException("褰撳墠浠诲姟涓嶅瓨鍦紒锛�");
@@ -1304,7 +1410,7 @@
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
.eq(Loc::getCode, task.getOrgLoc()));
if (Objects.isNull(loc)) {
- throw new CoolException("娌℃湁绌哄簱浣嶏紒锛�");
+ throw new CoolException("婧愬簱浣嶄笉瀛樺湪锛侊紒");
}
String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, task);
@@ -1312,14 +1418,19 @@
task.setTaskCode(ruleCode)
.setTaskType(type)
.setBarcode(task.getBarcode())
- .setTaskStatus(TaskStsType.GENERATE_IN.id);
+ .setTaskStatus(TaskStsType.MISSION_INITIAL.id);
TaskInParam param = new TaskInParam();
param.setSourceStaNo(task.getTargSite())
.setIoType(type)
.setLocType1(Integer.parseInt(loc.getType()));
//鑾峰彇鏂板簱浣�
- InTaskMsgDto locInfo = wcsService.getLocNo(param);
+ InTaskMsgDto locInfo = null;
+ try{
+ locInfo = wcsService.getLocNo(param);
+ } catch (Exception e) {
+ throw new CoolException("鑾峰彇搴撲綅澶辫触锛侊紒"+e.getMessage());
+ }
if (Objects.isNull(locInfo)) {
throw new CoolException("鑾峰彇搴撲綅澶辫触锛侊紒");
@@ -1345,7 +1456,7 @@
if (taskItem.getFieldsIndex().equals(working.getFieldsIndex())) {
Double minQty = taskItem.getAnfme();
if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
- minQty = Math.round((working.getAnfme() - taskItem.getQty()) * 1000000) / 1000000.0;
+ minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 1000000) / 1000000.0;
}
if (minQty.compareTo(0.0) >= 0) {
taskItem.setAnfme(minQty);
@@ -1424,7 +1535,7 @@
*/
@Synchronized
@Transactional(rollbackFor = Exception.class)
- public void complateOutStock(Task task, Long loginUserId) throws Exception {
+ public void complateOutStock2(Task task, Long loginUserId) throws Exception {
if (Objects.isNull(task)) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
@@ -1572,6 +1683,248 @@
*/
@Synchronized
@Transactional(rollbackFor = Exception.class)
+ public void complateOutStock(Task task, Long loginUserId) throws Exception {
+ if (Objects.isNull(task)) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
+ if (Objects.isNull(loc)) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+ }
+ if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勭悊浜嶳.鍑哄簱棰勭害锛侊紒");
+ }
+
+ List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ if (taskItems.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
+ if (locItems.isEmpty()) {
+ throw new CoolException("搴撲綅鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocItemWorking> workings = new ArrayList<>();
+ for (LocItem item : locItems) {
+ LocItemWorking working = new LocItemWorking();
+ BeanUtils.copyProperties(item, working);
+ working.setId(null)
+ .setTaskId(task.getId())
+ .setLocItemId(item.getId())
+ .setUpdateBy(loginUserId)
+ .setUpdateTime(new Date());
+ workings.add(working);
+ }
+
+ if (!locItemWorkingService.saveBatch(workings)) {
+ throw new CoolException("涓存椂搴撳瓨淇濆瓨澶辫触锛侊紒");
+ }
+
+ try {
+ //鏇存柊搴撲綅鏄庣粏
+ subtractLocItem(loc);
+ } catch (Exception e) {
+ logger.error("<UNK>", e);
+ throw new CoolException(e.getMessage());
+ }
+
+ //娣诲姞鍑哄叆搴撹褰曚俊鎭�
+ Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
+ /***鑾峰彇搴撳瓨鍑哄簱鍊硷紝濡傛灉涓虹┖琛ㄧず姝e父鍗曟嵁鍑哄簱锛岄潪绌鸿〃鏄庢槸搴撳瓨鍑哄簱
+ * 1. 搴撳瓨鍑哄簱娌℃湁鍗曟嵁淇℃伅锛屽崟鎹俊鎭粯璁や负绌�
+ * 2. 鍗曟嵁搴撳瓨闇�閫氳繃娉㈡鏌ヨ鍘熷鍗曟嵁淇℃伅锛屽皢鍗曟嵁淇℃伅濉叆stock涓�
+ * */
+ List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type));
+ if (Objects.isNull(list) || list.isEmpty()) {
+ Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
+ maps.keySet().forEach(key -> {
+ if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) {
+ WaveItem waveItem = waveItemService.getById(key);
+ if (Objects.isNull(waveItem)) {
+ throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+// try {
+// saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
+// } catch (Exception e) {
+// throw new CoolException(e.getMessage());
+// }
+ } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
+ WkOrderItem orderItem = asnOrderItemService.getById(key);
+ if (Objects.isNull(orderItem)) {
+ throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+ try {
+ saveOutStockItem(maps.get(key), orderItem, loginUserId);
+ } catch (Exception e) {
+ throw new CoolException(e.getMessage());
+ }
+ } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val)) {
+ WkOrderItem orderItem = asnOrderItemService.getById(key);
+ if (Objects.isNull(orderItem)) {
+ throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+ try {
+ saveOutStockItem(maps.get(key), null, null, orderItem, loginUserId);
+ } catch (Exception e) {
+ throw new CoolException(e.getMessage());
+ }
+ } else {
+
+ }
+ });
+ } else {
+ try {
+ saveOutStockItem(taskItems, null, null, null, loginUserId);
+ } catch (Exception e) {
+ throw new CoolException(e.getMessage());
+ }
+ }
+
+ /**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
+ if (!locService.update(new LambdaUpdateWrapper<Loc>()
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .set(Loc::getBarcode, null)
+ .set(Loc::getUpdateBy, loginUserId)
+ .set(Loc::getUpdateTime, new Date())
+ .eq(Loc::getId, loc.getId()))) {
+ throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+
+ if (!this.update(new LambdaUpdateWrapper<Task>()
+ .eq(Task::getId, task.getId())
+ .set(Task::getUpdateBy, loginUserId)
+ .set(Task::getUpdateTime, new Date())
+ .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
+ throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+ }
+
+// if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+// if (!this.update(new LambdaUpdateWrapper<Task>()
+// .eq(Task::getId, task.getId())
+// .set(Task::getUpdateBy, loginUserId)
+// .set(Task::getUpdateTime, new Date())
+// .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+// throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+// }
+// } else {
+// if (!this.update(new LambdaUpdateWrapper<Task>()
+// .eq(Task::getId, task.getId())
+// .set(Task::getUpdateBy, loginUserId)
+// .set(Task::getUpdateTime, new Date())
+// .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+// throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+// }
+//// //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
+//// if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
+//// throw new CoolException("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒");
+//// }
+// }
+
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/5/20
+ * @description: 瀹屾垚瓒婂簱浠诲姟锛屾洿鏂板嚭搴撳簱瀛樹俊鎭�
+ * @version 1.0
+ */
+ @Synchronized
+ @Transactional(rollbackFor = Exception.class)
+ public void complateOutStockDocking(Task task, Long loginUserId) throws Exception {
+
+ if (Objects.isNull(task)) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
+ if (Objects.isNull(loc)) {
+ throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+ }
+ if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
+ throw new CoolException("搴撲綅鐘舵�佷笉澶勭悊浜嶳.鍑哄簱棰勭害锛侊紒");
+ }
+
+ List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ if (taskItems.isEmpty()) {
+ throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
+ if (locItems.isEmpty()) {
+ throw new CoolException("搴撲綅鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocItemWorking> workings = new ArrayList<>();
+ for (LocItem item : locItems) {
+ LocItemWorking working = new LocItemWorking();
+ BeanUtils.copyProperties(item, working);
+ working.setId(null)
+ .setTaskId(task.getId())
+ .setLocItemId(item.getId())
+ .setUpdateBy(loginUserId)
+ .setUpdateTime(new Date());
+ workings.add(working);
+ }
+
+
+ //娣诲姞鍑哄叆搴撹褰曚俊鎭�
+ Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
+ /***鑾峰彇搴撳瓨鍑哄簱鍊硷紝濡傛灉涓虹┖琛ㄧず姝e父鍗曟嵁鍑哄簱锛岄潪绌鸿〃鏄庢槸搴撳瓨鍑哄簱
+ * 1. 搴撳瓨鍑哄簱娌℃湁鍗曟嵁淇℃伅锛屽崟鎹俊鎭粯璁や负绌�
+ * 2. 鍗曟嵁搴撳瓨闇�閫氳繃娉㈡鏌ヨ鍘熷鍗曟嵁淇℃伅锛屽皢鍗曟嵁淇℃伅濉叆stock涓�
+ * */
+ List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type));
+ if (Objects.isNull(list) || list.isEmpty()) {
+ Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
+ maps.keySet().forEach(key -> {
+ if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)) {
+ WkOrderItem orderItem = asnOrderItemService.getById(key);
+ if (Objects.isNull(orderItem)) {
+ throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+ try {
+ saveOutStockItem(taskItems, orderItem, null, null, loginUserId);
+ } catch (Exception e) {
+ throw new CoolException(e.getMessage());
+ }
+ }
+ });
+ } else {
+ try {
+ saveOutStockItem(taskItems, null, null, null, loginUserId);
+ } catch (Exception e) {
+ throw new CoolException(e.getMessage());
+ }
+ }
+
+ /**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
+ if (!locService.update(new LambdaUpdateWrapper<Loc>()
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+ .set(Loc::getBarcode, loc.getBarcode())
+ .set(Loc::getUpdateBy, loginUserId)
+ .set(Loc::getUpdateTime, new Date())
+ .eq(Loc::getId, loc.getId()))) {
+ throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+
+ if (!this.update(new LambdaUpdateWrapper<Task>()
+ .eq(Task::getId, task.getId())
+ .set(Task::getUpdateBy, loginUserId)
+ .set(Task::getUpdateTime, new Date())
+ .set(Task::getTargLoc, task.getOrgLoc())
+ .set(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id))) {
+ throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+ }
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/5/20
+ * @description: 瀹屾垚鍑哄簱浠诲姟锛屾洿鏂板嚭搴撳簱瀛樹俊鎭�
+ * @version 1.0
+ */
+ @Synchronized
+ @Transactional(rollbackFor = Exception.class)
public void complateOutStockEmpty(Task task, Long loginUserId) throws Exception {
if (Objects.isNull(task)) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
@@ -1598,7 +1951,7 @@
.eq(Task::getId, task.getId())
.set(Task::getUpdateBy, loginUserId)
.set(Task::getUpdateTime, new Date())
- .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+ .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
}
}
--
Gitblit v1.9.1