|
|
@@ -7,8 +7,10 @@ import com.zsElectric.boot.business.mapper.BannerInfoMapper;
|
|
|
import com.zsElectric.boot.business.mapper.PolicyFeeMapper;
|
|
|
import com.zsElectric.boot.business.mapper.ThirdPartyStationInfoMapper;
|
|
|
import com.zsElectric.boot.business.mapper.UserFirmMapper;
|
|
|
+import com.zsElectric.boot.charging.entity.ThirdPartyChargeStatus;
|
|
|
import com.zsElectric.boot.charging.entity.ThirdPartyConnectorInfo;
|
|
|
import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentInfo;
|
|
|
+import com.zsElectric.boot.charging.mapper.ThirdPartyChargeStatusMapper;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
|
|
|
import com.zsElectric.boot.charging.entity.ThirdPartyEquipmentPricePolicy;
|
|
|
import com.zsElectric.boot.charging.entity.ThirdPartyPolicyInfo;
|
|
|
@@ -26,6 +28,7 @@ import com.zsElectric.boot.business.model.vo.AppletStationPriceListVO;
|
|
|
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.service.AppletHomeService;
|
|
|
import com.zsElectric.boot.business.converter.BannerInfoConverter;
|
|
|
import com.zsElectric.boot.security.util.SecurityUtils;
|
|
|
@@ -56,6 +59,7 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
private final ThirdPartyEquipmentPricePolicyMapper thirdPartyEquipmentPricePolicyMapper;
|
|
|
private final ThirdPartyPolicyInfoMapper thirdPartyPolicyInfoMapper;
|
|
|
private final PolicyFeeMapper policyFeeMapper;
|
|
|
+ private final ThirdPartyChargeStatusMapper thirdPartyChargeStatusMapper;
|
|
|
|
|
|
/**
|
|
|
* 时间格式化器 HHmmss
|
|
|
@@ -610,4 +614,124 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AppletChargingCostVO getCurrentChargingCost(String chargeOrderNo) {
|
|
|
+ // 1. 查询充电状态记录
|
|
|
+ ThirdPartyChargeStatus chargeStatus = thirdPartyChargeStatusMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyChargeStatus>()
|
|
|
+ .eq(ThirdPartyChargeStatus::getStartChargeSeq, chargeOrderNo)
|
|
|
+ .orderByDesc(ThirdPartyChargeStatus::getUpdateTime)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (chargeStatus == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 通过connector_id查询充电终端信息
|
|
|
+ ThirdPartyConnectorInfo connectorInfo = thirdPartyConnectorInfoMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyConnectorInfo>()
|
|
|
+ .eq(ThirdPartyConnectorInfo::getConnectorId, chargeStatus.getConnectorId())
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (connectorInfo == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 通过station_id查询站点信息
|
|
|
+ ThirdPartyStationInfo stationInfo = thirdPartyStationInfoMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ThirdPartyStationInfo>()
|
|
|
+ .eq(ThirdPartyStationInfo::getStationId, connectorInfo.getStationId())
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ // 4. 构建返回结果
|
|
|
+ AppletChargingCostVO result = new AppletChargingCostVO();
|
|
|
+ result.setChargeOrderNo(chargeOrderNo);
|
|
|
+ result.setStationName(stationInfo != null ? stationInfo.getStationName() : "");
|
|
|
+ result.setConnectorName(connectorInfo.getConnectorName());
|
|
|
+
|
|
|
+ // 订单状态
|
|
|
+ result.setOrderStatus(chargeStatus.getStartChargeSeqStat());
|
|
|
+ result.setOrderStatusDesc(getOrderStatusDesc(chargeStatus.getStartChargeSeqStat()));
|
|
|
+
|
|
|
+ // 充电时长
|
|
|
+ if (chargeStatus.getStartTime() != null && chargeStatus.getEndTime() != null) {
|
|
|
+ long duration = java.time.Duration.between(
|
|
|
+ chargeStatus.getStartTime(),
|
|
|
+ chargeStatus.getEndTime()
|
|
|
+ ).getSeconds();
|
|
|
+ result.setChargingDuration(duration);
|
|
|
+ result.setChargingDurationDesc(formatDuration(duration));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 费用信息
|
|
|
+ result.setTotalPower(chargeStatus.getTotalPower() != null ? chargeStatus.getTotalPower() : BigDecimal.ZERO);
|
|
|
+ result.setElecMoney(chargeStatus.getElecMoney() != null ? chargeStatus.getElecMoney() : BigDecimal.ZERO);
|
|
|
+ result.setServiceMoney(chargeStatus.getServiceMoney() != null ? chargeStatus.getServiceMoney() : BigDecimal.ZERO);
|
|
|
+ result.setTotalMoney(chargeStatus.getTotalMoney() != null ? chargeStatus.getTotalMoney() : BigDecimal.ZERO);
|
|
|
+
|
|
|
+ // SOC
|
|
|
+ result.setSoc(chargeStatus.getSoc());
|
|
|
+
|
|
|
+ // 电压电流(取A相为主,如果没有则取其他相)
|
|
|
+ BigDecimal current = chargeStatus.getCurrentA() != null ? chargeStatus.getCurrentA() :
|
|
|
+ (chargeStatus.getCurrentB() != null ? chargeStatus.getCurrentB() : chargeStatus.getCurrentC());
|
|
|
+ BigDecimal voltage = chargeStatus.getVoltageA() != null ? chargeStatus.getVoltageA() :
|
|
|
+ (chargeStatus.getVoltageB() != null ? chargeStatus.getVoltageB() : chargeStatus.getVoltageC());
|
|
|
+
|
|
|
+ result.setCurrent(current);
|
|
|
+ result.setVoltage(voltage);
|
|
|
+
|
|
|
+ // 功率 = 电压 × 电流 / 1000 (kW)
|
|
|
+ if (current != null && voltage != null) {
|
|
|
+ BigDecimal power = voltage.multiply(current).divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ result.setPower(power);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 时间信息
|
|
|
+ if (chargeStatus.getStartTime() != null) {
|
|
|
+ result.setStartTime(chargeStatus.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ }
|
|
|
+ if (chargeStatus.getUpdateTime() != null) {
|
|
|
+ result.setLastUpdateTime(chargeStatus.getUpdateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单状态描述
|
|
|
+ */
|
|
|
+ private String getOrderStatusDesc(Integer status) {
|
|
|
+ if (status == null) {
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ switch (status) {
|
|
|
+ case 1:
|
|
|
+ return "启动中";
|
|
|
+ case 2:
|
|
|
+ return "充电中";
|
|
|
+ case 3:
|
|
|
+ return "停止中";
|
|
|
+ case 4:
|
|
|
+ return "已结束";
|
|
|
+ case 5:
|
|
|
+ return "未知";
|
|
|
+ default:
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化时长(秒)为 HH:mm:ss
|
|
|
+ */
|
|
|
+ private String formatDuration(long seconds) {
|
|
|
+ long hours = seconds / 3600;
|
|
|
+ long minutes = (seconds % 3600) / 60;
|
|
|
+ long secs = seconds % 60;
|
|
|
+ return String.format("%02d:%02d:%02d", hours, minutes, secs);
|
|
|
+ }
|
|
|
}
|