mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
UPDATE 同步充电桩数据
This commit is contained in:
@@ -7,12 +7,14 @@ import com.jsowell.common.util.StringUtils;
|
|||||||
import com.jsowell.pile.domain.JcppSyncRecord;
|
import com.jsowell.pile.domain.JcppSyncRecord;
|
||||||
import com.jsowell.pile.domain.PileBasicInfo;
|
import com.jsowell.pile.domain.PileBasicInfo;
|
||||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||||
|
import com.jsowell.pile.domain.PileModelInfo;
|
||||||
import com.jsowell.pile.jcpp.dto.sync.*;
|
import com.jsowell.pile.jcpp.dto.sync.*;
|
||||||
import com.jsowell.pile.jcpp.service.IJcppAuthService;
|
import com.jsowell.pile.jcpp.service.IJcppAuthService;
|
||||||
import com.jsowell.pile.jcpp.service.IJcppPileSyncService;
|
import com.jsowell.pile.jcpp.service.IJcppPileSyncService;
|
||||||
import com.jsowell.pile.mapper.JcppSyncRecordMapper;
|
import com.jsowell.pile.mapper.JcppSyncRecordMapper;
|
||||||
import com.jsowell.pile.service.PileBasicInfoService;
|
import com.jsowell.pile.service.PileBasicInfoService;
|
||||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||||
|
import com.jsowell.pile.service.PileModelInfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -48,6 +50,9 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileModelInfoService pileModelInfoService;
|
||||||
|
|
||||||
@Value("${jcpp.sync.api-url:http://localhost:8180/api/sync}")
|
@Value("${jcpp.sync.api-url:http://localhost:8180/api/sync}")
|
||||||
private String jcppApiUrl;
|
private String jcppApiUrl;
|
||||||
|
|
||||||
@@ -94,6 +99,7 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService {
|
|||||||
|
|
||||||
log.info("全量同步完成: 充电桩 {}/{}, 充电枪 {}/{}",
|
log.info("全量同步完成: 充电桩 {}/{}, 充电枪 {}/{}",
|
||||||
response.getSuccessPiles(), response.getTotalPiles(),
|
response.getSuccessPiles(), response.getTotalPiles(),
|
||||||
|
|
||||||
response.getSuccessGuns(), response.getTotalGuns());
|
response.getSuccessGuns(), response.getTotalGuns());
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@@ -228,18 +234,35 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService {
|
|||||||
|
|
||||||
// 基本字段
|
// 基本字段
|
||||||
dto.setPileCode(pile.getSn());
|
dto.setPileCode(pile.getSn());
|
||||||
dto.setPileName(pile.getName());
|
String pileName = pile.getName();
|
||||||
dto.setProtocol(pile.getSoftwareProtocol());
|
// 如果名称为空,使用充电桩编号
|
||||||
|
if (StringUtils.isBlank(pileName)) {
|
||||||
|
pileName = pile.getSn();
|
||||||
|
}
|
||||||
|
dto.setPileName(pileName);
|
||||||
|
dto.setProtocol("yunkuaichongV150");
|
||||||
|
|
||||||
// 品牌、型号、制造商(可为空)
|
// 品牌、型号、制造商(可为空)
|
||||||
dto.setBrand("jsowell"); // Web 项目中没有这些字段
|
dto.setBrand("jsowell"); // Web 项目中没有这些字段
|
||||||
dto.setModel(null);
|
dto.setModel(null);
|
||||||
dto.setManufacturer("jsowell");
|
dto.setManufacturer("jsowell");
|
||||||
|
|
||||||
// 类型映射:1-运营桩 → OPERATION, 2-个人桩 → PERSONAL
|
// 类型映射:从 pile_model_info 表获取 speed_type
|
||||||
String type = "OPERATION"; // 默认运营桩
|
// 1-快充(DC直流) → DC, 2-慢充(AC交流) → AC
|
||||||
if ("2".equals(pile.getBusinessType())) {
|
String type = "AC"; // 默认交流桩
|
||||||
type = "PERSONAL";
|
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);
|
dto.setType(type);
|
||||||
|
|
||||||
@@ -274,7 +297,16 @@ public class JcppPileSyncServiceImpl implements IJcppPileSyncService {
|
|||||||
|
|
||||||
// 基本字段
|
// 基本字段
|
||||||
dto.setGunCode(gun.getPileConnectorCode());
|
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());
|
dto.setPileCode(gun.getPileSn());
|
||||||
|
|
||||||
// 提取枪号(最后 2 位)
|
// 提取枪号(最后 2 位)
|
||||||
|
|||||||
Reference in New Issue
Block a user