优化
This commit is contained in:
+9
@@ -3,6 +3,7 @@ package com.baiyue.warehouse.controller;
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.warehouse.dto.DropshipPalletRequests;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletEntity;
|
||||
import com.baiyue.warehouse.dto.WarehousePalletResolveResponse;
|
||||
import com.baiyue.warehouse.security.InternalServiceTokenGuard;
|
||||
import com.baiyue.warehouse.service.WarehouseResourceService;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -22,4 +23,12 @@ public class InternalWarehousePalletController {
|
||||
tokenGuard.verify(token);
|
||||
return ApiResponse.success(service.ensureDropshipPallet(request.customerId(), request.warehouseId(), request.businessId()));
|
||||
}
|
||||
|
||||
@GetMapping("/resolve/{palletCode}")
|
||||
public ApiResponse<WarehousePalletResolveResponse> resolve(
|
||||
@RequestHeader(value = "X-Internal-Service-Token", required = false) String token,
|
||||
@PathVariable String palletCode) {
|
||||
tokenGuard.verify(token);
|
||||
return ApiResponse.success(service.resolvePublicPallet(palletCode));
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.baiyue.warehouse.dto;
|
||||
|
||||
public record WarehousePalletResolveResponse(
|
||||
long palletId,
|
||||
String palletCode,
|
||||
long warehouseId,
|
||||
long locationId,
|
||||
String status,
|
||||
String fbaWarehouseCode,
|
||||
int version
|
||||
) {
|
||||
}
|
||||
+9
@@ -17,6 +17,8 @@ import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class WarehouseResourceRepository {
|
||||
@Resource private WarehouseMapper warehouses;
|
||||
@@ -135,6 +137,13 @@ public class WarehouseResourceRepository {
|
||||
.eq(WarehousePalletEntity::getId, id));
|
||||
}
|
||||
|
||||
public List<WarehousePalletEntity> findPublicPalletsByCode(String palletCode) {
|
||||
return pallets.selectList(new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
.eq(WarehousePalletEntity::getCustomerId, 0L)
|
||||
.eq(WarehousePalletEntity::getPalletCode, palletCode)
|
||||
.orderByAsc(WarehousePalletEntity::getId));
|
||||
}
|
||||
|
||||
public boolean palletCodeExists(long customerId, long warehouseId, String code, Long excludedId) {
|
||||
return pallets.selectCount(new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
.eq(WarehousePalletEntity::getCustomerId, customerId)
|
||||
|
||||
+16
@@ -5,6 +5,7 @@ import com.baiyue.common.core.api.ResultCode;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.warehouse.dto.LocationRequests;
|
||||
import com.baiyue.warehouse.dto.PalletRequests;
|
||||
import com.baiyue.warehouse.dto.WarehousePalletResolveResponse;
|
||||
import com.baiyue.warehouse.entity.WarehouseLocationEntity;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletEntity;
|
||||
import com.baiyue.warehouse.entity.WarehouseEntity;
|
||||
@@ -175,6 +176,21 @@ public class WarehouseResourceService {
|
||||
return requirePallet(customerId, warehouseId, id);
|
||||
}
|
||||
|
||||
public WarehousePalletResolveResponse resolvePublicPallet(String palletCode) {
|
||||
if (!StringUtils.hasText(palletCode)) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "托盘码不能为空");
|
||||
}
|
||||
var matches = repository.findPublicPalletsByCode(palletCode.trim());
|
||||
if (matches.isEmpty()) throw new BizException(ResultCode.NOT_FOUND, "托盘码不存在");
|
||||
if (matches.size() != 1) throw new BizException(ResultCode.CONFLICT, "托盘码在多个仓库重复,无法解析");
|
||||
WarehousePalletEntity pallet = matches.get(0);
|
||||
if (pallet.getLocationId() == null) throw new BizException(ResultCode.CONFLICT, "托盘未绑定库位");
|
||||
if ("SCRAPPED".equals(pallet.getStatus())) throw new BizException(ResultCode.CONFLICT, "托盘已报废");
|
||||
return new WarehousePalletResolveResponse(pallet.getId(), pallet.getPalletCode(), pallet.getWarehouseId(),
|
||||
pallet.getLocationId(), pallet.getStatus(), pallet.getFbaWarehouseCode(),
|
||||
pallet.getVersion() == null ? 0 : pallet.getVersion());
|
||||
}
|
||||
|
||||
public PageResult<WarehousePalletEntity> pallets(long customerId, long warehouseId,
|
||||
PalletRequests.QueryRequest query) {
|
||||
requireWarehouse(customerId, warehouseId);
|
||||
|
||||
Reference in New Issue
Block a user