修复程序:1. 工作状态的判断改为只判断1状态。2. 修改发送入库与拣选任务的写法。

This commit is contained in:
梁州 2025-11-14 16:19:27 +08:00
parent 22fdaa6df3
commit e60c80d7b8
5 changed files with 159 additions and 186 deletions

View File

@ -112,10 +112,6 @@ public class TaskController {
* 物料服务
*/
private final GoodsService goodsService;
/**
* 流转中物料箱号数据
*/
private final OutsideVehiclesService outsideVehiclesService;
/**
* 拣选任务记录服务
*/
@ -132,10 +128,6 @@ public class TaskController {
* 工作站配置服务
*/
private final WorkStationConfigService workStationConfigService;
/**
* 站台要料服务
*/
private final GoodsToStationService goodsToStationService;
/**
* 非计划领料服务
*/
@ -161,7 +153,6 @@ public class TaskController {
*/
private final IWorkService workService;
private final WorkFlowLastService workFlowLastService;// 服务
private final StandStackerTaskService standStackerTaskService;// 特殊服务
private final InventoryListService inventoryService;
private final WorkSummaryService workSummaryService;
private final InventoryHistoryService inventoryHistoryService;
@ -642,7 +633,7 @@ public class TaskController {
response.setMessage("暂无可用库位!");
return convertJsonString(response);
} else {
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
Location nextLocation = locationService.getById(resultMap.get("nextLocationId"));
if (Objects.equals(nextLocation.getLocationStatus(), LocationStatus.OCCUPY.getCode()) && nextLocation.getVehicleId().equals(wcsVehicleInRequest.getVehicleNo())) {
nextLocationId = resultMap.get("nextLocationId");
break;
@ -1584,7 +1575,7 @@ public class TaskController {
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, standId)
.in(WorkFlow::getGoodsId, goodsIdList)
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
// 需要不放行返回前台提示信息
StandPickVo pickVoEntity = new StandPickVo();
pickVoEntity.setTip("当前料箱还有其他物料需要拣货");
@ -1608,7 +1599,7 @@ public class TaskController {
// 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, standId)
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
// 当前站台工作未全部完成
standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getLastUseTime, LocalDateTime.now())
@ -1647,7 +1638,7 @@ public class TaskController {
// 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, standId)
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
// 当前站台工作未全部完成
standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getLastUseTime, LocalDateTime.now())
@ -1765,7 +1756,7 @@ public class TaskController {
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId())
.in(WorkFlow::getGoodsId, goodsIdList)
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
// 更新站台信息
standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getPickGoods, "")
@ -1787,7 +1778,7 @@ public class TaskController {
// 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId())
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getLastUseTime, LocalDateTime.now())
.set(Stand::getPickVehicle, "")
@ -1823,7 +1814,7 @@ public class TaskController {
// 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId())
.notIn(WorkFlow::getWorkStatus, -1, 2))) {
.eq(WorkFlow::getWorkStatus, 1))) {
// 当前站台工作未全部完成
standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getLastUseTime, LocalDateTime.now())
@ -2209,8 +2200,6 @@ public class TaskController {
backTask.setCreateTime(LocalDateTime.now());
// 保存任务
taskService.save(backTask);
// 删除outsideVehicle表
outsideVehiclesService.remove(new LambdaQueryWrapper<OutsideVehicles>().eq(OutsideVehicles::getVehicleId, requestBackQuery.getVehicleId()));
// 设置库存状态为回库中
stockService.update(new LambdaUpdateWrapper<Stock>()
.set(Stock::getStockStatus, StockStatus.BACK.getCode())
@ -3336,7 +3325,7 @@ public class TaskController {
inventoryVo.setGoodsId(inventoryRequest.getGoodsId());
inventoryVo.setVehiclesQuantity(stockList.size());
inventoryVo.setVehicleIds(stock.getVehicleId());
String vehicleStatus = "";
String vehicleStatus;
if (Objects.equals(StockStatus.OK.getCode(), stock.getStockStatus())) {
vehicleStatus = "在库中";
} else if (Objects.equals(StockStatus.OUT.getCode(), stock.getStockStatus())) {

View File

@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import static com.wms.config.InitLocalConfig.configMap;
import static com.wms.utils.StringUtils.convertJsonString;
/**
* 普通任务发送定时器类
@ -30,7 +31,6 @@ public class CommonTaskSender implements Job {
* @param jobExecutionContext 执行文本
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void execute(JobExecutionContext jobExecutionContext) {
try {
String sendTask = configMap.get(ConfigMapKeyEnum.SEND_TASK.getConfigKey());
@ -40,8 +40,7 @@ public class CommonTaskSender implements Job {
// 发送正常任务
wmsJobService.sendCommonTasks();
} catch (Exception e) {
// 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("发送任务给wcs发生异常{}", convertJsonString(e));
}
}
}

View File

@ -6,10 +6,9 @@ import com.wms.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import static com.wms.config.InitLocalConfig.configMap;
import static com.wms.utils.StringUtils.convertJsonString;
@Slf4j
@PersistJobDataAfterExecution
@ -27,7 +26,6 @@ public class PickTaskSender implements Job {
* @param jobExecutionContext 执行上下文
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void execute(JobExecutionContext jobExecutionContext) {
try {
String sendTask = configMap.get(ConfigMapKeyEnum.SEND_TASK.getConfigKey());
@ -37,8 +35,7 @@ public class PickTaskSender implements Job {
// 发送拣选任务
wmsJobService.sendPickTasks();
} catch (Exception e) {
// 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("发送拣选任务任务给wcs发生异常{}", convertJsonString(e));
}
}
}

View File

@ -6,9 +6,8 @@ package com.wms.service.business;
public interface IWmsJobService {
/**
* 执行普通任务
* @throws Exception 异常用于回滚事务
*/
void sendCommonTasks() throws Exception;
void sendCommonTasks();
/**
* 下发拣选出库任务
@ -18,9 +17,8 @@ public interface IWmsJobService {
/**
* 发送拣选任务
* @throws Exception 异常用于回滚事务
*/
void sendPickTasks() throws Exception;
void sendPickTasks();
/**
* 发送重复入库修正后的任务

View File

@ -48,7 +48,6 @@ import static com.wms.utils.StringUtils.convertJsonString;
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class WmsJobServiceImplements implements IWmsJobService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());// 日志
private final String ROOT_PATH = "./file";
private final LogService logService;// 日志服务
private final TaskService taskService;// 任务服务
@ -72,8 +71,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
* 发送正常的任务
*/
@Override
public void sendCommonTasks() throws Exception {
try {
public void sendCommonTasks() {
// 检索任务表---新建未下发的任务
LambdaQueryWrapper<Task> waitForDistributeTaskQuery = new LambdaQueryWrapper<Task>()
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode());
@ -140,7 +138,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
logger.error("保存发送任务的日志错误。");
}
if (result == null) {
logger.error("发送任务异常。");
logger.error("发送堆垛机任务异常。");
} else {
if (Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
logger.info("发送WCS任务成功。");
@ -168,18 +166,13 @@ public class WmsJobServiceImplements implements IWmsJobService {
logger.error("WCS发送任务地址为空。");
}
}
} catch (Exception exception) {
logger.error("向WCS发送任务时发生异常{}", convertJsonString(exception));
throw new Exception("向WCS发送任务时发生异常。");
}
}
/**
* 发送拣选任务
*/
@Override
public void sendPickTasks() throws Exception {
try {
public void sendPickTasks() {
// 检索任务表---新建未下发的拣选任务
LambdaQueryWrapper<PickTask> waitForDistributePickTaskQuery = new LambdaQueryWrapper<PickTask>()
.eq(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode());
@ -225,7 +218,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
try {
logService.save(new WmsLog(WmsUtils.generateId("LOG_"), "向WCS发送拣选任务", "setConveyTask", convertJsonString(request), convertJsonString(result), url, LocalDateTime.now(), "WMS"));
} catch (Exception e) {
logger.error("插入日志错误。");
logger.error("保存发送拣选任务日志错误。");
}
if (result != null && Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
logger.info("发送拣选任务成功。");
@ -240,10 +233,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
logger.error("WCS发送拣选任务地址为空。");
}
}
} catch (Exception exception) {
logger.error("向WCS发送拣选任务时发生异常{}", convertJsonString(exception));
throw new Exception("向WCS发送拣选任务时发生异常。");
}
}
/**
@ -369,6 +358,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
// 查询过期任务记录
List<TaskRecord> expireTaskRecords = taskRecordService.list(new LambdaQueryWrapper<TaskRecord>()
.lt(TaskRecord::getCreateTime, deleteTime));
String ROOT_PATH = "./file";
if (expireTaskRecords != null && !expireTaskRecords.isEmpty()) {
List<String> needRemoveIds = new ArrayList<>();
List<DbOfTaskRecord> finishedExcelTemp = new ArrayList<>();
@ -1096,7 +1086,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
}
} else {
logger.error("WCS发送任务地址为空。");
logger.error("WCS发送站台出库任务地址为空。");
}
}
} catch (Exception exception) {