From c6c9b7d3baa822765768c110304d27623f946286 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期二, 15 七月 2025 14:29:09 +0800
Subject: [PATCH] `1`
---
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java | 176 +++++++++++++++++++++++++++++++++-------------------------
1 files changed, 99 insertions(+), 77 deletions(-)
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
index 190b579..ba6dff2 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
@@ -2,8 +2,9 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zy.asrs.framework.common.Cools;
-import com.zy.asrs.framework.common.R;
+import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.asrs.entity.*;
import com.zy.asrs.wms.asrs.entity.enums.*;
@@ -15,6 +16,8 @@
import com.zy.asrs.wms.utils.LocUtils;
import com.zy.asrs.wms.utils.OrderUtils;
import com.zy.asrs.wms.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,6 +26,8 @@
@Service("workService")
public class WorkServiceImpl implements WorkService {
+
+ public static final Logger logger = LoggerFactory.getLogger(WorkServiceImpl.class);
@Autowired
private TaskService taskService;
@@ -77,9 +82,11 @@
@Override
public String generateTaskNo(Long taskType) {
+ String format = DateUtils.format(new Date(), "MMddHHmm");
Random random = new Random();
int nextInt = random.nextInt(99999);
- return "R" + nextInt;
+ logger.info("R" + format + nextInt);
+ return "R" + format + nextInt;
}
@Override
@@ -90,7 +97,7 @@
@Override
public Loc generateEmptyLoc(Long taskType, Integer locTypeHeight) {
List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime));
- if(shelvesRules.isEmpty()) {
+ if (shelvesRules.isEmpty()) {
throw new CoolException("鏈厤缃笂鏋惰鍒�");
}
ShelvesRule shelvesRule = shelvesRules.get(0);
@@ -114,7 +121,7 @@
}
List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$();
- if(ruleDetls.isEmpty()) {
+ if (ruleDetls.isEmpty()) {
throw new CoolException("鏈厤缃笂鏋惰鍒欐槑缁�");
}
@@ -135,22 +142,23 @@
//鑾峰彇搴撲綅
if (!suggestLoc.isEmpty()) {
defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
- if(defaultLoc != null) {
+ if (defaultLoc != null) {
return defaultLoc;
}
}
}
if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
+ return locUtils.getGlobalEmptyLocToCtu(locTypeHeight);
//浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
- List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
- //鑾峰彇搴撲綅
- if (!globalLoc.isEmpty()) {
- defaultLoc = locUtils.filterAllLoc(globalLoc);
- if(defaultLoc != null) {
- return defaultLoc;
- }
- }
+// List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
+// //鑾峰彇搴撲綅
+// if (!globalLoc.isEmpty()) {
+// defaultLoc = locUtils.filterAllLoc(globalLoc);
+// if (defaultLoc != null) {
+// return defaultLoc;
+// }
+// }
}
}
@@ -240,15 +248,16 @@
}
if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
+ return locUtils.getGlobalEmptyLocToCtu(locTypeHeight);
//浠庡叏灞�搴撲綅涓幏鍙�(瀹屾暣宸烽亾)
- List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev);
- //鑾峰彇搴撲綅
- if (!globalLoc.isEmpty()) {
- defaultLoc = locUtils.filterAllLoc(globalLoc);
- if (defaultLoc != null) {
- return defaultLoc;
- }
- }
+// List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev);
+// //鑾峰彇搴撲綅
+// if (!globalLoc.isEmpty()) {
+// defaultLoc = locUtils.filterAllLoc(globalLoc);
+// if (defaultLoc != null) {
+// return defaultLoc;
+// }
+// }
}
}
return defaultLoc;
@@ -274,7 +283,7 @@
//鐢熸垚搴撲綅
Loc loc = this.generateLoc(param.getTaskType(), param.getBarcode(), param.getLocTypeHeight());
- if(loc == null) {
+ if (loc == null) {
throw new CoolException("娌℃湁绌哄簱浣�");
}
@@ -316,7 +325,7 @@
taskDetl.setMatId(waitPakin.getDetl$().getMatId());
taskDetl.setMatnr(waitPakin.getDetl$().getMat$().getMatnr());
boolean taskDetlSave = taskDetlService.save(taskDetl);
- if(!taskDetlSave){
+ if (!taskDetlSave) {
throw new CoolException("浠诲姟鏄庣粏鐢熸垚澶辫触");
}
@@ -329,7 +338,7 @@
taskDetlField.setDetlId(taskDetl.getId());
taskDetlField.setValue(orderDetlField.getValue());
boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
- if(!taskDetlFieldSave){
+ if (!taskDetlFieldSave) {
throw new CoolException("鏄庣粏鎵╁睍鐢熸垚澶辫触");
}
}
@@ -338,26 +347,26 @@
waitPakin.setIoStatus(1);
waitPakin.setUpdateTime(new Date());
boolean waitPakinUpdate = waitPakinService.updateById(waitPakin);
- if(!waitPakinUpdate){
+ if (!waitPakinUpdate) {
throw new CoolException("缁勬墭閫氱煡妗f洿鏂板け璐�");
}
//鏇存柊璁㈠崟鏄庣粏鏁版嵁
OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
- if(orderDetl == null){
+ if (orderDetl == null) {
throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
}
orderDetl.setWorkQty(orderDetl.getWorkQty() + taskDetl.getAnfme());
orderDetl.setUpdateTime(new Date());
boolean orderDetlUpdate = orderDetlService.updateById(orderDetl);
- if(!orderDetlUpdate){
+ if (!orderDetlUpdate) {
throw new CoolException("璁㈠崟鏄庣粏鏇存柊澶辫触");
}
//鑾峰彇璁㈠崟
Order order = orderService.getById(taskDetl.getOrderId());
- if(order == null){
+ if (order == null) {
throw new CoolException("璁㈠崟涓嶅瓨鍦�");
}
@@ -375,7 +384,7 @@
loc.setLocStsId(LocStsType.S.val());
loc.setUpdateTime(new Date());
boolean locUpdate = locService.updateById(loc);
- if(!locUpdate){
+ if (!locUpdate) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
@@ -391,7 +400,7 @@
//鐢熸垚搴撲綅
Loc loc = this.generateEmptyLoc(param.getTaskType(), param.getLocTypeHeight());
- if(loc == null) {
+ if (loc == null) {
throw new CoolException("娌℃湁绌哄簱浣�");
}
@@ -414,7 +423,7 @@
loc.setLocStsId(LocStsType.S.val());
loc.setUpdateTime(new Date());
boolean locUpdate = locService.updateById(loc);
- if(!locUpdate){
+ if (!locUpdate) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
@@ -424,7 +433,7 @@
@Override
public boolean completeTask(Long taskId) {
Task task = taskService.getById(taskId);
- if(task == null){
+ if (task == null) {
throw new CoolException("浠诲姟涓嶅瓨鍦�");
}
@@ -436,16 +445,15 @@
if (task.getTaskType() < 100) {
//鍏ュ簱
task.setTaskSts(TaskStsType.COMPLETE_IN.id);//99.鍏ュ簱瀹屾垚
- }else {
+ } else {
//鍑哄簱
TaskDetl taskDetl = taskDetls.get(0); //TODO 鍑哄簱娴佺▼寰呯‘璁わ紝ESS鍙栬揣鍚庯紝杈撻�佺嚎娴佽浆鍒版壂鐮佸鐘舵��
- if (taskDetl.getWaveId() == null) {
+ if (taskDetl.getWaveId() == null && task.getTaskType() != 103 && task.getTaskType() != 107) {
task.setTaskSts(TaskStsType.COMPLETE_OUT.id);//199.鍑哄簱瀹屾垚
- }else {
+ } else {
task.setTaskSts(TaskStsType.WAVE_SEED.id);//198.鎾涓�
}
}
-
task.setUpdateTime(new Date());
if (!taskService.updateById(task)) {
throw new CoolException("浠诲姟鏇存柊澶辫触");
@@ -458,7 +466,7 @@
@Transactional(rollbackFor = Exception.class)
public boolean cancelTask(Long taskId) {
Task task = taskService.getById(taskId);
- if(task == null){
+ if (task == null) {
throw new CoolException("浠诲姟涓嶅瓨鍦�");
}
@@ -471,15 +479,15 @@
case 54://骞舵澘
case 57://鐩樼偣
loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
- if(loc == null){
+ if (loc == null) {
throw new CoolException("搴撲綅涓嶅瓨鍦�");
}
- if(loc.getLocStsId() != LocStsType.S.val()){
+ if (loc.getLocStsId() != LocStsType.S.val()) {
throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
}
loc.setLocStsId(LocStsType.O.val());
loc.setUpdateTime(new Date());
- if(!locService.updateById(loc)){
+ if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�");
}
break;
@@ -489,15 +497,15 @@
case 107://鐩樼偣
case 110://绌烘澘
loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
- if(loc == null){
+ if (loc == null) {
throw new CoolException("搴撲綅涓嶅瓨鍦�");
}
- if(loc.getLocStsId() != LocStsType.R.val()){
+ if (loc.getLocStsId() != LocStsType.R.val()) {
throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
}
loc.setLocStsId(LocStsType.F.val());
loc.setUpdateTime(new Date());
- if(!locService.updateById(loc)){
+ if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�");
}
@@ -509,7 +517,7 @@
String matUniqueKey = Utils.getMatUniqueKey(taskDetl.getMatnr(), taskDetl.getBatch(), taskDetl.getUniqueField());
WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getStockIndex, matUniqueKey).eq(WaveDetl::getWaveId, taskDetl.getWaveId()));
- if(waveDetl == null){
+ if (waveDetl == null) {
continue;
}
waveDetl.setWorkQty(waveDetl.getWorkQty() - taskDetl.getAnfme());
@@ -521,7 +529,7 @@
break;
case 11://搴撲綅绉昏浆
Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
- if(originLoc == null){
+ if (originLoc == null) {
throw new CoolException("婧愬簱浣嶄笉瀛樺湪");
}
if (originLoc.getLocStsId() != LocStsType.R.val()) {
@@ -529,22 +537,22 @@
}
loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
- if(loc == null){
+ if (loc == null) {
throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�");
}
- if(loc.getLocStsId() != LocStsType.S.val()){
+ if (loc.getLocStsId() != LocStsType.S.val()) {
throw new CoolException("鐩爣搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
}
originLoc.setLocStsId(LocStsType.F.val());
originLoc.setUpdateTime(new Date());
- if(!locService.updateById(originLoc)){
+ if (!locService.updateById(originLoc)) {
throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�");
}
loc.setLocStsId(LocStsType.O.val());
loc.setUpdateTime(new Date());
- if(!locService.updateById(loc)){
+ if (!locService.updateById(loc)) {
throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�");
}
break;
@@ -560,7 +568,7 @@
//鍒犻櫎浠诲姟
boolean removeTask = taskService.removeById(taskId);
- if(!removeTask){
+ if (!removeTask) {
throw new CoolException("鍥炴粴浠诲姟澶辫触");
}
@@ -579,14 +587,14 @@
//鍏ュ簱鍥炴粴缁勬墭閫氱煡妗�
if (task.getTaskType() == 1) {
WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, taskDetl.getDetlId()).eq(WaitPakin::getBarcode, task.getBarcode()));
- if(waitPakin == null){
+ if (waitPakin == null) {
throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
}
waitPakin.setIoStatus(0);
waitPakin.setUpdateTime(new Date());
boolean updateWaitPakin = waitPakinService.updateById(waitPakin);
- if(!updateWaitPakin){
+ if (!updateWaitPakin) {
throw new CoolException("缁勬墭閫氱煡妗e洖婊氬け璐�");
}
}
@@ -602,7 +610,7 @@
//鍒犻櫎鏄庣粏
boolean removeDetl = taskDetlService.removeById(taskDetl.getId());
- if(!removeDetl){
+ if (!removeDetl) {
throw new CoolException("鍥炴粴鏄庣粏澶辫触");
}
@@ -619,7 +627,7 @@
//鍒犻櫎鏄庣粏鎵╁睍
boolean removeField = taskDetlFieldService.removeById(detlField.getId());
- if(!removeField){
+ if (!removeField) {
throw new CoolException("鍥炴粴鎵╁睍鏄庣粏澶辫触");
}
}
@@ -633,11 +641,11 @@
@Transactional(rollbackFor = Exception.class)
public boolean pickTask(Long taskId) {
Task task = taskService.getById(taskId);
- if(task == null){
+ if (task == null) {
throw new CoolException("浠诲姟涓嶅瓨鍦�");
}
- if (task.getTaskType() != 103) {
+ if (task.getTaskType() != 103 && task.getTaskType() != 107) {
throw new CoolException("浠诲姟绫诲瀷涓嶅彲鎷f枡");
}
@@ -647,21 +655,25 @@
//鑾峰彇婧愬簱浣�
Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
- if(originLoc == null){
+ if (originLoc == null) {
throw new CoolException("婧愬簱浣嶄笉瀛樺湪");
}
//鑾峰彇婧愬簱浣嶉珮搴�
- LocTypeBind locTypeBind = locTypeBindService.getOne(new LambdaQueryWrapper<LocTypeBind>().eq(LocTypeBind::getLocId, originLoc.getId()).in(LocTypeBind::getTypeId, LocBindType.HEIGHT.list()));
- if(locTypeBind == null){
+ LocTypeBind locTypeBind = locTypeBindService.getOne(new LambdaQueryWrapper<LocTypeBind>()
+ .eq(LocTypeBind::getLocId, originLoc.getId())
+ .in(LocTypeBind::getTypeId, LocBindType.HEIGHT.list()));
+ if (locTypeBind == null) {
throw new CoolException("搴撲綅绫诲瀷涓嶅瓨鍦�");
}
LocType locType = locTypeService.getById(locTypeBind.getTypeId());
- if(locType == null){
+
+ if (locType == null) {
throw new CoolException("搴撲綅绫诲瀷涓嶅瓨鍦�");
}
LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locType.getFlag());
- if(locTypeHeightType == null){
+
+ if (locTypeHeightType == null) {
throw new CoolException("楂樹綆搴撲綅绫诲瀷涓嶅瓨鍦�");
}
@@ -672,27 +684,37 @@
throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
}
TaskDetl taskDetl = taskDetls.get(0);
-
//鐢熸垚鏂扮殑搴撲綅 !important
- Loc loc = this.generateLoc(taskType, taskDetl.getMatId(), taskDetl.getBatch(), taskDetl.getUniqueField(), locTypeHeightType.id);
-
- if(loc == null) {
+// Loc loc = this.generateLoc(taskType, taskDetl.getMatId(), taskDetl.getBatch(), taskDetl.getUniqueField(), locTypeHeightType.id);
+// if(loc == null) {
+// throw new CoolException("娌℃湁绌哄簱浣�");
+// }
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
+ if (loc == null) {
throw new CoolException("娌℃湁绌哄簱浣�");
}
+ // 鑾峰彇鏂颁换鍔″彿
+ String taskNo = generateTaskNo(53L);
+ // 璁剧疆鏂颁换鍔″彿
+ task.setTaskNo(taskNo);
//102鎷f枡姝ゅ闇�淇敼涓篧CS_CONTAINER_RECEIVE,瀹氭椂浠诲姟鏌ヨ鍚庯紝鑷姩涓嬪彂鍏ュ簱浠诲姟鑷矱SS
- task.setTaskSts(TaskStsType.WCS_CONTAINER_RECEIVE.id);//1.鐢熸垚鍏ュ簱浠诲姟
+ task.setTaskSts(TaskStsType.GENERATE_IN.id);//1.鐢熸垚鍏ュ簱浠诲姟
task.setTaskType(taskType);
- task.setTargetLoc(loc.getLocNo());
+ //鍘熷簱浣嶅彉鐩爣搴撲綅, 鍘熺珯鐐瑰彉鐩爣绔欑偣
+ //todo 闇�纭鍘熺珯鐐逛负绌猴紝璇ユ�庝箞澶勭悊
+ task.setTargetLoc(task.getOriginLoc());
task.setUpdateTime(new Date());
if (!taskService.updateById(task)) {
throw new CoolException("鎷f枡澶辫触");
}
-
- //搴撲綅O => S
+ // 鏇存柊浠诲姟鏄庣粏鏂颁换鍔″彿
+ UpdateWrapper<TaskDetl> updateWrapper = new UpdateWrapper<>();
+ updateWrapper.set("task_no",taskNo).eq("task_id",task.getId());
+ //搴撲綅鐘舵�佹敼涓洪绾﹀叆搴� R => S
loc.setLocStsId(LocStsType.S.val());
loc.setUpdateTime(new Date());
boolean locUpdate = locService.updateById(loc);
- if(!locUpdate){
+ if (!locUpdate) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
@@ -700,7 +722,7 @@
}
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public boolean locAdjust(LocAdjustParam param) {
if (param == null) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
@@ -792,7 +814,7 @@
throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�");
}
- if(targetLoc.getLocStsId() != LocStsType.O.val()){
+ if (targetLoc.getLocStsId() != LocStsType.O.val()) {
throw new CoolException("鐩爣搴撲綅闈炵┖鐘舵��");
}
@@ -817,7 +839,7 @@
}
List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, sourceLoc.getId()));
- if(locDetls.isEmpty()){
+ if (locDetls.isEmpty()) {
throw new CoolException("婧愬簱浣嶆槑缁嗕笉瀛樺湪");
}
@@ -833,7 +855,7 @@
taskDetl.setMatId(locDetl.getMatId());
taskDetl.setMatnr(locDetl.getMatnr());
boolean taskDetlSave = taskDetlService.save(taskDetl);
- if(!taskDetlSave){
+ if (!taskDetlSave) {
throw new CoolException("浠诲姟鏄庣粏鐢熸垚澶辫触");
}
@@ -846,7 +868,7 @@
taskDetlField.setDetlId(taskDetl.getId());
taskDetlField.setValue(locDetlField.getValue());
boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
- if(!taskDetlFieldSave){
+ if (!taskDetlFieldSave) {
throw new CoolException("鏄庣粏鎵╁睍鐢熸垚澶辫触");
}
}
@@ -856,7 +878,7 @@
sourceLoc.setLocStsId(LocStsType.R.val());
sourceLoc.setUpdateTime(new Date());
boolean sourceLocUpdate = locService.updateById(sourceLoc);
- if(!sourceLocUpdate){
+ if (!sourceLocUpdate) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
@@ -864,7 +886,7 @@
targetLoc.setLocStsId(LocStsType.S.val());
targetLoc.setUpdateTime(new Date());
boolean targetLocUpdate = locService.updateById(targetLoc);
- if(!targetLocUpdate){
+ if (!targetLocUpdate) {
throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
}
--
Gitblit v1.9.1