From b5b400a615743a74e9d127261bd3785554aa06aa Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期六, 10 一月 2026 13:34:40 +0800
Subject: [PATCH] #
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 117 insertions(+), 0 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 251702c..cf7d0b9 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
@@ -446,6 +446,123 @@
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
+
+ /**
+ * @param loginUserId
+ * @author Munch D. Luffy
+ * @date 2026/01/10
+ * @description: WCS鍏ュ簱浠诲姟鐢宠
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public synchronized R generateTasksWcs(GenerateTaskParams waitPakin, Long loginUserId,List<Integer> rowList) {
+ if (Objects.isNull(waitPakin) || waitPakin.getWaitPakins().isEmpty()) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+
+ DeviceSite deviceSite = deviceSiteService.getById(waitPakin.getSiteId());
+ if (Objects.isNull(deviceSite)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+ }
+ DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(deviceSite.getSite()));
+ if (Cools.isEmpty(deviceBind)) {
+ throw new CoolException("搴撲綅瑙勫垯鏈煡");
+ }
+ WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
+ if (Cools.isEmpty(warehouseArea)) {
+ throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+ }
+
+ /**鑾峰彇缁勬嫋*/
+ List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
+ List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
+ .in(WaitPakin::getId, ids)
+ .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
+ if (waitPakins.isEmpty()) {
+ 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(), container.getContainerType(),rowList);
+ if (Cools.isEmpty(targetLoc)) {
+ throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
+ }
+
+ List<TaskItem> taskItems = new ArrayList<>();
+ String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
+ if (StringUtils.isBlank(ruleCode)) {
+ throw new CoolException("缂栫爜閿欒锛氳纭缂栫爜銆孲YS_TASK_CODE銆嶆槸鍚﹀凡鐢熸垚!!");
+ }
+ Task task = new Task();
+ task.setTaskCode(ruleCode)
+ .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
+ .setTaskType(TaskType.TASK_TYPE_IN.type)
+ .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
+ .setTargLoc(targetLoc)
+ .setBarcode(pakin.getBarcode())
+ .setOrgSite(deviceSite.getSite())
+ .setTargSite(deviceSite.getDeviceSite())
+ .setCreateBy(loginUserId)
+ .setUpdateBy(loginUserId);
+
+ if (!this.save(task)) {
+ 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("搴撲綅棰勭害澶辫触锛侊紒");
+ }
+ /**鑾峰彇缁勬嫋鏄庣粏**/
+ List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
+ if (waitPakinItems.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨槑缁嗕笉瀛樺湪");
+ }
+ waitPakinItems.forEach(item -> {
+ TaskItem taskItem = new TaskItem();
+ BeanUtils.copyProperties(item, taskItem);
+ taskItem.setTaskId(task.getId())
+ .setOrderType(OrderType.ORDER_IN.type)
+ .setSource(item.getId())
+ .setTrackCode(item.getTrackCode())
+ .setPlatItemId(item.getPlatItemId())
+ .setPlatOrderCode(item.getPlatOrderCode())
+ .setPlatWorkCode(item.getPlatWorkCode())
+ .setProjectCode(item.getProjectCode())
+ .setCreateBy(loginUserId)
+ .setUpdateBy(loginUserId)
+ .setExtendFields(item.getExtendFields())
+ .setOrderId(item.getAsnId())
+ .setOrderItemId(item.getAsnItemId());
+ taskItems.add(taskItem);
+ });
+ if (!taskItemService.saveBatch(taskItems)) {
+ throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
+ }
+ waitPakinItems.forEach(item -> {
+ if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
+ .set(WaitPakinItem::getWorkQty, item.getAnfme())
+ .eq(WaitPakinItem::getId, item.getId()))) {
+ throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
+ }
+ });
+ });
+
+ if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
+ .in(WaitPakin::getId, ids)
+ .set(WaitPakin::getUpdateBy, loginUserId)
+ .set(WaitPakin::getCreateBy, loginUserId)
+ .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
+ throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
+ }
+
/**
* 鍏ュ簱浠诲姟
*
--
Gitblit v1.9.1