修复程序:1. 工作状态的判断改为只判断1状态。2. 修改发送入库与拣选任务的写法。
This commit is contained in:
parent
22fdaa6df3
commit
e60c80d7b8
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
/**
|
||||
* 发送重复入库修正后的任务
|
||||
|
|
|
|||
|
|
@ -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,105 +71,100 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
* 发送正常的任务
|
||||
*/
|
||||
@Override
|
||||
public void sendCommonTasks() throws Exception {
|
||||
try {
|
||||
// 检索任务表---新建未下发的任务
|
||||
LambdaQueryWrapper<Task> waitForDistributeTaskQuery = new LambdaQueryWrapper<Task>()
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode());
|
||||
List<Task> allTasks = taskService.list(waitForDistributeTaskQuery);
|
||||
if (!allTasks.isEmpty()) {
|
||||
String max_wcs_accept_nums = configMap.get(ConfigMapKeyEnum.MAX_WCS_ACCEPT_NUMS.getConfigKey());
|
||||
if (StringUtils.isEmpty(max_wcs_accept_nums)) {
|
||||
logger.error("配置未生成");
|
||||
return;
|
||||
public void sendCommonTasks() {
|
||||
// 检索任务表---新建未下发的任务
|
||||
LambdaQueryWrapper<Task> waitForDistributeTaskQuery = new LambdaQueryWrapper<Task>()
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode());
|
||||
List<Task> allTasks = taskService.list(waitForDistributeTaskQuery);
|
||||
if (!allTasks.isEmpty()) {
|
||||
String max_wcs_accept_nums = configMap.get(ConfigMapKeyEnum.MAX_WCS_ACCEPT_NUMS.getConfigKey());
|
||||
if (StringUtils.isEmpty(max_wcs_accept_nums)) {
|
||||
logger.error("配置未生成");
|
||||
return;
|
||||
}
|
||||
int maxWcsAcceptNums = Integer.parseInt(max_wcs_accept_nums);
|
||||
// 需要发送给wcs的任务列表
|
||||
List<WcsTaskRequest> request = new ArrayList<>();
|
||||
// 已经下发的任务组列表
|
||||
List<String> taskGroupIds = new ArrayList<>();
|
||||
// 这里单独处理站台拣选出库以外的任务
|
||||
for (Task task : allTasks) {
|
||||
if (request.size() >= maxWcsAcceptNums) {
|
||||
// 每次给wcs下发数量
|
||||
break;
|
||||
}
|
||||
int maxWcsAcceptNums = Integer.parseInt(max_wcs_accept_nums);
|
||||
// 需要发送给wcs的任务列表
|
||||
List<WcsTaskRequest> request = new ArrayList<>();
|
||||
// 已经下发的任务组列表
|
||||
List<String> taskGroupIds = new ArrayList<>();
|
||||
// 这里单独处理站台拣选出库以外的任务
|
||||
for (Task task : allTasks) {
|
||||
if (request.size() >= maxWcsAcceptNums) {
|
||||
// 每次给wcs下发数量
|
||||
break;
|
||||
}
|
||||
if (taskGroupIds.contains(task.getTaskGroup())) {
|
||||
// 该任务组已经下发
|
||||
if (taskGroupIds.contains(task.getTaskGroup())) {
|
||||
// 该任务组已经下发
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getPreTask())) {// 当前任务具有前置任务
|
||||
// 查询一下前置的任务有没有存在,存在则不下发
|
||||
if (taskService.exists(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, task.getPreTask()))) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getPreTask())) {// 当前任务具有前置任务
|
||||
// 查询一下前置的任务有没有存在,存在则不下发
|
||||
if (taskService.exists(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, task.getPreTask()))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 创建发送的任务
|
||||
WcsTaskRequest tempTask = new WcsTaskRequest();
|
||||
tempTask.setTaskId(task.getTaskGroup());
|
||||
if (Objects.equals(task.getTaskType(), TaskType.INVENTORY.getCode())) {
|
||||
tempTask.setTaskType(TaskType.OUT.getCode());
|
||||
} else {
|
||||
tempTask.setTaskType(task.getTaskType());
|
||||
}
|
||||
tempTask.setOrigin(task.getOrigin());
|
||||
tempTask.setDestination(task.getDestination());
|
||||
tempTask.setVehicleNo(task.getVehicleId());
|
||||
tempTask.setVehicleSize(task.getVehicleSize());
|
||||
tempTask.setWeight(task.getWeight());
|
||||
tempTask.setPriority(task.getTaskPriority());
|
||||
request.add(tempTask);
|
||||
// 已经发送过的任务组
|
||||
taskGroupIds.add(task.getTaskGroup());
|
||||
}
|
||||
if (request.isEmpty()) {
|
||||
// 没有新任务发送
|
||||
return;
|
||||
}
|
||||
// 下面这行代码模拟wcs下发成功
|
||||
// simulateSendPickOutTasks(taskGroupIds, Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
|
||||
// 发送任务
|
||||
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_TASK.getConfigKey());
|
||||
if (url != null) {
|
||||
logger.info("向WCS发送任务,地址:{},请求详情:{}", url, convertJsonString(request));
|
||||
ResponseEntity result = JSON.parseObject(HttpUtils.sendHttpPostWithoutToken(url, convertJsonString(request)), ResponseEntity.class);
|
||||
try {
|
||||
logService.save(new WmsLog(WmsUtils.generateId("LOG_"), "向WCS发送任务", "SetStackerTask", JSON.toJSONString(request), JSON.toJSONString(result), url, LocalDateTime.now(), "WMS"));
|
||||
} catch (Exception e) {
|
||||
logger.error("保存发送任务的日志错误。");
|
||||
}
|
||||
if (result == null) {
|
||||
logger.error("发送任务异常。");
|
||||
} else {
|
||||
if (Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
|
||||
logger.info("发送WCS任务成功。");
|
||||
taskService.update(new LambdaUpdateWrapper<Task>()
|
||||
.set(Task::getTaskStatus, WmsTaskStatus.WAIT.getCode())
|
||||
.in(Task::getTaskGroup, taskGroupIds)
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
|
||||
} else {
|
||||
// 判断returnData的数据
|
||||
if (result.getReturnData() != null) {
|
||||
List<WcsTaskRequest> errorTasks = JSON.parseArray(result.getReturnData().toString(), WcsTaskRequest.class);
|
||||
if (!errorTasks.isEmpty()) {
|
||||
List<String> failedTaskIds = errorTasks.stream().map(WcsTaskRequest::getTaskId).distinct().toList();
|
||||
// 更新任务状态为异常
|
||||
taskService.update(new LambdaUpdateWrapper<Task>()
|
||||
.set(Task::getTaskStatus, WmsTaskStatus.EXCEPTION.getCode())
|
||||
.in(Task::getTaskGroup, failedTaskIds)
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
|
||||
}
|
||||
}
|
||||
logger.error("发送任务错误:{}", convertJsonString(result));
|
||||
}
|
||||
}
|
||||
// 创建发送的任务
|
||||
WcsTaskRequest tempTask = new WcsTaskRequest();
|
||||
tempTask.setTaskId(task.getTaskGroup());
|
||||
if (Objects.equals(task.getTaskType(), TaskType.INVENTORY.getCode())) {
|
||||
tempTask.setTaskType(TaskType.OUT.getCode());
|
||||
} else {
|
||||
logger.error("WCS发送任务地址为空。");
|
||||
tempTask.setTaskType(task.getTaskType());
|
||||
}
|
||||
tempTask.setOrigin(task.getOrigin());
|
||||
tempTask.setDestination(task.getDestination());
|
||||
tempTask.setVehicleNo(task.getVehicleId());
|
||||
tempTask.setVehicleSize(task.getVehicleSize());
|
||||
tempTask.setWeight(task.getWeight());
|
||||
tempTask.setPriority(task.getTaskPriority());
|
||||
request.add(tempTask);
|
||||
// 已经发送过的任务组
|
||||
taskGroupIds.add(task.getTaskGroup());
|
||||
}
|
||||
if (request.isEmpty()) {
|
||||
// 没有新任务发送
|
||||
return;
|
||||
}
|
||||
// 下面这行代码模拟wcs下发成功
|
||||
// simulateSendPickOutTasks(taskGroupIds, Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
|
||||
// 发送任务
|
||||
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_TASK.getConfigKey());
|
||||
if (url != null) {
|
||||
logger.info("向WCS发送任务,地址:{},请求详情:{}", url, convertJsonString(request));
|
||||
ResponseEntity result = JSON.parseObject(HttpUtils.sendHttpPostWithoutToken(url, convertJsonString(request)), ResponseEntity.class);
|
||||
try {
|
||||
logService.save(new WmsLog(WmsUtils.generateId("LOG_"), "向WCS发送任务", "SetStackerTask", JSON.toJSONString(request), JSON.toJSONString(result), url, LocalDateTime.now(), "WMS"));
|
||||
} catch (Exception e) {
|
||||
logger.error("保存发送任务的日志错误。");
|
||||
}
|
||||
if (result == null) {
|
||||
logger.error("发送堆垛机任务异常。");
|
||||
} else {
|
||||
if (Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
|
||||
logger.info("发送WCS任务成功。");
|
||||
taskService.update(new LambdaUpdateWrapper<Task>()
|
||||
.set(Task::getTaskStatus, WmsTaskStatus.WAIT.getCode())
|
||||
.in(Task::getTaskGroup, taskGroupIds)
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
|
||||
} else {
|
||||
// 判断returnData的数据
|
||||
if (result.getReturnData() != null) {
|
||||
List<WcsTaskRequest> errorTasks = JSON.parseArray(result.getReturnData().toString(), WcsTaskRequest.class);
|
||||
if (!errorTasks.isEmpty()) {
|
||||
List<String> failedTaskIds = errorTasks.stream().map(WcsTaskRequest::getTaskId).distinct().toList();
|
||||
// 更新任务状态为异常
|
||||
taskService.update(new LambdaUpdateWrapper<Task>()
|
||||
.set(Task::getTaskStatus, WmsTaskStatus.EXCEPTION.getCode())
|
||||
.in(Task::getTaskGroup, failedTaskIds)
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
|
||||
}
|
||||
}
|
||||
logger.error("发送任务错误:{}", convertJsonString(result));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.error("WCS发送任务地址为空。");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error("向WCS发送任务时发生异常:{}", convertJsonString(exception));
|
||||
throw new Exception("向WCS发送任务时发生异常。");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,71 +172,66 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
* 发送拣选任务
|
||||
*/
|
||||
@Override
|
||||
public void sendPickTasks() throws Exception {
|
||||
try {
|
||||
// 检索任务表---新建未下发的拣选任务
|
||||
LambdaQueryWrapper<PickTask> waitForDistributePickTaskQuery = new LambdaQueryWrapper<PickTask>()
|
||||
.eq(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode());
|
||||
List<PickTask> allPickTasks = pickTaskService.list(waitForDistributePickTaskQuery);
|
||||
if (allPickTasks == null || allPickTasks.isEmpty()) {
|
||||
return;
|
||||
public void sendPickTasks() {
|
||||
// 检索任务表---新建未下发的拣选任务
|
||||
LambdaQueryWrapper<PickTask> waitForDistributePickTaskQuery = new LambdaQueryWrapper<PickTask>()
|
||||
.eq(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode());
|
||||
List<PickTask> allPickTasks = pickTaskService.list(waitForDistributePickTaskQuery);
|
||||
if (allPickTasks == null || allPickTasks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 需要发送给wcs的拣选任务列表
|
||||
List<WcsStandTaskRequest> request = new ArrayList<>();
|
||||
// 载具对应站台列表
|
||||
Map<String, List<String>> vehicleAndStansMap = new HashMap<>();
|
||||
// 循环生成载具对应站台列表
|
||||
for (PickTask pickTask : allPickTasks) {
|
||||
// 当前载具已经添加过站台
|
||||
if (vehicleAndStansMap.containsKey(pickTask.getVehicleId())) {
|
||||
List<String> oldStandIds = vehicleAndStansMap.get(pickTask.getVehicleId());
|
||||
oldStandIds.add(pickTask.getStandId());
|
||||
vehicleAndStansMap.replace(pickTask.getVehicleId(), oldStandIds);
|
||||
} else {// 新载具
|
||||
List<String> newStandIds = new ArrayList<>();
|
||||
newStandIds.add(pickTask.getStandId());
|
||||
vehicleAndStansMap.put(pickTask.getVehicleId(), newStandIds);
|
||||
}
|
||||
// 需要发送给wcs的拣选任务列表
|
||||
List<WcsStandTaskRequest> request = new ArrayList<>();
|
||||
// 载具对应站台列表
|
||||
Map<String, List<String>> vehicleAndStansMap = new HashMap<>();
|
||||
// 循环生成载具对应站台列表
|
||||
for (PickTask pickTask : allPickTasks) {
|
||||
// 当前载具已经添加过站台
|
||||
if (vehicleAndStansMap.containsKey(pickTask.getVehicleId())) {
|
||||
List<String> oldStandIds = vehicleAndStansMap.get(pickTask.getVehicleId());
|
||||
oldStandIds.add(pickTask.getStandId());
|
||||
vehicleAndStansMap.replace(pickTask.getVehicleId(), oldStandIds);
|
||||
} else {// 新载具
|
||||
List<String> newStandIds = new ArrayList<>();
|
||||
newStandIds.add(pickTask.getStandId());
|
||||
vehicleAndStansMap.put(pickTask.getVehicleId(), newStandIds);
|
||||
}
|
||||
}
|
||||
// 循环生成Wcs任务请求
|
||||
for (String vehicleId : vehicleAndStansMap.keySet()) {
|
||||
WcsStandTaskRequest requestSingle = new WcsStandTaskRequest();
|
||||
requestSingle.setTaskGroup(WmsUtils.generateId(vehicleId));
|
||||
requestSingle.setTaskType(1);
|
||||
requestSingle.setVehicleNo(vehicleId);
|
||||
requestSingle.setLocation(vehicleAndStansMap.get(vehicleId));
|
||||
requestSingle.setRemark("站台拣选任务");
|
||||
request.add(requestSingle);
|
||||
}
|
||||
// 下面是模拟发送wcs拣选任务
|
||||
}
|
||||
// 循环生成Wcs任务请求
|
||||
for (String vehicleId : vehicleAndStansMap.keySet()) {
|
||||
WcsStandTaskRequest requestSingle = new WcsStandTaskRequest();
|
||||
requestSingle.setTaskGroup(WmsUtils.generateId(vehicleId));
|
||||
requestSingle.setTaskType(1);
|
||||
requestSingle.setVehicleNo(vehicleId);
|
||||
requestSingle.setLocation(vehicleAndStansMap.get(vehicleId));
|
||||
requestSingle.setRemark("站台拣选任务");
|
||||
request.add(requestSingle);
|
||||
}
|
||||
// 下面是模拟发送wcs拣选任务
|
||||
// simulateSendPickTasks(vehicleAndStansMap.keySet().stream().toList());
|
||||
if (!request.isEmpty()) {
|
||||
// 发送任务
|
||||
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_PICK_TASK.getConfigKey());
|
||||
if (url != null) {
|
||||
logger.info("向WCS发送拣选任务,地址:{},请求详情:{}", url, convertJsonString(request));
|
||||
ResponseEntity result = JSON.parseObject(HttpUtils.sendHttpPostWithoutToken(url, convertJsonString(request)), ResponseEntity.class);
|
||||
try {
|
||||
logService.save(new WmsLog(WmsUtils.generateId("LOG_"), "向WCS发送拣选任务", "setConveyTask", convertJsonString(request), convertJsonString(result), url, LocalDateTime.now(), "WMS"));
|
||||
} catch (Exception e) {
|
||||
logger.error("插入日志错误。");
|
||||
}
|
||||
if (result != null && Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
|
||||
logger.info("发送拣选任务成功。");
|
||||
pickTaskService.update(new LambdaUpdateWrapper<PickTask>()
|
||||
.set(PickTask::getPickStatus, PickTaskStatusEnum.SEND.getCode())
|
||||
.in(PickTask::getVehicleId, vehicleAndStansMap.keySet())
|
||||
.eq(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode()));
|
||||
} else {
|
||||
logger.error("发送拣选任务错误:{}", convertJsonString(result));
|
||||
}
|
||||
} else {
|
||||
logger.error("WCS发送拣选任务地址为空。");
|
||||
if (!request.isEmpty()) {
|
||||
// 发送任务
|
||||
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_PICK_TASK.getConfigKey());
|
||||
if (url != null) {
|
||||
logger.info("向WCS发送拣选任务,地址:{},请求详情:{}", url, convertJsonString(request));
|
||||
ResponseEntity result = JSON.parseObject(HttpUtils.sendHttpPostWithoutToken(url, convertJsonString(request)), ResponseEntity.class);
|
||||
try {
|
||||
logService.save(new WmsLog(WmsUtils.generateId("LOG_"), "向WCS发送拣选任务", "setConveyTask", convertJsonString(request), convertJsonString(result), url, LocalDateTime.now(), "WMS"));
|
||||
} catch (Exception e) {
|
||||
logger.error("保存发送拣选任务日志错误。");
|
||||
}
|
||||
if (result != null && Objects.equals(ResponseCode.OK.getCode(), result.getCode())) {
|
||||
logger.info("发送拣选任务成功。");
|
||||
pickTaskService.update(new LambdaUpdateWrapper<PickTask>()
|
||||
.set(PickTask::getPickStatus, PickTaskStatusEnum.SEND.getCode())
|
||||
.in(PickTask::getVehicleId, vehicleAndStansMap.keySet())
|
||||
.eq(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode()));
|
||||
} else {
|
||||
logger.error("发送拣选任务错误:{}", convertJsonString(result));
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user