ThirdPartyStationInfoServiceImpl.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.zsElectric.boot.charging.service.impl;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
  7. import com.zsElectric.boot.charging.mapper.ThirdPartyStationInfoMapper;
  8. import com.zsElectric.boot.charging.model.query.ThirdPartyStationInfoQuery;
  9. import com.zsElectric.boot.charging.model.vo.ThirdPartyStationInfoVO;
  10. import com.zsElectric.boot.charging.service.ThirdPartyStationInfoService;
  11. import lombok.RequiredArgsConstructor;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.stereotype.Service;
  14. /**
  15. * 第三方充电站信息服务实现
  16. *
  17. * @author system
  18. * @since 2025-12-11
  19. */
  20. @Service
  21. @RequiredArgsConstructor
  22. public class ThirdPartyStationInfoServiceImpl implements ThirdPartyStationInfoService {
  23. private final ThirdPartyStationInfoMapper stationInfoMapper;
  24. @Override
  25. public IPage<ThirdPartyStationInfoVO> getStationInfoPage(ThirdPartyStationInfoQuery queryParams) {
  26. // 构建分页
  27. Page<ThirdPartyStationInfo> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
  28. // 构建查询条件
  29. LambdaQueryWrapper<ThirdPartyStationInfo> queryWrapper = new LambdaQueryWrapper<>();
  30. queryWrapper.eq(StrUtil.isNotBlank(queryParams.getStationId()), ThirdPartyStationInfo::getStationId, queryParams.getStationId())
  31. .like(StrUtil.isNotBlank(queryParams.getStationName()), ThirdPartyStationInfo::getStationName, queryParams.getStationName())
  32. .eq(StrUtil.isNotBlank(queryParams.getAreaCode()), ThirdPartyStationInfo::getAreaCode, queryParams.getAreaCode())
  33. .eq(StrUtil.isNotBlank(queryParams.getEquipmentOwnerId()), ThirdPartyStationInfo::getEquipmentOwnerId, queryParams.getEquipmentOwnerId())
  34. .eq(queryParams.getStationStatus() != null && queryParams.getStationStatus() != 0, ThirdPartyStationInfo::getStationStatus, queryParams.getStationStatus())
  35. .eq(queryParams.getStationType() != null && queryParams.getStationType() != 0, ThirdPartyStationInfo::getStationType, queryParams.getStationType())
  36. .eq(StrUtil.isNotBlank(queryParams.getServiceTel()), ThirdPartyStationInfo::getServiceTel, queryParams.getServiceTel())
  37. .orderByDesc(ThirdPartyStationInfo::getUpdateTime);
  38. // 查询
  39. Page<ThirdPartyStationInfo> stationPage = stationInfoMapper.selectPage(page, queryWrapper);
  40. // 实体转换
  41. Page<ThirdPartyStationInfoVO> voPage = new Page<>(stationPage.getCurrent(), stationPage.getSize(), stationPage.getTotal());
  42. voPage.setRecords(stationPage.getRecords().stream().map(entity -> {
  43. ThirdPartyStationInfoVO vo = new ThirdPartyStationInfoVO();
  44. BeanUtils.copyProperties(entity, vo);
  45. return vo;
  46. }).toList());
  47. return voPage;
  48. }
  49. }