| | |
| | | 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.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.integration.api.feignClient.ChargingHandshakeClient; |
| | | import com.ruoyi.integration.api.feignClient.SendMessageClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.ChargingHandshake; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy; |
| | | import com.ruoyi.order.api.model.TChargingOrderRefund; |
| | | import com.ruoyi.order.api.model.TOrderEvaluate; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.api.vo.TCharingOrderVO; |
| | |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.service.TChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.order.service.TOrderEvaluateService; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | | import com.ruoyi.payment.api.vo.*; |
| | |
| | | @Resource |
| | | private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; |
| | | |
| | | @Resource |
| | | private ChargingHandshakeClient chargingHandshakeClient; |
| | | |
| | | @Resource |
| | | private SendMessageClient sendMessageClient; |
| | | |
| | | @Resource |
| | | private TOrderEvaluateService orderEvaluateService; |
| | | |
| | | |
| | | |
| | |
| | | BigDecimal payMoney = tChargingOrder.getStatus() < 4 ? tChargingOrder.getRechargeAmount() : tChargingOrder.getPaymentAmount(); |
| | | myChargingOrderList.setPayMoney(payMoney); |
| | | myChargingOrderList.setCreateTime(tChargingOrder.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | long count = orderEvaluateService.count(new LambdaQueryWrapper<TOrderEvaluate>().eq(TOrderEvaluate::getOrderType, 1) |
| | | .eq(TOrderEvaluate::getOrderId, tChargingOrder.getId()).eq(TOrderEvaluate::getDelFlag, 0)); |
| | | myChargingOrderList.setEvaluate(count + 1L); |
| | | orderLists.add(myChargingOrderList); |
| | | } |
| | | list = this.baseMapper.getMyChargingOrderList(appUserId, query.getType(), null, null); |
| | | map.put("list", orderLists); |
| | | map.put("totle", list.size()); |
| | | return map; |
| | | } |
| | | |
| | |
| | | map.put("time", time.get(i)); |
| | | //soc |
| | | map.put("soc", soc.get(i)); |
| | | //电压 |
| | | //功率 |
| | | map.put("power", po.get(i)); |
| | | power.add(map); |
| | | } |
| | |
| | | BigDecimal payMoney = tChargingOrder.getStatus() < 4 ? tChargingOrder.getRechargeAmount() : tChargingOrder.getPaymentAmount(); |
| | | myChargingOrderList.setPayMoney(payMoney); |
| | | myChargingOrderList.setCreateTime(tChargingOrder.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | myChargingOrderList.setElectricCharge(tChargingOrder.getElectrovalence()); |
| | | myChargingOrderList.setServiceCharge(tChargingOrder.getServiceCharge()); |
| | | list.add(myChargingOrderList); |
| | | } |
| | | return list; |
| | |
| | | preChargeCheck.setSecureConnectionDetection(false); |
| | | String key = "AQJC_" + chargingOrder.getChargingGunId(); |
| | | redisService.setCacheObject(key, preChargeCheck); |
| | | //开始检测充电桩状,将检查状态写入缓存。检测完成后开始开启充电 |
| | | //充电结束后需要计算退款剩余金额 |
| | | // todo 需要完善 |
| | | |
| | | //根据当前充值的金额和计费模板算出充电的金额 |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | //计算充电金额,会员需要将折扣金额加入到充电总金额中 |
| | | |
| | | // TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | // if(){ |
| | | // appUser.getVipId() |
| | | // } |
| | | // |
| | | // |
| | | // //调用远程启动充电消息 |
| | | // PlatformStartCharging platformStartCharging = new PlatformStartCharging(); |
| | | // platformStartCharging.setTransaction_serial_number(chargingOrder.getCode()); |
| | | // platformStartCharging.setCharging_pile_code(); |
| | | // platformStartCharging.setCharging_gun_code(); |
| | | // platformStartCharging.setCard_number(); |
| | | // platformStartCharging.setAccount_balance() |
| | | // sendMessageClient.platformStartCharging(platformStartCharging); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | if(null == one){ |
| | | return null; |
| | | } |
| | | // todo 需要完善充电实时数据 |
| | | ChargingDetails chargingDetails = new ChargingDetails(); |
| | | chargingDetails.setId(one.getId().toString()); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); |
| | |
| | | chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); |
| | | chargingDetails.setCode(one.getCode()); |
| | | chargingDetails.setStatus(one.getStatus()); |
| | | 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()); |
| | | chargingDetails.setChargedTime(data.getCumulative_charging_time()); |
| | | chargingDetails.setChargingCost(data.getPaid_amount()); |
| | | } |
| | | 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); |
| | | } |
| | | return chargingDetails; |
| | | } |
| | | |
| | |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | //调用硬件停止充电,停止成功后开始计算费用退款 |
| | | |
| | | |
| | | |
| | | // todo 待完善 |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | public void endCharge(){ |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public TCharingOrderVO chargingOrder(ChargingOrderQuery dto) { |
| | |
| | | BigDecimal electronicMoney = new BigDecimal("0"); |
| | | BigDecimal serviceMoney = new BigDecimal("0"); |
| | | for (ChargingOrderVO chargingOrderVO : list) { |
| | | total = total.add(chargingOrderVO.getChargingCapacity()); |
| | | if (chargingOrderVO.getChargingCapacity()!=null){ |
| | | total = total.add(chargingOrderVO.getChargingCapacity()); |
| | | } |
| | | // 充电订单 明细记录 |
| | | List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>() |
| | | .eq("charging_order_id", chargingOrderVO.getId())); |
| | |
| | | LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderVO.getEndTime(); |
| | | // 计算时间差 秒 充电时长 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderVO.setChargingSecond(between); |
| | | time += between; |
| | | if (startTime!=null && endTime!=null){ |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderVO.setChargingSecond(between); |
| | | time += between; |
| | | } |
| | | // 总收入 |
| | | if (chargingOrderVO.getRefundStatus() == 2){ |
| | | if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){ |
| | | income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount())); |
| | | }else{ |
| | | income = income.add(chargingOrderVO.getPaymentAmount()); |
| | | if (chargingOrderVO.getPaymentAmount()!=null){ |
| | | income = income.add(chargingOrderVO.getPaymentAmount()); |
| | | } |
| | | } |
| | | for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : chargingOrderId) { |
| | | // 累计电费 |
| | |
| | | // 车牌号 |
| | | chargingOrderVO.setPhone(data.getPhone()); |
| | | List<Long> longs = new ArrayList<>(); |
| | | longs.add(chargingOrderVO.getAppUserCarId()); |
| | | List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); |
| | | if (!data1.isEmpty()){ |
| | | chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); |
| | | if (chargingOrderVO.getAppUserCarId()!=null){ |
| | | longs.add(chargingOrderVO.getAppUserCarId()); |
| | | List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); |
| | | if (!data1.isEmpty()){ |
| | | chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | tCharingOrderVO.setTotal(total); |
| | |
| | | tCharingOrderVO.setList(pageInfo); |
| | | return tCharingOrderVO; |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<PayOrderDto>> payOrderQuery(PayOrderQueryDto payOrderQueryDto) { |
| | | PageInfo<PayOrderDto> pageInfo = new PageInfo<>(payOrderQueryDto.getPageCurr(),payOrderQueryDto.getPageSize()); |
| | | List<PayOrderDto> list = this.baseMapper.payOrderQuery(pageInfo,payOrderQueryDto); |
| | | pageInfo.setRecords(list); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<TChargingOrderRefund>> getRefundList(ChargingRefundDto chargingRefundDto) { |
| | | PageInfo<TChargingOrderRefund> pageInfo = new PageInfo<>(chargingRefundDto.getPageCurr(),chargingRefundDto.getPageSize()); |
| | | List<TChargingOrderRefund> list = this.baseMapper.getRefundList(pageInfo,chargingRefundDto); |
| | | pageInfo.setRecords(list); |
| | | |
| | | return R.ok(pageInfo); |
| | | } |
| | | } |