| | |
| | | |
| | | @Resource |
| | | private AppUserTagClient appUserTagClient; |
| | | |
| | | @Resource |
| | | private SecurityDetectionClient securityDetectionClient; |
| | | |
| | | //计数器 |
| | | private Map<String, Integer> counter_map = new HashMap<>(); |
| | |
| | | //执行5分钟的定时任务检测 |
| | | ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | scheduler.scheduleAtFixedRate(()->{ |
| | | //获取安全校验 |
| | | SecurityDetection securityDetection = securityDetectionClient.getSecurityDetection(chargingOrder.getCode()).getData(); |
| | | if(null != securityDetection){ |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject("AQJC_" + chargingOrder.getChargingGunId()); |
| | | if(null != preChargeCheck1){ |
| | | preChargeCheck1.setElectronicLockLock(preChargeCheck1.getElectronicLockLock()); |
| | | preChargeCheck1.setInsulationTesting(true); |
| | | preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection()); |
| | | preChargeCheck1.setStartupSuccess(1); |
| | | redisService.setCacheObject("AQJC_" + chargingOrder.getChargingGunId(), preChargeCheck1); |
| | | } |
| | | } |
| | | |
| | | List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData(); |
| | | System.err.println("-------------------开始检查调起充电结果-------------------"); |
| | | System.err.println(data.toString()); |
| | |
| | | Integer failure_cause = platformStartChargingReply.getFailure_cause(); |
| | | Integer counter = counter_map.get(code); |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); |
| | | //状态为5的时候,硬件会间隔60秒后再次检测,依然未插枪,则不启动充电 |
| | | //因这里是间隔5秒执行检测,所以累计次数在30次以上 |
| | | if(failure_cause == 5 && (null == counter || counter < 35)){ |
| | | counter++; |
| | | //5分钟内还未插枪则取消充电,退回金额。 |
| | | if(failure_cause == 5 && (null == counter || counter < 300)){ |
| | | counter = (null == counter ? 0 : counter) + 1; |
| | | counter_map.put(code, counter); |
| | | //启动失败 |
| | | preChargeCheck1.setStartupSuccess(3); |
| | |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | return; |
| | | } |
| | | |
| | | //清除计时器中的无效数据 |
| | | counter_map.remove(code); |
| | | //开始处理退款 |
| | | TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); |
| | | if(0 == startup_result){ |
| | | //启动失败 |
| | |
| | | order.setStatus(-1); |
| | | order.setEndMode(0); |
| | | }else{ |
| | | //启动成功 |
| | | preChargeCheck1.setStartupSuccess(2); |
| | | order.setStatus(3); |
| | | order.setStartTime(LocalDateTime.now()); |
| | |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | //提前结束定时任务 |
| | | scheduler.shutdown(); |
| | | }else{ |
| | | log.error("未上传开启充电结果........"); |
| | | } |
| | | }, 5, 300, TimeUnit.SECONDS); |
| | | }, 5, 1, TimeUnit.SECONDS); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | throw new RuntimeException(failure_cause); |
| | | } |
| | | |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | //计算费用,处理退款 |
| | | endCharge(chargingOrder); |
| | | break; |
| | |
| | | for (ChargingOrderVO chargingOrderVO : list) { |
| | | TChargingGun data3 = chargingGunClient.getChargingGunById(chargingOrderVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderVO.getChargingPileId()).getData(); |
| | | if (chargingOrderVO.getSiteId()!=null){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(chargingOrderVO.getSiteId()); |
| | | List<Site> data = siteClient.getSiteByIds(integers).getData(); |
| | | if (!data.isEmpty())chargingOrderVO.setSiteName(data.get(0).getName()); |
| | | } |
| | | if (data2!=null && data3!=null){ |
| | | chargingOrderVO.setTerminalName(data2.getName()+"-"+data3.getName()); |
| | | |
| | |
| | | // 单个订单累计服务费 |
| | | BigDecimal serviceMoney1 = new BigDecimal("0"); |
| | | UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrderVO.getCode()).getData(); |
| | | chargingOrderVO.setChargingSecond(data5.getTime_remaining()*60L); |
| | | if (data5!=null){ |
| | | chargingOrderVO.setChargingSecond(data5.getTime_remaining()*60L); |
| | | } |
| | | // 总收入 |
| | | if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){ |
| | | income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount())); |