From eb3aa089103a0cdd3d2d160e074c3df98026a99b Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期一, 23 六月 2025 13:48:17 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java | 123 +++++++++++++++++++++++++++++++----------
1 files changed, 93 insertions(+), 30 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
index b10811a..c4890eb 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaveServiceImpl.java
@@ -1,22 +1,21 @@
package com.vincent.rsf.server.manager.service.impl;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
-import com.vincent.rsf.server.manager.enums.TaskStsType;
-import com.vincent.rsf.server.manager.enums.TaskType;
+import com.vincent.rsf.server.manager.enums.*;
import com.vincent.rsf.server.manager.entity.*;
-import com.vincent.rsf.server.manager.enums.AsnExceStatus;
-import com.vincent.rsf.server.manager.enums.WaveExceStatus;
import com.vincent.rsf.server.manager.mapper.WaveMapper;
import com.vincent.rsf.server.manager.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vincent.rsf.server.manager.utils.OptimalAlgorithmUtil;
import com.vincent.rsf.server.system.constant.SerialRuleCode;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
+import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -45,6 +44,8 @@
private LocItemService locItemService;
@Autowired
private LocService locService;
+ @Autowired
+ private OutStockService outStockService;
/**
* @param
@@ -61,33 +62,73 @@
if (Objects.isNull(itemParams) || itemParams.isEmpty()) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
- List<WaveItem> items = JSONArray.parseArray(JSONArray.toJSONString(itemParams), WaveItem.class);
String waveId = map.get("wave").toString();
Wave waves = this.getById(Long.parseLong(waveId));
if (Objects.isNull(waves)) {
throw new CoolException("娉㈡鏁版嵁涓嶅瓨鍦紒锛�");
}
- List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>().eq(WaveItem::getWaveId, waves.getId()));
+ List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>()
+ .eq(WaveItem::getWaveId, waves.getId())
+ .apply("anfme > work_qty"));
if (waveItems.isEmpty()) {
throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
}
/**鐢熸垚鍑哄簱浠诲姟*/
try {
- generateOutTask(items, loginUserId, waves);
+ generateOutTask(waveItems, loginUserId, waves);
} catch (Exception e) {
log.error(e.getMessage());
throw new CoolException("鍑哄簱浠诲姟鐢熸垚澶辫触锛侊紒锛�");
}
- //TODO 1. 鏍规嵁娉㈡鏄庣粏鐢熸垚鍑哄簱浠诲姟
- // 2. 鏍规嵁鐗╂枡SKU瀵绘壘绗﹀悎鐗╂枡搴撲綅 {1. 鏍规嵁鐗╂枡缂栫爜锛屾壒娆★紝鍔ㄦ�佸瓧娈� 鏌ヨ绗﹀悎鐨勫簱浣嶏紝鍐嶆牴鎹簱浣嶄腑鐗╂枡鐨勬暟閲忛�夋嫨鏈�閫傚悎鐨勫簱浣� 2. 鍒ゆ柇褰撳墠璁㈠崟鏄叏鎷栧嚭搴撹繕鏄嫞鏂欏叆搴搣
- // 3. 淇敼涓诲崟銆佹尝娆℃墽琛屾暟閲�
- // 4. 鍒ゆ柇鍏ㄤ粨鍑哄簱鎴栨嫞鏂欏嚭搴�
List<Long> orderIds = waveItems.stream().map(WaveItem::getOrderId).collect(Collectors.toList());
/**淇敼鍑哄簱鍗曠姸鎬�*/
if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>()
.set(AsnOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val)
.in(AsnOrder::getId, orderIds))) {
throw new CoolException("鍑哄簱鍗曟嵁鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ return R.ok();
+ }
+
+
+ /**
+ * 閫夋嫨娉㈡鏄庣粏涓嬪彂浠诲姟
+ * @param map
+ * @param loginUserId
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R waveToTask(Map<String, Object> map, Long loginUserId) {
+ if (Objects.isNull(map.get("waveItem"))) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ String waveId = map.get("wave").toString();
+ Wave waves = this.getById(Long.parseLong(waveId));
+ if (Objects.isNull(waves)) {
+ throw new CoolException("娉㈡鏁版嵁涓嶅瓨鍦紒锛�");
+ }
+ List<Long> waveItems = JSONArray.parseArray(JSON.toJSONString(map.get("waveItem")), Long.class);
+ if (waveItems.isEmpty()) {
+ throw new CoolException("娉㈡鏄庣粏涓嶈兘涓虹┖锛侊紒");
+ }
+ List<WaveItem> items = waveItemService.listByIds(waveItems);
+ if (items.isEmpty()) {
+ throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
+ .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val)
+ .in(WaveItem::getId, waveItems))) {
+ throw new CoolException("涓嬪彂鎵ц寮傚父锛岃绋嶅�欓噸璇曪紒");
+ }
+
+ /**鐢熸垚鍑哄簱浠诲姟*/
+ try {
+ generateOutTask(items, loginUserId, waves);
+ } catch (Exception e) {
+ log.error("UNK", e);
+ throw new CoolException(e.getMessage());
}
return R.ok();
}
@@ -101,21 +142,26 @@
* @description 鐢熸垚鍑哄簱浠诲姟
* @time 2025/4/28 14:01
*/
+ @Synchronized
@Transactional(rollbackFor = Exception.class)
- private synchronized void generateOutTask(List<WaveItem> itemParams, Long loginUserId, Wave wave) throws Exception {
+ public void generateOutTask(List<WaveItem> itemParams, Long loginUserId, Wave wave) throws Exception {
List<LocItem> locItemList = new ArrayList<>();
for (WaveItem param : itemParams) {
String locs = param.getStockLocs();
List<LocItem> locItems = JSONArray.parseArray(locs, LocItem.class);
- if (locItems.isEmpty()) {
- continue;
+ List<Long> list = new ArrayList<>();
+ if (Objects.isNull(locItems) || locItems.isEmpty()) {
+ //TODO
+ } else {
+ list = locItems.stream().map(LocItem::getLocId).collect(Collectors.toList());
}
- List<Long> list = locItems.stream().map(LocItem::getLocId).collect(Collectors.toList());
+
/**鏍规嵁渚涘簲鍟嗘壒娆★紝鐗╂枡鐮侊紝 鍔ㄦ�佸瓧娈垫煡璇㈡寚瀹氱殑鐗╂枡搴撳瓨淇℃伅*/
+ //TODO 杩欓噷闇�瑕佽鏍规嵁娉㈡瑙勫垯鏌ユ壘搴撳瓨淇℃伅
List<LocItem> items = locItemService.list(new LambdaQueryWrapper<LocItem>()
- .eq(LocItem::getSplrBatch, param.getSplrBatch())
- .in(LocItem::getLocId, list)
- .eq(StringUtils.isNotBlank(param.getFieldsIndex()), LocItem::getFieldsIndex, param.getFieldsIndex())
+ .eq(LocItem::getBatch, param.getSplrBatch())
+ .in(!list.isEmpty(), LocItem::getLocId, list)
+// .eq(StringUtils.isNotBlank(param.getFieldsIndex()), LocItem::getFieldsIndex, param.getFieldsIndex())
.eq(LocItem::getMatnrCode, param.getMatnrCode()));
if (items.isEmpty()) {
throw new CoolException("搴撳瓨淇℃伅鏈夊彉锛岃鍙栨秷褰撳墠娉㈡锛岀敓鏂扮敓鎴愭柊鐨勬尝娆★紒锛�");
@@ -123,9 +169,9 @@
/***灏嗘湁璐ф湁鐨勬槑缁嗕俊鎭瓨鏀惧埌搴撲綅淇℃伅涓�*/
for (int i = 0; i < items.size(); i++) {
items.get(i)
- .setWaveId(param.getWaveId())
- .setWaveCode(param.getWaveCode())
- .setWaveItemId(param.getId());
+ .setSourceId(param.getWaveId())
+ .setSourceCode(param.getWaveCode())
+ .setSource(param.getId());
}
locItemList.addAll(items);
}
@@ -139,8 +185,8 @@
listMap.keySet().forEach(key -> {
List<LocItem> locItems = listMap.get(key);
LocItem item1 = locItems.stream().findFirst().get();
- WaveItem waveItem = waveItemService.getById(item1.getWaveItemId());
- if (null == waveItem || Objects.isNull(waveItem)) {
+ WaveItem waveItem = waveItemService.getById(item1.getSource());
+ if (Objects.isNull(waveItem)) {
throw new CoolException("鏁版嵁閿欒锛氭尝娆℃槑缁嗕笉瀛樺湪锛侊紒");
}
//TODO 褰撳墠浠诲姟瀹屾垚鍚庯紝閫氳繃瀹氭椂浜嬩欢鍒ゆ柇鏄叏鐩樺嚭搴擄紝杩樻槸鎷f枡鍐嶅叆搴�
@@ -154,14 +200,15 @@
throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
}
- List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSourceId, wave.getId()));
- if (items.isEmpty()) {
- throw new CoolException("娉㈡浠诲姟宸茬敓鎴愶紝涓嶈兘閲嶅鐢熸垚锛侊紒");
- }
+// List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSourceId, wave.getId()));
+// if (!items.isEmpty()) {
+// throw new CoolException("娉㈡浠诲姟宸茬敓鎴愶紝涓嶈兘閲嶅鐢熸垚锛侊紒");
+// }
task.setTaskCode(ruleCode)
.setTaskType(TaskType.TASK_TYPE_OUT.type)
.setTaskStatus(TaskStsType.GENERATE_OUT.id)
+ .setResource(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)
.setBarcode(loc.getBarcode())
.setOrgLoc(loc.getCode())
.setCreateBy(loginUserId)
@@ -177,11 +224,11 @@
TaskItem taskItem = new TaskItem();
BeanUtils.copyProperties(item, taskItem);
taskItem.setTaskId(task.getId())
- .setAnfme(waveItem.getAnfme())
+ .setAnfme(item.getAnfme())
.setId(null)
.setSourceCode(wave.getCode())
.setSourceId(wave.getId())
- .setSource(item.getWaveItemId());
+ .setSource(item.getSource());
taskItems.add(taskItem);
}
if (!taskItemService.saveBatch(taskItems)) {
@@ -192,6 +239,7 @@
taskItems.forEach(item -> {
boolean update = waveItemService.update(new LambdaUpdateWrapper<WaveItem>()
.eq(WaveItem::getId, item.getSource())
+ .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_SEED.val)
.set(WaveItem::getWorkQty, item.getAnfme()));
if (!update) {
throw new CoolException("娉㈡鎵ц鏁伴噺淇敼澶辫触锛侊紒");
@@ -239,6 +287,20 @@
}
/**
+ * @author Ryan
+ * @description 鍙栨秷娉㈡
+ * @param
+ * @return
+ * @time 2025/6/17 10:04
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R cancelWave(List<Long> ids) {
+
+ return null;
+ }
+
+ /**
* @param
* @param waveItems
* @return
@@ -246,7 +308,8 @@
* @description 鏍规嵁鐗╂枡缂栫爜锛屾壒娆★紝鍔ㄦ�佸瓧娈� 鏌ヨ绗﹀悎鐨勫簱浣嶏紝鍐嶆牴鎹簱浣嶄腑鐗╂枡鐨勬暟閲忛�夋嫨鏈�閫傚悎鐨勫簱浣�
* @time 2025/4/27 09:26
*/
- private synchronized List<WaveItem> getLocs(List<WaveItem> waveItems) throws Exception {
+ @Synchronized
+ private List<WaveItem> getLocs(List<WaveItem> waveItems) throws Exception {
//TODO 鏍规嵁鐗╂枡缂栫爜锛屾壒娆★紝鍔ㄦ�佸瓧娈� 鏌ヨ绗﹀悎鐨勫簱浣嶏紝鍐嶆牴鎹簱浣嶄腑鐗╂枡鐨勬暟閲忛�夋嫨鏈�閫傚悎鐨勫簱浣�
waveItems.forEach(waveItem -> {
List<LocItem> locItems = locItemService.list(new QueryWrapper<LocItem>()
--
Gitblit v1.9.1