Procházet zdrojové kódy

feat(charging): 实现第三方充电站及充电桩信息分页查询接口

- 新增第三方充电站查询控制器并提供分页列表API
- 新增第三方充电桩查询控制器及对应分页查询接口
- 设计充电站及充电桩查询参数对象支持多条件筛选
- 实现充电站信息服务及分页查询逻辑
- 实现充电桩信息服务,支持按接口类型条件过滤
- 封装充电站及充电桩查询结果VO,包含详细信息和接口参数
- 集成分页组件并返回统一格式分页结果
- 利用注解支持接口文档生成及操作日志记录
SheepHy před 4 dny
rodič
revize
e6b723cf33

+ 51 - 0
src/main/java/com/zsElectric/boot/business/controller/ThirdPartyChargingController.java

@@ -0,0 +1,51 @@
+package com.zsElectric.boot.business.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.zsElectric.boot.charging.model.query.ThirdPartyStationInfoQuery;
+import com.zsElectric.boot.charging.model.query.ThirdPartyEquipmentInfoQuery;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyStationInfoVO;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyEquipmentInfoVO;
+import com.zsElectric.boot.charging.service.ThirdPartyStationInfoService;
+import com.zsElectric.boot.charging.service.ThirdPartyEquipmentInfoService;
+import com.zsElectric.boot.common.annotation.Log;
+import com.zsElectric.boot.common.enums.LogModuleEnum;
+import com.zsElectric.boot.core.web.PageResult;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 第三方充电站/充电桩信息查询控制器
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Tag(name = "第三方充电站/充电桩信息查询接口")
+@RestController
+@RequestMapping("/api/v1/third-party-charging")
+@RequiredArgsConstructor
+public class ThirdPartyChargingController {
+
+    private final ThirdPartyStationInfoService stationInfoService;
+    private final ThirdPartyEquipmentInfoService equipmentInfoService;
+
+    @Operation(summary = "充电站信息分页列表")
+    @PostMapping("/stations/page")
+    @Log(value = "充电站信息分页列表", module = LogModuleEnum.OTHER)
+    public PageResult<ThirdPartyStationInfoVO> getStationInfoPage(@RequestBody ThirdPartyStationInfoQuery queryParams) {
+        IPage<ThirdPartyStationInfoVO> result = stationInfoService.getStationInfoPage(queryParams);
+        return PageResult.success(result);
+    }
+
+    @Operation(summary = "充电桩信息分页列表")
+    @PostMapping("/equipments/page")
+    @Log(value = "充电桩信息分页列表", module = LogModuleEnum.OTHER)
+    public PageResult<ThirdPartyEquipmentInfoVO> getEquipmentInfoPage(@RequestBody ThirdPartyEquipmentInfoQuery queryParams) {
+        IPage<ThirdPartyEquipmentInfoVO> result = equipmentInfoService.getEquipmentInfoPage(queryParams);
+        return PageResult.success(result);
+    }
+}

+ 45 - 0
src/main/java/com/zsElectric/boot/charging/model/query/ThirdPartyEquipmentInfoQuery.java

@@ -0,0 +1,45 @@
+package com.zsElectric.boot.charging.model.query;
+
+import com.zsElectric.boot.common.base.BasePageQuery;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 第三方充电桩信息查询对象
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Schema(description = "第三方充电桩信息查询对象")
+@Getter
+@Setter
+public class ThirdPartyEquipmentInfoQuery extends BasePageQuery {
+
+    @Schema(description = "充电桩编码")
+    private String equipmentId;
+
+    @Schema(description = "充电桩名称")
+    private String equipmentName;
+
+    @Schema(description = "所属充电站ID")
+    private String stationId;
+
+    @Schema(description = "电站名称")
+    private String stationName;
+
+    @Schema(description = "设备类型")
+    private Integer equipmentType;
+
+    @Schema(description = "设备状态")
+    private String deviceStatus;
+
+    @Schema(description = "接口类型")
+    private Integer connectorType;
+
+    @Schema(description = "车位号")
+    private String parkNo;
+
+    @Schema(description = "国家标准")
+    private Integer nationalStandard;
+}

+ 39 - 0
src/main/java/com/zsElectric/boot/charging/model/query/ThirdPartyStationInfoQuery.java

@@ -0,0 +1,39 @@
+package com.zsElectric.boot.charging.model.query;
+
+import com.zsElectric.boot.common.base.BasePageQuery;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 第三方充电站信息查询对象
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Schema(description = "第三方充电站信息查询对象")
+@Getter
+@Setter
+public class ThirdPartyStationInfoQuery extends BasePageQuery {
+
+    @Schema(description = "充电站ID")
+    private String stationId;
+
+    @Schema(description = "充电站名称")
+    private String stationName;
+
+    @Schema(description = "所在城市(区域编码)")
+    private String areaCode;
+
+    @Schema(description = "设备所属方")
+    private String equipmentOwnerId;
+
+    @Schema(description = "站点状态")
+    private Integer stationStatus;
+
+    @Schema(description = "站点类型")
+    private Integer stationType;
+
+    @Schema(description = "服务电话")
+    private String serviceTel;
+}

+ 68 - 0
src/main/java/com/zsElectric/boot/charging/model/vo/ThirdPartyEquipmentInfoVO.java

@@ -0,0 +1,68 @@
+package com.zsElectric.boot.charging.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 第三方充电桩信息VO
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Schema(description = "第三方充电桩信息VO")
+@Data
+public class ThirdPartyEquipmentInfoVO {
+
+    @Schema(description = "主键ID")
+    private Long id;
+
+    @Schema(description = "充电桩编码")
+    private String equipmentId;
+
+    @Schema(description = "充电桩名称")
+    private String equipmentName;
+
+    @Schema(description = "电站名称")
+    private String stationName;
+
+    @Schema(description = "接口类型")
+    private Integer connectorType;
+
+    @Schema(description = "设备状态")
+    private String deviceStatus;
+
+    @Schema(description = "充电总功率")
+    private BigDecimal power;
+
+    @Schema(description = "车位号")
+    private String parkNo;
+
+    @Schema(description = "国家标准")
+    private Integer nationalStandard;
+
+    @Schema(description = "接口编码")
+    private String connectorId;
+
+    @Schema(description = "接口名称")
+    private String connectorName;
+
+    @Schema(description = "额定电压上限(V)")
+    private Integer voltageUpperLimits;
+
+    @Schema(description = "额定电压下限(V)")
+    private Integer voltageLowerLimits;
+
+    @Schema(description = "额定电流(A)")
+    private Integer current;
+
+    @Schema(description = "设备类型")
+    private Integer equipmentType;
+
+    @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+}

+ 71 - 0
src/main/java/com/zsElectric/boot/charging/model/vo/ThirdPartyStationInfoVO.java

@@ -0,0 +1,71 @@
+package com.zsElectric.boot.charging.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 第三方充电站信息VO
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Schema(description = "第三方充电站信息VO")
+@Data
+public class ThirdPartyStationInfoVO {
+
+    @Schema(description = "主键ID")
+    private Long id;
+
+    @Schema(description = "充电站ID")
+    private String stationId;
+
+    @Schema(description = "充电站名称")
+    private String stationName;
+
+    @Schema(description = "所在城市")
+    private String areaCode;
+
+    @Schema(description = "设备所属方")
+    private String equipmentOwnerId;
+
+    @Schema(description = "详细地址")
+    private String address;
+
+    @Schema(description = "场所类型")
+    private Integer construction;
+
+    @Schema(description = "充电终端数量")
+    private Integer equipmentCount;
+
+    @Schema(description = "站点状态")
+    private Integer stationStatus;
+
+    @Schema(description = "服务电话")
+    private String serviceTel;
+
+    @Schema(description = "站点类型")
+    private Integer stationType;
+
+    @Schema(description = "经度")
+    private BigDecimal stationLng;
+
+    @Schema(description = "纬度")
+    private BigDecimal stationLat;
+
+    @Schema(description = "站点引导")
+    private String siteGuide;
+
+    @Schema(description = "电费")
+    private BigDecimal electricityFee;
+
+    @Schema(description = "服务费")
+    private BigDecimal serviceFee;
+
+    @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+}

+ 22 - 0
src/main/java/com/zsElectric/boot/charging/service/ThirdPartyEquipmentInfoService.java

@@ -0,0 +1,22 @@
+package com.zsElectric.boot.charging.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.zsElectric.boot.charging.model.query.ThirdPartyEquipmentInfoQuery;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyEquipmentInfoVO;
+
+/**
+ * 第三方充电桩信息服务接口
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+public interface ThirdPartyEquipmentInfoService {
+
+    /**
+     * 获取充电桩信息分页列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电桩信息分页列表
+     */
+    IPage<ThirdPartyEquipmentInfoVO> getEquipmentInfoPage(ThirdPartyEquipmentInfoQuery queryParams);
+}

+ 22 - 0
src/main/java/com/zsElectric/boot/charging/service/ThirdPartyStationInfoService.java

@@ -0,0 +1,22 @@
+package com.zsElectric.boot.charging.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.zsElectric.boot.charging.model.query.ThirdPartyStationInfoQuery;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyStationInfoVO;
+
+/**
+ * 第三方充电站信息服务接口
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+public interface ThirdPartyStationInfoService {
+
+    /**
+     * 获取充电站信息分页列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电站信息分页列表
+     */
+    IPage<ThirdPartyStationInfoVO> getStationInfoPage(ThirdPartyStationInfoQuery queryParams);
+}

+ 81 - 0
src/main/java/com/zsElectric/boot/charging/service/impl/ThirdPartyEquipmentInfoServiceImpl.java

@@ -0,0 +1,81 @@
+package com.zsElectric.boot.charging.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.charging.entity.ThirdPartyConnectorInfo;
+import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentInfo;
+import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
+import com.zsElectric.boot.charging.mapper.ThirdPartyEquipmentInfoMapper;
+import com.zsElectric.boot.charging.model.query.ThirdPartyEquipmentInfoQuery;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyEquipmentInfoVO;
+import com.zsElectric.boot.charging.service.ThirdPartyEquipmentInfoService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * 第三方充电桩信息服务实现
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Service
+@RequiredArgsConstructor
+public class ThirdPartyEquipmentInfoServiceImpl implements ThirdPartyEquipmentInfoService {
+
+    private final ThirdPartyEquipmentInfoMapper equipmentInfoMapper;
+    private final ThirdPartyConnectorInfoMapper connectorInfoMapper;
+
+    @Override
+    public IPage<ThirdPartyEquipmentInfoVO> getEquipmentInfoPage(ThirdPartyEquipmentInfoQuery queryParams) {
+        // 构建分页
+        Page<ThirdPartyEquipmentInfo> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
+
+        // 构建查询条件
+        LambdaQueryWrapper<ThirdPartyEquipmentInfo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StrUtil.isNotBlank(queryParams.getEquipmentId()), ThirdPartyEquipmentInfo::getEquipmentId, queryParams.getEquipmentId())
+                .like(StrUtil.isNotBlank(queryParams.getEquipmentName()), ThirdPartyEquipmentInfo::getEquipmentName, queryParams.getEquipmentName())
+                .eq(StrUtil.isNotBlank(queryParams.getStationId()), ThirdPartyEquipmentInfo::getStationId, queryParams.getStationId())
+                .like(StrUtil.isNotBlank(queryParams.getStationName()), ThirdPartyEquipmentInfo::getStationName, queryParams.getStationName())
+                .eq(queryParams.getEquipmentType() != null, ThirdPartyEquipmentInfo::getEquipmentType, queryParams.getEquipmentType())
+                .eq(StrUtil.isNotBlank(queryParams.getDeviceStatus()), ThirdPartyEquipmentInfo::getDeviceStatus, queryParams.getDeviceStatus())
+                .eq(StrUtil.isNotBlank(queryParams.getParkNo()), ThirdPartyEquipmentInfo::getParkNo, queryParams.getParkNo())
+                .eq(queryParams.getNationalStandard() != null, ThirdPartyEquipmentInfo::getNationalStandard, queryParams.getNationalStandard())
+                .orderByDesc(ThirdPartyEquipmentInfo::getUpdateTime);
+
+        // 查询设备信息
+        Page<ThirdPartyEquipmentInfo> equipmentPage = equipmentInfoMapper.selectPage(page, queryWrapper);
+
+        // 实体转换并填充接口信息
+        Page<ThirdPartyEquipmentInfoVO> voPage = new Page<>(equipmentPage.getCurrent(), equipmentPage.getSize(), equipmentPage.getTotal());
+        voPage.setRecords(equipmentPage.getRecords().stream().map(entity -> {
+            ThirdPartyEquipmentInfoVO vo = new ThirdPartyEquipmentInfoVO();
+            BeanUtils.copyProperties(entity, vo);
+
+            // 根据接口类型查询参数,查询接口信息
+            LambdaQueryWrapper<ThirdPartyConnectorInfo> connectorWrapper = new LambdaQueryWrapper<>();
+            connectorWrapper.eq(ThirdPartyConnectorInfo::getEquipmentId, entity.getEquipmentId())
+                    .eq(ThirdPartyConnectorInfo::getStationId, entity.getStationId());
+            if (queryParams.getConnectorType() != null) {
+                connectorWrapper.eq(ThirdPartyConnectorInfo::getConnectorType, queryParams.getConnectorType());
+            }
+            connectorWrapper.last("LIMIT 1");
+
+            ThirdPartyConnectorInfo connectorInfo = connectorInfoMapper.selectOne(connectorWrapper);
+            if (connectorInfo != null) {
+                vo.setConnectorId(connectorInfo.getConnectorId());
+                vo.setConnectorName(connectorInfo.getConnectorName());
+                vo.setConnectorType(connectorInfo.getConnectorType());
+                vo.setVoltageUpperLimits(connectorInfo.getVoltageUpperLimits());
+                vo.setVoltageLowerLimits(connectorInfo.getVoltageLowerLimits());
+                vo.setCurrent(connectorInfo.getCurrent());
+            }
+
+            return vo;
+        }).toList());
+
+        return voPage;
+    }
+}

+ 57 - 0
src/main/java/com/zsElectric/boot/charging/service/impl/ThirdPartyStationInfoServiceImpl.java

@@ -0,0 +1,57 @@
+package com.zsElectric.boot.charging.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
+import com.zsElectric.boot.charging.mapper.ThirdPartyStationInfoMapper;
+import com.zsElectric.boot.charging.model.query.ThirdPartyStationInfoQuery;
+import com.zsElectric.boot.charging.model.vo.ThirdPartyStationInfoVO;
+import com.zsElectric.boot.charging.service.ThirdPartyStationInfoService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * 第三方充电站信息服务实现
+ *
+ * @author system
+ * @since 2025-12-11
+ */
+@Service
+@RequiredArgsConstructor
+public class ThirdPartyStationInfoServiceImpl implements ThirdPartyStationInfoService {
+
+    private final ThirdPartyStationInfoMapper stationInfoMapper;
+
+    @Override
+    public IPage<ThirdPartyStationInfoVO> getStationInfoPage(ThirdPartyStationInfoQuery queryParams) {
+        // 构建分页
+        Page<ThirdPartyStationInfo> page = new Page<>(queryParams.getPageNum(), queryParams.getPageSize());
+
+        // 构建查询条件
+        LambdaQueryWrapper<ThirdPartyStationInfo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StrUtil.isNotBlank(queryParams.getStationId()), ThirdPartyStationInfo::getStationId, queryParams.getStationId())
+                .like(StrUtil.isNotBlank(queryParams.getStationName()), ThirdPartyStationInfo::getStationName, queryParams.getStationName())
+                .eq(StrUtil.isNotBlank(queryParams.getAreaCode()), ThirdPartyStationInfo::getAreaCode, queryParams.getAreaCode())
+                .eq(StrUtil.isNotBlank(queryParams.getEquipmentOwnerId()), ThirdPartyStationInfo::getEquipmentOwnerId, queryParams.getEquipmentOwnerId())
+                .eq(queryParams.getStationStatus() != null, ThirdPartyStationInfo::getStationStatus, queryParams.getStationStatus())
+                .eq(queryParams.getStationType() != null, ThirdPartyStationInfo::getStationType, queryParams.getStationType())
+                .eq(StrUtil.isNotBlank(queryParams.getServiceTel()), ThirdPartyStationInfo::getServiceTel, queryParams.getServiceTel())
+                .orderByDesc(ThirdPartyStationInfo::getUpdateTime);
+
+        // 查询
+        Page<ThirdPartyStationInfo> stationPage = stationInfoMapper.selectPage(page, queryWrapper);
+
+        // 实体转换
+        Page<ThirdPartyStationInfoVO> voPage = new Page<>(stationPage.getCurrent(), stationPage.getSize(), stationPage.getTotal());
+        voPage.setRecords(stationPage.getRecords().stream().map(entity -> {
+            ThirdPartyStationInfoVO vo = new ThirdPartyStationInfoVO();
+            BeanUtils.copyProperties(entity, vo);
+            return vo;
+        }).toList());
+
+        return voPage;
+    }
+}