From 98d88ac8caf7f0991d741079474c262f1e252927 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期五, 06 三月 2026 08:14:54 +0800
Subject: [PATCH] 拣货过程中的出库库存匹配
---
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index d2d1fc1..f1dd469 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -39,6 +39,7 @@
import com.vincent.rsf.server.manager.enums.LocStsType;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import lombok.extern.slf4j.Slf4j;
+import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -497,6 +498,8 @@
log.warn("[RCS鍏ュ簱鐢宠-鑷姩缁勬墭] 鍏ュ簱鍗曠紪鐮佽鍒欐湭閰嶇疆");
return;
}
+// val orderWorkTypeOtherIn = OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type;
+ // .setWkType(orderWorkTypeOtherIn)
WkOrder order = new WkOrder();
order.setCode(ruleCode)
.setType(OrderType.ORDER_IN.type)
@@ -578,10 +581,18 @@
*/
private Task createTask(String ruleCode, String targetLoc, String barcode,
String targetSite, String sourceSiteNo, Long loginUserId) {
+ return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type);
+ }
+
+ /**
+ * 鍒涘缓骞朵繚瀛樹换鍔★紙鏀寔鎸囧畾浠诲姟绫诲瀷锛屽绌烘澘鍏ュ簱锛�
+ */
+ private Task createTask(String ruleCode, String targetLoc, String barcode,
+ String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType) {
Task task = new Task();
task.setTaskCode(ruleCode)
.setTaskStatus(TaskStsType.GENERATE_IN.id)
- .setTaskType(TaskType.TASK_TYPE_IN.type)
+ .setTaskType(taskType != null ? taskType : TaskType.TASK_TYPE_IN.type)
.setWarehType(WarehType.WAREHOUSE_TYPE_CRN.val)
.setTargLoc(targetLoc)
.setBarcode(barcode)
@@ -607,6 +618,75 @@
if (!updated) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
+ }
+
+ /**
+ * 绌烘澘鍏ュ簱锛歊CS 鐢宠鏃� full=true锛屾棤闇�缁勬墭锛屽垎閰嶅簱浣嶅苟鍒涘缓 TASK_TYPE_EMPITY_IN 浠诲姟銆�
+ * 闇�鍦ㄨ澶囩珯鐐逛腑閰嶇疆 type=10锛堢┖鏉垮叆搴擄級鐨勭珯鐐硅矾寰勩��
+ */
+ private InTaskMsgDto createInTaskForEmptyPallet(String barcode, String staNo, Integer type) {
+ TaskInParam param = new TaskInParam();
+ param.setBarcode(barcode);
+ param.setSourceStaNo(staNo);
+ param.setLocType1(type != null ? type : 1);
+ param.setIoType(TaskType.TASK_TYPE_EMPITY_IN.type);
+ param.setUser(1L);
+
+ // 鏍¢獙璁惧绔欑偣锛堥渶閰嶇疆 type=10 绌烘澘鍏ュ簱鐨勭珯鐐癸級
+ DeviceSite deviceSite = validateDeviceSite(param);
+
+ // 妫�鏌ヨ鎵樼洏鍙锋槸鍚﹀凡鏈夌┖鏉垮叆搴撲换鍔★紝鏈夊垯澶嶇敤
+ Task existingInTask = taskService.getOne(new LambdaQueryWrapper<Task>()
+ .eq(Task::getBarcode, barcode)
+ .eq(Task::getTaskType, TaskType.TASK_TYPE_EMPITY_IN.type)
+ .orderByDesc(Task::getCreateTime)
+ .last("LIMIT 1"));
+ if (existingInTask != null) {
+ log.info("鎵惧埌璇ユ墭鐩樺彿宸叉湁绌烘澘鍏ュ簱浠诲姟锛屽鐢� - 浠诲姟缂栫爜锛歿}锛岀鍙凤細{}", existingInTask.getTaskCode(), barcode);
+ if (StringUtils.isNotBlank(staNo) && !staNo.equals(existingInTask.getOrgSite())) {
+ existingInTask.setOrgSite(staNo);
+ taskService.updateById(existingInTask);
+ }
+ InTaskMsgDto msgDto = new InTaskMsgDto();
+ msgDto.setWorkNo(existingInTask.getTaskCode());
+ msgDto.setTaskId(existingInTask.getId());
+ msgDto.setLocNo(existingInTask.getTargLoc());
+ msgDto.setSourceStaNo(existingInTask.getOrgSite());
+ msgDto.setStaNo(existingInTask.getTargSite());
+ return msgDto;
+ }
+
+ // 璇ユ墭鐩樺凡鍦ㄥ簱鎴栧嚭搴撲腑锛屼笉鍙噸澶嶇敵璇风┖鏉垮叆搴�
+ List<Loc> inStock = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, barcode));
+ if (!inStock.isEmpty()) {
+ throw new CoolException("barcode=" + barcode + ": 璇ユ墭鐩樺凡鍦ㄥ簱锛屼笉鍙噸澶嶇敵璇峰叆搴�");
+ }
+ Task outboundTask = taskService.getOne(new LambdaQueryWrapper<Task>()
+ .eq(Task::getBarcode, barcode)
+ .in(Task::getTaskType, Arrays.asList(TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_EMPITY_OUT.type,
+ TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, TaskType.TASK_TYPE_CHECK_OUT.type))
+ .lt(Task::getTaskStatus, TaskStsType.COMPLETE_OUT.id));
+ if (outboundTask != null) {
+ throw new CoolException("barcode=" + barcode + ": 璇ユ墭鐩樺嚭搴撲腑鏈畬鎴愶紝涓嶅彲鐢宠鍏ュ簱");
+ }
+
+ InTaskMsgDto locNo;
+ try {
+ locNo = getLocNo(param);
+ } catch (Exception e) {
+ throw new CoolException("鑾峰彇绌烘澘鍏ュ簱搴撲綅澶辫触锛�" + e.getMessage());
+ }
+ if (locNo == null || StringUtils.isBlank(locNo.getLocNo())) {
+ throw new CoolException("鏈壘鍒板彲鐢ㄧ殑绌哄簱浣嶏紝璇锋鏌ュ簱鍖轰笌璁惧绔欑偣閰嶇疆锛堢┖鏉垮叆搴撻渶閰嶇疆 type=10 鐨勭珯鐐癸級");
+ }
+ String ruleCode = generateTaskCode();
+ String targetSite = StringUtils.isNotBlank(deviceSite.getDeviceSite()) ? deviceSite.getDeviceSite() : staNo;
+ Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type);
+ updateLocStatus(task.getTargLoc(), barcode);
+ locNo.setWorkNo(ruleCode);
+ locNo.setTaskId(task.getId());
+ log.info("[绌烘澘鍏ュ簱] 宸插垱寤轰换鍔�: {}, 搴撲綅: {}, 鏂欑: {}", ruleCode, locNo.getLocNo(), barcode);
+ return locNo;
}
/**
@@ -1476,9 +1556,19 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public R allocateLocation(String barcode, String staNo, Integer type) {
+ public R allocateLocation(String barcode, String staNo, Integer type, Boolean full) {
log.info("========== 寮�濮嬬敵璇峰叆搴撲换鍔★紝鍒嗛厤搴撲綅 ==========");
- log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}", barcode, staNo, type);
+ log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岀┖鏉匡細{}", barcode, staNo, type, full);
+
+ // full=true 鏃惰蛋绌烘澘鍏ュ簱锛堟棤闇�缁勬墭锛夛紱鍚﹀垯璧版櫘閫氬叆搴擄紙闇�缁勬墭鎴栬嚜鍔ㄧ粍鎵橈級
+ if (Boolean.TRUE.equals(full)) {
+ InTaskMsgDto msgDto = createInTaskForEmptyPallet(barcode, staNo, type);
+ JSONObject result = new JSONObject();
+ result.put("locNo", msgDto.getLocNo());
+ result.put("batchNo", msgDto.getWorkNo());
+ result.put("taskNo", msgDto.getWorkNo());
+ return R.ok(result);
+ }
// 鏋勫缓 TaskInParam 鍙傛暟锛屼笌 /wcs/create/in/task 鎺ュ彛鍙傛暟涓�鑷�
TaskInParam param = new TaskInParam();
--
Gitblit v1.9.1