From 409a68481bf07e3c3628d2b04cdbd113c72ac210 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期六, 07 二月 2026 10:57:50 +0800
Subject: [PATCH] 拣料
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 150 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 105 insertions(+), 45 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 5599cb5..de53eb0 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
@@ -508,22 +508,74 @@
@Override
@Transactional(rollbackFor = Exception.class)
public Task operateComplete(Long id, Long loginUserId) {
- List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
+ // 鍏堟煡璇换鍔★紝涓嶉檺鍒剁姸鎬�
Task task = taskService.getOne(new LambdaQueryWrapper<Task>()
- .eq(Task::getId, id)
- .in(Task::getTaskStatus, longs));
+ .eq(Task::getId, id));
if (Objects.isNull(task)) {
- throw new CoolException("鏁版嵁閿欒锛氬綋鍓嶄换鍔′笉鍙墽琛屽畬缁撴搷浣滐紒锛�");
+ throw new CoolException("浠诲姟涓嶅瓨鍦紒锛�");
+ }
+
+ // 鏍规嵁鍓嶇閫昏緫鍒ゆ柇鏄惁鍏佽瀹屾垚锛�
+ // 鍓嶇鏉′欢锛�((taskStatus < 98) || (taskType >= 101 && taskStatus < 198)) || (taskType == 11 && taskStatus == 101)
+ // 1. 浠讳綍浠诲姟鐘舵�� < 98 閮藉彲浠ュ畬鎴�
+ // 2. 鍑哄簱浠诲姟锛坱askType >= 101锛変笖鐘舵�� < 198 鍙互瀹屾垚
+ // 3. 搴撴牸绉昏浇锛坱askType == 11锛変笖鐘舵�� == 101 鍙互瀹屾垚
+ boolean canComplete = false;
+ if (task.getTaskStatus() < TaskStsType.COMPLETE_IN.id) {
+ // 浠讳綍浠诲姟鐘舵�� < 98 閮藉彲浠ュ畬鎴�
+ canComplete = true;
+ } else if (task.getTaskType() >= 101 && task.getTaskStatus() < TaskStsType.COMPLETE_OUT.id) {
+ // 鍑哄簱浠诲姟涓旂姸鎬� < 198
+ canComplete = true;
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)
+ && task.getTaskStatus().equals(TaskStsType.GENERATE_OUT.id)) {
+ // 搴撴牸绉昏浇涓旂姸鎬� == 101
+ canComplete = true;
+ }
+
+ if (!canComplete) {
+ throw new CoolException("鏁版嵁閿欒锛氬綋鍓嶄换鍔′笉鍙墽琛屽畬缁撴搷浣滐紒锛佷换鍔$被鍨嬶細" + task.getTaskType() + "锛屼换鍔$姸鎬侊細" + task.getTaskStatus());
}
modiftyTaskSort(task, loginUserId);
- //
-// if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-// task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
-// } else {
- task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.AWAIT.id);
-// }
+
+ // 濡傛灉浠诲姟鐘舵�佸凡缁忔槸AWAIT (196)锛屽啀娆$偣鍑诲畬缁撴椂锛岀洿鎺ュ畬鎴�
+ if (task.getTaskStatus().equals(TaskStsType.AWAIT.id)) {
+ // AWAIT鐘舵�佺殑浠诲姟鍐嶆瀹岀粨锛岀洿鎺ヨ缃负鍑哄簱瀹屾垚
+ task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
+
+ // 鏇存柊鍑哄簱绔欑偣鐘舵�侊紙涓嶳CS閫氱煡瀹岀粨淇濇寔涓�鑷达級
+ if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && StringUtils.isNotBlank(task.getTargSite())) {
+ BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getStationName, task.getTargSite()));
+ if (Objects.nonNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ station.setUseStatus(LocStsType.LOC_STS_TYPE_F.type);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鍑哄簱绔欑偣鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ }
+ }
+ } else {
+ // 鍏朵粬鎯呭喌鎸夊師鏈夐�昏緫澶勭悊
+ // 鍏ュ簱浠诲姟锛坱askType < 100锛夛細璁剧疆涓哄叆搴撳畬鎴�
+ // 鍑哄簱浠诲姟锛坱askType >= 100锛夛細璁剧疆涓虹瓑寰呯‘璁�
+ Integer newStatus = task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.AWAIT.id;
+ task.setTaskStatus(newStatus);
+
+ // 濡傛灉鏄叆搴撲换鍔″畬鎴愶紝鏇存柊鍏ュ簱绔欑偣鐘舵�侊紙涓嶳CS閫氱煡瀹岀粨淇濇寔涓�鑷达級
+ if (newStatus.equals(TaskStsType.COMPLETE_IN.id) && StringUtils.isNotBlank(task.getOrgSite())) {
+ BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getStationName, task.getOrgSite()));
+ if (Objects.nonNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ station.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鍏ュ簱绔欑偣鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ }
+ }
+ }
+
if (!this.updateById(task)) {
throw new CoolException("瀹屾垚浠诲姟澶辫触");
}
@@ -733,7 +785,7 @@
LocItem locItem = new LocItem();
LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>()
.eq(LocItemWorking::getTaskId, taskItem.getTaskId())
- .eq(LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex())
+ .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex())
.eq(StringUtils.isNotEmpty(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
.eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()));
if (Objects.isNull(locWorking)) {
@@ -1165,7 +1217,7 @@
tempLocs.forEach(working -> {
taskItems.forEach(taskItem -> {
- if (taskItem.getFieldsIndex().equals(working.getFieldsIndex())) {
+ if (Objects.equals(taskItem.getFieldsIndex(), 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;
@@ -1183,10 +1235,13 @@
}
});
});
- List<String> matnrIds = taskItems.stream().map(TaskItem::getFieldsIndex).collect(Collectors.toList());
+ List<String> matnrIds = taskItems.stream()
+ .map(TaskItem::getFieldsIndex)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
//鍒犻櫎涓庝换鍔℃槑缁嗛噸澶嶇殑搴撳瓨淇℃伅锛屼互浠诲姟鏄庣粏涓哄噯
List<LocItemWorking> itemWorkings = tempLocs.stream()
- .filter(working -> !matnrIds.contains(working.getFieldsIndex()))
+ .filter(working -> working.getFieldsIndex() != null && !matnrIds.contains(working.getFieldsIndex()))
.collect(Collectors.toList());
itemWorkings.forEach(working -> {
TaskItem taskItem = taskItems.stream().findFirst().get();
@@ -1264,32 +1319,31 @@
}
List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
- if (locItems.isEmpty()) {
- throw new CoolException("搴撲綅鏄庣粏涓嶅瓨鍦紒锛�");
- }
+ // 濡傛灉搴撲綅鏄庣粏涓虹┖锛屽彲鑳芥槸宸茬粡琚鐞嗚繃浜嗭紝鍏佽缁х画鎵ц
+ if (!locItems.isEmpty()) {
+ 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);
+ }
- 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 (!workings.isEmpty() && !locItemWorkingService.saveBatch(workings)) {
+ throw new CoolException("涓存椂搴撳瓨淇濆瓨澶辫触锛侊紒");
+ }
- if (!locItemWorkingService.saveBatch(workings)) {
- throw new CoolException("涓存椂搴撳瓨淇濆瓨澶辫触锛侊紒");
- }
-
- try {
- //鏇存柊搴撲綅鏄庣粏
- subtractLocItem(loc);
- } catch (Exception e) {
- logger.error("<UNK>", e);
- throw new CoolException(e.getMessage());
+ try {
+ //鏇存柊搴撲綅鏄庣粏
+ subtractLocItem(loc);
+ } catch (Exception e) {
+ logger.error("<UNK>", e);
+ throw new CoolException(e.getMessage());
+ }
}
//娣诲姞鍑哄叆搴撹褰曚俊鎭�
@@ -1845,9 +1899,8 @@
*/
@Transactional(rollbackFor = Exception.class)
public void subtractLocItem(Loc loc) throws Exception {
- if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()))) {
- throw new CoolException("搴撳瓨鏄庣粏鍒犻櫎澶辫触锛侊紒");
- }
+ // 鍒犻櫎搴撲綅鏄庣粏锛屽鏋滄病鏈夎褰曞垯蹇界暐锛堝彲鑳藉凡缁忚鍒犻櫎杩囦簡锛�
+ locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
}
/**
@@ -1889,8 +1942,10 @@
List<TaskItem> items = orderMap.get(key);
//淇濆瓨鍏ュ嚭搴撴槑缁�
saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
- //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵��
- removeReceiptStock(pakinItem, loginUserId);
+ //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵�侊紙鍙湁褰搒ource涓嶄负null鏃舵墠闇�瑕佺Щ闄ゆ敹璐у尯搴撳瓨锛�
+ if (Objects.nonNull(pakinItem.getSource())) {
+ removeReceiptStock(pakinItem, loginUserId);
+ }
});
Set<Long> pkinItemIds = taskItems.stream().map(TaskItem::getSource).collect(Collectors.toSet());
@@ -1926,6 +1981,10 @@
*/
@Transactional(rollbackFor = Exception.class)
public synchronized void removeReceiptStock(WaitPakinItem pakinItem, Long loginUserId) {
+ // 濡傛灉source涓簄ull锛岃鏄庣粍鎵樻槑缁嗕笉鍦ㄦ敹璐у尯锛屾棤闇�绉婚櫎鏀惰揣鍖哄簱瀛�
+ if (Objects.isNull(pakinItem.getSource())) {
+ return;
+ }
WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
.eq(WarehouseAreasItem::getId, pakinItem.getSource()));
if (Objects.isNull(itemServiceOne)) {
@@ -1973,7 +2032,8 @@
.eq(LocItem::getMatnrId, taskItem.getMatnrId())
.eq(LocItem::getLocId, loc.getId())
.eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch())
- .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex()));
+ .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex())
+ );
if (Objects.isNull(locItem)) {
BeanUtils.copyProperties(taskItem, item);
item.setLocCode(loc.getCode())
@@ -1986,7 +2046,7 @@
throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
}
} else {
- logger.error("褰撳墠绁ㄥ彿:" + locItem.getFieldsIndex() + " 宸插湪搴撳唴锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
+// logger.error("褰撳墠绁ㄥ彿:" + locItem.getFieldsIndex() + " 宸插湪搴撳唴锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
// throw new CoolException("褰撳墠绁ㄥ彿宸插湪搴撳唴锛岃妫�鏌ュ悗鍐嶆搷浣滐紒锛�");
// locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 1000000) / 1000000.0)
// .setUpdateTime(new Date());
--
Gitblit v1.9.1