From ffa9d4d80998832aa036211fc4c7db2572c9b52e Mon Sep 17 00:00:00 2001
From: zc <zyzc>
Date: 星期五, 21 十一月 2025 15:34:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/devlop_whxrwms' into devlop_whxrwms
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 149 ++++++++++++++++++++++++++++++-------------------
1 files changed, 91 insertions(+), 58 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 0604bc7..36f4f97 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
@@ -23,6 +23,7 @@
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import com.vincent.rsf.server.system.utils.SystemAuthUtils;
import lombok.Synchronized;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +35,7 @@
import java.util.*;
import java.util.stream.Collectors;
+@Slf4j
@Service("taskService")
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
@@ -91,6 +93,8 @@
private CheckDiffService checkDiffService;
@Autowired
private CheckDiffItemService checkDiffItemService;
+ @Autowired
+ private BasContainerService basContainerService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -303,8 +307,13 @@
throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
}
waitPakins.forEach(pakin -> {
+ BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
+ .eq(BasContainer::getCode, pakin.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
+ }
/**鑾峰彇搴撲綅*/
- String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId());
+ String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
if (Cools.isEmpty(targetLoc)) {
throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
}
@@ -345,6 +354,18 @@
if (!this.save(task)) {
throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
}
+ BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getStationName, deviceSite.getSite()));
+ if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦ㄦ垨绔欑偣涓嶅浜庣┖搴撶姸鎬侊紒锛�");
+ }
+ station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+
+ if (!basStationService.updateById(station)) {
+ 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()))) {
throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
@@ -406,22 +427,24 @@
*/
@Synchronized
@Override
- @Transactional(rollbackFor = Exception.class)
public void complateInTask(List<Task> tasks) throws Exception {
Long loginUserId = SystemAuthUtils.getLoginUserId();
for (Task task : tasks) {
- if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
- //1.鍏ュ簱
- complateInstock(task, loginUserId);
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
- //53.鎷f枡鍐嶅叆搴�
- //57.鐩樼偣鍐嶅叆搴�
- pickComplateInStock(task, loginUserId);
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- //绉诲簱
- moveInStock(task, loginUserId);
+ try {
+ if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
+ //1.鍏ュ簱
+ complateInstock(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
+ //53.鎷f枡鍐嶅叆搴�
+ //57.鐩樼偣鍐嶅叆搴�
+ pickComplateInStock(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ //绉诲簱
+ moveInStock(task, loginUserId);
+ }
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
}
-
}
}
@@ -590,7 +613,7 @@
//鏇存柊搴撲綅鏄庣粏
saveLocItem(taskItems, task.getId(), loginUserId);
} catch (Exception e) {
- throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
+ throw new CoolException("浠诲姟鍙凤細" + task.getTaskCode() + "搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
}
if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) {
@@ -635,7 +658,6 @@
*/
@Synchronized
@Override
- @Transactional(rollbackFor = Exception.class)
public void completeTask(List<Task> tasks) {
Long loginUserId = SystemAuthUtils.getLoginUserId();
for (Task task : tasks) {
@@ -643,7 +665,8 @@
try {
complateOutStock(task, loginUserId);
} catch (Exception e) {
- throw new CoolException(e.getMessage());
+ log.error(e.getMessage(), e);
+// throw new CoolException(e.getMessage());
}
}
}
@@ -663,10 +686,9 @@
if (Objects.isNull(loc)) {
throw new CoolException("搴撳瓨涓嶅瓨鍦紒锛�");
}
- if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
- throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
- }
-
+// 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());
@@ -685,6 +707,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.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
.eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()));
if (Objects.isNull(locWorking)) {
@@ -768,7 +791,6 @@
} else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, Arrays.asList(ids)));
if (!taskItems.isEmpty()) {
-
taskItems.forEach(taskItem -> {
if (!checkOrderItemService.update(new LambdaUpdateWrapper<WkOrderItem>()
.eq(WkOrderItem::getId, taskItem.getOrderItemId())
@@ -848,7 +870,7 @@
if (Objects.isNull(waveItem)) {
throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
}
- Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+ Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 100) / 100.0;
waveItem.setWorkQty(workQty).setExceStatus(WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val);
if (!waveItemService.updateById(waveItem)) {
throw new CoolException("娉㈡鏄庣粏鏇存柊澶辫触锛侊紒");
@@ -872,7 +894,7 @@
if (Objects.isNull(wkOrder)) {
throw new CoolException("鏁版嵁閿欒锛氬崟鎹凡涓嶅瓨鍦紒锛�");
}
- Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+ Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 100) / 100.0;
wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val)
.setWorkQty(workQty.compareTo(0.00) > 0 ? workQty : 0.00)
@@ -887,7 +909,7 @@
throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗗凡涓嶅瓨鍦紒锛�");
}
- Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0;
+ Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 100) / 100.0;
orderItem.setWorkQty(workItmQty);
if (!outStockItemService.updateById(orderItem)) {
@@ -979,7 +1001,8 @@
if (Objects.isNull(locInfo)) {
throw new CoolException("鑾峰彇搴撲綅澶辫触锛侊紒");
}
- task.setTargLoc(locInfo.getLocNo());
+ task.setTargLoc(locInfo.getLocNo())
+ .setOrgSite(task.getTargSite());
if (!this.updateById(task)) {
throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
@@ -999,7 +1022,7 @@
if (taskItem.getMatnrId().equals(working.getMatnrId())) {
Double minQty = taskItem.getAnfme();
if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
- minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0;
+ minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 100) / 100.0;
}
if (minQty.compareTo(0.0) > 0) {
taskItem.setAnfme(minQty);
@@ -1008,16 +1031,16 @@
}
} else {
if (!taskItemService.removeById(taskItem)) {
- throw new CoolException("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
+ log.error("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
}
}
}
});
});
- List<Long> matnrIds = taskItems.stream().map(TaskItem::getMatnrId).collect(Collectors.toList());
+ List<String> matnrIds = taskItems.stream().map(TaskItem::getFieldsIndex).collect(Collectors.toList());
//鍒犻櫎涓庝换鍔℃槑缁嗛噸澶嶇殑搴撳瓨淇℃伅锛屼互浠诲姟鏄庣粏涓哄噯
List<LocItemWorking> itemWorkings = tempLocs.stream()
- .filter(working -> !matnrIds.contains(working.getMatnrId()))
+ .filter(working -> !matnrIds.contains(working.getFieldsIndex()))
.collect(Collectors.toList());
itemWorkings.forEach(working -> {
TaskItem taskItem = taskItems.stream().findFirst().get();
@@ -1138,11 +1161,11 @@
if (Objects.isNull(waveItem)) {
throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
}
- try {
- saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
- } catch (Exception e) {
- throw new CoolException(e.getMessage());
- }
+// 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)) {
@@ -1185,27 +1208,36 @@
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.UPDATED_OUT.id))) {
- throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
- //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
- if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.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.WAVE_SEED.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("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒");
+//// }
+// }
}
@@ -1230,6 +1262,7 @@
* @description: 鍑哄簱淇℃伅淇濆瓨鑷冲簱瀛樻槑缁嗚〃
* @version 1.0
*/
+ @Override
@Transactional(rollbackFor = Exception.class)
public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, WkOrderItem diffItem, Long loginUserId) throws Exception {
Stock stock = new Stock();
@@ -1247,7 +1280,7 @@
stock.setSourceId(waveItem.getId()).setType(OrderType.ORDER_OUT.type);
} else if (!Objects.isNull(orderItem) && StringUtils.isNotBlank(orderItem.getId() + "")) {
WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId());
- Double qty = Math.round((wkOrder.getQty() + sum) * 10000) / 10000.0;
+ Double qty = Math.round((wkOrder.getQty() + sum) * 100) / 100.0;
wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val)
.setQty(qty);
if (!asnOrderService.updateById(wkOrder)) {
@@ -1371,8 +1404,8 @@
if (Objects.isNull(itemServiceOne)) {
throw new CoolException("鏁版嵁閿欒锛氳鏌ョ湅璇疯揣鍖哄簱瀛樻槸鍚﹀瓨鍦紒锛�");
}
- Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 10000) / 10000.0;
- Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 10000) / 10000.0;
+ Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 100) / 100.0;
+ Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 100) / 100.0;
itemServiceOne.setWorkQty(workQty).setQty(qty);
if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -1431,7 +1464,7 @@
.setType(taskItem.getOrderType());
locItems.add(item);
} else {
- locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 10000) / 10000.0)
+ locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 100) / 100.0)
.setUpdateTime(new Date());
locItems.add(locItem);
}
--
Gitblit v1.9.1