| | |
| | | package com.ruoyi.order; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.feignClient.*; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.chargingPile.api.feignClient.*; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.integration.api.feignClient.*; |
| | | import com.ruoyi.integration.api.model.ChargingHandshake; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.dto.ChargingDetails; |
| | | import com.ruoyi.order.dto.MyChargingOrderInfo; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.order.mapper.TSettlementConfirmMapper; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.UserTagClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | |
| | | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = RuoYiOrderApplication.class) |
| | | public class RuoYiOrderApplicationTests { |
| | |
| | | @Resource |
| | | private TChargingOrderService chargingOrderService; |
| | | |
| | | @Resource |
| | | private ChargingGunClient chargingGunClient; |
| | | @Resource |
| | | private TSettlementConfirmMapper tSettlementConfirmMapper; |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | @Resource |
| | | private AppUserCarClient appUserCarClient; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | @Resource |
| | | private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private WxPaymentClient wxPaymentClient; |
| | | |
| | | @Resource |
| | | private AliPaymentClient aliPaymentClient; |
| | | |
| | | @Resource |
| | | private AppCouponClient appCouponClient; |
| | | |
| | | @Resource |
| | | private AppUserVipDetailClient appUserVipDetailClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; |
| | | |
| | | @Resource |
| | | private ChargingHandshakeClient chargingHandshakeClient; |
| | | |
| | | @Resource |
| | | private SendMessageClient sendMessageClient; |
| | | |
| | | @Resource |
| | | private TOrderEvaluateService orderEvaluateService; |
| | | |
| | | @Resource |
| | | private AccountingStrategyDetailClient accountingStrategyDetailClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyDetailOrderClient accountingStrategyDetailOrderClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyClient accountingStrategyClient; |
| | | |
| | | @Resource |
| | | private PlatformStartChargingReplyClient platformStartChargingReplyClient; |
| | | |
| | | @Resource |
| | | private TChargingOrderRefundService chargingOrderRefundService; |
| | | |
| | | @Resource |
| | | private PlatformStopChargingReplyClient platformStopChargingReplyClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyOrderService accountingStrategyOrderService; |
| | | |
| | | @Resource |
| | | private AccountingStrategyDetailOrderService accountingStrategyDetailOrderService; |
| | | |
| | | @Resource |
| | | private InviteUserClient inviteUserClient; |
| | | |
| | | @Resource |
| | | private AppUserIntegralChangeClient appUserIntegralChangeClient; |
| | | |
| | | @Resource |
| | | private IntegralRuleClient integralRuleClient; |
| | | |
| | | @Resource |
| | | private VipClient vipClient; |
| | | |
| | | @Resource |
| | | private UserTagClient userTagClient; |
| | | |
| | | @Resource |
| | | private AppUserTagClient appUserTagClient; |
| | | |
| | | @Resource |
| | | private SecurityDetectionClient securityDetectionClient; |
| | | |
| | | |
| | | @Test |
| | | public void test(){ |
| | | ChargingDetails chargingDetails = chargingOrderService.getChargingDetails(75); |
| | | Integer id = 75; |
| | | TChargingOrder one = chargingOrderService.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, 1839480334642704385L).eq(TChargingOrder::getChargingGunId, id) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).eq(TChargingOrder::getDelFlag, 0).orderByDesc(TChargingOrder::getStartTime).last(" limit 0, 1")); |
| | | ChargingDetails chargingDetails = new ChargingDetails(); |
| | | chargingDetails.setId(one.getId().toString()); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); |
| | | Site site = siteClient.getSiteByIds(Arrays.asList(chargingPile.getSiteId())).getData().get(0); |
| | | chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); |
| | | chargingDetails.setCode(one.getCode()); |
| | | chargingDetails.setStatus(one.getStatus()); |
| | | chargingDetails.setChargingCost(one.getResidualAmount()); |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(one.getCode()).getData(); |
| | | if(null != data){ |
| | | chargingDetails.setChargeCurrent(data.getOutput_current()); |
| | | chargingDetails.setChargeVoltage(data.getOutput_voltage()); |
| | | BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000)); |
| | | chargingDetails.setChargePower(power); |
| | | chargingDetails.setCompletionRatio(data.getSoc()); |
| | | chargingDetails.setRemainingChargeTime(data.getTime_remaining()); |
| | | chargingDetails.setChargedDegrees(data.getCharging_degree()); |
| | | Integer h = Integer.valueOf(data.getCumulative_charging_time() / 60); |
| | | Integer m = Integer.valueOf(data.getCumulative_charging_time() % 60); |
| | | chargingDetails.setChargedTime(String.format("%02d", h) + ":" + String.format("%02d", m)); |
| | | } |
| | | ChargingHandshake chargingHandshake = chargingHandshakeClient.getDataByOrderCode(one.getCode()).getData(); |
| | | if(null != chargingHandshake && null != data && null != one.getAppUserCarId()){ |
| | | BigDecimal bms_battery_capacity = chargingHandshake.getBms_battery_capacity(); |
| | | TAppUserCar appUserCar = appUserCarClient.getCarByIds(Arrays.asList(one.getAppUserCarId())).getData().get(0); |
| | | // 续航 = 电池容量 / 续航里程 * soc |
| | | BigDecimal divide = bms_battery_capacity.divide(new BigDecimal(appUserCar.getEndurance())); |
| | | BigDecimal multiply = new BigDecimal(data.getSoc() / 100).multiply(divide); |
| | | chargingDetails.setEndurance(multiply); |
| | | } |
| | | System.err.println(JSON.toJSONString(chargingDetails)); |
| | | } |
| | | } |