| | |
| | | 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.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.ChargingOrderAndUploadRealTimeMonitoringDataDto; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringPageData; |
| | | import com.ruoyi.order.api.dto.ChargingStatisticeDTO; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.common.core.dto.MongoChargingOrderQuery; |
| | |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.order.util.PreviousSixMonths; |
| | | import com.ruoyi.order.vo.EndOfChargePageInfo; |
| | | import com.ruoyi.order.vo.WatchChargingOrderVo; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private RoleSiteClient roleSiteClient; |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 远程调用 监管平台查询前一天用能统计 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping(value = "/getChargingStatistics") |
| | | public R<List<TChargingOrder>> getChargingStatistics(@RequestBody ChargingStatisticeDTO dto) { |
| | | List<Long> collect = chargingOrderAccountingStrategyService.lambdaQuery().between(TChargingOrderAccountingStrategy::getCreateTime, dto.getStartTime(), dto.getEndTime()) |
| | | .list().stream().map(TChargingOrderAccountingStrategy::getChargingOrderId).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()){ |
| | | List<TChargingOrder> list = chargingOrderService.lambdaQuery() |
| | | .in(TChargingOrder::getId,collect).list(); |
| | | return R.ok(list); |
| | | } |
| | | return R.ok(new ArrayList<TChargingOrder>()); |
| | | } |
| | | |
| | | /** |
| | | * 远程调用 增加管理后台赠送会员记录 |
| | |
| | | chargingOrderInfoVO.setList(list); |
| | | return AjaxResult.success(chargingOrderInfoVO); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Log(title = "【扫一扫】添加评价", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE) |
| | | @ResponseBody |
| | | @PostMapping(value = "/addEvaluate") |
| | | @ApiOperation(value = "添加评价", tags = {"小程序-扫一扫"}) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Log(title = "【扫一扫】支付充电充值费用", businessType = BusinessType.UPDATE,operatorType = OperatorType.MOBILE) |
| | | @ResponseBody |
| | | @PostMapping(value = "/paymentChargingOrder") |
| | | @ApiOperation(value = "支付充电充值费用", tags = {"小程序-扫一扫"}) |
| | |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param code |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping(value = "/refund1") |
| | | public R refund1(@RequestParam(value = "code") String code, @RequestParam(value = "money") BigDecimal money){ |
| | | chargingOrderService.refund1(code, money); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 远程启动失败后退款回调 |
| | | */ |
| | | @ResponseBody |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/preChargeCheck/{id}") |
| | | @ApiOperation(value = "获取安全检测数据", tags = {"小程序-扫一扫"}) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getChargingDetails/{id}") |
| | | @ApiOperation(value = "获取充电中页面数据", tags = {"小程序-扫一扫"}) |
| | |
| | | ChargingDetails chargingDetails = chargingOrderService.getChargingDetails(id); |
| | | return AjaxResult.success(chargingDetails); |
| | | } |
| | | |
| | | |
| | | |
| | | @Log(title = "【扫一扫】手动停止充电", businessType = BusinessType.STOP,operatorType = OperatorType.MOBILE) |
| | | @ResponseBody |
| | | @PutMapping(value = "/stopCharging/{id}") |
| | | @ApiOperation(value = "手动停止充电", tags = {"小程序-扫一扫"}) |
| | |
| | | PageInfo<TChargingOrder> orderPageInfo = chargingOrderService.page(pageInfo, queryWrapper.orderByDesc(TChargingOrder::getCreateTime)); |
| | | List<Site> siteList = siteClient.getSiteAll().getData(); |
| | | |
| | | List<WatchChargingOrderVo> list = new ArrayList<>(); |
| | | for (TChargingOrder record : orderPageInfo.getRecords()) { |
| | | record.setIdStr(record.getId().toString()); |
| | | WatchChargingOrderVo vo = new WatchChargingOrderVo(); |
| | | BeanUtils.copyProperties(record, vo); |
| | | vo.setIdStr(record.getId().toString()); |
| | | Site site = siteList.stream().filter(s->s.getId().equals(record.getSiteId())).findFirst().get(); |
| | | record.setSiteName(site.getName()); |
| | | vo.setSiteName(site.getName()); |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(record.getChargingPileId()).getData(); |
| | | record.setTerminalName(chargingPile.getName()); |
| | | vo.setTerminalName(chargingPile.getName()); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(record.getChargingGunId()).getData(); |
| | | record.setTerminalCode(chargingGun.getName()); |
| | | vo.setTerminalCode(chargingGun.getName()); |
| | | |
| | | if(null != record.getStartTime() && null != record.getEndTime()){ |
| | | long time = record.getEndTime().toEpochSecond(ZoneOffset.UTC) - record.getStartTime().toEpochSecond(ZoneOffset.UTC); |
| | | record.setChargingTime(time + ""); |
| | | vo.setChargingTime(time + ""); |
| | | } |
| | | long count = chargingOrderAccountingStrategyService.count(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, record.getId())); |
| | | record.setTimeFrame(count); |
| | | vo.setTimeFrame(count); |
| | | |
| | | vo.setAuthInfo(roleType == 1 ? true : partnerClient.authMenu(objectId, record.getSiteId(), SiteMenu.CHARGING_PILE_ORDER_MONITORING_RECORD_INFO.getValue())); |
| | | vo.setAuthDelete(roleType == 1 ? true : partnerClient.authMenu(objectId, record.getSiteId(), SiteMenu.CHARGING_PILE_ORDER_MONITORING_RECORD_DEL.getValue())); |
| | | list.add(vo); |
| | | } |
| | | return R.ok(orderPageInfo); |
| | | PageInfo<WatchChargingOrderVo> pageInfos = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | pageInfos.setRecords(list); |
| | | pageInfos.setCurrent(pageInfo.getCurrent()); |
| | | pageInfos.setPages(pageInfo.getPages()); |
| | | pageInfos.setSize(pageInfo.getSize()); |
| | | pageInfos.setStartIndex(pageInfo.getStartIndex()); |
| | | pageInfos.setTotal(pageInfo.getTotal()); |
| | | return R.ok(pageInfos); |
| | | } |
| | | |
| | | |
| | |
| | | start = statisticsQueryDto.getStartTime(); |
| | | end = statisticsQueryDto.getEndTime(); |
| | | }else if (statisticsQueryDto.getDayType()==5){ |
| | | // 获取今年1月1日的日期 |
| | | start = statisticsQueryDto.getStartTime(); |
| | | end = statisticsQueryDto.getEndTime(); |
| | | if (start.equals(end)){ |
| | |
| | | BigDecimal commissionAmount = BigDecimal.ZERO; |
| | | for (Map<String, Object> map : maps) { |
| | | BigDecimal periodElectricPrice = (BigDecimal) map.get("period_electric_price"); |
| | | allMoney = allMoney.add(periodElectricPrice); |
| | | Long order_source = (Long)map.get("order_source"); |
| | | if(2 != order_source){ |
| | | allMoney = allMoney.add(periodElectricPrice); |
| | | } |
| | | BigDecimal total_amount = (BigDecimal) map.get("total_amount"); |
| | | allMoney = allMoney.add(total_amount); |
| | | commissionAmount = commissionAmount.add((BigDecimal) map.get("commissionAmount")); |
| | |
| | | @PostMapping(value = "/work/chargeDetail") |
| | | @ApiOperation(value = "运营情况", tags = {"管理后台-工作台"}) |
| | | public R workCharge(@RequestBody ChargingDetailQueryDto statisticsQueryDto) { |
| | | List<Integer> siteIds = new ArrayList<>(); |
| | | if (statisticsQueryDto.getSiteId() == null) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | //获取当前登录的siteIds |
| | | List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); |
| | | for (GetSiteListDTO datum : data) { |
| | | siteIds.add(datum.getId()); |
| | | } |
| | | } else { |
| | | siteIds.add(statisticsQueryDto.getSiteId()); |
| | | } |
| | | if (statisticsQueryDto.getDayType()==1) { |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(charMap1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("electrovalence", 0); |
| | | timeMap.put("orderCount", 0); |
| | | timeMap.put("servicecharge", 0); |
| | | timeMap.put("electricity", 0); |
| | | charMap.add(timeMap); |
| | | try { |
| | | List<Integer> siteIds = new ArrayList<>(); |
| | | if (statisticsQueryDto.getSiteId() == null) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | //获取当前登录的siteIds |
| | | List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); |
| | | for (GetSiteListDTO datum : data) { |
| | | siteIds.add(datum.getId()); |
| | | } |
| | | } else { |
| | | siteIds.add(statisticsQueryDto.getSiteId()); |
| | | } |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==2){ |
| | | // 假设 chargingOrderService.getDateType() 返回的是按天的数据 |
| | | List<Map<String, Object>> charMap1 = chargingOrderService.getDateType(siteIds, statisticsQueryDto); |
| | | |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | if (statisticsQueryDto.getDayType()==1) { |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(charMap1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("electrovalence", 0); |
| | | timeMap.put("orderCount", 0); |
| | | timeMap.put("servicecharge", 0); |
| | | timeMap.put("electricity", 0); |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==2){ |
| | | // 假设 chargingOrderService.getDateType() 返回的是按天的数据 |
| | | List<Map<String, Object>> charMap1 = chargingOrderService.getDateType(siteIds, statisticsQueryDto); |
| | | |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | |
| | | // return dateRangeStatistics; |
| | | return R.ok(dateRangeStatistics); |
| | | }else if (statisticsQueryDto.getDayType()==3){ |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | return R.ok(dateRangeStatistics); |
| | | }else if (statisticsQueryDto.getDayType()==3){ |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(charMap1, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusMonths(1); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusMonths(1); |
| | | return R.ok(dateRangeStatistics); |
| | | |
| | | } |
| | | return R.ok(dateRangeStatistics); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(); |
| | | |
| | |
| | | return chargingOrderService.getNotPaymentChargingOrder(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 手动推送订单给三方平台 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @PostMapping("/pushOrderInfo") |
| | | public R pushOrderInfo(@RequestParam String code){ |
| | | return chargingOrderService.pushOrderInfo(code); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加汇总数据(临时) |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping(value = "/addChargingOrderSummaryData") |
| | | public R addChargingOrderSummaryData(){ |
| | | return chargingOrderService.addChargingOrderSummaryData(); |
| | | } |
| | | } |