| | |
| | | package com.ruoyi.integration.drainage; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.chargingPile.api.feignClient.*; |
| | | import com.ruoyi.chargingPile.api.model.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.integration.drainage.kuaidian.TCECKDUtil; |
| | | import com.ruoyi.integration.drainage.kuaidian.model.NotificationStationChangeResult; |
| | | import com.ruoyi.integration.drainage.kuaidian.model.QueryTerminalCode; |
| | | import com.ruoyi.integration.drainage.kuaidian.model.QueryTerminalCodeResult; |
| | | import com.ruoyi.integration.drainage.model.*; |
| | | import com.ruoyi.integration.drainage.model.enu.*; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | |
| | | private TokenUtil tokenUtil; |
| | | |
| | | private static Map<Long, Integer> map = new HashMap<>(); |
| | | |
| | | @Resource |
| | | private ParkingLotClient parkingLotClient; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | pageSize = 10; |
| | | } |
| | | PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize); |
| | | List<TParkingLot> parkingLots = parkingLotClient.getAllParkingLot().getData(); |
| | | QueryStationsInfoResult queryStationsInfoResult = new QueryStationsInfoResult(); |
| | | queryStationsInfoResult.setPageNo(pageNo); |
| | | queryStationsInfoResult.setPageCount((0 == (siteListPaging.getTotal() % pageSize) ? 0 : 1) + Double.valueOf(siteListPaging.getTotal() / pageSize).intValue()); |
| | | queryStationsInfoResult.setItemSize(Long.valueOf(siteListPaging.getTotal()).intValue()); |
| | | queryStationsInfoResult.setStationInfos(buildSite(siteListPaging.getRecords())); |
| | | queryStationsInfoResult.setStationInfos(buildSite(parkingLots, siteListPaging.getRecords())); |
| | | //参数加密 |
| | | String jsonString = JSON.toJSONString(queryStationsInfoResult); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); |
| | |
| | | * @param sites |
| | | * @return |
| | | */ |
| | | public List<StationInfo> buildSite(List<Site> sites){ |
| | | public List<StationInfo> buildSite(List<TParkingLot> parkingLots, List<Site> sites){ |
| | | List<Integer> siteIds = sites.stream().map(Site::getId).collect(Collectors.toList()); |
| | | List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); |
| | | List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | |
| | | stationInfo.setMatchCars(datum.getVehicleDescription()); |
| | | stationInfo.setBusineHours(datum.getStartServiceTime() + "-" + datum.getEndServiceTime()); |
| | | stationInfo.setElectricityFee(datum.getRateDescription()); |
| | | //添加停车费信息 |
| | | Optional<TParkingLot> first = parkingLots.stream().filter(s -> s.getSiteId().equals(datum.getId())).findFirst(); |
| | | if(first.isPresent()){ |
| | | TParkingLot tParkingLot = first.get(); |
| | | buildPlaceHolder(tParkingLot, stationInfo); |
| | | } |
| | | |
| | | //构建充电设备信息数据 |
| | | stationInfo.setEquipmentInfos(buildEquipmentInfo(datum.getId(), tChargingPiles, chargingGunList)); |
| | | StationInfos.add(stationInfo); |
| | | |
| | | } |
| | | return StationInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建停车费信息 |
| | | * @param tParkingLot |
| | | * @param stationInfo |
| | | */ |
| | | public void buildPlaceHolder(TParkingLot tParkingLot, StationInfo stationInfo){ |
| | | stationInfo.setOvertimeFee(tParkingLot.getName() + "停车费"); |
| | | PlaceHolder placeHolder = new PlaceHolder(); |
| | | placeHolder.setFreeTime(tParkingLot.getChargeFreeDuration()); |
| | | placeHolder.setMaxFee(tParkingLot.getChargeCapping()); |
| | | List<PlaceHolderPrice> PlaceHolderPrices = new ArrayList<>(); |
| | | PlaceHolderPrice placeHolderPrice = new PlaceHolderPrice(); |
| | | placeHolderPrice.setStartTime("00:00"); |
| | | placeHolderPrice.setEndTime("23:59"); |
| | | placeHolderPrice.setPrice(tParkingLot.getChargeRate()); |
| | | PlaceHolderPrices.add(placeHolderPrice); |
| | | placeHolder.setPlaceHolderPrices(PlaceHolderPrices); |
| | | stationInfo.setPlaceHolder(placeHolder); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | //构建设备接口信息 |
| | | equipmentInfo.setConnectorInfos(buildConnectorInfos(tChargingPile.getId(), chargingGunList)); |
| | | equipmentInfo.setConnectorInfos(buildConnectorInfos(tChargingPile.getId(), tChargingPile.getCode(), chargingGunList)); |
| | | equipmentInfos.add(equipmentInfo); |
| | | } |
| | | return equipmentInfos; |
| | |
| | | * @param chargingGunList |
| | | * @return |
| | | */ |
| | | public List<ConnectorInfo> buildConnectorInfos(Integer chargingPileId, List<TChargingGun> chargingGunList){ |
| | | public List<ConnectorInfo> buildConnectorInfos(Integer chargingPileId, String code, List<TChargingGun> chargingGunList){ |
| | | List<ConnectorInfo> connectorInfos = new ArrayList<>(); |
| | | List<TChargingGun> collect = chargingGunList.stream().filter(s -> s.getChargingPileId().equals(chargingPileId)).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : collect) { |
| | |
| | | connectorInfo.setPower(chargingGun.getRatedPower()); |
| | | connectorInfo.setParkNo(chargingGun.getParkingNumber()); |
| | | connectorInfo.setNationalStandard(Integer.valueOf(chargingGun.getNationalStandard())); |
| | | connectorInfo.setQRCode("https://mxcd.zhinenganguan.com?No=" + code + chargingGun.getCode()); |
| | | connectorInfos.add(connectorInfo); |
| | | } |
| | | return connectorInfos; |
| | |
| | | |
| | | |
| | | /** |
| | | * 站点变更推送通知(快电) |
| | | * @param siteIds |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationStationChange") |
| | | public R notificationStationChange(@RequestParam("siteIds") List<Integer> siteIds){ |
| | | Operator operator = operatorClient.getOperatorByName("KuaiDian").getData(); |
| | | NotificationStationChangeResult notificationStationChange = TCECKDUtil.notificationStationChange(operator, 3, siteIds); |
| | | //启动重试推送机制 |
| | | if(null == notificationStationChange || 1 == notificationStationChange.getSuccStat()){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationStationChangeResult notificationStationChange1 = TCECKDUtil.notificationStationChange(operator, 3, siteIds); |
| | | //启动重试推送机制 |
| | | if(null != notificationStationChange1 && 0 == notificationStationChange1.getSuccStat()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 请求定充电 |
| | | * @return |
| | | */ |
| | |
| | | addTripartitePlatformOrder.setOperatorId(operator.getOperatorId()); |
| | | addTripartitePlatformOrder.setPaymentAmount(queryStartCharge.getPaymentAmount()); |
| | | addTripartitePlatformOrder.setRechargePaymentType(queryStartCharge.getPaymentType()); |
| | | addTripartitePlatformOrder.setPlateNum(queryStartCharge.getPlateNum()); |
| | | R order = chargingOrderClient.addTripartitePlatformOrder(addTripartitePlatformOrder); |
| | | //启动失败 |
| | | if(200 != order.getCode()){ |
| | |
| | | notificationChargeOrderInfo.setChargeDetails(chargeDetails); |
| | | return notificationChargeOrderInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 二维码查询抢号(快电) |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_terminal_code") |
| | | public BaseResult queryTerminalCode(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.buildSign(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getDataSecret(), operator.getDataSecretIv()); |
| | | QueryTerminalCode queryTerminalCode = JSON.parseObject(decrypt, QueryTerminalCode.class); |
| | | String qrCode = queryTerminalCode.getQRCode(); |
| | | String substring = qrCode.substring(qrCode.indexOf("=") + 1); |
| | | QueryTerminalCodeResult queryTerminalCodeResult = new QueryTerminalCodeResult(); |
| | | queryTerminalCodeResult.setTerminalCode(substring); |
| | | |
| | | //参数加密 |
| | | String jsonString = JSON.toJSONString(queryTerminalCodeResult); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.buildSign(baseResult)); |
| | | return baseResult; |
| | | } |
| | | } |