1. 盘点请求中增加站台号字段;

2. 增加在拣选站台盘点的功能;
3. 增加每个站台的电子标签数量到160。
This commit is contained in:
梁州 2025-12-10 14:54:05 +08:00
parent 0c82ebffc3
commit feaa3f6377
3 changed files with 90 additions and 18 deletions

View File

@ -259,7 +259,11 @@ public class LocationController {
try {
List<ETagLocation> eLocations = new ArrayList<>();
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 120; j++) {
for (int j = 1; j <= 160; j++) {
if (j == 128) {
// 128号标签不用
continue;
}
ETagLocation eTagLocation = new ETagLocation();
if (j < 100) {
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0"));

View File

@ -3204,6 +3204,36 @@ public class TaskController {
response.setMessage("盘点,请输入料号。");
return convertJsonString(response);
}
// 获取站台号
Stand targetStand;
if (StringUtils.isNotEmpty(inventoryRequest.getStandId())) {
// 站台号从请求参数中获取
targetStand = standService.getById(inventoryRequest.getStandId());
} else {
// 站台号从ip获取
targetStand = standService.getOne(new LambdaQueryWrapper<Stand>()
.eq(Stand::getStandIp, HttpUtils.getIpAddr(servletRequest))
.eq(Stand::getStandType, 1)
.last("limit 1"));
}
if (targetStand == null) {
logger.error("查询盘点站台错误。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("查询盘点站台错误。");
return convertJsonString(response);
}
// 判断当前站台是否有工作流
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, inventoryRequest.getGoodsId())
@ -3218,7 +3248,10 @@ public class TaskController {
// 生成出库任务
List<Task> outTasks = new ArrayList<>();
List<InventoryList> inventoryList = new ArrayList<>();
// 本次出库的料箱
List<String> thisTimeOutVehicleIds = new ArrayList<>();
for (Stock stock : stockList) {
if (!thisTimeOutVehicleIds.contains(stock.getVehicleId())) {
// 创建出库任务
Task tempOutTask = new Task();
tempOutTask.setTaskId(generateId("INV_"));
@ -3233,6 +3266,9 @@ public class TaskController {
tempOutTask.setCreateTime(LocalDateTime.now());
tempOutTask.setIsPicking(1);
outTasks.add(tempOutTask);
thisTimeOutVehicleIds.add(stock.getVehicleId());
}
// 创建盘点
InventoryList tempInventoryList = new InventoryList();
tempInventoryList.setInventoryId(generateId("INV_"));
@ -3250,16 +3286,43 @@ public class TaskController {
taskService.saveBatch(outTasks);
// 保存盘点
inventoryService.saveBatch(inventoryList);
List<String> vehicleIds = outTasks.stream().map(Task::getVehicleId).distinct().toList();
// 判断本次是否需要生成拣选任务
if (targetStand.getStandType() == 2) {
List<PickTask> newPickTasks = new ArrayList<>();
// 如果是拣选站台的话需要生成拣选任务
List<PickTask> oldPickTasks = pickTaskService.list(new LambdaQueryWrapper<PickTask>()
.eq(PickTask::getStandId, targetStand.getStandId())
.in(PickTask::getVehicleId, thisTimeOutVehicleIds));
for (String vehicleId : thisTimeOutVehicleIds) {
// 判断这个料箱是否需要生成新的拣选任务
List<PickTask> hasOldPickTask = oldPickTasks.stream().filter(pickTask -> pickTask.getVehicleId().equals(vehicleId)).toList();
if (!hasOldPickTask.isEmpty()) {
continue;
}
// 创建拣选任务
PickTask tempPickTask = new PickTask();
String key = vehicleId + "_" + targetStand.getStandId();
tempPickTask.setPickTaskId(key);
tempPickTask.setVehicleId(vehicleId);
tempPickTask.setStandId(targetStand.getStandId());
tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode());
tempPickTask.setLastUpdateTime(LocalDateTime.now());
newPickTasks.add(tempPickTask);
}
if (!newPickTasks.isEmpty()) {
// 保存拣选任务
pickTaskService.saveOrUpdateBatch(newPickTasks);
}
}
// 更新库存状态
stockService.update(new LambdaUpdateWrapper<Stock>()
.set(Stock::getStockStatus, StockStatus.OUT.getCode())
.in(Stock::getVehicleId, vehicleIds)
.in(Stock::getVehicleId, thisTimeOutVehicleIds)
.eq(Stock::getStockStatus, StockStatus.OK.getCode()));
// 更新料箱状态
vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
.in(Vehicle::getVehicleId, vehicleIds)
.in(Vehicle::getVehicleId, thisTimeOutVehicleIds)
.eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode()));
}

View File

@ -39,4 +39,9 @@ public class InventoryRequest {
*/
@JsonProperty("userName")
private String userName;
/**
* 站台
*/
@JsonProperty("standId")
private String standId;
}