From 62f455fe708c8059f32cfa8c4cf785762b1d7076 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Mon, 5 Jan 2026 13:37:18 +0800 Subject: [PATCH] =?UTF-8?q?UPDATE=20=E5=90=8C=E6=AD=A5=E5=85=85=E7=94=B5?= =?UTF-8?q?=E6=A1=A9=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/JcppPileSyncServiceImpl.java | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/jcpp/service/impl/JcppPileSyncServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/jcpp/service/impl/JcppPileSyncServiceImpl.java index 05c6a50fe..f93ac7332 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/jcpp/service/impl/JcppPileSyncServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/jcpp/service/impl/JcppPileSyncServiceImpl.java @@ -7,12 +7,14 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.JcppSyncRecord; import com.jsowell.pile.domain.PileBasicInfo; import com.jsowell.pile.domain.PileConnectorInfo; +import com.jsowell.pile.domain.PileModelInfo; import com.jsowell.pile.jcpp.dto.sync.*; import com.jsowell.pile.jcpp.service.IJcppAuthService; import com.jsowell.pile.jcpp.service.IJcppPileSyncService; import com.jsowell.pile.mapper.JcppSyncRecordMapper; import com.jsowell.pile.service.PileBasicInfoService; import com.jsowell.pile.service.PileConnectorInfoService; +import com.jsowell.pile.service.PileModelInfoService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -48,6 +50,9 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService { @Autowired private RestTemplate restTemplate; + @Autowired + private PileModelInfoService pileModelInfoService; + @Value("${jcpp.sync.api-url:http://localhost:8180/api/sync}") private String jcppApiUrl; @@ -94,6 +99,7 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService { log.info("全量同步完成: 充电桩 {}/{}, 充电枪 {}/{}", response.getSuccessPiles(), response.getTotalPiles(), + response.getSuccessGuns(), response.getTotalGuns()); return response; @@ -228,18 +234,35 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService { // 基本字段 dto.setPileCode(pile.getSn()); - dto.setPileName(pile.getName()); - dto.setProtocol(pile.getSoftwareProtocol()); + String pileName = pile.getName(); + // 如果名称为空,使用充电桩编号 + if (StringUtils.isBlank(pileName)) { + pileName = pile.getSn(); + } + dto.setPileName(pileName); + dto.setProtocol("yunkuaichongV150"); // 品牌、型号、制造商(可为空) dto.setBrand("jsowell"); // Web 项目中没有这些字段 dto.setModel(null); dto.setManufacturer("jsowell"); - // 类型映射:1-运营桩 → OPERATION, 2-个人桩 → PERSONAL - String type = "OPERATION"; // 默认运营桩 - if ("2".equals(pile.getBusinessType())) { - type = "PERSONAL"; + // 类型映射:从 pile_model_info 表获取 speed_type + // 1-快充(DC直流) → DC, 2-慢充(AC交流) → AC + String type = "AC"; // 默认交流桩 + if (pile.getModelId() != null) { + try { + PileModelInfo modelInfo = pileModelInfoService.selectPileModelInfoById(pile.getModelId()); + if (modelInfo != null && StringUtils.isNotEmpty(modelInfo.getSpeedType())) { + if ("1".equals(modelInfo.getSpeedType())) { + type = "DC"; // 快充-直流 + } else if ("2".equals(modelInfo.getSpeedType())) { + type = "AC"; // 慢充-交流 + } + } + } catch (Exception e) { + log.warn("查询充电桩型号信息失败,使用默认类型AC: pileSn={}, modelId={}", pile.getSn(), pile.getModelId(), e); + } } dto.setType(type); @@ -274,7 +297,16 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService { // 基本字段 dto.setGunCode(gun.getPileConnectorCode()); - dto.setGunName(gun.getName()); + + // 充电枪名称:如果为空,使用枪号生成默认名称 + String gunName = gun.getName(); + if (StringUtils.isEmpty(gunName)) { + String gunNo = extractGunNo(gun.getPileConnectorCode()); + gunName = "充电枪" + gunNo; + log.warn("充电枪名称为空,使用默认名称: {} (gunCode: {})", gunName, gun.getPileConnectorCode()); + } + dto.setGunName(gunName); + dto.setPileCode(gun.getPileSn()); // 提取枪号(最后 2 位)