From 2fa1c824c63048b49e45d867191ab3645aeaf3a4 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期四, 30 四月 2026 09:54:40 +0800
Subject: [PATCH] 补充收货
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 200 insertions(+), 32 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 9b841c4..8b6c53f 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
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
@@ -56,8 +55,13 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@@ -175,7 +179,9 @@
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
}
if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -207,6 +213,7 @@
throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
}
});
+ syncAsnOrderItemBarcodeByPakin(waitPakinItems, pakin.getBarcode(), loginUserId);
});
if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -264,7 +271,8 @@
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
- .set(Loc::getBarcode, pakin.getBarcode()))) {
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -296,6 +304,7 @@
throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
}
});
+ syncAsnOrderItemBarcodeByPakin(waitPakinItems, pakin.getBarcode(), loginUserId);
});
if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -406,7 +415,9 @@
if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+ .set(Loc::getBarcode, pakin.getBarcode())
+ .set(Loc::getWeight, task.getWeight()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
}
/**鑾峰彇缁勬嫋鏄庣粏**/
@@ -446,6 +457,7 @@
throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
}
});
+ syncAsnOrderItemBarcodeByPakin(waitPakinItems, pakin.getBarcode(), loginUserId);
});
if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -456,6 +468,27 @@
throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
+ }
+
+ /** 缁勬墭鍚庡皢閫氱煡鍗曟槑缁嗘潯鐮佸洖鍐欎负鏂欑鐮� */
+ private void syncAsnOrderItemBarcodeByPakin(List<WaitPakinItem> waitPakinItems, String pakinBarcode, Long loginUserId) {
+ if (waitPakinItems == null || waitPakinItems.isEmpty() || StringUtils.isBlank(pakinBarcode)) {
+ return;
+ }
+ Set<Long> asnItemIds = waitPakinItems.stream()
+ .map(WaitPakinItem::getAsnItemId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ if (asnItemIds.isEmpty()) {
+ return;
+ }
+ if (!asnOrderItemService.update(new LambdaUpdateWrapper<WkOrderItem>()
+ .in(WkOrderItem::getId, asnItemIds)
+ .set(WkOrderItem::getBarcode, pakinBarcode)
+ .set(WkOrderItem::getUpdateBy, loginUserId)
+ .set(WkOrderItem::getUpdateTime, new Date()))) {
+ throw new CoolException("閫氱煡鍗曟槑缁嗘潯鐮佸洖鍐欏け璐ワ紒锛�");
+ }
}
/**
@@ -590,15 +623,44 @@
if (StringUtils.isNotBlank(task.getTaskCode())) {
rcsBusTaskNoticeService.notifyTaskStatus(task.getTaskCode(), task.getTaskStatus());
}
+ final Long taskIdForFinish = task.getId();
+ if (TransactionSynchronizationManager.isSynchronizationActive()) {
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+ @Override
+ public void afterCommit() {
+ taskService.runStockFinishAfterManualComplete(taskIdForFinish);
+ }
+ });
+ }
return task;
}
+ @Override
+ public void runStockFinishAfterManualComplete(Long taskId) {
+ if (taskId == null) {
+ return;
+ }
+ try {
+ Task t = taskService.getById(taskId);
+ if (t == null) {
+ return;
+ }
+ if (Objects.equals(t.getTaskStatus(), TaskStsType.COMPLETE_IN.id)) {
+ taskService.complateInTask(Collections.singletonList(t));
+ } else if (Objects.equals(t.getTaskStatus(), TaskStsType.COMPLETE_OUT.id)) {
+ taskService.completeTask(Collections.singletonList(t));
+ }
+ } catch (Exception e) {
+ log.warn("鎵嬪姩瀹岀粨鍚庣珛鍗冲簱瀛樻敹灏惧け璐ワ紝灏嗙敱瀹氭椂浠诲姟閲嶈瘯锛宼askId={}锛歿}", taskId, e.getMessage());
+ }
+ }
+
/**
- * 鍏ㄧ増鍑哄簱瀹岀粨锛氭墸闄ゅ簱浣嶆暟閲忥紝灏嗗簱浣嶇姸鎬佽涓虹┖
+ * 鍏ㄦ澘鍑哄簱瀹岀粨锛氭墸闄ゅ簱浣嶆暟閲忥紝灏嗗簱浣嶇姸鎬佽涓虹┖
*
* @param id 浠诲姟ID
* @param loginUserId 鐧诲綍鐢ㄦ埛ID
- * @param notifyRcsFromAdmin 绠$悊鍚庡彴鍏ㄧ増鍑哄簱瀹岀粨鎺ュ彛涓� true 鏃堕�氱煡 RCS锛涘畾鏃�/PDA 绛変负 false
+ * @param notifyRcsFromAdmin 绠$悊鍚庡彴鍏ㄦ澘鍑哄簱瀹岀粨鎺ュ彛涓� true 鏃堕�氱煡 RCS锛涘畾鏃�/PDA 绛変负 false
* @return 浠诲姟瀵硅薄
*/
@Override
@@ -612,9 +674,9 @@
throw new CoolException("浠诲姟涓嶅瓨鍦紒锛�");
}
- // 妫�鏌ヤ换鍔$被鍨嬫槸鍚︿负鍏ㄧ増鍑哄簱
+ // 妫�鏌ヤ换鍔$被鍨嬫槸鍚︿负鍏ㄦ澘鍑哄簱
if (!task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
- throw new CoolException("褰撳墠浠诲姟涓嶆槸鍏ㄧ増鍑哄簱浠诲姟锛屾棤娉曟墽琛屾鎿嶄綔锛侊紒");
+ throw new CoolException("褰撳墠浠诲姟涓嶆槸鍏ㄦ澘鍑哄簱浠诲姟锛屾棤娉曟墽琛屾鎿嶄綔锛侊紒");
}
// 妫�鏌ヤ换鍔$姸鎬侊細蹇呴』鏄�199锛圵AVE_SEED锛夌姸鎬佹墠鑳芥墜鍔ㄥ畬缁�
@@ -643,6 +705,7 @@
// 灏嗗簱浣嶇姸鎬佽涓虹┖锛圤鐘舵�侊級
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
@@ -802,6 +865,7 @@
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, task.getBarcode())
+ .set(Loc::getWeight, task.getWeight())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
@@ -811,6 +875,7 @@
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
@@ -873,6 +938,7 @@
// }
loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
.setBarcode(task.getBarcode())
+ .setWeight(task.getWeight())
.setUpdateBy(loginUserId).setUpdateTime(new Date());
if (!locService.updateById(loc)) {
@@ -945,14 +1011,24 @@
List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type,
TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type,
TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type);
- List<Task> allTasks = this.list(new LambdaQueryWrapper<Task>()
- .in(Task::getTaskType, list)
- .in(Task::getId, (Object[]) ids));
-
- if (allTasks.isEmpty()) {
+ List<Task> tasksById = this.list(new LambdaQueryWrapper<Task>().in(Task::getId, (Object[]) ids));
+ if (tasksById.isEmpty()) {
throw new CoolException("浠诲姟涓嶅瓨鍦紒锛�");
}
-
+ // 鎷f枡鍑哄簱/鐩樼偣鍑哄簱杩涘叆鍐嶅叆搴撻樁娈靛悗绂佹鍙栨秷锛堜换鍔$被鍨嬪凡鐢� 103/107 鍙樹负鍐嶅叆搴擄級
+ for (Task t : tasksById) {
+ if (TaskType.TASK_TYPE_PICK_IN.type.equals(t.getTaskType())
+ || TaskType.TASK_TYPE_CHECK_IN.type.equals(t.getTaskType())) {
+ throw new CoolException("鎷f枡/鐩樼偣鍑哄簱宸茶繘鍏ュ啀鍏ュ簱闃舵锛岀姝㈠彇娑堬紒锛�");
+ }
+ }
+ List<Task> allTasks = tasksById.stream()
+ .filter(t -> list.contains(t.getTaskType()))
+ .collect(Collectors.toList());
+ if (allTasks.isEmpty()) {
+ throw new CoolException("褰撳墠浠诲姟绫诲瀷涓嶆敮鎸佸彇娑堬紒锛�");
+ }
+
// 鏀堕泦闇�瑕佸彇娑堢殑RCS浠诲姟缂栧彿鍜屾壒娆$紪鍙凤紙涓嶉檺鍒剁姸鎬侊紝鍙宸蹭笅鍙戝埌RCS灏遍渶瑕佸彇娑堬級
List<String> rcsTaskCodes = new ArrayList<>();
String batchNo = null;
@@ -1029,6 +1105,10 @@
log.info("RCS鍙栨秷浠诲姟鍝嶅簲鐘舵�佺爜锛歿}", exchange.getStatusCode());
log.info("RCS鍙栨秷浠诲姟鍝嶅簲浣擄細{}", exchange.getBody());
+ if (!exchange.getStatusCode().is2xxSuccessful()) {
+ throw new CoolException("RCS鍙栨秷浠诲姟澶辫触锛欻TTP " + exchange.getStatusCode().value());
+ }
+
if (Objects.isNull(exchange.getBody())) {
log.error("RCS鍙栨秷浠诲姟澶辫触锛氬搷搴斾綋涓虹┖");
throw new CoolException("RCS鍙栨秷浠诲姟澶辫触锛氬搷搴斾綋涓虹┖");
@@ -1058,7 +1138,7 @@
}
}
- // 鍙彇娑堢姸鎬侊細鍘� 1/101锛堜笉鍚� 199锛夛紱鎷f枡/鐩樼偣鍑哄簱 RCS 鎵ц涓�(<198)锛涙嫞鏂�/鐩樼偣鍐嶅叆搴�(53/57)涓嶆敮鎸佸彇娑�
+ // 鍙彇娑堢姸鎬侊細鍘� 1/101锛堜笉鍚� 199锛夛紱鎷f枡/鐩樼偣鍑哄簱 RCS 鎵ц涓�(<198)锛涘啀鍏ュ簱(53/57)鍦ㄦ柟娉曞叆鍙e凡绂佹鍙栨秷
List<Task> tasks = this.list(new LambdaQueryWrapper<Task>()
.in(Task::getTaskType, list)
.in(Task::getId, (Object[]) ids)
@@ -1090,7 +1170,9 @@
}
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.eq(Loc::getCode, task.getTargLoc())
- .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) {
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null))) {
throw new CoolException("绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
@@ -1142,6 +1224,14 @@
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) {
throw new CoolException("婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�");
}
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) {
+ // 绌烘澘鍑哄簱锛氬缓鍗曟椂 D鈫扲锛屽彇娑堟仮澶嶄负绌烘澘 D
+ if (!locService.update(new LambdaUpdateWrapper<Loc>()
+ .eq(Loc::getCode, task.getOrgLoc())
+ .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type))) {
+ throw new CoolException("绌烘澘鍑哄簱婧愬簱浣嶆仮澶嶇┖鏉垮け璐ワ紒锛�");
+ }
}
if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) {
@@ -1178,13 +1268,14 @@
}
loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
.setBarcode(task.getBarcode())
+ .setWeight(task.getWeight())
.setUpdateBy(loginUserId)
.setUpdateTime(new Date());
if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅淇℃伅淇敼澶辫触锛侊紒");
}
//鍑哄簱
- if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))) {
+ if (Objects.equals(item.getWkType(), OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)) {
//搴撳瓨鍑哄簱
} else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) {
WaveItem waveItem = waveItemService.getById(item.getSource());
@@ -1206,7 +1297,7 @@
throw new CoolException("娉㈡鏇存柊澶辫触锛侊紒");
}
- } else if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER.type))) {
+ } else if (Objects.equals(item.getWkType(), OrderWorkType.ORDER_WORK_TYPE_OTHER.type)) {
//鍏跺畠鍑哄簱
} else {
@@ -1252,7 +1343,9 @@
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTaskType() < TaskStsType.UPDATED_IN.id ? task.getTargLoc() : task.getOrgLoc()));
if (null != loc && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)
|| loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) {
- loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
+ loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type)
+ .setBarcode(null)
+ .setWeight(null);
if (!locService.updateById(loc)) {
throw new CoolException("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�");
}
@@ -1491,7 +1584,8 @@
throw new CoolException("涓存椂搴撳瓨鏇存柊澶辫触锛侊紒");
}
}
- loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
+ .setWeight(task.getWeight());
locService.updateById(loc1);
// if (!locService.updateById(loc1)) {
// throw new CoolException("搴撲綅棰勭害鍏ュ簱澶辫触锛侊紒");
@@ -1616,11 +1710,13 @@
if (!workings.isEmpty()) {
locItemWorkingService.saveBatch(workings);
}
- loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type)
+ .setWeight(first.getWeight());
locService.updateById(loc);
} else {
loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
loc.setBarcode(null);
+ loc.setWeight(null);
loc.setUpdateBy(loginUserId);
loc.setUpdateTime(new Date());
locService.updateById(loc);
@@ -1659,6 +1755,7 @@
.eq(Loc::getId, loc.getId())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date()))) {
throw new CoolException("绌烘澘鍑哄簱搴撲綅鐘舵�佹洿鏂板け璐ワ紒锛�");
@@ -1725,7 +1822,7 @@
try {
// 鏍规嵁浠诲姟绫诲瀷鏇存柊搴撲綅鏄庣粏
if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
- // 鍏ㄧ増鍑哄簱锛氫笉鍒犻櫎搴撲綅鏄庣粏锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶅垹闄�
+ // 鍏ㄦ澘鍑哄簱锛氫笉鍒犻櫎搴撲綅鏄庣粏锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶅垹闄�
// subtractLocItem(loc); // 宸茬Щ闄わ紝鏀逛负鍦╟ompleteFullOutStock涓垹闄�
} else if (!TaskType.TASK_TYPE_PICK_AGAIN_OUT.type.equals(task.getTaskType())) {
// 閮ㄥ垎鍑哄簱锛堝鐩樼偣鍑哄簱锛夛細鏍规嵁TaskItem鏁伴噺鎵e噺搴撲綅鏄庣粏锛涙嫞鏂欏嚭搴撳湪鐢熸垚鎷f枡鍏ュ簱鍗曟椂鎵e噺
@@ -1738,12 +1835,12 @@
}
//娣诲姞鍑哄叆搴撹褰曚俊鎭�
- Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
+ Map<String, 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));
+ List<TaskItem> list = listMap.get(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 -> {
@@ -1794,13 +1891,14 @@
// 鎷f枡鍑哄簱/鐩樼偣鍑哄簱锛氬湪鏈敓鎴愭嫞鏂欏叆搴撳崟涔嬪墠淇濇寔 R.棰勭害鍑哄簱锛屽惁鍒欎笅鍙戜换鍔℃椂鏌ヤ笉鍒拌搴撲綅锛堝彧鏌� F+R锛夊鑷粹�滃簱瀛樹笉瓒斥��
// 绛� PDA 纭骞剁敓鎴愭嫞鏂欏叆搴撲换鍔℃椂锛屽啀鍦� pickOrCheckTask 涓皢鐩爣搴撲綅鏀逛负 S.棰勭害鍏ュ簱
} else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
- // 鍏ㄧ増鍑哄簱锛氫笉鏇存柊搴撲綅鐘舵�佷负O锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶆洿鏂�
+ // 鍏ㄦ澘鍑哄簱锛氫笉鏇存柊搴撲綅鐘舵�佷负O锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶆洿鏂�
// 搴撲綅鐘舵�佷繚鎸佸師鏍凤紙R.鍑哄簱棰勭害鐘舵�侊級
} else {
/**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
if (!locService.update(new LambdaUpdateWrapper<Loc>()
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
.set(Loc::getBarcode, null)
+ .set(Loc::getWeight, null)
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date())
.eq(Loc::getId, loc.getId()))) {
@@ -1914,13 +2012,13 @@
if (!asnOrderService.updateById(wkOrder)) {
throw new CoolException("鍑哄簱鍗曟洿鏂板け璐ワ紒锛�");
}
- stock.setWkType(Short.parseShort(wkOrder.getWkType()))
+ stock.setWkType(wkOrder.getWkType())
.setType(OrderType.ORDER_OUT.type);
} else if (!Objects.isNull(diffItem)) {
- stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type))
+ stock.setWkType(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type)
.setType(OrderType.ORDER_CHECK.type);
} else {
- stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))
+ stock.setWkType(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)
.setMemo("搴撳瓨鍑哄簱锛屾棤鍗曟嵁淇℃伅锛侊紒")
.setType(OrderType.ORDER_OUT.type);
}
@@ -2046,6 +2144,15 @@
log.error("========== RCS浠诲姟涓嬪彂澶辫触 ==========");
log.error("绔欑偣涓嶅瓨鍦紒锛佷换鍔$紪鐮侊細{}锛岀洰鏍囩珯鐐癸細{}", task.getTaskCode(), task.getTargSite());
continue;
+ }
+ // 鍑哄簱涓嬪彂鍓嶆牎楠岀珯鐐圭姸鎬佷笌鍑哄簱鑳藉姏
+ if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
+ if (!Integer.valueOf(1).equals(station.getStatus()) || !Integer.valueOf(1).equals(station.getOutAble())) {
+ log.error("========== RCS浠诲姟涓嬪彂澶辫触 ==========");
+ log.error("绔欑偣涓嶅彲鍑哄簱涓嬪彂锛侊紒浠诲姟缂栫爜锛歿}锛岀洰鏍囩珯鐐癸細{}锛岀珯鐐圭姸鎬�(status)锛歿}锛岃兘鍑�(outAble)锛歿}",
+ task.getTaskCode(), task.getTargSite(), station.getStatus(), station.getOutAble());
+ continue;
+ }
}
}
@@ -2219,6 +2326,13 @@
log.error("RCS璧勬簮璁块棶寮傚父锛屼换鍔′笅鍙戝け璐ワ紒浠诲姟缂栫爜锛歿}锛岄敊璇俊鎭細{}", task.getTaskCode(), errorMsg);
}
continue;
+ } catch (HttpStatusCodeException e) {
+ long endTime = System.currentTimeMillis();
+ log.error("========== RCS浠诲姟涓嬪彂寮傚父 ==========");
+ log.error("璇锋眰RCS-HTTP鐘舵�佸紓甯革紝鑰楁椂锛歿}ms锛屼换鍔$紪鐮侊細{}锛宻tatus锛歿}锛宐ody锛歿}", (endTime - startTime), task.getTaskCode(), e.getRawStatusCode(), e.getResponseBodyAsString(), e);
+ log.error("璇锋眰RCS-鍦板潃锛歿}", pubTakUrl);
+ log.error("璇锋眰RCS-鍙傛暟锛歿}", JSONObject.toJSONString(taskParams));
+ continue;
} catch (Exception e) {
long endTime = System.currentTimeMillis();
log.error("========== RCS浠诲姟涓嬪彂寮傚父 ==========");
@@ -2344,7 +2458,7 @@
/**
* @author Ryan
* @date 2025/5/20
- * @description: 鎵e噺搴撳瓨鏄庣粏锛堝叏鐗堝嚭搴擄細鍒犻櫎鎵�鏈夊簱浣嶆槑缁嗭級
+ * @description: 鎵e噺搴撳瓨鏄庣粏锛堝叏鏉垮嚭搴擄細鍒犻櫎鎵�鏈夊簱浣嶆槑缁嗭級
* @version 1.0
*/
@Transactional(rollbackFor = Exception.class)
@@ -2438,6 +2552,7 @@
if (TaskType.TASK_TYPE_EMPITY_IN.type.equals(task.getTaskType())) {
if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
.set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type)
+ .set(Loc::getWeight, task.getWeight())
.set(Loc::getUpdateBy, loginUserId)
.set(Loc::getUpdateTime, new Date()))) {
throw new CoolException("绌烘澘鍏ュ簱搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
@@ -2506,6 +2621,10 @@
WkOrder o = asnOrderService.getById(e.getKey());
if (o != null) {
Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(o.getQty() != null ? o.getQty() : 0.0, e.getValue()));
+ Double planQty = QuantityUtils.roundToScale(o.getAnfme() != null ? o.getAnfme() : 0.0);
+ if (QuantityUtils.compare(newQty, planQty) > 0) {
+ newQty = planQty;
+ }
o.setQty(newQty);
if (!asnOrderService.updateById(o)) {
throw new CoolException("鍏ュ簱鍗曞畬鎴愭暟閲忔洿鏂板け璐ワ紒锛�");
@@ -2516,6 +2635,10 @@
WkOrderItem oi = asnOrderItemService.getById(e.getKey());
if (oi != null) {
Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(oi.getQty() != null ? oi.getQty() : 0.0, e.getValue()));
+ Double planQty = QuantityUtils.roundToScale(oi.getAnfme() != null ? oi.getAnfme() : 0.0);
+ if (QuantityUtils.compare(newQty, planQty) > 0) {
+ newQty = planQty;
+ }
oi.setQty(newQty);
if (!asnOrderItemService.updateById(oi)) {
throw new CoolException("鍏ュ簱鍗曟槑缁嗗畬鎴愭暟閲忔洿鏂板け璐ワ紒锛�");
@@ -2524,7 +2647,10 @@
}
/**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
- if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
+ if (!locService.update(new LambdaUpdateWrapper<Loc>()
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)
+ .set(Loc::getWeight, task.getWeight())
+ .eq(Loc::getCode, task.getTargLoc()))) {
throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
}
if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
@@ -2645,7 +2771,7 @@
* @return
*/
@Transactional(rollbackFor = Exception.class)
- public synchronized void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) {
+ public synchronized void saveStockItems(List<TaskItem> items, Task task, Long id, String code, String wkType, String type, Long loginUserId) {
Stock stock = new Stock();
String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
if (StringUtils.isBlank(ruleCode)) {
@@ -2669,12 +2795,27 @@
} else {
stock.setLocCode(task.getOrgLoc());
}
+ BigDecimal trayWeight = task.getWeight();
+ BigDecimal groupWeight = null;
+ if (trayWeight != null && sum > 0) {
+ List<TaskItem> allLines = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+ double totalQty = allLines.stream().mapToDouble(t -> t.getAnfme() != null ? t.getAnfme() : 0.0).sum();
+ if (totalQty > 0) {
+ groupWeight = trayWeight.multiply(BigDecimal.valueOf(sum)).divide(BigDecimal.valueOf(totalQty), 4, RoundingMode.HALF_UP);
+ } else {
+ groupWeight = trayWeight;
+ }
+ stock.setWeight(groupWeight);
+ }
if (!stockService.save(stock)) {
throw new CoolException("搴撳瓨淇濆瓨澶辫触锛侊紒");
}
List<StockItem> stockItems = new ArrayList<>();
- for (TaskItem item : items) {
+ BigDecimal allocatedWeight = BigDecimal.ZERO;
+ BigDecimal sumBd = sum > 0 ? BigDecimal.valueOf(sum) : null;
+ for (int i = 0; i < items.size(); i++) {
+ TaskItem item = items.get(i);
/**閫氳繃浠诲姟鏄庣粏涓殑taskId鏌ヨ,鑾峰彇TASK鐨勭洰鏍囧簱浣嶄俊鎭�*/
StockItem stockItem = new StockItem();
BeanUtils.copyProperties(item, stockItem);
@@ -2685,6 +2826,16 @@
.setUpdateBy(loginUserId)
.setId(null)
.setStockId(stock.getId());
+ if (groupWeight != null && sumBd != null) {
+ if (i == items.size() - 1) {
+ stockItem.setWeight(groupWeight.subtract(allocatedWeight));
+ } else {
+ double lineQty = item.getAnfme() != null ? item.getAnfme() : 0.0;
+ BigDecimal lineW = groupWeight.multiply(BigDecimal.valueOf(lineQty)).divide(sumBd, 4, RoundingMode.HALF_UP);
+ stockItem.setWeight(lineW);
+ allocatedWeight = allocatedWeight.add(lineW);
+ }
+ }
stockItems.add(stockItem);
}
if (!stockItemService.saveBatch(stockItems)) {
@@ -2729,9 +2880,18 @@
}
}
}
+ // 鍏�/鍑哄簱鍧囦粎浜戜粨鏉ユ簮鍗曟嵁鍙備笌涓婃姤锛堟槑缁嗛渶甯� platOrderCode 鎴� platWorkCode锛�
+ boolean hasCloudSource = taskItems.stream().anyMatch(this::hasCloudOrderRef);
+ if (!hasCloudSource) {
+ log.info("鍏�/鍑哄簱缁撴灉涓婃姤寰呭姙璺宠繃锛氭棤浜戜粨鏉ユ簮鍗曟嵁锛宼askId={}", task.getId());
+ return;
+ }
ObjectMapper om = new ObjectMapper();
Date now = new Date();
for (TaskItem item : taskItems) {
+ if (!hasCloudOrderRef(item)) {
+ continue;
+ }
String orderNo = isInbound ? sourceToOrderNo.get(item.getSource()) : (item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode());
if (orderNo == null && isInbound) {
orderNo = item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode();
@@ -2770,4 +2930,12 @@
log.warn("鍏�/鍑哄簱缁撴灉涓婃姤寰呭姙澶辫触锛宼askId={}锛宨sInbound={}锛歿}", task.getId(), isInbound, e.getMessage());
}
}
+
+ private boolean hasCloudOrderRef(TaskItem item) {
+ if (item == null) {
+ return false;
+ }
+ return StringUtils.isNotBlank(item.getPlatOrderCode())
+ || StringUtils.isNotBlank(item.getPlatWorkCode());
+ }
}
--
Gitblit v1.9.1