实现设备盘库的分页查询
This commit is contained in:
parent
a66ac26002
commit
36720e7a38
|
@ -72,4 +72,19 @@ public interface EquipmentService extends IService<EquipmentEntity> {
|
|||
* 修改设备采购记录
|
||||
*/
|
||||
void updateProcurement(String equipmentId, EquipmentReq req);
|
||||
|
||||
/**
|
||||
* 分页查询设备盘库记录
|
||||
*/
|
||||
IPage<EquipmentResp> inventoryPage(EquipmentListReq req);
|
||||
|
||||
/**
|
||||
* 执行设备盘库
|
||||
*/
|
||||
void executeInventory(String equipmentId, String inventoryResult, String remark);
|
||||
|
||||
/**
|
||||
* 批量执行设备盘库
|
||||
*/
|
||||
void batchExecuteInventory(List<String> equipmentIds, String inventoryResult, String remark);
|
||||
}
|
||||
|
|
|
@ -673,11 +673,12 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateProcurement(String equipmentId, EquipmentReq req) {
|
||||
log.info("开始修改设备采购记录,设备ID: {}, 请求参数: {}", equipmentId, req);
|
||||
// 实现更新设备采购记录的逻辑
|
||||
log.info("更新设备采购记录,设备ID: {}, 请求参数: {}", equipmentId, req);
|
||||
|
||||
// 检查设备是否存在
|
||||
EquipmentEntity existingEntity = this.getById(equipmentId);
|
||||
if (existingEntity == null) {
|
||||
// 验证设备是否存在
|
||||
EquipmentEntity existingEquipment = this.getById(equipmentId);
|
||||
if (existingEquipment == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
|
||||
|
@ -697,7 +698,7 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
entity.setEquipmentId(equipmentId);
|
||||
this.updateById(entity);
|
||||
|
||||
log.info("设备采购记录修改成功,设备ID: {}", equipmentId);
|
||||
log.info("设备采购记录更新成功,设备ID: {}", equipmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -733,4 +734,110 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
|||
log.info("采购统计信息获取完成,总金额: {}, 供应商数: {}, 设备数: {}", totalAmount, supplierCount, equipmentCount);
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<EquipmentResp> inventoryPage(EquipmentListReq req) {
|
||||
log.info("开始执行设备盘库分页查询,请求参数: {}", req);
|
||||
|
||||
// 获取分页参数
|
||||
Integer pageNum = req.getPageNum() != null ? req.getPageNum() : 1;
|
||||
Integer pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
|
||||
|
||||
log.info("分页参数 - pageNum: {}, pageSize: {}", pageNum, pageSize);
|
||||
|
||||
// 使用分页插件
|
||||
PageUtil.startPage();
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<EquipmentEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加搜索条件
|
||||
if (StringUtils.hasText(req.getEquipmentName())) {
|
||||
queryWrapper.like(EquipmentEntity::getEquipmentName, req.getEquipmentName());
|
||||
}
|
||||
if (StringUtils.hasText(req.getEquipmentType())) {
|
||||
queryWrapper.eq(EquipmentEntity::getEquipmentType, req.getEquipmentType());
|
||||
}
|
||||
if (StringUtils.hasText(req.getAssetCode())) {
|
||||
queryWrapper.like(EquipmentEntity::getAssetCode, req.getAssetCode());
|
||||
}
|
||||
if (StringUtils.hasText(req.getBrand())) {
|
||||
queryWrapper.like(EquipmentEntity::getBrand, req.getBrand());
|
||||
}
|
||||
if (StringUtils.hasText(req.getLocationStatus())) {
|
||||
queryWrapper.eq(EquipmentEntity::getLocationStatus, req.getLocationStatus());
|
||||
}
|
||||
if (StringUtils.hasText(req.getResponsiblePerson())) {
|
||||
queryWrapper.like(EquipmentEntity::getResponsiblePerson, req.getResponsiblePerson());
|
||||
}
|
||||
if (StringUtils.hasText(req.getInventoryBarcode())) {
|
||||
queryWrapper.like(EquipmentEntity::getInventoryBarcode, req.getInventoryBarcode());
|
||||
}
|
||||
|
||||
// 按创建时间倒序排列
|
||||
queryWrapper.orderByDesc(EquipmentEntity::getCreateTime);
|
||||
|
||||
// 执行查询
|
||||
IPage<EquipmentEntity> page = this.page(new Page<>(pageNum, pageSize), queryWrapper);
|
||||
|
||||
// 转换为响应对象
|
||||
IPage<EquipmentResp> result = page.convert(this::convertToResp);
|
||||
|
||||
log.info("设备盘库分页查询完成,总记录数: {}, 当前页记录数: {}", result.getTotal(), result.getRecords().size());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeInventory(String equipmentId, String inventoryResult, String remark) {
|
||||
log.info("执行设备盘库,设备ID: {}, 盘点结果: {}, 备注: {}", equipmentId, inventoryResult, remark);
|
||||
|
||||
// 验证设备是否存在
|
||||
EquipmentEntity equipment = this.getById(equipmentId);
|
||||
if (equipment == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
|
||||
// 更新盘点状态
|
||||
EquipmentEntity updateEquipment = new EquipmentEntity();
|
||||
updateEquipment.setEquipmentId(equipmentId);
|
||||
updateEquipment.setInventoryTimeStatus1(LocalDateTime.now().toString() + "_" + inventoryResult);
|
||||
updateEquipment.setDynamicRecord(remark);
|
||||
|
||||
// 保存更新
|
||||
boolean success = this.updateById(updateEquipment);
|
||||
if (!success) {
|
||||
throw new ServiceException("执行设备盘库失败");
|
||||
}
|
||||
|
||||
log.info("设备盘库执行成功,设备ID: {}", equipmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchExecuteInventory(List<String> equipmentIds, String inventoryResult, String remark) {
|
||||
log.info("批量执行设备盘库,设备ID列表: {}, 盘点结果: {}, 备注: {}", equipmentIds, inventoryResult, remark);
|
||||
|
||||
if (equipmentIds == null || equipmentIds.isEmpty()) {
|
||||
throw new ServiceException("设备ID列表不能为空");
|
||||
}
|
||||
|
||||
// 批量更新盘点状态
|
||||
List<EquipmentEntity> updateList = equipmentIds.stream()
|
||||
.map(equipmentId -> {
|
||||
EquipmentEntity equipment = new EquipmentEntity();
|
||||
equipment.setEquipmentId(equipmentId);
|
||||
equipment.setInventoryTimeStatus1(LocalDateTime.now().toString() + "_" + inventoryResult);
|
||||
equipment.setDynamicRecord(remark);
|
||||
return equipment;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量更新
|
||||
boolean success = this.updateBatchById(updateList);
|
||||
if (!success) {
|
||||
throw new ServiceException("批量执行设备盘库失败");
|
||||
}
|
||||
|
||||
log.info("批量设备盘库执行成功,处理设备数量: {}", equipmentIds.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -103,6 +104,36 @@ public class EquipmentController {
|
|||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询设备盘库记录", httpMethod = "GET")
|
||||
@GetMapping("/inventory/page")
|
||||
public PageResult<EquipmentResp> inventoryPage(EquipmentListReq req) {
|
||||
log.info("=== 设备盘库记录查询接口被调用 ===");
|
||||
log.info("接收到的请求参数: {}", req);
|
||||
|
||||
IPage<EquipmentResp> page = equipmentService.inventoryPage(req);
|
||||
return PageResult.ok(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "执行设备盘库", httpMethod = "POST")
|
||||
@PostMapping("/inventory/{equipmentId}")
|
||||
public Result<?> executeInventory(
|
||||
@PathVariable String equipmentId,
|
||||
@RequestParam String inventoryResult,
|
||||
@RequestParam(required = false) String remark) {
|
||||
equipmentService.executeInventory(equipmentId, inventoryResult, remark);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量执行设备盘库", httpMethod = "POST")
|
||||
@PostMapping("/inventory/batch")
|
||||
public Result<?> batchExecuteInventory(
|
||||
@RequestParam List<String> equipmentIds,
|
||||
@RequestParam String inventoryResult,
|
||||
@RequestParam(required = false) String remark) {
|
||||
equipmentService.batchExecuteInventory(equipmentIds, inventoryResult, remark);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取采购统计信息", httpMethod = "GET")
|
||||
@GetMapping("/procurement/stats")
|
||||
public Result<?> getProcurementStats(){
|
||||
|
|
Loading…
Reference in New Issue