feat(智能柜): 新增格口状态重置接口和详情字段

- 在CabinetDetailDTO中新增password、usageStatus和cellType字段
- 移除开柜后自动重置格口状态的逻辑
- 新增resetCellById接口用于手动重置格口状态
- 优化智能柜查询逻辑,处理空列表情况
- 在返回数据中添加格口密码、使用状态和类型信息
This commit is contained in:
dzq 2025-12-20 17:18:05 +08:00
parent 94b403898d
commit c9e5b18ddc
4 changed files with 18 additions and 5 deletions

View File

@ -226,6 +226,13 @@ public class CabinetCellController {
} }
} }
@Operation(summary = "重置格口状态")
@PutMapping("/reset/{cellId}")
public ResponseDTO<Void> resetCellById(@PathVariable Long cellId) {
cabinetCellApplicationService.resetCellById(cellId);
return ResponseDTO.ok();
}
@Operation(summary = "存入物品分配格口") @Operation(summary = "存入物品分配格口")
@PostMapping("/storeItem") @PostMapping("/storeItem")
public ResponseDTO<CabinetCellDTO> storeItem(@RequestBody StoreItemToCellCommand command) { public ResponseDTO<CabinetCellDTO> storeItem(@RequestBody StoreItemToCellCommand command) {

View File

@ -192,11 +192,6 @@ public class CabinetCellApplicationService {
log.error("发送开柜指令失败", e); log.error("发送开柜指令失败", e);
throw new RuntimeException("开柜失败,请重试"); throw new RuntimeException("开柜失败,请重试");
} }
// 更新格口状态清除密码设置空闲状态
cellModel.setPassword(null);
cellModel.setUsageStatus(1); // 空闲
cellModel.updateById();
} }
/** /**

View File

@ -34,6 +34,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -176,6 +177,10 @@ public class SmartCabinetApplicationService {
.eq("deleted", false); .eq("deleted", false);
List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper); List<SmartCabinetEntity> smartCabinets = smartCabinetService.list(smartCabinetEntityQueryWrapper);
if (smartCabinets == null || smartCabinets.isEmpty()) {
return Collections.emptyList();
}
QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>(); QueryWrapper<CabinetCellEntity> cabinetCellEntityQueryWrapper = new QueryWrapper<>();
cabinetCellEntityQueryWrapper.in("cabinet_id", cabinetCellEntityQueryWrapper.in("cabinet_id",
smartCabinets.stream() smartCabinets.stream()
@ -224,6 +229,9 @@ public class SmartCabinetApplicationService {
cellInfo.setCellNo(cell.getCellNo()); cellInfo.setCellNo(cell.getCellNo());
cellInfo.setPinNo(cell.getPinNo()); cellInfo.setPinNo(cell.getPinNo());
cellInfo.setStock(cell.getStock()); cellInfo.setStock(cell.getStock());
cellInfo.setPassword(cell.getPassword());
cellInfo.setUsageStatus(cell.getUsageStatus());
cellInfo.setCellType(cell.getCellType());
// 处理单元格关联的商品信息 // 处理单元格关联的商品信息
if (cell.getGoodsId() != null) { if (cell.getGoodsId() != null) {

View File

@ -22,6 +22,9 @@ public class CabinetDetailDTO {
private Long orderId; private Long orderId;
private Long orderGoodsId; private Long orderGoodsId;
private ProductInfoDTO product; private ProductInfoDTO product;
private String password;
private Integer usageStatus;
private Integer cellType;
} }
@Data @Data