| | |
| | | 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.api.model.TChargingOrderAccountingStrategy; |
| | | import com.ruoyi.order.api.vo.AccountingStrategyDetailOrderVo; |
| | | import com.ruoyi.order.api.vo.ChargingOrderInfoVO; |
| | | import com.ruoyi.order.api.vo.TransactionRecordMessageVO; |
| | | import com.ruoyi.order.dto.ChargingDetails; |
| | | import com.ruoyi.order.dto.MyChargingOrderInfo; |
| | | import com.ruoyi.order.mapper.TSettlementConfirmMapper; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.order.vo.EndOfChargePageInfo; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.UserTagClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.*; |
| | | |
| | | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = RuoYiOrderApplication.class) |
| | | public class RuoYiOrderApplicationTests { |
| | |
| | | |
| | | @Test |
| | | public void test(){ |
| | | 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)); |
| | | // TransactionRecordMessageVO vo = JSON.parseObject("{\n" + |
| | | // "\t\"charging_gun_code\": \"02\",\n" + |
| | | // "\t\"charging_pile_code\": \"2024123100001003\",\n" + |
| | | // "\t\"end_time\": \"2025-02-12 00:32:18.00\",\n" + |
| | | // "\t\"flat_amount2\": 0.000000,\n" + |
| | | // "\t\"flat_amount4\": 0.000000,\n" + |
| | | // "\t\"flat_amount6\": 0.000000,\n" + |
| | | // "\t\"flat_charge2\": 0.000000,\n" + |
| | | // "\t\"flat_charge4\": 0.000000,\n" + |
| | | // "\t\"flat_charge6\": 0.000000,\n" + |
| | | // "\t\"loss_peak_charge3\": 0,\n" + |
| | | // "\t\"loss_peak_charge5\": 0,\n" + |
| | | // "\t\"loss_total_electricity\": 0,\n" + |
| | | // "\t\"loss_valley_charge1\": 0,\n" + |
| | | // "\t\"loss_valley_charge7\": 0,\n" + |
| | | // "\t\"payment_amount\": 41.650000,\n" + |
| | | // "\t\"peak_amount3\": 0.000000,\n" + |
| | | // "\t\"peak_amount5\": 0.000000,\n" + |
| | | // "\t\"peak_charge3\": 0.000000,\n" + |
| | | // "\t\"peak_charge5\": 0.000000,\n" + |
| | | // "\t\"physical_card_number\": \"1234567812345678\",\n" + |
| | | // "\t\"result\": \"{\\\"service_id\\\":\\\"transaction_record\\\",\\\"transaction_serial_number\\\":\\\"CD69120250211231439794\\\",\\\"charging_pile_code\\\":\\\"2024123100001003\\\",\\\"charging_gun_code\\\":\\\"02\\\",\\\"start_time\\\":\\\"2025-02-11 23:14:46.00\\\",\\\"end_time\\\":\\\"2025-02-12 00:32:18.00\\\",\\\"valley_charge1\\\":\\\"16.516000\\\",\\\"loss_valley_charge1\\\":\\\"0\\\",\\\"valley_amount1\\\":\\\"12.380000\\\",\\\"flat_charge2\\\":\\\"0.000000\\\",\\\"loss_flat_charg2\\\":\\\"0\\\",\\\"flat_amount2\\\":\\\"0.000000\\\",\\\"peak_charge3\\\":\\\"0.000000\\\",\\\"loss_peak_charge3\\\":\\\"0\\\",\\\"peak_amount3\\\":\\\"0.000000\\\",\\\"flat_charge4\\\":\\\"0.000000\\\",\\\"loss_flat_charg4\\\":\\\"0\\\",\\\"flat_amount4\\\":\\\"0.000000\\\",\\\"peak_charge5\\\":\\\"0.000000\\\",\\\"loss_peak_charge5\\\":\\\"0\\\",\\\"peak_amount5\\\":\\\"0.000000\\\",\\\"flat_charge6\\\":\\\"0.000000\\\",\\\"loss_flat_charg6\\\":\\\"0\\\",\\\"flat_amount6\\\":\\\"0.000000\\\",\\\"valley_charge7\\\":\\\"39.045000\\\",\\\"loss_valley_charge7\\\":\\\"0\\\",\\\"valley_amount7\\\":\\\"29.270000\\\",\\\"total_electricity\\\":\\\"55.561001\\\",\\\"loss_total_electricity\\\":\\\"0\\\",\\\"payment_amount\\\":\\\"41.650000\\\",\\\"trade_date\\\":\\\"0\\\",\\\"stop_reason\\\":\\\"1\\\",\\\"physical_card_number\\\":\\\"1234567812345678\\\"}\",\n" + |
| | | // "\t\"retryTimes\": 0,\n" + |
| | | // "\t\"sendTime\": 1739291543546,\n" + |
| | | // "\t\"serviceId\": \"transaction_record\",\n" + |
| | | // "\t\"source\": \"\",\n" + |
| | | // "\t\"start_time\": \"2025-02-11 23:14:46.00\",\n" + |
| | | // "\t\"stop_reason\": 1,\n" + |
| | | // "\t\"total_electricity\": 55.561001,\n" + |
| | | // "\t\"trade_date\": \"0\",\n" + |
| | | // "\t\"transaction_serial_number\": \"CD69120250211231439794\",\n" + |
| | | // "\t\"valley_amount1\": 12.380000,\n" + |
| | | // "\t\"valley_amount7\": 29.270000,\n" + |
| | | // "\t\"valley_charge1\": 16.516000,\n" + |
| | | // "\t\"valley_charge7\": 39.045000\n" + |
| | | // "}", TransactionRecordMessageVO.class); |
| | | // chargingOrderService.endChargeBillingCharge(vo); |
| | | } |
| | | } |