| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ChargingOrderGroup; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | |
| | | List<ChargingOrderGroup> groups = chargingOrderService.chargingOrderGroup(chargingPercentProvinceDto); |
| | | return R.ok(groups); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据站点id和时间区间查询订单数据 |
| | | * @param chargingPercentProvinceDto |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/getOrderBySiteIdAndTime") |
| | | public R<List<TChargingOrder>> getOrderBySiteIdAndTime(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto){ |
| | | LocalDate date1 = chargingPercentProvinceDto.getDate1(); |
| | | LocalDate date2 = chargingPercentProvinceDto.getDate2(); |
| | | String tripartitePlatformName = chargingPercentProvinceDto.getTripartitePlatformName(); |
| | | List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>().in(TChargingOrder::getSiteId, chargingPercentProvinceDto.getSiteIds()) |
| | | .between(null != date1 && null != date2, TChargingOrder::getPayTime, date1.atTime(0, 0, 0), date2.atTime(23, 59, 59)) |
| | | .eq(TChargingOrder::getDelFlag, 0).eq(TChargingOrder::getStatus, 5) |
| | | .eq(StringUtils.isNotEmpty(tripartitePlatformName), TChargingOrder::getOrderSource, 2) |
| | | .eq(StringUtils.isNotEmpty(tripartitePlatformName), TChargingOrder::getTripartitePlatformName, tripartitePlatformName)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据充电枪id获取正在进行中的订单 |
| | |
| | | List<Integer> gunIds = list.stream().map(TChargingOrder::getChargingGunId).collect(Collectors.toList()); |
| | | return R.ok(gunIds); |
| | | } |
| | | |
| | | |
| | | |
| | | private static List<TChargingOrder> getSampleData() { |
| | | // 这里可以替换为实际查询逻辑 |
| | | List<TChargingOrder> list = new ArrayList<>(); |
| | | // 示例数据 |
| | | for (int i = 0; i < 24; i++) { |
| | | TChargingOrder order = new TChargingOrder(); |
| | | order.setStartTime(LocalDateTime.now().minusHours(23 - i)); |
| | | order.setOrderAmount(BigDecimal.valueOf(i + 1)); |
| | | list.add(order); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private static List<Map<String, BigDecimal>> processData(List<TChargingOrder> list) { |
| | | Map<LocalDateTime, BigDecimal> hourlySum = new HashMap<>(); |
| | | |
| | | // 按每个小时分组并求和 |
| | | for (TChargingOrder order : list) { |
| | | LocalDateTime hour = order.getStartTime().truncatedTo(ChronoUnit.HOURS); |
| | | BigDecimal amount = order.getOrderAmount(); |
| | | hourlySum.merge(hour, amount, BigDecimal::add); |
| | | } |
| | | |
| | | // 创建结果列表 |
| | | List<Map<String, BigDecimal>> resultList = new ArrayList<>(); |
| | | for (int i = 1; i <= 23; i++) { |
| | | LocalDateTime keyHour = LocalDateTime.now().withHour(i); |
| | | BigDecimal sum = BigDecimal.ZERO; |
| | | |
| | | // 计算键之后的一小时的数据之和 |
| | | for (int j = i + 1; j <= 23; j++) { |
| | | LocalDateTime nextHour = LocalDateTime.now().withHour(j); |
| | | sum = sum.add(hourlySum.getOrDefault(nextHour, BigDecimal.ZERO)); |
| | | } |
| | | |
| | | Map<String, BigDecimal> entry = new HashMap<>(); |
| | | entry.put(String.valueOf(i), sum); |
| | | resultList.add(entry); |
| | | } |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加三方平台充电订单数据 |
| | | * @return |
| | | */ |
| | | @PostMapping("/addTripartitePlatformOrder") |
| | | public R addTripartitePlatformOrder(@RequestBody AddTripartitePlatformOrder query){ |
| | | return chargingOrderService.addTripartitePlatformOrder(query.getChargingGunId(), query.getOperatorId(), |
| | | query.getRechargePaymentType(), |
| | | query.getPaymentAmount(), |
| | | query.getStartChargeSeq()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据三方平台订单id获取充电数据 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | @PostMapping("/getChargingOrderByStartChargeSeq") |
| | | public R<TChargingOrder> getChargingOrderByStartChargeSeq(@RequestParam("startChargeSeq") String startChargeSeq){ |
| | | TChargingOrder chargingOrder = chargingOrderService.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getStartChargeSeq, startChargeSeq)); |
| | | return R.ok(chargingOrder); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 三方平台请求停止充电 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | @PostMapping("/tripartitePlatformStopCharge") |
| | | public R tripartitePlatformStopCharge(@RequestParam("startChargeSeq") String startChargeSeq){ |
| | | return chargingOrderService.tripartitePlatformStopCharge(startChargeSeq); |
| | | } |
| | | } |