库存查询新增按未使用时长筛选

This commit is contained in:
杨学谦 2025-12-24 10:38:26 +08:00
parent c102f16720
commit 2f3fe17f52
4 changed files with 126 additions and 66 deletions

View File

@ -31,6 +31,7 @@ import com.wms_main.service.controller.ITaskControllerService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -136,69 +137,35 @@ public class TaskController {
/** /**
* test * test
*/ */
@PostMapping("/status") // @PostMapping("/status")
public EwmApiBackResponse test(@RequestBody StockConfirmEntity stockConfirm) { // public EwmApiBackResponse test(@RequestBody StockConfirmEntity stockConfirm) {
//return taskControllerService.ewmInformationBack(wcsVehicleInRequest); // //return taskControllerService.ewmInformationBack(wcsVehicleInRequest);
// return ewmApiService.getEwmStock(request); // // return ewmApiService.getEwmStock(request);
//return ewmApiService.sendWarehouseOutCompleted(request); // //return ewmApiService.sendWarehouseOutCompleted(request);
//return ewmApiService.sendWarehouseInCompleted(new SendWarehouseInCompletedRequest()); // //return ewmApiService.sendWarehouseInCompleted(new SendWarehouseInCompletedRequest());
// 查询对应的库存信息 // // 查询对应的库存信息
List<TAppStock> stockList = appStockService.list(new LambdaQueryWrapper<TAppStock>() //
.eq(TAppStock::getVehicleId, stockConfirm.getVehicleId()) // }
.eq(TAppStock::getGoodsId, stockConfirm.getGoodsId()) // private boolean test(String stand1, String stand2) {
// 特殊库存字段精确匹配 - 根据传入值决定匹配条件 //
.and(wrapper -> { // stand1 = "P22";
if (StringUtils.isEmpty(stockConfirm.getSpecialStock())) { // stand2 = "P18";
// 如果传入null或空字符串匹配数据库中为null或空字符串的记录 //
wrapper.isNull(TAppStock::getSpecialStock) // // P11-P19为一组
.or() // boolean isStand1InP11ToP19 = stand1.compareTo("P11") >= 0 && stand1.compareTo("P19") <= 0;
.eq(TAppStock::getSpecialStock, ""); // boolean isStand2InP11ToP19 = stand2.compareTo("P11") >= 0 && stand2.compareTo("P19") <= 0;
} else { // if (isStand1InP11ToP19 && isStand2InP11ToP19) {
// 如果传入有值精确匹配该值 // return true;
wrapper.eq(TAppStock::getSpecialStock, stockConfirm.getSpecialStock()); // }
} //
}) // // P21-P23为一组
.and(wrapper -> { // List<String> p21ToP23 = Arrays.asList("P21", "P22", "P23");
if (StringUtils.isEmpty(stockConfirm.getSpecialStockNo())) { // if (p21ToP23.contains(stand1) && p21ToP23.contains(stand2)) {
// 如果传入null或空字符串匹配数据库中为null或空字符串的记录 // return true;
wrapper.isNull(TAppStock::getSpecialStockNo) // }
.or() //
.eq(TAppStock::getSpecialStockNo, ""); // return false;
} else { // }
// 如果传入有值精确匹配该值
wrapper.eq(TAppStock::getSpecialStockNo, stockConfirm.getSpecialStockNo());
}
})
.and(wrapper -> {
if (StringUtils.isEmpty(stockConfirm.getSpecialStockItemNo())) {
// 如果传入null或空字符串匹配数据库中为null或空字符串的记录
wrapper.isNull(TAppStock::getSpecialStockItemNo)
.or()
.eq(TAppStock::getSpecialStockItemNo, "");
} else {
// 如果传入有值精确匹配该值
wrapper.eq(TAppStock::getSpecialStockItemNo, stockConfirm.getSpecialStockItemNo());
}
})
.and(wrapper -> {
if (StringUtils.isEmpty(stockConfirm.getBatchNo())) {
// 如果传入null或空字符串匹配数据库中为null或空字符串的记录
wrapper.isNull(TAppStock::getBatchNo)
.or()
.eq(TAppStock::getBatchNo, "");
} else {
// 如果传入有值精确匹配该值
wrapper.eq(TAppStock::getBatchNo, stockConfirm.getBatchNo());
}
})
.orderByDesc(TAppStock::getFirstInTime)
);
return EwmApiBackResponse.success(
"查询成功",
stockList
);
}
/** /**
* wcs请求载具入库 * wcs请求载具入库
@ -290,6 +257,17 @@ public class TaskController {
return taskControllerService.requestInventory(inventoryRequest); return taskControllerService.requestInventory(inventoryRequest);
} }
/**
* 批量下发盘点请求
* @param batchInventoryRequest 批量盘点请求
* @return 请求结果
*/
@PostMapping("/batchRequestInventory")
public BaseWmsApiResponse batchRequestInventory(@RequestBody BatchInventoryRequest batchInventoryRequest) {
return taskControllerService.batchRequestInventory(batchInventoryRequest);
}
/** /**
* 查询盘点任务确认信息 * 查询盘点任务确认信息
* @param inventoryConfirmRequest 请求 * @param inventoryConfirmRequest 请求

View File

@ -57,4 +57,10 @@ public class StockQuery extends PageQuery{
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate toDate; private LocalDate toDate;
/**
* 未使用天数
*/
@JsonProperty("noUseDays")
private Integer noUseDays;
} }

View File

@ -93,6 +93,14 @@ public class StockVo {
*/ */
@JsonProperty("firstInUser") @JsonProperty("firstInUser")
private String firstInUser; private String firstInUser;
/**
* 上次盘点时间
*/
@JsonProperty("lastInventoryTime")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime lastInventoryTime;
/** /**
* 上次更新时间 * 上次更新时间
*/ */
@ -150,6 +158,7 @@ public class StockVo {
stockPo.getSled(), stockPo.getSled(),
stockPo.getFirstInTime(), stockPo.getFirstInTime(),
stockPo.getFirstInUser(), stockPo.getFirstInUser(),
stockPo.getLastInventoryTime(),
stockPo.getLastUpdateTime(), stockPo.getLastUpdateTime(),
stockPo.getLastUpdateUser(), stockPo.getLastUpdateUser(),
stockPo.getSpecialStock(), stockPo.getSpecialStock(),

View File

@ -351,6 +351,35 @@ public class OutsExecutorServiceImpl implements IOutsExecutorService {
} }
/**
* 判断两个站台是否属于同一组
* @param stand1 站台1
* @param stand2 站台2
* @return 是否属于同一组
*/
private boolean isSameStandGroup(String stand1, String stand2) {
if (stand1 == null || stand2 == null) {
return false;
}
// P11-P19为一组
boolean isStand1InP11ToP19 = stand1.compareTo("P11") >= 0 && stand1.compareTo("P19") <= 0;
boolean isStand2InP11ToP19 = stand2.compareTo("P11") >= 0 && stand2.compareTo("P19") <= 0;
if (isStand1InP11ToP19 && isStand2InP11ToP19) {
return true;
}
// P21-P23为一组
List<String> p21ToP23 = Arrays.asList("P21", "P22", "P23");
if (p21ToP23.contains(stand1) && p21ToP23.contains(stand2)) {
return true;
}
return false;
}
/** /**
* 处理紧急出库任务 * 处理紧急出库任务
* *
@ -403,6 +432,25 @@ public class OutsExecutorServiceImpl implements IOutsExecutorService {
// 当前堆垛机已经无法生成新的出库任务了 // 当前堆垛机已经无法生成新的出库任务了
continue; continue;
} }
if (!Objects.equals(stock.getStockStatus(), WmsStockStatusEnums.OK.getCode())) {
// 需要判断对应的pickTask的终点
List<TAppPickTask> pickTasksByJudge = appPickTaskService.list(
new LambdaQueryWrapper<TAppPickTask>()
.eq(TAppPickTask::getVehicleId, stock.getVehicleId())
);
// 如果有拣选任务检查是否为同一组站台
if (!pickTasksByJudge.isEmpty()) {
TAppPickTask firstPickTask = pickTasksByJudge.getFirst();
String pickTaskDestination = firstPickTask.getPickStand();
// 如果不是同一组站台则跳过
if (!isSameStandGroup(pickTaskDestination, optimalDestination)) {
continue;
}
}
// 如果没有拣选任务或为同一组站台继续执行后续逻辑
}
// 判断当前的这条库存当前站台是否需要 // 判断当前的这条库存当前站台是否需要
int stockIsEmpty; int stockIsEmpty;
int originNum = stock.getRemainNum(); int originNum = stock.getRemainNum();
@ -1192,6 +1240,25 @@ public class OutsExecutorServiceImpl implements IOutsExecutorService {
// 当前堆垛机已经无法生成新的出库任务了 // 当前堆垛机已经无法生成新的出库任务了
continue; continue;
} }
if (!Objects.equals(stock.getStockStatus(), WmsStockStatusEnums.OK.getCode())) {
// 需要判断对应的pickTask的终点
List<TAppPickTask> pickTasksByJudge = appPickTaskService.list(
new LambdaQueryWrapper<TAppPickTask>()
.eq(TAppPickTask::getVehicleId, stock.getVehicleId())
);
// 如果有拣选任务检查是否为同一组站台
if (!pickTasksByJudge.isEmpty()) {
TAppPickTask firstPickTask = pickTasksByJudge.getFirst();
String pickTaskDestination = firstPickTask.getPickStand();
// 如果不是同一组站台则跳过
if (!isSameStandGroup(pickTaskDestination, getOptimalSubStand(inventory.getInvStand()))) {
continue;
}
}
// 如果没有拣选任务或为同一组站台继续执行后续逻辑
}
// 拣选任务状态 // 拣选任务状态
int pickTaskStatus = WmsPickTaskStatusEnum.TEMP.getCode(); int pickTaskStatus = WmsPickTaskStatusEnum.TEMP.getCode();
// 库存正常 // 库存正常