代码更新:

1.修复入库和出库的问题
This commit is contained in:
梁州 2024-08-26 16:45:14 +08:00
parent f596f46b72
commit 8b658cd2c0
2 changed files with 25 additions and 22 deletions

View File

@ -232,7 +232,7 @@ public class TaskController {
TaskDetailInfo goodsRelatedInfo = new TaskDetailInfo(); TaskDetailInfo goodsRelatedInfo = new TaskDetailInfo();
// TODO 物料信息需要完善 // TODO 物料信息需要完善
goodsRelatedInfo.setGoodsId(goodsInRequest.getGoodsId()); goodsRelatedInfo.setGoodsId(goodsInRequest.getGoodsId());
goodsRelatedInfo.setGoodsName(""); goodsRelatedInfo.setGoodsName(goodsInRequest.getGoodsName());
goodsRelatedInfo.setOpNum(goodsInRequest.getGoodsNum()); goodsRelatedInfo.setOpNum(goodsInRequest.getGoodsNum());
goodsRelatedInfo.setOriginNum(BigDecimal.ZERO); goodsRelatedInfo.setOriginNum(BigDecimal.ZERO);
tempInTask.setGoodsRelated(goodsRelatedInfo); tempInTask.setGoodsRelated(goodsRelatedInfo);
@ -308,11 +308,12 @@ public class TaskController {
// 验证物料编号 // 验证物料编号
if (StringUtils.isEmpty(goodsInRequest.getGoodsId())) { if (StringUtils.isEmpty(goodsInRequest.getGoodsId())) {
return TaskInValidationEnum.NO_GOODS_ID.getErrorMessage(); return TaskInValidationEnum.NO_GOODS_ID.getErrorMessage();
} else {
if (!goodsService.validateGoodsId(goodsInRequest.getGoodsId())) {
return TaskInValidationEnum.ERROR_GOODS_ID.getErrorMessage();
}
} }
// } else {
// if (!goodsService.validateGoodsId(goodsInRequest.getGoodsId())) {
// return TaskInValidationEnum.ERROR_GOODS_ID.getErrorMessage();
// }
// }
// 验证数量 // 验证数量
if (goodsInRequest.getGoodsNum() == null || goodsInRequest.getGoodsNum().compareTo(BigDecimal.ZERO) <= 0) { if (goodsInRequest.getGoodsNum() == null || goodsInRequest.getGoodsNum().compareTo(BigDecimal.ZERO) <= 0) {
return TaskInValidationEnum.ERROR_GOODS_NUM.getErrorMessage(); return TaskInValidationEnum.ERROR_GOODS_NUM.getErrorMessage();
@ -483,7 +484,7 @@ public class TaskController {
boolean lockVehicleFlag = vehicleService.update(new LambdaUpdateWrapper<Vehicle>() boolean lockVehicleFlag = vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode()) .set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
.eq(Vehicle::getVehicleId, stock.getVehicleId()) .eq(Vehicle::getVehicleId, stock.getVehicleId())
.eq(Vehicle::getVehicleStatus, VehicleStatus.ON)); .eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode()));
if (!lockStocksFlag || !lockVehicleFlag) { if (!lockStocksFlag || !lockVehicleFlag) {
// 释放锁 // 释放锁
stockService.update(new LambdaUpdateWrapper<Stock>() stockService.update(new LambdaUpdateWrapper<Stock>()
@ -603,21 +604,21 @@ public class TaskController {
} }
// 验证载具号 // 验证载具号
if (StringUtils.isNotEmpty(taskOutRequest.getVehicleId()) if (StringUtils.isNotEmpty(taskOutRequest.getVehicleId())
&& vehicleService.exists(new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getVehicleId, taskOutRequest.getVehicleId()))) { && !vehicleService.exists(new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getAreaId, taskOutRequest.getAreaId()).eq(Vehicle::getVehicleId, taskOutRequest.getVehicleId()))) {
return TaskOutValidationEnum.ERROR_VEHICLE_ID.getErrorMessage(); return TaskOutValidationEnum.ERROR_VEHICLE_ID.getErrorMessage();
} }
// 验证库位 // 验证库位
if (StringUtils.isNotEmpty(taskOutRequest.getOriginPoint()) if (StringUtils.isNotEmpty(taskOutRequest.getOriginPoint())
&& locationService.exists(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, taskOutRequest.getOriginPoint()))) { && !locationService.exists(new LambdaQueryWrapper<Location>().eq(Location::getAreaId, taskOutRequest.getAreaId()).eq(Location::getLocationId, taskOutRequest.getOriginPoint()))) {
return TaskOutValidationEnum.ERROR_ORIGIN_POINT.getErrorMessage(); return TaskOutValidationEnum.ERROR_ORIGIN_POINT.getErrorMessage();
} }
// 验证终点站台 // 验证终点站台
if (taskOutRequest.getIsPicking() == 0) {// 出库 if (taskOutRequest.getIsPicking() == 0) {// 出库
if (!standService.validateStand(taskOutRequest.getDestinationPoint(), 2)) { if (!standService.validateStand(taskOutRequest.getDestinationPoint(), TaskType.OUT.getCode())) {
return TaskOutValidationEnum.ERROR_DESTINATION_POINT.getErrorMessage(); return TaskOutValidationEnum.ERROR_DESTINATION_POINT.getErrorMessage();
} }
} else {// 拣选出库 } else {// 拣选出库
if (!standService.validateStand(taskOutRequest.getDestinationPoint(), 3)) { if (!standService.validateStand(taskOutRequest.getDestinationPoint(), TaskType.INVENTORY.getCode())) {
return TaskOutValidationEnum.ERROR_PICK_STAND.getErrorMessage(); return TaskOutValidationEnum.ERROR_PICK_STAND.getErrorMessage();
} }
} }
@ -628,6 +629,7 @@ public class TaskController {
} }
// 查询库存信息 // 查询库存信息
LambdaQueryWrapper<Stock> stockQueryWrapper = new LambdaQueryWrapper<Stock>() LambdaQueryWrapper<Stock> stockQueryWrapper = new LambdaQueryWrapper<Stock>()
.eq(Stock::getAreaId, taskOutRequest.getAreaId())
.apply("goods_related -> '$.goodsId' = {0}", taskOutRequest.getGoodsId()) .apply("goods_related -> '$.goodsId' = {0}", taskOutRequest.getGoodsId())
.apply("goods_related -> '$.remainNum' > 0") .apply("goods_related -> '$.remainNum' > 0")
.eq(StringUtils.isNotEmpty(taskOutRequest.getVehicleId()), Stock::getVehicleId, taskOutRequest.getVehicleId()) .eq(StringUtils.isNotEmpty(taskOutRequest.getVehicleId()), Stock::getVehicleId, taskOutRequest.getVehicleId())

View File

@ -57,11 +57,11 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
// 生成当前深度-1的库位的移库任务 // 生成当前深度-1的库位的移库任务
TaskDto depthMinus1MoveTask = new TaskDto(); TaskDto depthMinus1MoveTask = new TaskDto();
Location depthMinus1Location = locationMapper.selectOne(new LambdaQueryWrapper<Location>() Location depthMinus1Location = locationMapper.selectOne(new LambdaQueryWrapper<Location>()
.eq(Location::getAreaId, outLocation.getAreaId()) .eq(Location::getAreaId, outLocation.getAreaId())
.eq(Location::getWRow, outLocation.getWRow()) .eq(Location::getWRow, outLocation.getWRow())
.eq(Location::getWCol, outLocation.getWCol()) .eq(Location::getWCol, outLocation.getWCol())
.eq(Location::getWLayer, outLocation.getWLayer()) .eq(Location::getWLayer, outLocation.getWLayer())
.eq(Location::getWDepth, outLocation.getWDepth() - 1)); .eq(Location::getWDepth, outLocation.getWDepth() - 1));
if (depthMinus1Location.getIsLock() == 1) {// 外层库位锁定 if (depthMinus1Location.getIsLock() == 1) {// 外层库位锁定
depthMinus1MoveTask.setTaskId("LOCKED"); depthMinus1MoveTask.setTaskId("LOCKED");
return depthMinus1MoveTask; return depthMinus1MoveTask;
@ -71,7 +71,7 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
// 查看这个库位是否有入库任务 // 查看这个库位是否有入库任务
Task depthMinusIn1Task = taskMapper.selectOne(new LambdaQueryWrapper<Task>() Task depthMinusIn1Task = taskMapper.selectOne(new LambdaQueryWrapper<Task>()
.eq(Task::getTaskType, TaskType.IN.getCode()) .eq(Task::getTaskType, TaskType.IN.getCode())
.eq(Task::getAreaId, depthMinus1Location.getAreaId()) .eq(Task::getAreaId, depthMinus1Location.getAreaId())
.eq(Task::getDestination, depthMinus1Location.getLocationId())); .eq(Task::getDestination, depthMinus1Location.getLocationId()));
if (depthMinusIn1Task != null) { if (depthMinusIn1Task != null) {
// 生成移库任务并把移库任务的前置任务设置为该入库任务 // 生成移库任务并把移库任务的前置任务设置为该入库任务
@ -81,19 +81,19 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
// 对应载具所有库存上锁 // 对应载具所有库存上锁
stockMapper.update(new LambdaUpdateWrapper<Stock>() stockMapper.update(new LambdaUpdateWrapper<Stock>()
.set(Stock::getStockStatus, StockStatus.MOVE.getCode()) .set(Stock::getStockStatus, StockStatus.MOVE.getCode())
.eq(Stock::getAreaId, depthMinus1Location.getAreaId()) .eq(Stock::getAreaId, depthMinus1Location.getAreaId())
.eq(Stock::getLocationId, depthMinus1Location.getLocationId())); .eq(Stock::getLocationId, depthMinus1Location.getLocationId()));
// 对应载具状态设置 // 对应载具状态设置
vehicleMapper.update(new LambdaUpdateWrapper<Vehicle>() vehicleMapper.update(new LambdaUpdateWrapper<Vehicle>()
.set(Vehicle::getVehicleStatus, VehicleStatus.MOVE.getCode()) .set(Vehicle::getVehicleStatus, VehicleStatus.MOVE.getCode())
.eq(Vehicle::getAreaId, depthMinus1Location.getAreaId()) .eq(Vehicle::getAreaId, depthMinus1Location.getAreaId())
.eq(Vehicle::getCurrentLocation, depthMinus1Location.getLocationId())); .eq(Vehicle::getCurrentLocation, depthMinus1Location.getLocationId()));
depthMinus1MoveTask.setTaskId(moveTask.getTaskId()); depthMinus1MoveTask.setTaskId(moveTask.getTaskId());
return depthMinus1MoveTask; return depthMinus1MoveTask;
} else { } else {
// 判断是否有出库移库盘点拣选等任务 // 判断是否有出库移库盘点拣选等任务
Task depthMinusOut1Task = taskMapper.selectOne(new LambdaQueryWrapper<Task>() Task depthMinusOut1Task = taskMapper.selectOne(new LambdaQueryWrapper<Task>()
.eq(Task::getAreaId, depthMinus1Location.getAreaId()) .eq(Task::getAreaId, depthMinus1Location.getAreaId())
.eq(Task::getOrigin, depthMinus1Location.getLocationId())); .eq(Task::getOrigin, depthMinus1Location.getLocationId()));
if (depthMinusOut1Task != null) { if (depthMinusOut1Task != null) {
depthMinus1MoveTask.setTaskId(depthMinusOut1Task.getTaskId()); depthMinus1MoveTask.setTaskId(depthMinusOut1Task.getTaskId());
@ -111,12 +111,12 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
// 对应载具所有库存上锁 // 对应载具所有库存上锁
stockMapper.update(new LambdaUpdateWrapper<Stock>() stockMapper.update(new LambdaUpdateWrapper<Stock>()
.set(Stock::getStockStatus, StockStatus.MOVE.getCode()) .set(Stock::getStockStatus, StockStatus.MOVE.getCode())
.eq(Stock::getAreaId, depthMinus1Location.getAreaId()) .eq(Stock::getAreaId, depthMinus1Location.getAreaId())
.eq(Stock::getLocationId, depthMinus1Location.getLocationId())); .eq(Stock::getLocationId, depthMinus1Location.getLocationId()));
// 对应载具状态设置 // 对应载具状态设置
vehicleMapper.update(new LambdaUpdateWrapper<Vehicle>() vehicleMapper.update(new LambdaUpdateWrapper<Vehicle>()
.set(Vehicle::getVehicleStatus, VehicleStatus.MOVE.getCode()) .set(Vehicle::getVehicleStatus, VehicleStatus.MOVE.getCode())
.eq(Vehicle::getAreaId, depthMinus1Location.getAreaId()) .eq(Vehicle::getAreaId, depthMinus1Location.getAreaId())
.eq(Vehicle::getCurrentLocation, depthMinus1Location.getLocationId())); .eq(Vehicle::getCurrentLocation, depthMinus1Location.getLocationId()));
depthMinus1MoveTask.setTaskId(moveTask.getTaskId()); depthMinus1MoveTask.setTaskId(moveTask.getTaskId());
} }
@ -134,6 +134,7 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
/** /**
* 生成一个移库任务 * 生成一个移库任务
*
* @param originLocation 原库位 * @param originLocation 原库位
* @return 生成的移库任务 * @return 生成的移库任务
*/ */
@ -142,7 +143,7 @@ public class TaskServiceImplements extends ServiceImpl<TaskMapper, Task> impleme
// 先找一个新库位同一个设备号但是不同的排列层 // 先找一个新库位同一个设备号但是不同的排列层
Location newLocation = new Location(); Location newLocation = new Location();
List<Location> availableLocations = locationMapper.selectList(new LambdaQueryWrapper<Location>() List<Location> availableLocations = locationMapper.selectList(new LambdaQueryWrapper<Location>()
.eq(Location::getAreaId, originLocation.getAreaId()) .eq(Location::getAreaId, originLocation.getAreaId())
.eq(Location::getEquipmentId, originLocation.getEquipmentId()) .eq(Location::getEquipmentId, originLocation.getEquipmentId())
.eq(Location::getLocationType, originLocation.getLocationType()) .eq(Location::getLocationType, originLocation.getLocationType())
.eq(Location::getIsLock, 0) .eq(Location::getIsLock, 0)