代码更新:

1. 增加站台非计划功能
This commit is contained in:
梁州 2024-12-16 12:41:47 +08:00
parent 91f3f45015
commit 635e75fa0e
4 changed files with 105 additions and 23 deletions

View File

@ -477,7 +477,6 @@ public class TaskController {
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
.eq(Vehicle::getVehicleId, outTask.getVehicleId())
.ne(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode()));
if (StringUtils.isNotEmpty(outTask.getPickStand())) {
// 当前载具上所有库存状态设置为拣选
stockService.update(new LambdaUpdateWrapper<Stock>()
.set(Stock::getStockStatus, StockStatus.PICKING.getCode())
@ -488,7 +487,6 @@ public class TaskController {
.set(PickTask::getPickStatus, PickTaskStatusEnum.NEW.getCode())
.eq(PickTask::getVehicleId, outTask.getVehicleId())
.eq(PickTask::getPickStatus, PickTaskStatusEnum.TEMP.getCode()));
}
} else {// 代表整出
// 删除当前载具上所有库存
List<Stock> removeStocks = stockService.list(new LambdaQueryWrapper<Stock>().eq(Stock::getVehicleId, outTask.getVehicleId()));
@ -854,6 +852,7 @@ public class TaskController {
pickTaskService.update(new LambdaUpdateWrapper<PickTask>()
.set(PickTask::getPickStatus, PickTaskStatusEnum.FINISH.getCode())
.set(PickTask::getLastUpdateTime, LocalDateTime.now())
.set(PickTask::getArriveTime, LocalDateTime.now())
.eq(PickTask::getVehicleId, boxArriveRequest.getVehicleNo())
.eq(PickTask::getStandId, boxArriveRequest.getLocation()));
// 更新这个箱子其他的暂存任务为待下发
@ -1577,7 +1576,7 @@ public class TaskController {
}
}
}
if (goodsIdList.size() > 0) {
if (!goodsIdList.isEmpty()) {
// 判断这些物料是不是当前站台的工作流中仍然需要
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, standId)
@ -1757,7 +1756,7 @@ public class TaskController {
}
}
}
if (goodsIdList.size() > 0) {
if (!goodsIdList.isEmpty()) {
// 判断这些物料是不是当前站台的工作流中是否需要
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId())
@ -2820,11 +2819,31 @@ public class TaskController {
response.setMessage("查询拣选站台错误。");
return convertJsonString(response);
}
// TODO 以下是非计划领料变动
// 1. 判断当前站台是否允许非计划
if (targetStand.getAllowNoPlan() != 1) {
logger.error("当前站台不允许非计划领料:{}。", targetStand.getStandId());
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("当前站台不允许非计划领料。");
return convertJsonString(response);
}
// 2. 判断当前站台是否有工作流
boolean haveWorkFlows = workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId()));
if (haveWorkFlows) {
logger.error("当前站台还有工作不允许非计划领料:{}。", targetStand.getStandId());
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("当前站台还有工作不允许非计划领料。");
return convertJsonString(response);
}
// 查询库存
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, noPlanRequest.getGoodsId())
.apply("goods_related ->> '$.remainNum' > 0")
.orderByAsc(Stock::getCreateTime));
.orderByAsc(Stock::getCreateTime, Stock::getStockStatus));
// 查询应该的库存总数
List<StockOfGoodsDto> stockOfGoodsList = stockService.selectSumOfGoods(noPlanRequest.getGoodsId());
// 总数量
@ -2834,6 +2853,12 @@ public class TaskController {
BigDecimal needNum = noPlanRequest.getNeedNum();
// 出库任务列表
List<Task> outTasks = new ArrayList<>();
// TODO 非计划变动
// 拣选任务列表
List<PickTask> pickTasks = new ArrayList<>();
// 尝试生成出库任务
List<String> pickStandIds = new ArrayList<>();
for (Stock tempStock : stockList) {
@ -2870,6 +2895,21 @@ public class TaskController {
tempOutTask.setCreateTime(LocalDateTime.now());
tempOutTask.setIsPicking(1);
outTasks.add(tempOutTask);
// TODO 非计划变动
// 只有备料站台才下发拣选任务
if (targetStand.getStandType() == 2) {
// 创建拣选任务
PickTask tempPickTask = new PickTask();
String key = tempStock.getVehicleId() + "_" + targetStand.getStandId();
tempPickTask.setPickTaskId(key);
tempPickTask.setVehicleId(tempStock.getVehicleId());
tempPickTask.setStandId(targetStand.getStandId());
tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode());
tempPickTask.setLastUpdateTime(LocalDateTime.now());
pickTasks.add(tempPickTask);
}
} else if (Objects.equals(tempStock.getStockStatus(), StockStatus.OUT.getCode())
|| Objects.equals(tempStock.getStockStatus(), StockStatus.PICKING.getCode())) {
// 查询这个箱子的拣选任务
@ -2897,17 +2937,44 @@ public class TaskController {
.set(Task::getTaskPriority, 2)
.eq(Task::getVehicleId, tempStock.getVehicleId())
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
// TODO 非计划变动
if (targetStand.getStandType() == 1) {
// 入库站台
thisVehiclePickTasks.forEach(pickTask -> {
if (!pickStandIds.contains(pickTask.getStandId())) {
pickStandIds.add(pickTask.getStandId());
}
});
} else {
// 备料站台---是否有当前站台的任务
List<PickTask> thisStandPickTask = thisVehiclePickTasks.stream().filter(pickTask -> pickTask.getStandId().equals(targetStand.getStandId())).toList();
if (thisStandPickTask.isEmpty()) {
// 创建拣选任务
PickTask tempPickTask = new PickTask();
String key = tempStock.getVehicleId() + "_" + targetStand.getStandId();
tempPickTask.setPickTaskId(key);
tempPickTask.setVehicleId(tempStock.getVehicleId());
tempPickTask.setStandId(targetStand.getStandId());
tempPickTask.setPickStatus(PickTaskStatusEnum.NEW.getCode());
tempPickTask.setLastUpdateTime(LocalDateTime.now());
pickTasks.add(tempPickTask);
}
}
}
}
}
// 添加出库任务
if (!outTasks.isEmpty()) {
// 保存出库任务
taskService.saveBatch(outTasks);
// TODO 非计划变动
// 保存拣选任务
if (!pickTasks.isEmpty()) {
pickTaskService.saveBatch(pickTasks);
}
List<String> vehicleIds = outTasks.stream().map(Task::getVehicleId).distinct().toList();
// 更新库存状态
stockService.update(new LambdaUpdateWrapper<Stock>()
@ -3065,12 +3132,12 @@ public class TaskController {
boolean hasInTask = taskService.exists(new LambdaQueryWrapper<Task>()
.eq(Task::getVehicleId, pickNumQuery.getVehicleId())
.eq(Task::getTaskType, TaskType.IN.getCode())
.eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode())
// .eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode())
.likeRight(Task::getTaskId, "RK_"));
if (!hasInTask) {
// 生成回库任务
Task backTask = new Task();
backTask.setTaskId(generateId("HK_"));
backTask.setTaskId(generateId("HK_FJH_"));
backTask.setTaskGroup(generateId(""));
backTask.setTaskType(TaskType.IN.getCode());
backTask.setTaskStatus(WmsTaskStatus.TEMP.getCode());
@ -3087,9 +3154,9 @@ public class TaskController {
response.setCode(ResponseCode.OK.getCode());
response.setMessage("确认回库成功。");
} else {
logger.error("当前箱子还有拣选任务,不能回库,请将箱子置入拣货环线。");
logger.error("当前箱子还有拣选任务,不能回库,请将箱子置入拣货环线。(如果在备料站台操作时,请确认不需要拿料时,按站台按钮放行即可。)");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("当前箱子还有拣选任务,不能回库,请将箱子置入拣货环线。");
response.setMessage("当前箱子还有拣选任务,不能回库,请将箱子置入拣货环线。(如果在备料站台操作时,请确认不需要拿料时,按站台按钮放行即可。)");
}
return convertJsonString(response);
} catch (Exception e) {

View File

@ -42,4 +42,9 @@ public class PickTask {
*/
@TableField("last_update_time")
private LocalDateTime lastUpdateTime;
/**
* 到达时间
*/
@TableField("arrive_time")
private LocalDateTime arriveTime;
}

View File

@ -42,4 +42,9 @@ public class PickTaskRecord {
*/
@TableField("last_update_time")
private LocalDateTime lastUpdateTime;
/**
* 到达时间
*/
@TableField("arrive_time")
private LocalDateTime arriveTime;
}

View File

@ -91,4 +91,9 @@ public class Stand {
*/
@TableField("pick_vehicle_count")
private Integer pickVehicleCount;
/**
* 是否允许非计划领料
*/
@TableField("allow_no_plan")
private Integer allowNoPlan;
}