|
|
@@ -29,6 +29,7 @@ import com.zsElectric.boot.business.model.vo.BannerInfoVO;
|
|
|
import com.zsElectric.boot.business.model.vo.StationInfoMapVO;
|
|
|
import com.zsElectric.boot.business.model.vo.StationInfoVO;
|
|
|
import com.zsElectric.boot.business.model.vo.applet.AppletChargingCostVO;
|
|
|
+import com.zsElectric.boot.business.model.vo.applet.AppletConnectorDetailVO;
|
|
|
import com.zsElectric.boot.business.model.vo.applet.AppletStationSearchVO;
|
|
|
import com.zsElectric.boot.business.service.AppletHomeService;
|
|
|
import com.zsElectric.boot.business.converter.BannerInfoConverter;
|
|
|
@@ -674,4 +675,198 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
// 调用Mapper查询
|
|
|
return thirdPartyStationInfoMapper.searchStations(keyword.trim(), longitude, latitude);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AppletConnectorDetailVO getConnectorDetail(Long connectorId) {
|
|
|
+ // 查询充电接口信息
|
|
|
+ ThirdPartyConnectorInfo connectorInfo = thirdPartyConnectorInfoMapper.selectById(connectorId);
|
|
|
+ if (connectorInfo == null) {
|
|
|
+ log.warn("充电接口不存在,connectorId: {}", connectorId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建返回VO
|
|
|
+ AppletConnectorDetailVO result = new AppletConnectorDetailVO();
|
|
|
+ result.setConnectorId(connectorId);
|
|
|
+ result.setConnectorCode(connectorInfo.getConnectorId());
|
|
|
+ result.setConnectorName(connectorInfo.getConnectorName());
|
|
|
+ result.setConnectorType(connectorInfo.getConnectorType());
|
|
|
+ result.setConnectorTypeName(getConnectorTypeName(connectorInfo.getConnectorType()));
|
|
|
+ result.setVoltageUpperLimits(connectorInfo.getVoltageUpperLimits());
|
|
|
+ result.setVoltageLowerLimits(connectorInfo.getVoltageLowerLimits());
|
|
|
+ result.setCurrent(connectorInfo.getCurrent());
|
|
|
+ result.setPower(connectorInfo.getPower());
|
|
|
+ result.setParkNo(connectorInfo.getParkNo());
|
|
|
+ result.setNationalStandard(connectorInfo.getNationalStandard());
|
|
|
+ result.setNationalStandardName(getNationalStandardName(connectorInfo.getNationalStandard()));
|
|
|
+ result.setStatus(connectorInfo.getStatus());
|
|
|
+ result.setStatusName(getStatusName(connectorInfo.getStatus()));
|
|
|
+
|
|
|
+ // 查询设备信息
|
|
|
+ ThirdPartyEquipmentInfo equipmentInfo = thirdPartyEquipmentInfoMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyEquipmentInfo>()
|
|
|
+ .eq(ThirdPartyEquipmentInfo::getEquipmentId, connectorInfo.getEquipmentId())
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (equipmentInfo != null) {
|
|
|
+ result.setEquipmentId(equipmentInfo.getId());
|
|
|
+ result.setEquipmentCode(equipmentInfo.getEquipmentId());
|
|
|
+ result.setEquipmentName(equipmentInfo.getEquipmentName());
|
|
|
+ result.setEquipmentType(equipmentInfo.getEquipmentType());
|
|
|
+ result.setEquipmentTypeName(getEquipmentTypeName(equipmentInfo.getEquipmentType()));
|
|
|
+
|
|
|
+ // 查询充电站信息
|
|
|
+ ThirdPartyStationInfo stationInfo = thirdPartyStationInfoMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyStationInfo>()
|
|
|
+ .eq(ThirdPartyStationInfo::getStationId, equipmentInfo.getStationId())
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (stationInfo != null) {
|
|
|
+ result.setStationId(stationInfo.getId());
|
|
|
+ result.setStationName(stationInfo.getStationName());
|
|
|
+ result.setStationAddress(stationInfo.getAddress());
|
|
|
+ result.setParkingTips(stationInfo.getStationTips());
|
|
|
+
|
|
|
+ // 获取当前价格信息
|
|
|
+ String currentTime = LocalTime.now().format(TIME_FORMATTER);
|
|
|
+
|
|
|
+ // 查询价格策略
|
|
|
+ ThirdPartyEquipmentPricePolicy pricePolicy = thirdPartyEquipmentPricePolicyMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyEquipmentPricePolicy>()
|
|
|
+ .eq(ThirdPartyEquipmentPricePolicy::getConnectorId, connectorInfo.getConnectorId())
|
|
|
+ .eq(ThirdPartyEquipmentPricePolicy::getIsDeleted, 0)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (pricePolicy != null) {
|
|
|
+ // 查询当前时段的价格
|
|
|
+ List<ThirdPartyPolicyInfo> policyInfoList = thirdPartyPolicyInfoMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyPolicyInfo>()
|
|
|
+ .eq(ThirdPartyPolicyInfo::getPricePolicyId, pricePolicy.getId())
|
|
|
+ .eq(ThirdPartyPolicyInfo::getIsDeleted, 0)
|
|
|
+ .le(ThirdPartyPolicyInfo::getStartTime, currentTime)
|
|
|
+ .orderByDesc(ThirdPartyPolicyInfo::getStartTime)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!policyInfoList.isEmpty()) {
|
|
|
+ ThirdPartyPolicyInfo currentPolicyInfo = policyInfoList.get(0);
|
|
|
+ BigDecimal elecPrice = currentPolicyInfo.getElecPrice() != null ? currentPolicyInfo.getElecPrice() : BigDecimal.ZERO;
|
|
|
+ BigDecimal servicePrice = currentPolicyInfo.getServicePrice() != null ? currentPolicyInfo.getServicePrice() : BigDecimal.ZERO;
|
|
|
+ result.setCurrentPrice(elecPrice.add(servicePrice));
|
|
|
+ result.setCurrentPeriodDesc(getPeriodFlagName(currentPolicyInfo.getPeriodFlag()));
|
|
|
+
|
|
|
+ // 获取当前登录用户ID,查询是否为企业用户
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ if (userId != null) {
|
|
|
+ UserFirm userFirm = userFirmMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<UserFirm>()
|
|
|
+ .eq(UserFirm::getUserId, userId)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (userFirm != null) {
|
|
|
+ // 查询企业价格
|
|
|
+ PolicyFee policyFee = policyFeeMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<PolicyFee>()
|
|
|
+ .eq(PolicyFee::getStationInfoId, stationInfo.getId())
|
|
|
+ .eq(PolicyFee::getSalesType, 1) // 1-企业
|
|
|
+ .eq(PolicyFee::getFirmId, userFirm.getFirmId())
|
|
|
+ .eq(PolicyFee::getStartTime, currentPolicyInfo.getStartTime())
|
|
|
+ .eq(PolicyFee::getIsDeleted, 0)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (policyFee != null) {
|
|
|
+ // 企业价格 = 电费 + 服务费 + 运营费 + 综合销售费
|
|
|
+ BigDecimal opFee = policyFee.getOpFee() != null ? policyFee.getOpFee() : BigDecimal.ZERO;
|
|
|
+ BigDecimal compSalesFee = policyFee.getCompSalesFee() != null ? policyFee.getCompSalesFee() : BigDecimal.ZERO;
|
|
|
+ BigDecimal enterprisePrice = elecPrice.add(servicePrice).add(opFee).add(compSalesFee);
|
|
|
+ result.setEnterprisePrice(enterprisePrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是充电中状态,查询实时充电数据
|
|
|
+ if (connectorInfo.getStatus() != null && connectorInfo.getStatus() == 3) {
|
|
|
+ // 查询正在充电的订单
|
|
|
+ ThirdPartyChargeStatus chargeStatus = thirdPartyChargeStatusMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyChargeStatus>()
|
|
|
+ .eq(ThirdPartyChargeStatus::getConnectorId, connectorInfo.getConnectorId())
|
|
|
+ .eq(ThirdPartyChargeStatus::getStartChargeSeqStat, 2) // 充电中
|
|
|
+ .orderByDesc(ThirdPartyChargeStatus::getUpdateTime)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (chargeStatus != null) {
|
|
|
+ // 电流取A相电流
|
|
|
+ result.setCurrentCurrent(chargeStatus.getCurrentA());
|
|
|
+ // 电压取A相电压
|
|
|
+ result.setCurrentVoltage(chargeStatus.getVoltageA());
|
|
|
+ // 功率 = 电压 * 电流 / 1000 (转换为kW)
|
|
|
+ if (chargeStatus.getVoltageA() != null && chargeStatus.getCurrentA() != null) {
|
|
|
+ BigDecimal power = chargeStatus.getVoltageA()
|
|
|
+ .multiply(chargeStatus.getCurrentA())
|
|
|
+ .divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ result.setCurrentPower(power);
|
|
|
+ }
|
|
|
+ result.setSoc(chargeStatus.getSoc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置最后更新时间
|
|
|
+ if (connectorInfo.getUpdateTime() != null) {
|
|
|
+ result.setLastUpdateTime(connectorInfo.getUpdateTime().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取接口类型名称
|
|
|
+ */
|
|
|
+ private String getConnectorTypeName(Integer connectorType) {
|
|
|
+ if (connectorType == null) {
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ switch (connectorType) {
|
|
|
+ case 1:
|
|
|
+ return "家用插座";
|
|
|
+ case 2:
|
|
|
+ return "交流接口插座";
|
|
|
+ case 3:
|
|
|
+ return "交流接口插头";
|
|
|
+ case 4:
|
|
|
+ return "直流接口枪头";
|
|
|
+ case 5:
|
|
|
+ return "无线充电座";
|
|
|
+ case 6:
|
|
|
+ return "其他";
|
|
|
+ default:
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取国家标准名称
|
|
|
+ */
|
|
|
+ private String getNationalStandardName(Integer nationalStandard) {
|
|
|
+ if (nationalStandard == null) {
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ switch (nationalStandard) {
|
|
|
+ case 1:
|
|
|
+ return "2011版";
|
|
|
+ case 2:
|
|
|
+ return "2015版";
|
|
|
+ default:
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|