瀏覽代碼

feat(third-party-equipment): 新增充电提示语编辑与导出功能

- 在第三方充电设备管理新增“编辑提示语”弹窗支持单条及批量修改充电提示语
- 实现“按站点一键修改提示语”弹窗,可批量修改指定站点下所有充电桩提示语
- 后台接口新增修改充电桩提示语接口,支持单个、批量及按站点修改
- 新增充电桩信息导出功能,支持导出包含提示语的详细设备信息Excel文件
- 前端页面优化,增加充电提示语列及相关操作按钮
- 充电设备实体类新增connectorTips字段,数据库查询语句及mapper更新支持提示语字段
- 充电桩价格同步任务调整为一分钟执行一次,提升实时性
SheepHy 2 天之前
父節點
當前提交
1dfab6ce28

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

@@ -1,9 +1,12 @@
 package com.zsElectric.boot.business.controller;
 
+import cn.idev.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
 import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
 import com.zsElectric.boot.business.model.dto.StationDetailDTO;
+import com.zsElectric.boot.business.model.dto.ThirdPartyEquipmentExportDTO;
+import com.zsElectric.boot.business.model.dto.ConnectorTipsUpdateDTO;
 import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
@@ -15,6 +18,7 @@ import com.zsElectric.boot.core.web.PageResult;
 import com.zsElectric.boot.core.web.Result;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -24,6 +28,9 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 /**
@@ -72,4 +79,25 @@ public class ThirdPartyChargingController {
         return Result.success(result);
     }
 
+    @Operation(summary = "导出充电桩信息")
+    @GetMapping("/equipments/export")
+    @Log(value = "导出充电桩信息", module = LogModuleEnum.OTHER)
+    public void exportEquipments(ThirdPartyEquipmentInfoQuery queryParams, HttpServletResponse response) throws IOException {
+        String fileName = "充电桩信息.xlsx";
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
+
+        List<ThirdPartyEquipmentExportDTO> exportList = chargingService.listExportEquipments(queryParams);
+        EasyExcel.write(response.getOutputStream(), ThirdPartyEquipmentExportDTO.class).sheet("充电桩信息")
+                .doWrite(exportList);
+    }
+
+    @Operation(summary = "修改充电桩提示语", description = "支持单个修改、批量修改、按站点一键修改")
+    @PostMapping("/equipments/tips/update")
+    @Log(value = "修改充电桩提示语", module = LogModuleEnum.OTHER)
+    public Result<Integer> updateConnectorTips(@Valid @RequestBody ConnectorTipsUpdateDTO dto) {
+        int count = chargingService.updateConnectorTips(dto);
+        return Result.success(count);
+    }
+
 }

+ 11 - 0
src/main/java/com/zsElectric/boot/business/mapper/ThirdPartyEquipmentInfoMapper.java

@@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentInfo;
+import com.zsElectric.boot.business.model.dto.ThirdPartyEquipmentExportDTO;
 import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
 import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 第三方充电设备信息Mapper接口
  *
@@ -26,4 +29,12 @@ public interface ThirdPartyEquipmentInfoMapper extends BaseMapper<ThirdPartyEqui
      * @return 充电桩信息分页列表
      */
     IPage<ThirdPartyEquipmentInfoVO> selectEquipmentInfoPage(Page<ThirdPartyEquipmentInfoVO> page, @Param("query") ThirdPartyEquipmentInfoQuery query);
+
+    /**
+     * 查询充电桩导出列表
+     *
+     * @param query 查询条件
+     * @return 充电桩导出列表
+     */
+    List<ThirdPartyEquipmentExportDTO> selectEquipmentExportList(@Param("query") ThirdPartyEquipmentInfoQuery query);
 }

+ 31 - 0
src/main/java/com/zsElectric/boot/business/model/dto/ConnectorTipsUpdateDTO.java

@@ -0,0 +1,31 @@
+package com.zsElectric.boot.business.model.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 充电桩提示语修改DTO
+ *
+ * @author system
+ * @since 2025-12-29
+ */
+@Data
+@Schema(description = "充电桩提示语修改DTO")
+public class ConnectorTipsUpdateDTO {
+
+    @Schema(description = "充电桩ID(单个修改时使用)")
+    private Long id;
+
+    @Schema(description = "充电桩ID列表(批量修改时使用)")
+    private List<Long> ids;
+
+    @Schema(description = "充电站ID(按站点批量修改时使用,会修改该站点下所有充电桩)")
+    private Long stationInfoId;
+
+    @Schema(description = "充电提示语", example = "充电减免2小时停车费")
+    @Size(max = 500, message = "提示语不能超过500个字符")
+    private String connectorTips;
+}

+ 45 - 0
src/main/java/com/zsElectric/boot/business/model/dto/ThirdPartyEquipmentExportDTO.java

@@ -0,0 +1,45 @@
+package com.zsElectric.boot.business.model.dto;
+
+import cn.idev.excel.annotation.ExcelProperty;
+import cn.idev.excel.annotation.write.style.ColumnWidth;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 第三方充电桩信息导出DTO
+ *
+ * @author system
+ * @since 2025-12-29
+ */
+@Data
+@ColumnWidth(20)
+public class ThirdPartyEquipmentExportDTO {
+
+    @ExcelProperty(value = "接口ID")
+    private String connectorId;
+
+    @ExcelProperty(value = "接口名称")
+    private String connectorName;
+
+    @ExcelProperty(value = "所属充电站")
+    private String stationName;
+
+    @ExcelProperty(value = "总功率(kW)")
+    private BigDecimal power;
+
+    @ExcelProperty(value = "设备编码")
+    private String equipmentId;
+
+    @ExcelProperty(value = "设备名称")
+    private String equipmentName;
+
+    @ExcelProperty(value = "车位号")
+    private String parkNo;
+
+    @ExcelProperty(value = "国家标准")
+    private String nationalStandardName;
+
+    @ExcelProperty(value = "充电提示语")
+    private String connectorTips;
+}

+ 3 - 0
src/main/java/com/zsElectric/boot/business/model/vo/ThirdPartyEquipmentInfoVO.java

@@ -59,6 +59,9 @@ public class ThirdPartyEquipmentInfoVO {
     @Schema(description = "设备类型")
     private Integer equipmentType;
 
+    @Schema(description = "充电提示语")
+    private String connectorTips;
+
     @Schema(description = "更新时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;

+ 18 - 0
src/main/java/com/zsElectric/boot/business/service/ThirdPartyChargingService.java

@@ -2,6 +2,8 @@ package com.zsElectric.boot.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zsElectric.boot.business.model.dto.StationDetailDTO;
+import com.zsElectric.boot.business.model.dto.ThirdPartyEquipmentExportDTO;
+import com.zsElectric.boot.business.model.dto.ConnectorTipsUpdateDTO;
 import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
 import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
 import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
@@ -90,4 +92,20 @@ public interface ThirdPartyChargingService {
      * @return 操作结果
      */
     boolean updateStationDetail(StationDetailDTO dto);
+
+    /**
+     * 导出充电桩信息列表
+     *
+     * @param queryParams 查询参数
+     * @return 充电桩导出列表
+     */
+    List<ThirdPartyEquipmentExportDTO> listExportEquipments(ThirdPartyEquipmentInfoQuery queryParams);
+
+    /**
+     * 修改充电桩提示语
+     *
+     * @param dto 修改参数
+     * @return 影响行数
+     */
+    int updateConnectorTips(ConnectorTipsUpdateDTO dto);
 }

+ 36 - 0
src/main/java/com/zsElectric/boot/business/service/impl/ThirdPartyChargingServiceImpl.java

@@ -26,6 +26,8 @@ import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
 import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
 import com.zsElectric.boot.business.model.vo.StationDetailVO;
 import com.zsElectric.boot.business.model.dto.StationDetailDTO;
+import com.zsElectric.boot.business.model.dto.ThirdPartyEquipmentExportDTO;
+import com.zsElectric.boot.business.model.dto.ConnectorTipsUpdateDTO;
 import com.zsElectric.boot.business.service.ThirdPartyChargingService;
 import com.zsElectric.boot.charging.vo.ChargingPricePolicyVO;
 import com.zsElectric.boot.charging.vo.QueryStationsInfoVO;
@@ -398,6 +400,8 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
             entity.setId(existingConnector.getId());
             // 保留原有的status字段,该字段由设备状态推送接口单独维护
             entity.setStatus(existingConnector.getStatus());
+            // 保留原有的connectorTips字段,该字段由后台手动维护,不被第三方数据覆盖
+            entity.setConnectorTips(existingConnector.getConnectorTips());
         }
 
         // 设置字段值
@@ -887,4 +891,36 @@ public class ThirdPartyChargingServiceImpl implements ThirdPartyChargingService
                 .set(ThirdPartyStationInfo::getCustomerServiceHotline, dto.getCustomerServiceHotline())
                 .set(bannerJson != null, ThirdPartyStationInfo::getBannerPictures, bannerJson)) > 0;
     }
+
+    @Override
+    public List<ThirdPartyEquipmentExportDTO> listExportEquipments(ThirdPartyEquipmentInfoQuery queryParams) {
+        return equipmentInfoMapper.selectEquipmentExportList(queryParams);
+    }
+
+    @Override
+    public int updateConnectorTips(ConnectorTipsUpdateDTO dto) {
+        // 根据不同的参数执行不同的更新逻辑
+        if (dto.getStationInfoId() != null) {
+            // 按站点批量修改:查询站点信息获取stationId,然后更新该站点下所有充电桩
+            ThirdPartyStationInfo stationInfo = stationInfoMapper.selectById(dto.getStationInfoId());
+            if (stationInfo == null) {
+                log.warn("站点不存在,stationInfoId: {}", dto.getStationInfoId());
+                return 0;
+            }
+            return connectorInfoMapper.update(null, Wrappers.<ThirdPartyConnectorInfo>lambdaUpdate()
+                    .eq(ThirdPartyConnectorInfo::getStationId, stationInfo.getStationId())
+                    .set(ThirdPartyConnectorInfo::getConnectorTips, dto.getConnectorTips()));
+        } else if (dto.getIds() != null && !dto.getIds().isEmpty()) {
+            // 批量修改:根据ID列表更新
+            return connectorInfoMapper.update(null, Wrappers.<ThirdPartyConnectorInfo>lambdaUpdate()
+                    .in(ThirdPartyConnectorInfo::getId, dto.getIds())
+                    .set(ThirdPartyConnectorInfo::getConnectorTips, dto.getConnectorTips()));
+        } else if (dto.getId() != null) {
+            // 单个修改
+            return connectorInfoMapper.update(null, Wrappers.<ThirdPartyConnectorInfo>lambdaUpdate()
+                    .eq(ThirdPartyConnectorInfo::getId, dto.getId())
+                    .set(ThirdPartyConnectorInfo::getConnectorTips, dto.getConnectorTips()));
+        }
+        return 0;
+    }
 }

+ 6 - 0
src/main/java/com/zsElectric/boot/charging/entity/ThirdPartyConnectorInfo.java

@@ -76,6 +76,12 @@ public class ThirdPartyConnectorInfo extends BaseEntity {
      */
     private Integer nationalStandard;
 
+    /**
+     * 充电提示语(用户充电时显示)
+     * 该字段不会被第三方数据同步覆盖
+     */
+    private String connectorTips;
+
     /**
      * 充电设备接口状态
      * 0-离网,1-空闲,2-占用(未充电),3-占用(充电中),4-占用(预约锁定),255-故障

+ 1 - 1
src/main/java/com/zsElectric/boot/charging/quartz/ChargingJob.java

@@ -83,7 +83,7 @@ public class ChargingJob {
      * 每10分钟执行一次,查询所有充电桩的价格策略并存储到数据库
      * cron表达式: 0 10 * * * ? 表示每10分钟执行
      */
-//    @Scheduled(cron = "0 */1 * * * ?")
+    @Scheduled(cron = "0 */1 * * * ?")
     public void syncEquipmentPricePolicy() {
         // 检查任务是否正在执行,防止并发
         if (isPricePolicySyncRunning) {

+ 50 - 1
src/main/resources/mapper/business/ThirdPartyEquipmentInfoMapper.xml

@@ -19,7 +19,56 @@
             c.voltage_lower_limits,
             c.current,
             c.park_no,
-            c.national_standard
+            c.national_standard,
+            c.connector_tips
+        FROM
+            third_party_equipment_info e
+        LEFT JOIN third_party_station_info s ON e.station_id = s.station_id
+        LEFT JOIN third_party_connector_info c ON e.equipment_id = c.equipment_id
+        <where>
+            e.is_deleted = 0
+            <if test="query.equipmentId != null and query.equipmentId != ''">
+                AND e.equipment_id = #{query.equipmentId}
+            </if>
+            <if test="query.equipmentName != null and query.equipmentName != ''">
+                AND e.equipment_name LIKE CONCAT('%', #{query.equipmentName}, '%')
+            </if>
+            <if test="query.stationId != null and query.stationId != ''">
+                AND e.station_id = #{query.stationId}
+            </if>
+            <if test="query.stationName != null and query.stationName != ''">
+                AND s.station_name LIKE CONCAT('%', #{query.stationName}, '%')
+            </if>
+            <if test="query.equipmentType != null and query.equipmentType != 0">
+                AND e.equipment_type = #{query.equipmentType}
+            </if>
+            <if test="query.connectorType != null and query.connectorType != 0">
+                AND c.connector_type = #{query.connectorType}
+            </if>
+            <if test="query.parkNo != null and query.parkNo != ''">
+                AND c.park_no = #{query.parkNo}
+            </if>
+            <if test="query.nationalStandard != null and query.nationalStandard != 0">
+                AND c.national_standard = #{query.nationalStandard}
+            </if>
+        </where>
+        ORDER BY e.update_time DESC
+    </select>
+
+    <select id="selectEquipmentExportList" resultType="com.zsElectric.boot.business.model.dto.ThirdPartyEquipmentExportDTO">
+        SELECT
+            c.connector_id,
+            c.connector_name,
+            s.station_name,
+            e.power,
+            e.equipment_id,
+            e.equipment_name,
+            c.park_no,
+            CASE c.national_standard
+                WHEN 1 THEN '2011'
+                ELSE '2015'
+            END AS national_standard_name,
+            c.connector_tips
         FROM
             third_party_equipment_info e
         LEFT JOIN third_party_station_info s ON e.station_id = s.station_id