puzhibing
2026-07-17 3d7b7ffc07551c6c7c8236286d5f4f3620aa6a2f
修改后台报表充电数据查询bug
4个文件已修改
8935 ■■■■■ 已修改文件
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 784 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 8099 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -1,4 +1,5 @@
package com.ruoyi.order.controller;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -80,7 +81,7 @@
/**
 * <p>
 *  前端控制器
 * 前端控制器
 * </p>
 *
 * @author xiaochen
@@ -90,7 +91,7 @@
@RestController
@RequestMapping("/t-charging-order")
public class TChargingOrderController {
    private Logger log = LoggerFactory.getLogger(TChargingOrderController.class);
    @Resource
@@ -103,18 +104,18 @@
    private TGrantVipService tGrantVipService;
    @Resource
    private WxPaymentClient wxPaymentClient;
    @Resource
    private RedisService redisService;
    @Resource
    private AliPaymentClient aliPaymentClient;
    @Resource
    private TShoppingOrderService shoppingOrderService;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private TVipOrderService vipOrderService;
@@ -137,7 +138,7 @@
    private AppUserCarClient appUserCarClient;
    @Resource
    private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService;
    @Resource
    private TOrderInvoiceService invoiceService;
    @Resource
@@ -146,19 +147,19 @@
    private PartnerClient partnerClient;
    @Resource
    private SysUserClient sysUserClient;
    @Resource
    private UserSiteClient userSiteClient;
    @Resource
    private RoleSiteClient roleSiteClient;
    @Resource
    private SysUserRoleClient sysUserRoleClient;
    /**
     * 远程调用 监管平台查询前一天用能统计
     *
     * @return
     */
    @ResponseBody
@@ -166,9 +167,9 @@
    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()){
        if (!collect.isEmpty()) {
            List<TChargingOrder> list = chargingOrderService.lambdaQuery()
                    .in(TChargingOrder::getId,collect).list();
                    .in(TChargingOrder::getId, collect).list();
            return R.ok(list);
        }
        return R.ok(new ArrayList<TChargingOrder>());
@@ -176,6 +177,7 @@
    /**
     * 远程调用 增加管理后台赠送会员记录
     *
     * @return
     */
    @ResponseBody
@@ -186,6 +188,7 @@
    /**
     * 远程调用根据枪id 查询最新的订单id 用户后台结束充电
     *
     * @param id
     * @return
     */
@@ -200,13 +203,13 @@
                .eq(TChargingOrder::getChargingGunId, id)
                .in(TChargingOrder::getStatus, integers)
                .one();
        if (one!=null){
        if (one != null) {
            return R.ok(one.getId().toString());
        }
        return R.ok();
    }
    @RequiresPermissions(value = {"/invoiceManagement/select_order", "/paymentOrder/order"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/pay/order/list")
@@ -216,29 +219,27 @@
    }
    public static List<PayOrderDto> testing5(long total, long current, long size, List<PayOrderDto> str){
    List<PayOrderDto> result = new ArrayList<>();
    //获取初始化分页结构
    com.ruoyi.order.util.Page<PayOrderDto> page = new com.ruoyi.order.util.Page().getPage(total, size, current - 1);
    //获取集合下标初始值
    long startIndex = page.getStartIndex();
    //获取集合下标结束值
    long endInddex = 0;
    if(startIndex + page.getCurrent() >= total || size > total){
        endInddex = total;
    }else {
        endInddex = Math.min(startIndex + page.getSize(), total);
    public static List<PayOrderDto> testing5(long total, long current, long size, List<PayOrderDto> str) {
        List<PayOrderDto> result = new ArrayList<>();
        //获取初始化分页结构
        com.ruoyi.order.util.Page<PayOrderDto> page = new com.ruoyi.order.util.Page().getPage(total, size, current - 1);
        //获取集合下标初始值
        long startIndex = page.getStartIndex();
        //获取集合下标结束值
        long endInddex = 0;
        if (startIndex + page.getCurrent() >= total || size > total) {
            endInddex = total;
        } else {
            endInddex = Math.min(startIndex + page.getSize(), total);
        }
        //如果输入的开始查询下标大于集合大小,则查询为空值
        if (startIndex > total) {
            result = Collections.emptyList();
        } else {
            result = str.subList((int) startIndex, (int) endInddex);
        }
        return result;
    }
    //如果输入的开始查询下标大于集合大小,则查询为空值
    if(startIndex > total){
        result = Collections.emptyList();
    }else{
        result = str.subList((int)startIndex,(int)endInddex);
    }
    return result;
}
    @ResponseBody
@@ -247,8 +248,8 @@
    public R refund(@RequestBody PayOrderRefundDto payOrderQueryDto) {
        return chargingOrderService.payRefund(payOrderQueryDto);
    }
    @RequiresPermissions(value = {"/paymentOrder/order"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/pay/order/pay/detail")
@@ -300,24 +301,21 @@
                payOrderInfoDto2.setFinalAmount(byId2.getPaymentAmount().subtract(byId2.getRefundAmount()));
                return R.ok(payOrderInfoDto2);
            //todo luo 停车场订单
                case 4:
                    R<TParkingRecord> recordById = parkingLotClient.getRecordById(orderId);
                    TParkingRecord byId3 =recordById.getData();
                    PayOrderInfoDto payOrderInfoDto3 = new PayOrderInfoDto();
                    payOrderInfoDto3.setOrderId(byId3.getId().toString());
                    payOrderInfoDto3.setCode(byId3.getCode());
                    payOrderInfoDto3.setPayTime(byId3.getCreateTime());
                    payOrderInfoDto3.setRechargeAmount(byId3.getPayment());
                    return R.ok(payOrderInfoDto3);
            case 4:
                R<TParkingRecord> recordById = parkingLotClient.getRecordById(orderId);
                TParkingRecord byId3 = recordById.getData();
                PayOrderInfoDto payOrderInfoDto3 = new PayOrderInfoDto();
                payOrderInfoDto3.setOrderId(byId3.getId().toString());
                payOrderInfoDto3.setCode(byId3.getCode());
                payOrderInfoDto3.setPayTime(byId3.getCreateTime());
                payOrderInfoDto3.setRechargeAmount(byId3.getPayment());
                return R.ok(payOrderInfoDto3);
            }
        }
        return R.ok();
    }
    @ResponseBody
@@ -357,12 +355,12 @@
        Long count = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).count();
        payOrderChargingInfo.setPeriodCount(count);
        if (byId.getAppUserCarId()!=null && 0 != byId.getAppUserCarId()) {
        if (byId.getAppUserCarId() != null && 0 != byId.getAppUserCarId()) {
            List<Long> carid = new ArrayList<>();
            carid.add(byId.getAppUserCarId());
            R<List<TAppUserCar>> carByIds = appUserCarClient.getCarByIds(carid);
            payOrderChargingInfo.setCarNum(carByIds.getData().get(0).getLicensePlate());
        }else{
        } else {
            payOrderChargingInfo.setCarNum(byId.getPlateNum());
        }
        payOrderChargingInfo.setStartTime(byId.getStartTime());
@@ -383,12 +381,12 @@
            LocalDateTime createTime = chargingOrder.getStartTime();
            String format = createTime.format(formatter);
            String startTime = tChargingOrderAccountingStrategy.getStartTime();
            if("00:00".equals(startTime)){
            if ("00:00".equals(startTime)) {
                createTime = createTime.plusDays(1);
                format = createTime.format(formatter);
            }
            tChargingOrderAccountingStrategy.setStartTime(format+" "+tChargingOrderAccountingStrategy.getStartTime());
            tChargingOrderAccountingStrategy.setEndTime(format+" "+tChargingOrderAccountingStrategy.getEndTime());
            tChargingOrderAccountingStrategy.setStartTime(format + " " + tChargingOrderAccountingStrategy.getStartTime());
            tChargingOrderAccountingStrategy.setEndTime(format + " " + tChargingOrderAccountingStrategy.getEndTime());
        }
        //从新排序
        list.sort(new Comparator<TChargingOrderAccountingStrategy>() {
@@ -398,10 +396,10 @@
                String startTime1 = o2.getStartTime();
                LocalDateTime localDateTime = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
                LocalDateTime localDateTime1 = LocalDateTime.parse(startTime1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
                if(localDateTime.isBefore(localDateTime1)){
                if (localDateTime.isBefore(localDateTime1)) {
                    return -1;
                }
                if(localDateTime.isAfter(localDateTime1)){
                if (localDateTime.isAfter(localDateTime1)) {
                    return 1;
                }
                return 0;
@@ -409,9 +407,8 @@
        });
        return R.ok(list);
    }
    @RequiresPermissions(value = {"/paymentOrder/refund"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/pay/order/refund/list")
@@ -426,14 +423,14 @@
        Long userId = tokenService.getLoginUser().getUserid();
        //如果没传siteId,获取当前登陆人所有的siteIds
        List<Integer> siteIds = new ArrayList<>();
            if (userId != null){
                List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
                for (GetSiteListDTO datum : data) {
                    siteIds.add(datum.getId());
                }
        if (userId != null) {
            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
            for (GetSiteListDTO datum : data) {
                siteIds.add(datum.getId());
            }
        }
        if (siteIds.isEmpty()){
        if (siteIds.isEmpty()) {
            siteIds.add(-1);
        }
        // 查询当前登陆人按钮权限
@@ -441,19 +438,19 @@
        Integer roleType = sysUser.getRoleType();
        List<TChargingOrderRefund> tChargingOrderRefunds = new ArrayList<>();
        for (TChargingOrderRefund record : refundList1.getData().getRecords()) {
            if (roleType==1){
            if (roleType == 1) {
                tChargingOrderRefunds.add(record);
                continue;
            }
            if (record.getType()!=1){
            if (record.getType() != 1) {
                tChargingOrderRefunds.add(record);
            }
            TChargingOrder byId = chargingOrderService.getById(record.getOrderId());
            record.setUid(record.getId().toString());
            if (byId==null){
            if (byId == null) {
                continue;
            }
            if (roleType==2&&siteIds.contains(byId.getSiteId())){
            if (roleType == 2 && siteIds.contains(byId.getSiteId())) {
                tChargingOrderRefunds.add(record);
            }
@@ -466,11 +463,9 @@
        return refundList1;
    }
    public static List<TChargingOrderRefund> testing4(long total, long current, long size, List<TChargingOrderRefund> str){
    public static List<TChargingOrderRefund> testing4(long total, long current, long size, List<TChargingOrderRefund> str) {
        List<TChargingOrderRefund> result = new ArrayList<>();
        //获取初始化分页结构
        com.ruoyi.order.util.Page<TChargingOrderRefund> page = new com.ruoyi.order.util.Page().getPage(total, size, current - 1);
@@ -478,21 +473,19 @@
        long startIndex = page.getStartIndex();
        //获取集合下标结束值
        long endInddex = 0;
        if(startIndex + page.getCurrent() >= total || size > total){
        if (startIndex + page.getCurrent() >= total || size > total) {
            endInddex = total;
        }else {
        } else {
            endInddex = Math.min(startIndex + page.getSize(), total);
        }
        //如果输入的开始查询下标大于集合大小,则查询为空值
        if(startIndex > total){
        if (startIndex > total) {
            result = Collections.emptyList();
        }else{
            result = str.subList((int)startIndex,(int)endInddex);
        } else {
            result = str.subList((int) startIndex, (int) endInddex);
        }
        return result;
    }
    @ResponseBody
@@ -502,12 +495,8 @@
        return chargingOrderService.getRefundList(chargingRefundDto);
    }
    @RequiresPermissions(value = {"/chargingPileOrder"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/chargingOrder")
@@ -537,19 +526,19 @@
    public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String strategyId) {
        TChargingOrder byId = chargingOrderService.getById(strategyId);
        ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        if (byId.getAppUserCarId()!=null){
            TAppUserCar data = appUserCarClient.getCarById(byId.getAppUserCarId()+"").getData();
            if (data!=null){
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent() != null ? byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN) + "" : "");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage() != null ? byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN) + "" : "");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity() != null ? byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN) + "" : "");
        chargingOrderInfoVO.setTotalPower(byId.getPower() != null ? byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN) + "" : "");
        if (byId.getAppUserCarId() != null) {
            TAppUserCar data = appUserCarClient.getCarById(byId.getAppUserCarId() + "").getData();
            if (data != null) {
                chargingOrderInfoVO.setLicensePlate(data.getLicensePlate());
                chargingOrderInfoVO.setVehicleBrand(data.getVehicleBrand());
                chargingOrderInfoVO.setVehicleModel(data.getVehicleModel());
                chargingOrderInfoVO.setVehicleUse(data.getVehicleUse());
            }
        }else{
        } else {
            chargingOrderInfoVO.setLicensePlate(byId.getPlateNum());
        }
        // 时段总服务费
@@ -559,12 +548,12 @@
            LocalDateTime createTime = byId.getStartTime();
            String format = createTime.format(formatter);
            String startTime = tChargingOrderAccountingStrategy.getStartTime();
            if("00:00".equals(startTime)){
            if ("00:00".equals(startTime)) {
                createTime = createTime.plusDays(1);
                format = createTime.format(formatter);
            }
            tChargingOrderAccountingStrategy.setStartTime(format+" "+tChargingOrderAccountingStrategy.getStartTime());
            tChargingOrderAccountingStrategy.setEndTime(format+" "+tChargingOrderAccountingStrategy.getEndTime());
            tChargingOrderAccountingStrategy.setStartTime(format + " " + tChargingOrderAccountingStrategy.getStartTime());
            tChargingOrderAccountingStrategy.setEndTime(format + " " + tChargingOrderAccountingStrategy.getEndTime());
//            if (byId.getVipDiscountAmount()!=null && byId.getServiceCharge().compareTo(BigDecimal.ZERO) != 0){
//                BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
//                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
@@ -575,7 +564,7 @@
//                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
//                tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
//            }
            if(null == tChargingOrderAccountingStrategy.getCouponDiscount()){
            if (null == tChargingOrderAccountingStrategy.getCouponDiscount()) {
                tChargingOrderAccountingStrategy.setCouponDiscount(BigDecimal.ZERO);
            }
        }
@@ -587,10 +576,10 @@
                String startTime1 = o2.getStartTime();
                LocalDateTime localDateTime = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
                LocalDateTime localDateTime1 = LocalDateTime.parse(startTime1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
                if(localDateTime.isBefore(localDateTime1)){
                if (localDateTime.isBefore(localDateTime1)) {
                    return -1;
                }
                if(localDateTime.isAfter(localDateTime1)){
                if (localDateTime.isAfter(localDateTime1)) {
                    return 1;
                }
                return 0;
@@ -599,11 +588,9 @@
        chargingOrderInfoVO.setList(list);
        return AjaxResult.success(chargingOrderInfoVO);
    }
    @Log(title = "【扫一扫】添加评价", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE)
    @Log(title = "【扫一扫】添加评价", businessType = BusinessType.INSERT, operatorType = OperatorType.MOBILE)
    @ResponseBody
    @PostMapping(value = "/addEvaluate")
    @ApiOperation(value = "添加评价", tags = {"小程序-扫一扫"})
@@ -612,9 +599,8 @@
        orderEvaluateService.addOrderEvaluate(dto);
        return AjaxResult.success();
    }
    /**
     * 查询用户最近一次充电记录使用的车辆
     *
@@ -622,24 +608,23 @@
     * @return
     */
    @GetMapping(value = "/getCar/{id}")
    public R<Long> getCar(@PathVariable("id")String id) {
    public R<Long> getCar(@PathVariable("id") String id) {
        List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
                .eq(TChargingOrder::getAppUserId, id)
                .isNotNull(TChargingOrder::getAppUserCarId));
        if (!list.isEmpty()){
        if (!list.isEmpty()) {
            // 最近使用的车辆id
            Long size = list.get(0).getAppUserCarId();
            return R.ok(size);
        }else{
        } else {
            return R.ok(-1L);
        }
    }
    /**
     * 查询会员在本月有多少次享受了充电折扣
     *
     * @param req
     * @return
     */
@@ -662,13 +647,11 @@
    }
    //订单详情
    @PostMapping(value = "/detail")
    public R<TChargingOrder> detail(@RequestParam("orderId") Long orderId) {
        return R.ok(chargingOrderService.getById(orderId));
    }
    @PostMapping(value = "/getList")
@@ -677,7 +660,6 @@
        List<TChargingOrder> list = chargingOrderService.lambdaQuery().eq(TChargingOrder::getSiteId, siteId).list();
        return R.ok(list);
    }
    @PostMapping(value = "/getBySiteIdAndTime")
@@ -690,11 +672,12 @@
    /**
     * 根据站点id和时间区间查询订单数据
     *
     * @param chargingPercentProvinceDto
     * @return
     */
    @PostMapping(value = "/getOrderBySiteIdAndTime")
    public R<List<TChargingOrder>> getOrderBySiteIdAndTime(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto){
    public R<List<TChargingOrder>> getOrderBySiteIdAndTime(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto) {
        LocalDate date1 = chargingPercentProvinceDto.getDate1();
        LocalDate date2 = chargingPercentProvinceDto.getDate2();
        String tripartitePlatformName = chargingPercentProvinceDto.getTripartitePlatformName();
@@ -707,9 +690,9 @@
    }
    /**
     * 根据充电枪id获取正在进行中的订单
     *
     * @param chargingGunId 充电枪id
     * @return
     */
@@ -719,10 +702,8 @@
                .eq(TChargingOrder::getDelFlag, 0).eq(TChargingOrder::getStatus, 3));
        return R.ok(one);
    }
    @ResponseBody
    @GetMapping(value = "/getMyChargingOrderList")
    @ApiOperation(value = "获取充电记录列表", tags = {"小程序-充电记录"})
@@ -730,23 +711,22 @@
        Map<String, Object> orderList = chargingOrderService.getMyChargingOrderList(query);
        return AjaxResult.success(orderList);
    }
    @ResponseBody
    @GetMapping(value = "/getMyChargingOrderInfo")
    @ApiOperation(value = "获取充电记订单明细", tags = {"小程序-充电记录"})
    public AjaxResult<MyChargingOrderInfo> getMyChargingOrderInfo(String id) {
        TChargingOrder tChargingOrder = chargingOrderService.getById(id);
        Long userId = tokenService.getLoginUserApplet().getUserId();
        if(!tChargingOrder.getAppUserId().equals(userId)){
        if (!tChargingOrder.getAppUserId().equals(userId)) {
            return AjaxResult.error("权限不足");
        }
        MyChargingOrderInfo myChargingOrderInfo = chargingOrderService.getMyChargingOrderInfo(id);
        return AjaxResult.success(myChargingOrderInfo);
    }
    @ResponseBody
    @GetMapping(value = "/getNoInvoicedOrder")
    @ApiOperation(value = "获取未开票的订单数据", tags = {"小程序-充电发票"})
@@ -754,16 +734,16 @@
        List<MyChargingOrderList> list = chargingOrderService.getNoInvoicedOrder(query);
        return AjaxResult.success(list);
    }
    @Log(title = "【扫一扫】支付充电充值费用", businessType = BusinessType.UPDATE,operatorType = OperatorType.MOBILE)
    @Log(title = "【扫一扫】支付充电充值费用", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
    @ResponseBody
    @PostMapping(value = "/paymentChargingOrder")
    @ApiOperation(value = "支付充电充值费用", tags = {"小程序-扫一扫"})
    public AjaxResult paymentChargingOrder(@RequestBody AddChargingOrder addChargingOrder) {
        return chargingOrderService.paymentChargingOrder(addChargingOrder);
    }
    /**
     * 充电充值支付回调
     */
@@ -773,31 +753,32 @@
                                        @RequestParam("attach") String attach) {
        chargingOrderService.chargingOrderCallback(1, out_trade_no, transaction_id, attach);
    }
    /**
     * 修改安全检测数据
     *
     * @param securityDetection
     */
    @ResponseBody
    @PostMapping(value = "/securityDetection")
    public void securityDetection(@RequestBody SecurityDetectionVO securityDetection){
    public void securityDetection(@RequestBody SecurityDetectionVO securityDetection) {
        log.info("-------------------安全检测数据-------------------:" + securityDetection);
        chargingOrderService.securityDetection(securityDetection);
    }
    /**
     * 远程启动充电应答
     *
     * @param message
     */
    @ResponseBody
    @PostMapping(value = "/startChargeSuccessfully")
    public void startChargeSuccessfully(@RequestBody PlatformStartChargingReplyMessageVO message){
    public void startChargeSuccessfully(@RequestBody PlatformStartChargingReplyMessageVO message) {
        log.info("-------------------远程启动充电请求应答-------------------:" + message);
        chargingOrderService.startChargeSuccessfully(message);
    }
    /**
     * 支付宝支付成功后的回调
@@ -809,47 +790,47 @@
                                         @RequestParam("attach") String attach) {
        chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
    }
    /**
     * 支付宝H5支付成功后的回调
     */
    @ResponseBody
    @PostMapping(value = "/chargingOrderALIH5Callback")
    public void chargingOrderALIH5Callback(@RequestParam("out_trade_no") String out_trade_no,
                                         @RequestParam("transaction_id") String transaction_id,
                                         @RequestParam("attach") String attach) {
                                           @RequestParam("transaction_id") String transaction_id,
                                           @RequestParam("attach") String attach) {
        chargingOrderService.chargingOrderCallback(3, out_trade_no, transaction_id, attach);
    }
    /**
     *
     * @param code
     */
    @ResponseBody
    @PostMapping(value = "/refund")
    public R refund(@RequestParam(value = "code") String code){
    public R refund(@RequestParam(value = "code") String code) {
        List<UploadRealTimeMonitoringData> dataByOrderCode = uploadRealTimeMonitoringDataService.getDataByOrderCode(code);
        if(!dataByOrderCode.isEmpty()){
        if (!dataByOrderCode.isEmpty()) {
            return R.fail("订单有充电数据,无法全额退款");
        }
        chargingOrderService.refund(code);
        return R.ok();
    }
    /**
     *
     * @param code
     */
    @ResponseBody
    @PostMapping(value = "/refund1")
    public R refund1(@RequestParam(value = "code") String code, @RequestParam(value = "money") BigDecimal money){
    public R refund1(@RequestParam(value = "code") String code, @RequestParam(value = "money") BigDecimal money) {
        chargingOrderService.refund1(code, money);
        return R.ok();
    }
    /**
     * 远程启动失败后退款回调
     */
@@ -858,13 +839,11 @@
    public void chargingOrderStartupFailureWxRefund(@RequestParam("out_refund_no") String out_refund_no,
                                                    @RequestParam("refund_id") String refund_id,
                                                    @RequestParam("tradeState") String tradeState,
                                                    @RequestParam("success_time") String success_time){
                                                    @RequestParam("success_time") String success_time) {
        chargingOrderService.chargingOrderStartupFailureWxRefund(out_refund_no, refund_id, tradeState, success_time);
    }
    @ResponseBody
    @GetMapping(value = "/preChargeCheck/{id}")
    @ApiOperation(value = "获取安全检测数据", tags = {"小程序-扫一扫"})
@@ -874,16 +853,16 @@
    public AjaxResult<PreChargeCheck> preChargeCheck(@PathVariable Integer id) {
        String key = "AQJC_" + id;
        PreChargeCheck cacheObject = redisService.getCacheObject(key);
        if(null != cacheObject){
            if(LocalDateTime.now().minusMinutes(1).isAfter(cacheObject.getAddTime())){
        if (null != cacheObject) {
            if (LocalDateTime.now().minusMinutes(1).isAfter(cacheObject.getAddTime())) {
                redisService.deleteObject(key);
                cacheObject = null;
            }
        }
        return AjaxResult.success(cacheObject);
    }
    @ResponseBody
    @GetMapping(value = "/getChargingDetails/{id}")
    @ApiOperation(value = "获取充电中页面数据", tags = {"小程序-扫一扫"})
@@ -896,8 +875,7 @@
    }
    @Log(title = "【扫一扫】手动停止充电", businessType = BusinessType.STOP,operatorType = OperatorType.MOBILE)
    @Log(title = "【扫一扫】手动停止充电", businessType = BusinessType.STOP, operatorType = OperatorType.MOBILE)
    @ResponseBody
    @PutMapping(value = "/stopCharging/{id}")
    @ApiOperation(value = "手动停止充电", tags = {"小程序-扫一扫"})
@@ -908,33 +886,32 @@
        log.info("小程序主动发起停止充电,订单ID:{}", id);
        return chargingOrderService.stopCharging(id);
    }
    /**
     * 停止充电应答处理逻辑
     *
     * @param platformStopChargingReply
     */
    @PostMapping("/terminateSuccessfulResponse")
    public void terminateSuccessfulResponse(@RequestBody PlatformStopChargingReplyVO platformStopChargingReply){
    public void terminateSuccessfulResponse(@RequestBody PlatformStopChargingReplyVO platformStopChargingReply) {
        log.info("-------------------远程停止充电请求应答-------------------:" + platformStopChargingReply);
        chargingOrderService.terminateSuccessfulResponse(platformStopChargingReply);
    }
    /**
     * 停止充电返回账单后计算费用
     *
     * @param vo
     */
    @PostMapping("/endChargeBillingCharge")
    public R endChargeBillingCharge(@RequestBody TransactionRecordMessageVO vo){
    public R endChargeBillingCharge(@RequestBody TransactionRecordMessageVO vo) {
        log.info("-------------------停止充电返回账单后计算费用及修改业务状态-------------------:" + vo);
        return chargingOrderService.endChargeBillingCharge(vo);
    }
    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/six/charge")
@@ -949,8 +926,8 @@
        List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds);
        for (SixChargingDto sixChargingDto : sixChargingDtos) {
            for (SixChargingDto chargingDto : chargingDtos) {
                if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
                    BeanUtils.copyProperties(chargingDto,sixChargingDto);
                if (sixChargingDto.getMonth().equals(chargingDto.getMonth())) {
                    BeanUtils.copyProperties(chargingDto, sixChargingDto);
                }
            }
@@ -976,7 +953,7 @@
        return months;
    }
    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/six/circle")
@@ -986,7 +963,7 @@
        SysUser sysUser = sysUserClient.getSysUser(userId).getData();
        List<Integer> siteIds = resolvePlatformRevenueSiteIds(userId, sysUser, null);
        LocalDate sixBefore = PreviousSixMonths.get();
        List<SixCircleDto> sixCircleDtos = chargingOrderService.circle(siteIds,sixBefore);
        List<SixCircleDto> sixCircleDtos = chargingOrderService.circle(siteIds, sixBefore);
        for (SixCircleDto sixCircleDto : sixCircleDtos) {
            Site site = siteClient.getSiteByIds(Arrays.asList(sixCircleDto.getSiteId())).getData().get(0);
            sixCircleDto.setSiteName(site.getName());
@@ -994,8 +971,8 @@
        return R.ok(sixCircleDtos);
    }
    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/six/shop")
@@ -1003,12 +980,12 @@
    public R<List<SixShopDto>> shop(Integer status) {
        //count近6个月的数据
        LocalDate sixBefore = PreviousSixMonths.get();
        List<SixShopDto> sixShopDtos =  shoppingOrderService.sixBefore(sixBefore,status);
        List<SixShopDto> sixShopDtos = shoppingOrderService.sixBefore(sixBefore, status);
        List<SixShopDto> sixChargingDtos = generateLastSixMonths1();
        for (SixShopDto sixChargingDto : sixChargingDtos) {
            for (SixShopDto chargingDto : sixShopDtos) {
                if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
                    BeanUtils.copyProperties(chargingDto,sixChargingDto);
                if (sixChargingDto.getMonth().equals(chargingDto.getMonth())) {
                    BeanUtils.copyProperties(chargingDto, sixChargingDto);
                }
            }
@@ -1032,8 +1009,8 @@
        return months;
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/work/shop")
@@ -1041,10 +1018,10 @@
    public R workShop(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) {
        //count近6个月的数据
        LocalDate sixBefore = PreviousSixMonths.get();
        List<Map<String,Object >> shopData =  shoppingOrderService.getData(statisticsQueryDto);
        List<Map<String, Object>> shopData = shoppingOrderService.getData(statisticsQueryDto);
        return R.ok(shopData);
    }
    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/six/vip")
@@ -1052,14 +1029,11 @@
    public R<List<SixVipDto>> vip() {
        //count近6个月的数据
        LocalDate sixBefore = PreviousSixMonths.get();
        List<SixVipDto> vipDtos =  vipOrderService.sixBefore(sixBefore);
        List<SixVipDto> vipDtos = vipOrderService.sixBefore(sixBefore);
        return R.ok(vipDtos);
    }
    /**
     * 查询平台收入分析底部数据分类,充电订单金额由数据库聚合,避免全量订单和计费明细加载超时。
     */
@@ -1067,27 +1041,27 @@
    @ResponseBody
    @GetMapping(value = "/six/total")
    @ApiOperation(value = "底部数据分类", tags = {"后台-数据分析-平台收入分析"})
    public R<Map<String,Object>> total() {
    public R<Map<String, Object>> total() {
        //count近6个月的数据
        Long userId = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userId).getData();
        List<Integer> siteIds = resolvePlatformRevenueSiteIds(userId, sysUser, null);
        Map<String,Object>  map = chargingOrderService.countAll(siteIds);
        Map<String, Object> map = chargingOrderService.countAll(siteIds);
        boolean platformVisible = 1 == sysUser.getObjectId();
        if(platformVisible){
        if (platformVisible) {
            BigDecimal data = parkingLotClient.getRecordAmount().getData();
            if (map ==null){
                map = new HashMap<String,Object>();
            if (map == null) {
                map = new HashMap<String, Object>();
            }
            map.put("parkingAmount",data);
            BigDecimal data1 =   shoppingOrderService.getSumAmount();
            map.put("shopAmount",data1);
            BigDecimal data2 =   vipOrderService.getSumAmout();
            map.put("vipAmount",data2);
        }else{
            map.put("parkingAmount",0);
            map.put("shopAmount",0);
            map.put("vipAmount",0);
            map.put("parkingAmount", data);
            BigDecimal data1 = shoppingOrderService.getSumAmount();
            map.put("shopAmount", data1);
            BigDecimal data2 = vipOrderService.getSumAmout();
            map.put("vipAmount", data2);
        } else {
            map.put("parkingAmount", 0);
            map.put("shopAmount", 0);
            map.put("vipAmount", 0);
        }
        map.put("platformIncomeVisible", platformVisible);
        return R.ok(map);
@@ -1133,7 +1107,7 @@
        return siteIds;
    }
    @RequiresPermissions(value = {"/chargeOrderMonitoring"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/watch/chargingOrder")
@@ -1146,22 +1120,22 @@
        Integer objectId = sysUser.getObjectId();
        R<Integer> admin = sysUserClient.isAdmin(tokenService.getLoginUser().getUserid());
        //合作商
        if(roleType == 2){
        if (roleType == 2) {
            ids = partnerClient.authSite(objectId, SiteMenu.SITE_LIST.getValue()).getData();
        }else{
        } else {
            //非管理员需要根据角色和用户配置查询允许的站点数据
            //改用roleId=1来判断
            if(admin.getData()!=1){
            if (admin.getData() != 1) {
                List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
                List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData();
                if(data2.size() > 0){
                if (data2.size() > 0) {
                    List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData();
                    data.addAll(data1);
                }
                ids = new HashSet<>(data);
            }
        }
        LambdaQueryWrapper<TChargingOrder> queryWrapper = new LambdaQueryWrapper<TChargingOrder>().like(StringUtils.isNotEmpty(query.getCode()), TChargingOrder::getCode, query.getCode())
                .eq(null != query.getOrderType(), TChargingOrder::getOrderType, query.getOrderType())
                .eq(null != query.getSiteId(), TChargingOrder::getSiteId, query.getSiteId())
@@ -1170,37 +1144,37 @@
                .eq(null != query.getStatus(), TChargingOrder::getStatus, query.getStatus())
                .eq(TChargingOrder::getDelFlag, 0).eq(TChargingOrder::getRechargePaymentStatus, 2)
                .in(null != ids && ids.size() > 0, TChargingOrder::getSiteId, ids);
        if(StringUtils.isNotEmpty(query.getCreateTime())){
        if (StringUtils.isNotEmpty(query.getCreateTime())) {
            String[] split = query.getCreateTime().split(" - ");
            queryWrapper.between(TChargingOrder::getStartTime, split[0], split[1]);
        }
        if(StringUtils.isNotEmpty(query.getLastTime())){
        if (StringUtils.isNotEmpty(query.getLastTime())) {
            String[] split = query.getLastTime().split(" - ");
            queryWrapper.between(TChargingOrder::getEndTime, split[0], split[1]);
        }
        PageInfo<TChargingOrder> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize());
        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()) {
            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();
            Site site = siteList.stream().filter(s -> s.getId().equals(record.getSiteId())).findFirst().get();
            vo.setSiteName(site.getName());
            TChargingPile chargingPile = chargingPileClient.getChargingPileById(record.getChargingPileId()).getData();
            vo.setTerminalName(chargingPile.getName());
            TChargingGun chargingGun = chargingGunClient.getChargingGunById(record.getChargingGunId()).getData();
            vo.setTerminalCode(chargingGun.getName());
            if(null != record.getStartTime() && null != record.getEndTime()){
            if (null != record.getStartTime() && null != record.getEndTime()) {
                long time = record.getEndTime().toEpochSecond(ZoneOffset.UTC) - record.getStartTime().toEpochSecond(ZoneOffset.UTC);
                vo.setChargingTime(time + "");
            }
            long count = chargingOrderAccountingStrategyService.count(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, record.getId()));
            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);
@@ -1214,8 +1188,8 @@
        pageInfos.setTotal(pageInfo.getTotal());
        return R.ok(pageInfos);
    }
    @RequiresPermissions(value = {"/chargeOrderMonitoring/del"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/watch/deletes")
@@ -1224,91 +1198,87 @@
        uploadRealTimeMonitoringDataService.delete(id);
        return R.ok();
    }
    /**
     * 处理充电订单实时监控数据相关的业务逻辑
     *
     * @param query
     */
    @PostMapping("/chargeMonitoring")
    public void chargeMonitoring(@RequestBody UploadRealTimeMonitoringDataQuery query){
    public void chargeMonitoring(@RequestBody UploadRealTimeMonitoringDataQuery query) {
        chargingOrderService.chargeMonitoring(query);
    }
    /**
     * 通过流水号查询订单
     *
     * @param code
     * @return
     */
    @PostMapping(value = "/getOrderByCode/{code}")
    public R<TChargingOrder> getOrderByCode(@PathVariable("code") String code){
    public R<TChargingOrder> getOrderByCode(@PathVariable("code") String code) {
        TChargingOrder one = chargingOrderService.getOne(Wrappers.lambdaQuery(TChargingOrder.class)
                .eq(TChargingOrder::getCode, code));
        one.setIdStr(one.getId().toString());
        return R.ok(one);
    }
    @RequiresPermissions(value = {"/chargingOperationAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/charging/statistics")
    @ApiOperation(value = "统计,充电订单分析", tags = {"管理后台-数据分析-充电运营分析"})
    public R<TCharingOrderMapVO> watchChargingOrder(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
        List<Integer> siteIds =new ArrayList<>();
        if (statisticsQueryDto.getSiteId()==null) {
    public R<TCharingOrderMapVO> watchChargingOrder(@RequestBody ChargingStatisticsQueryDto 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 {
        } else {
            siteIds.add(statisticsQueryDto.getSiteId());
        }
        if (siteIds.isEmpty())siteIds.add(-1);
        if (siteIds.isEmpty()) siteIds.add(-1);
        TCharingOrderMapVO tCharingOrderMapVO = new TCharingOrderMapVO();
        LocalDate start = null;
        LocalDate end = null;
        if (statisticsQueryDto.getDayType()==1){
        if (statisticsQueryDto.getDayType() == 1) {
            start = LocalDate.now();
            end = LocalDate.now().plusDays(1);
        }else if (statisticsQueryDto.getDayType()==2){
            LocalDate today = LocalDate.now();
        } else if (statisticsQueryDto.getDayType() == 2) {
            // 获取本周一的日期
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
        } else if (statisticsQueryDto.getDayType()==3){
            end = statisticsQueryDto.getEndTime().plusDays(1);
        } else if (statisticsQueryDto.getDayType() == 3) {
            // 获取当前日期
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
        }else if (statisticsQueryDto.getDayType()==4){
            end = statisticsQueryDto.getEndTime().plusDays(1);
        } else if (statisticsQueryDto.getDayType() == 4) {
            // 获取今年1月1日的日期
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
        }else if (statisticsQueryDto.getDayType()==5){
            end = statisticsQueryDto.getEndTime().plusDays(1);
        } else if (statisticsQueryDto.getDayType() == 5) {
            start = statisticsQueryDto.getStartTime();
            end = statisticsQueryDto.getEndTime();
            if (start.equals(end)){
                end =  end.plusDays(1);
            }
        }
        //上方饼图
         List<Map<String,Object>> maps = chargingOrderService.getSumByType(start,end, siteIds);
        List<Map<String, Object>> maps = chargingOrderService.getSumByType(start, end, siteIds);
        if (statisticsQueryDto.getDayType()==1){
            List<Map<String,Object>> maps1 = chargingOrderService.getDateData(start,end, siteIds);
        if (statisticsQueryDto.getDayType() == 1) {
            List<Map<String, Object>> maps1 = chargingOrderService.getDateData(start, end, siteIds);
            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(maps1, time);
                if (mapWithTimeValue!=null){
                if (mapWithTimeValue != null) {
                    charMap.add(mapWithTimeValue);
                }else {
                } else {
                    Map<String, Object> timeMap = new HashMap<>();
                    timeMap.put("time", time); // 初始化值为 null
                    timeMap.put("electrovalence", 0);
@@ -1322,8 +1292,8 @@
            }
            tCharingOrderMapVO.setMaps1(charMap);
        }else if (statisticsQueryDto.getDayType()==2){
            List<Map<String,Object>> maps1 = chargingOrderService.getWeekData(start,end, siteIds);
        } else if (statisticsQueryDto.getDayType() == 2) {
            List<Map<String, Object>> maps1 = chargingOrderService.getWeekData(start, end, siteIds);
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
@@ -1352,8 +1322,8 @@
                startDate = startDate.plusDays(1);
            }
            tCharingOrderMapVO.setMaps1(dateRangeStatistics);
        }else if (statisticsQueryDto.getDayType()==3){
            List<Map<String,Object>> maps1 = chargingOrderService.getMonthData(start,end, siteIds);
        } else if (statisticsQueryDto.getDayType() == 3) {
            List<Map<String, Object>> maps1 = chargingOrderService.getMonthData(start, end, siteIds);
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
@@ -1382,8 +1352,8 @@
                startDate = startDate.plusDays(1);
            }
            tCharingOrderMapVO.setMaps1(dateRangeStatistics);
        }else  if (statisticsQueryDto.getDayType()==4){
            List<Map<String,Object>> maps1 = chargingOrderService.getYearData(start,end, siteIds);
        } else if (statisticsQueryDto.getDayType() == 4) {
            List<Map<String, Object>> maps1 = chargingOrderService.getYearData(start, end, siteIds);
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
@@ -1413,12 +1383,11 @@
                startDate = startDate.plusDays(1);
            }
            tCharingOrderMapVO.setMaps1(dateRangeStatistics);
        }else if (statisticsQueryDto.getDayType()==5){
            List<Map<String,Object>> maps1 = chargingOrderService.getByDate(start,end, siteIds);
        } else if (statisticsQueryDto.getDayType() == 5) {
            List<Map<String, Object>> maps1 = chargingOrderService.getByDate(start, end, siteIds);
            LocalDate startDate = statisticsQueryDto.getStartTime();
            LocalDate endDate = statisticsQueryDto.getEndTime();
            List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
@@ -1453,15 +1422,15 @@
        BigDecimal commissionAmount = BigDecimal.ZERO;
        for (Map<String, Object> map : maps) {
            BigDecimal periodElectricPrice = (BigDecimal) map.get("period_electric_price");
            Long order_source = (Long)map.get("order_source");
            if(2 != order_source){
            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"));
        }
        allMoney =  allMoney.multiply(new BigDecimal("0.006"));
        allMoney = allMoney.multiply(new BigDecimal("0.006"));
        tCharingOrderMapVO.setAllMoney(allMoney);
        tCharingOrderMapVO.setCommissionAmount(commissionAmount);
        return R.ok(tCharingOrderMapVO);
@@ -1486,10 +1455,10 @@
        }
        List<Map<String,Object>> maps1 =  chargingOrderService.queryPower(siteIds);
        List<Map<String, Object>> maps1 = chargingOrderService.queryPower(siteIds);
        Map<String,Object> map =  chargingOrderService.qureryPowerLevel(siteIds,statisticsQueryDto);
        Map<String, Object> map = chargingOrderService.qureryPowerLevel(siteIds, statisticsQueryDto);
        TCharingOrderPowerMapVO tCharingOrderPowerMapVO = new TCharingOrderPowerMapVO();
        tCharingOrderPowerMapVO.setMaps1(map);
@@ -1497,41 +1466,41 @@
        return R.ok(tCharingOrderPowerMapVO);
    }
    @RequiresPermissions(value = {"/chargingUserAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/charging/users")
    @ApiOperation(value = "除电站流量外", tags = {"管理后台-数据分析-充电用户分析"})
    public R<TCharingUserMapVO> users(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
    public R<TCharingUserMapVO> users(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) {
        Long userId = tokenService.getLoginUser().getUserid();
        List<Integer> siteIds = new ArrayList<>();
        if (statisticsQueryDto.getSiteId()==null){
        if (statisticsQueryDto.getSiteId() == null) {
            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
            for (GetSiteListDTO datum : data) {
                siteIds.add(datum.getId());
            }
        }else {
        } else {
            siteIds.add(statisticsQueryDto.getSiteId());
        }
        if (siteIds.isEmpty())siteIds.add(-1);
        if (siteIds.isEmpty()) siteIds.add(-1);
        statisticsQueryDto.setSiteIds(siteIds);
        TCharingUserMapVO tCharingUserMapVO = new TCharingUserMapVO();
        //上方折现
        if (statisticsQueryDto.getDayType()==1){
        List<Map<String,Object>> map = chargingOrderService.usersDay(statisticsQueryDto);
        if (statisticsQueryDto.getDayType() == 1) {
            List<Map<String, Object>> map = chargingOrderService.usersDay(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(map, time);
                if (mapWithTimeValue!=null){
                if (mapWithTimeValue != null) {
                    charMap.add(mapWithTimeValue);
                }else {
                } else {
                    Map<String, Object> timeMap = new HashMap<>();
                    timeMap.put("time", time); // 初始化值为 null
                    timeMap.put("counts", 0);
@@ -1540,16 +1509,16 @@
                }
            }
            List<Map<String,Object>> map1 = chargingOrderService.usersDay1();
            List<Map<String, Object>> map1 = chargingOrderService.usersDay1();
            List<Map<String, Object>> charMap1 = 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(map1, time);
                if (mapWithTimeValue!=null){
                if (mapWithTimeValue != null) {
                    charMap1.add(mapWithTimeValue);
                }else {
                } else {
                    Map<String, Object> timeMap = new HashMap<>();
                    timeMap.put("time", time); // 初始化值为 null
                    timeMap.put("counts", 0);
@@ -1559,12 +1528,12 @@
            }
        tCharingUserMapVO.setMap(charMap);
        tCharingUserMapVO.setMap1(charMap1);
        }else {
            tCharingUserMapVO.setMap(charMap);
            tCharingUserMapVO.setMap1(charMap1);
        } else {
            List<Map<String,Object>> map =  chargingOrderService.usersByQuery(statisticsQueryDto);
            List<Map<String, Object>> map = chargingOrderService.usersByQuery(statisticsQueryDto);
            //按日
@@ -1595,8 +1564,7 @@
            tCharingUserMapVO.setMap(dateRangeStatistics);
            List<Map<String,Object>> map1 =  chargingOrderService.usersByQuery1(statisticsQueryDto);
            List<Map<String, Object>> map1 = chargingOrderService.usersByQuery1(statisticsQueryDto);
            LocalDate startDate1 = statisticsQueryDto.getStartTime();
@@ -1625,22 +1593,20 @@
            tCharingUserMapVO.setMap1(dateRangeStatistics1);
        }
        //用户标签
      List<Map<String,Object>> maps =    chargingOrderService.getUserTagCount();
        Map<String,Object> stringObjectMap = new HashMap<>();
        Long noTagCount =  chargingOrderService.countNoTag();
        stringObjectMap.put("count",noTagCount);
        List<Map<String, Object>> maps = chargingOrderService.getUserTagCount();
        Map<String, Object> stringObjectMap = new HashMap<>();
        Long noTagCount = chargingOrderService.countNoTag();
        stringObjectMap.put("count", noTagCount);
        maps.add(stringObjectMap);
        //会员标签
        List<Map<String,Object>> maps1 =  chargingOrderService.getVipCount();
        List<Map<String, Object>> maps1 = chargingOrderService.getVipCount();
        //单位消费
        List<Map<String, Object>> untiMap  = chargingOrderService.unitConsumption(statisticsQueryDto);
        List<Map<String, Object>> untiMap = chargingOrderService.unitConsumption(statisticsQueryDto);
        //车辆用途
        List<Map<String, Object>> carMap = chargingOrderService.carUserMethod();
@@ -1652,7 +1618,7 @@
            brands.add(objectMap.get("vehicle_brand").toString());
        }
        if (carBrandMap.size()>=5) {
        if (carBrandMap.size() >= 5) {
            Long count = chargingOrderService.countCar(brands);
            Map<String, Object> others = new HashMap<>();
            others.put("vehicle_brand", "其他");
@@ -1660,7 +1626,7 @@
            carBrandMap.add(others);
        }
        //本地车数量
        Map<String,Object> localCarMap = chargingOrderService.countLocalCar();
        Map<String, Object> localCarMap = chargingOrderService.countLocalCar();
        tCharingUserMapVO.setUserMaps(maps);
@@ -1672,28 +1638,28 @@
        return R.ok(tCharingUserMapVO);
    }
    @RequiresPermissions(value = {"/chargingUserAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/charging/sites")
    @ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-充电用户分析"})
    public R<TCharingUserEvaluateVO> sites(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
        List<Integer> siteIds =new ArrayList<>();
        if (statisticsQueryDto.getSiteId()==null) {
    public R<TCharingUserEvaluateVO> sites(@RequestBody ChargingStatisticsQueryDto 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 {
        } else {
            siteIds.add(statisticsQueryDto.getSiteId());
        }
        //查询评价分
        Double aver = chargingOrderService.getAver(siteIds);
        //查询各个分数
       List<Map<String,Object>> evaluate =  chargingOrderService.getLevelEvaluate(siteIds);
        List<Map<String, Object>> evaluate = chargingOrderService.getLevelEvaluate(siteIds);
        //查询差评回复数
        List<Integer> mark = new ArrayList<>();
        mark.add(1);
@@ -1706,38 +1672,38 @@
        //好评标签
       List<Map<String,Object>> goodTop = orderEvaluateService.goodTop(siteIds);
       //差评标签
        List<Map<String,Object>> badTop = orderEvaluateService.badTop(siteIds);
        List<Map<String, Object>> goodTop = orderEvaluateService.goodTop(siteIds);
        //差评标签
        List<Map<String, Object>> badTop = orderEvaluateService.badTop(siteIds);
        //流量分析
        List<Map<String,Object>> sourceMap = chargingOrderService.countBySource(siteIds,statisticsQueryDto);
        List<Map<String, Object>> sourceMap = chargingOrderService.countBySource(siteIds, statisticsQueryDto);
        tCharingUserEvaluateVO.setGoodTop(goodTop);
        tCharingUserEvaluateVO.setBadTop(badTop);
        tCharingUserEvaluateVO.setFlow(sourceMap);
        //流量
        return R.ok(tCharingUserEvaluateVO);
    }
    @RequiresPermissions(value = {"/operationMaintenanceAnalysis"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/charging/equipment")
    @ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-设备运维分析"})
    public R<TCharingUserEquimentVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
        List<Integer> siteIds =new ArrayList<>();
        if (statisticsQueryDto.getSiteId()==null||statisticsQueryDto.getSiteId()==0) {
    public R<TCharingUserEquimentVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) {
        List<Integer> siteIds = new ArrayList<>();
        if (statisticsQueryDto.getSiteId() == null || statisticsQueryDto.getSiteId() == 0) {
            Long userId = tokenService.getLoginUser().getUserid();
            //获取当前登录的siteIds
            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
            for (GetSiteListDTO datum : data) {
                siteIds.add(datum.getId());
            }
        }else {
        } else {
            siteIds.add(statisticsQueryDto.getSiteId());
        }
        //直流可用率
        List<Map<String,Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds, statisticsQueryDto);
        for (Map<String, Object> result : equipmentMap1) {
            Object percentObj = result.get("percent");
            if (percentObj instanceof String) {
@@ -1759,7 +1725,7 @@
        }
        //交流可用率
        List<Map<String,Object>> equipmentMap2= chargingOrderService.equipmentUserType2(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMap2 = chargingOrderService.equipmentUserType2(siteIds, statisticsQueryDto);
        for (Map<String, Object> result : equipmentMap2) {
            Object percentObj = result.get("percent");
@@ -1788,28 +1754,27 @@
        //直流故障率
        List<Map<String,Object>> equipmentMapbroke1 = chargingOrderService.equipmentMapbroke1(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMapbroke1 = chargingOrderService.equipmentMapbroke1(siteIds, statisticsQueryDto);
        //交流故障率
        List<Map<String,Object>> equipmentMapbroke2 = chargingOrderService.equipmentMapbroke2(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMapbroke2 = chargingOrderService.equipmentMapbroke2(siteIds, statisticsQueryDto);
        double average2 = calculateAveragePercent(equipmentMapbroke1, equipmentMapbroke2);
        System.out.printf("The average percent is: %.2f\n", average2);
        //直流离网率
        List<Map<String,Object>> equipmentMapOut1 = chargingOrderService.equipmentMapOut1(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMapOut1 = chargingOrderService.equipmentMapOut1(siteIds, statisticsQueryDto);
        //交流离网率
        List<Map<String,Object>> equipmentMapOut2 = chargingOrderService.equipmentMapOut2(siteIds,statisticsQueryDto);
        List<Map<String, Object>> equipmentMapOut2 = chargingOrderService.equipmentMapOut2(siteIds, statisticsQueryDto);
        double average3 = calculateAveragePercent(equipmentMapOut1, equipmentMapOut2);
        System.out.printf("The average percent is: %.2f\n", average3);
        //需求电流满足率
        List<Map<String,Object>>  needElec1 =  chargingOrderService.needElec(siteIds,statisticsQueryDto);
        List<Map<String,Object>>  needElec2 =  chargingOrderService.needElec1(siteIds,statisticsQueryDto);
        List<Map<String, Object>> needElec1 = chargingOrderService.needElec(siteIds, statisticsQueryDto);
        List<Map<String, Object>> needElec2 = chargingOrderService.needElec1(siteIds, statisticsQueryDto);
        double average4 = calculateAveragePercent(needElec1, needElec2);
        System.out.printf("The average percent is: %.2f\n", average4);
        TCharingUserEquimentVO tCharingUserEquimentVO = new TCharingUserEquimentVO();
@@ -1829,6 +1794,7 @@
    }
    private static final DecimalFormat DF = new DecimalFormat("#.00");
    public static double calculateAveragePercent(List<Map<String, Object>> mapList1, List<Map<String, Object>> mapList2) {
        int totalElements = mapList1.size() + mapList2.size();
        double sum = 0.0;
@@ -1856,8 +1822,8 @@
        // 格式化为两位小数
        return Double.parseDouble(DF.format(average));
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/work/charge")
@@ -1886,14 +1852,14 @@
        BigDecimal totalServiceCharge = BigDecimal.ZERO;
        //计算list中charging_capacity的总和
        BigDecimal totalChargingCapacity = BigDecimal.ZERO;
        if(null != stringObjectMap){
        if (null != stringObjectMap) {
            size = Integer.parseInt(stringObjectMap.get("num").toString());
            totalElectrovalence = new BigDecimal(stringObjectMap.get("electrovalence").toString());
            totalServiceCharge = new BigDecimal(stringObjectMap.get("servicecharge").toString());
            totalChargingCapacity = new BigDecimal(stringObjectMap.get("electricity").toString());
            totalPaymentAmount = totalElectrovalence.add(totalServiceCharge);
        }
        TCharingWorkVO tCharingWorkVO = new TCharingWorkVO();
        tCharingWorkVO.setCount(size);
        tCharingWorkVO.setTotalPaymentAmount(totalPaymentAmount);
@@ -1902,9 +1868,8 @@
        tCharingWorkVO.setTotalChargingCapacity(totalChargingCapacity);
        return R.ok(tCharingWorkVO);
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/work/chargeDetail")
@@ -1922,16 +1887,16 @@
            } else {
                siteIds.add(statisticsQueryDto.getSiteId());
            }
            if (statisticsQueryDto.getDayType()==1) {
                List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto);
            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){
                    if (mapWithTimeValue != null) {
                        charMap.add(mapWithTimeValue);
                    }else {
                    } else {
                        Map<String, Object> timeMap = new HashMap<>();
                        timeMap.put("time", time); // 初始化值为 null
                        timeMap.put("electrovalence", 0);
@@ -1942,21 +1907,21 @@
                    }
                }
                return R.ok(charMap);
            }else if (statisticsQueryDto.getDayType()==2){
            } 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 {
@@ -1968,26 +1933,26 @@
                        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);
            } 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 {
@@ -1999,14 +1964,14 @@
                        dateMap.put("electricity", 0);
                        dateRangeStatistics.add(dateMap);
                    }
                    // 移动到下一天
                    startDate = startDate.plusMonths(1);
                }
                return R.ok(dateRangeStatistics);
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.ok();
@@ -2014,7 +1979,7 @@
    }
    private static Map<String, Object> findMapWithTimeValue(List<Map<String, Object>> charMap1,String timeValue) {
    private static Map<String, Object> findMapWithTimeValue(List<Map<String, Object>> charMap1, String timeValue) {
        for (Map<String, Object> map : charMap1) {
            if (map.containsKey("time") && map.get("time").equals(timeValue)) {
                return map;
@@ -2031,10 +1996,8 @@
        }
        return null;
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping(value = "/work/use")
@@ -2051,10 +2014,10 @@
        } else {
            siteIds.add(statisticsQueryDto.getSiteId());
        }
       List<Map<String,Object>>   capMap  =   chargingOrderService.getchargingCapacity(siteIds,statisticsQueryDto);
        List<Map<String, Object>> capMap = chargingOrderService.getchargingCapacity(siteIds, statisticsQueryDto);
        List<TChargingPile> chargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData();
        BigDecimal totalRatedPower = chargingPiles.stream().map(TChargingPile::getRatedPower).reduce(BigDecimal.ZERO, BigDecimal::add);
        //每日利用率=当日充电度数/(桩总功率*24小时)
        BigDecimal multiply1 = totalRatedPower.multiply(new BigDecimal(24));
//        System.err.println(JSON.toJSONString(capMap) + "---" + chargingPiles.size() + "---" + totalRatedPower + "---" + multiply1);
@@ -2090,8 +2053,8 @@
        }
        return R.ok(dateRangeStatistics);
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/work/shopOrder")
@@ -2104,8 +2067,8 @@
        counts.add(count1);
        return R.ok(counts);
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/work/invoice")
@@ -2118,14 +2081,14 @@
        counts.add(count1);
        return R.ok(counts);
    }
    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping(value = "/work/users/count")
    @ApiOperation(value = "用户数量", tags = {"管理后台-工作台"})
    public R usersCount() {
       List<Map<String,Object>>  userMap  =    chargingOrderService.countAllUserData();
            return R.ok(userMap);
        List<Map<String, Object>> userMap = chargingOrderService.countAllUserData();
        return R.ok(userMap);
    }
@@ -2135,32 +2098,31 @@
        Long userId = tokenService.getLoginUserApplet().getUserId();
        List<TChargingOrder> list = chargingOrderService.list(Wrappers.lambdaQuery(TChargingOrder.class)
                .eq(TChargingOrder::getAppUserId, userId)
                .in(TChargingOrder::getStatus, Arrays.asList(1,2,3,4)));
                .in(TChargingOrder::getStatus, Arrays.asList(1, 2, 3, 4)));
        List<Integer> gunIds = list.stream().map(TChargingOrder::getChargingGunId).collect(Collectors.toList());
        return R.ok(gunIds);
    }
    /**
     * 硬件充电结束后的处理逻辑
     *
     * @param code
     */
    @PostMapping("/endCharge")
    public void endCharge(@RequestParam("code") String code){
    public void endCharge(@RequestParam("code") String code) {
        log.info(code + ":-------------------充电桩自动结束充电-------------------");
        chargingOrderService.endCharge(code, 2);
    }
    /**
     * 硬件异常结束充电后的处理逻辑
     *
     * @param code
     */
    @PostMapping("/excelEndCharge")
    public void excelEndCharge(@RequestParam("code") String code){
    public void excelEndCharge(@RequestParam("code") String code) {
        log.info(code + ":-------------------充电异常,停止充电-------------------");
        chargingOrderService.excelEndCharge(code);
    }
@@ -2168,11 +2130,12 @@
    /**
     * 根据车牌号和时间查询有效的充电数据
     *
     * @param query
     * @return
     */
    @PostMapping("/getChargingOrderByLicensePlate")
    public R<TChargingOrder> getChargingOrderByLicensePlate(@RequestBody GetChargingOrderByLicensePlate query){
    public R<TChargingOrder> getChargingOrderByLicensePlate(@RequestBody GetChargingOrderByLicensePlate query) {
        TChargingOrder chargingOrder = chargingOrderService.getChargingOrderByLicensePlate(query);
        return R.ok(chargingOrder);
    }
@@ -2180,23 +2143,24 @@
    /**
     * 修改充电订单
     *
     * @param chargingOrder
     * @return
     */
    @PostMapping("/updateChargingOrder")
    public R<String> updateChargingOrder(@RequestBody TChargingOrder chargingOrder){
    public R<String> updateChargingOrder(@RequestBody TChargingOrder chargingOrder) {
        chargingOrderService.updateById(chargingOrder);
        return R.ok();
    }
    @ResponseBody
    @GetMapping(value = "/getEndOfChargePageInfo/{id}")
    @ApiOperation(value = "获取充电结束页面数据", tags = {"小程序-扫一扫"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "订单id", required = true)
    })
    public AjaxResult<EndOfChargePageInfo> getEndOfChargePageInfo(@PathVariable("id") String id){
    public AjaxResult<EndOfChargePageInfo> getEndOfChargePageInfo(@PathVariable("id") String id) {
        EndOfChargePageInfo endOfChargePageInfo = chargingOrderService.getEndOfChargePageInfo(id);
        return AjaxResult.success(endOfChargePageInfo);
    }
@@ -2204,33 +2168,36 @@
    /**
     * 获取订单数据
     *
     * @param order
     * @return
     */
    @PostMapping("/getChargingOrder")
    public R<List<TChargingOrder>> getChargingOrder(@RequestBody TChargingOrderVo order){
    public R<List<TChargingOrder>> getChargingOrder(@RequestBody TChargingOrderVo order) {
        List<TChargingOrder> chargingOrder = chargingOrderService.getChargingOrder(order);
        return R.ok(chargingOrder);
    }
    /**
     * 根据车辆id获取指定时间范围内的数据
     *
     * @param carId
     * @param startTime
     * @param endTime
     * @return
     */
    @PostMapping("/getCarChargingOrder")
    public R<List<TChargingOrder>> getCarChargingOrder(@RequestParam("carId") Long carId, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime){
    public R<List<TChargingOrder>> getCarChargingOrder(@RequestParam("carId") Long carId, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
        List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserCarId, carId).eq(TChargingOrder::getDelFlag, 0)
                .in(TChargingOrder::getStatus, Arrays.asList(4, 5)).between(TChargingOrder::getStartTime, startTime, endTime));
        return R.ok(list);
    }
    /**
     * 根据车牌号查询指定时间范围内的数据
     *
     * @param plateNum
     * @param startTime
     * @param endTime
@@ -2238,7 +2205,7 @@
     */
    @PostMapping("/getCarChargingOrderByPlateNum")
    public R<List<TChargingOrder>> getCarChargingOrderByPlateNum(@RequestParam("plateNum") String plateNum, @RequestParam("startTime") String startTime,
                                                          @RequestParam("endTime") String endTime){
                                                                 @RequestParam("endTime") String endTime) {
        List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getPlateNum, plateNum).eq(TChargingOrder::getDelFlag, 0)
                .in(TChargingOrder::getStatus, Arrays.asList(4, 5)).between(TChargingOrder::getStartTime, startTime, endTime));
        return R.ok(list);
@@ -2247,38 +2214,36 @@
    /**
     * 添加三方平台充电订单数据
     *
     * @return
     */
    @PostMapping("/addTripartitePlatformOrder")
    public R addTripartitePlatformOrder(@RequestBody AddTripartitePlatformOrder query){
    public R addTripartitePlatformOrder(@RequestBody AddTripartitePlatformOrder query) {
        return chargingOrderService.addTripartitePlatformOrder(query);
    }
    /**
     * 根据三方平台订单id获取充电数据
     *
     * @param startChargeSeq
     * @return
     */
    @PostMapping("/getChargingOrderByStartChargeSeq")
    public R<TChargingOrder> getChargingOrderByStartChargeSeq(@RequestParam("startChargeSeq") String startChargeSeq){
    public R<TChargingOrder> getChargingOrderByStartChargeSeq(@RequestParam("startChargeSeq") String startChargeSeq) {
        TChargingOrder chargingOrder = chargingOrderService.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getStartChargeSeq, startChargeSeq));
        return R.ok(chargingOrder);
    }
    /**
     * 根据三方平台订单ids获取充电数据
     *
     * @param startChargeSeqs
     * @return
     */
    @PostMapping("/getChargingOrderByStartChargeSeqs")
    public R<List<TChargingOrder>> getChargingOrderByStartChargeSeqs(@RequestParam("startChargeSeqs") List<String> startChargeSeqs){
    public R<List<TChargingOrder>> getChargingOrderByStartChargeSeqs(@RequestParam("startChargeSeqs") List<String> startChargeSeqs) {
        List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>().in(TChargingOrder::getStartChargeSeq, startChargeSeqs));
        return R.ok(list);
    }
@@ -2286,44 +2251,48 @@
    /**
     * 三方平台请求停止充电
     *
     * @param startChargeSeq
     * @return
     */
    @PostMapping("/tripartitePlatformStopCharge")
    public R tripartitePlatformStopCharge(@RequestParam("startChargeSeq") String startChargeSeq){
    public R tripartitePlatformStopCharge(@RequestParam("startChargeSeq") String startChargeSeq) {
        return chargingOrderService.tripartitePlatformStopCharge(startChargeSeq);
    }
    /**
     * 临时接口
     * 获取充电后没有扣除费用的数据
     *
     * @return
     */
    @GetMapping("/getNotPaymentChargingOrder")
    public R getNotPaymentChargingOrder(){
    public R getNotPaymentChargingOrder() {
        return chargingOrderService.getNotPaymentChargingOrder();
    }
    /**
     * 手动推送订单给三方平台
     *
     * @param code
     * @return
     */
    @PostMapping("/pushOrderInfo")
    public R pushOrderInfo(@RequestParam String code){
    public R pushOrderInfo(@RequestParam String code) {
        return chargingOrderService.pushOrderInfo(code);
    }
    /**
     * 添加汇总数据(临时)
     *
     * @return
     */
    @ResponseBody
    @GetMapping(value = "/addChargingOrderSummaryData")
    public R addChargingOrderSummaryData(){
    public R addChargingOrderSummaryData() {
        return chargingOrderService.addChargingOrderSummaryData();
    }
@@ -2333,7 +2302,7 @@
    @ResponseBody
    @GetMapping(value = "/getStatisticsOfBattery")
    @ApiOperation(value = "新能源汽车电池安全检测次数统计", tags = {"充电桩数据大屏"})
    public R<StatisticsOfBatteryVO> getStatisticsOfBattery(){
    public R<StatisticsOfBatteryVO> getStatisticsOfBattery() {
        return chargingOrderService.getStatisticsOfBattery();
    }
@@ -2343,14 +2312,15 @@
     */
    @ResponseBody
    @GetMapping("/getSumDegreeBySiteIds")
    public R<BigDecimal> getSumDegreeBySiteIds(@RequestParam("siteIds") List<Integer> SiteIds){
    public R<BigDecimal> getSumDegreeBySiteIds(@RequestParam("siteIds") List<Integer> SiteIds) {
        Double sumDegreeBySiteIds = chargingOrderService.getSumDegreeBySiteIds(SiteIds);
        return R.ok(new BigDecimal(sumDegreeBySiteIds));
    }
    @ResponseBody
    @PostMapping("/addChargingOrder")
    public R<Long> addChargingOrder(@RequestBody TChargingOrder chargingOrder){
    public R<Long> addChargingOrder(@RequestBody TChargingOrder chargingOrder) {
        chargingOrderService.save(chargingOrder);
        return R.ok(chargingOrder.getId());
    }
@@ -2362,10 +2332,10 @@
        Long userId = tokenService.getLoginUserApplet().getUserId();
        TChargingOrder chargingOrder = chargingOrderService.getOne(Wrappers.lambdaQuery(TChargingOrder.class)
                .eq(TChargingOrder::getAppUserId, userId)
                .in(TChargingOrder::getStatus, Arrays.asList(1,2,3,4))
                .in(TChargingOrder::getStatus, Arrays.asList(1, 2, 3, 4))
                .orderByDesc(TChargingOrder::getCreateTime)
                .last("LIMIT 1"));
        if(Objects.isNull(chargingOrder)){
        if (Objects.isNull(chargingOrder)) {
            return R.ok();
        }
        return R.ok(String.valueOf(chargingOrder.getId()));
@@ -2374,22 +2344,24 @@
    /**
     * 手动查询订单和退款数据,完善退款记录
     *
     * @param orderId
     * @param refund_out_trade_no
     * @return
     */
    @PostMapping("/orderQueryRefund")
    public R<?> orderQueryRefund(@RequestParam("orderId") Long orderId, @RequestParam("refund_out_trade_no") String refund_out_trade_no){
    public R<?> orderQueryRefund(@RequestParam("orderId") Long orderId, @RequestParam("refund_out_trade_no") String refund_out_trade_no) {
        chargingOrderService.orderQueryRefund(orderId, refund_out_trade_no);
        return R.ok();
    }
    /**
     * 手动查询订单和退款数据,批量完善退款记录
     *
     * @return
     */
    @PostMapping("/orderQueryRefundList")
    public R<?> orderQueryRefundList(@RequestBody List<String> dto){
    public R<?> orderQueryRefundList(@RequestBody List<String> dto) {
        for (String s : dto) {
            String[] split = s.split(",");
            chargingOrderService.orderQueryRefund(Long.valueOf(split[0]), split[1]);
@@ -2400,11 +2372,12 @@
    /**
     * 手动添加完善订单费用明细
     *
     * @param orderId
     * @return
     */
    @PostMapping("/addOrderExpenseBreakdown")
    public R<?> addOrderExpenseBreakdown(@RequestParam("orderId") Long orderId){
    public R<?> addOrderExpenseBreakdown(@RequestParam("orderId") Long orderId) {
        chargingOrderService.addOrderExpenseBreakdown(orderId);
        return R.ok();
    }
@@ -2412,11 +2385,12 @@
    /**
     * 手动批量修改订单支付金额
     *
     * @param dtos
     * @return
     */
    @PostMapping("/updateOrderPaymentAmount")
    public R<?> updateOrderPaymentAmount(@RequestBody List<UpdateOrderPaymentAmountDto> dtos){
    public R<?> updateOrderPaymentAmount(@RequestBody List<UpdateOrderPaymentAmountDto> dtos) {
        for (UpdateOrderPaymentAmountDto dto : dtos) {
            chargingOrderService.update(new UpdateWrapper<TChargingOrder>().eq("id", dto.getOrderId())
                    .set("payment_amount", dto.getPaymentAmount()));
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
@@ -78,15 +78,15 @@
    Map<String, Object> countAll(@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getSumByType(@Param("start")LocalDateTime start,@Param("end")LocalDateTime end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getSumByType(@Param("start")String start,@Param("end")String end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getDateData(@Param("start")LocalDateTime start,@Param("end")LocalDateTime end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getDateData(@Param("start")String start,@Param("end")String end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getWeekData(@Param("start")LocalDateTime start,@Param("end")LocalDateTime end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getWeekData(@Param("start")String start,@Param("end")String end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getMonthData(@Param("start")LocalDateTime start,@Param("end")LocalDateTime end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getMonthData(@Param("start")String start,@Param("end")String end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getYearData(@Param("start")LocalDateTime start,@Param("end")LocalDateTime end,@Param("siteIds")List<Integer> siteIds);
    List<Map<String, Object>> getYearData(@Param("start")String start,@Param("end")String end,@Param("siteIds")List<Integer> siteIds);
    List<ChargingOrderListVO> chargingList(@Param("req") ChargingListQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2, @Param("endTime1")String endTime1, @Param("endTime2")String endTime2);
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
Diff too large
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -490,7 +490,7 @@
        FROM
        t_charging_order_accounting_strategy t1
        LEFT JOIN t_charging_order t2 on t1.charging_order_id = t2.id
        where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time between #{start} and #{end}
        where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time IS NOT NULL and t2.end_time is not null and t2.pay_time between #{start} and #{end}
        <if test="null != siteIds and siteIds.size() > 0">
            and t2.site_id in
            <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -502,7 +502,7 @@
    </select>
    <select id="getDateData" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(a.create_time, '%H:00' ) as time,
        DATE_FORMAT(a.pay_time, '%H:00' ) as time,
        SUM(CASE
        WHEN a.order_source = 0 THEN b.period_service_price
        WHEN a.order_source = 1 THEN b.period_service_price
@@ -522,8 +522,8 @@
        sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
        from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
        <where>
            a.del_flag = 0 and a.recharge_payment_status = 2 and DATE(a.create_time) = CURDATE()
            and a.start_time between #{start} and #{end}
            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
            and a.pay_time between #{start} and #{end}
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -539,7 +539,7 @@
    </select>
    <select id="getWeekData" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
        SUM(CASE
        WHEN a.order_source = 0 THEN b.period_service_price
        WHEN a.order_source = 1 THEN b.period_service_price
@@ -559,9 +559,8 @@
        sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
        from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
        <where>
            a.del_flag = 0 and a.recharge_payment_status = 2 and YEARWEEK(DATE_FORMAT(a.create_time,
            '%Y-%m-%d'), 1) = YEARWEEK(NOW(), 1)
            and a.start_time between #{start} and #{end}
            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
            and a.pay_time between #{start} and #{end}
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -577,7 +576,7 @@
    </select>
    <select id="getMonthData" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
        SUM(CASE
        WHEN a.order_source = 0 THEN b.period_service_price
        WHEN a.order_source = 1 THEN b.period_service_price
@@ -597,9 +596,8 @@
        sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
        from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
        <where>
            a.del_flag = 0 and a.recharge_payment_status = 2 and MONTH(a.create_time) = MONTH(NOW())
            AND YEAR(a.create_time) = YEAR(NOW())
            and a.start_time between #{start} and #{end}
            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
            and a.pay_time between #{start} and #{end}
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -615,7 +613,7 @@
    </select>
    <select id="getYearData" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
        SUM(CASE
        WHEN a.order_source = 0 THEN b.period_service_price
        WHEN a.order_source = 1 THEN b.period_service_price
@@ -635,8 +633,8 @@
        sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
        from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
        <where>
            a.del_flag = 0 and a.recharge_payment_status = 2 and YEAR(a.create_time) = YEAR(NOW())
            and a.start_time between #{start} and #{end}
            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
            and a.pay_time between #{start} and #{end}
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -651,7 +649,7 @@
    </select>
    <select id="getByDate" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time,
        SUM(CASE
        WHEN a.order_source = 0 THEN b.period_service_price
        WHEN a.order_source = 1 THEN b.period_service_price
@@ -671,8 +669,8 @@
        sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money
        from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id)
        <where>
            a.del_flag = 0 and a.recharge_payment_status = 2
            and a.start_time between #{start} and #{end}
            a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null
            and a.pay_time between #{start} and #{end}
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index">
@@ -1110,7 +1108,7 @@
            and a.site_id = #{req.siteId}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and (a.create_time between #{startTime1} and #{startTime2})
            and (a.pay_time between #{startTime1} and #{startTime2})
        </if>
        <if test="endTime1 != null and endTime1!=''">
            and (a.end_time between #{endTime1} and #{endTime2})
@@ -1240,7 +1238,7 @@
                and b.site_id = #{req.siteId}
            </if>
            <if test="startTime1 != null and startTime1!=''">
                and b.start_time between #{startTime1} and #{startTime2}
                and b.pay_time between #{startTime1} and #{startTime2}
            </if>
            <if test="endTime1 != null and endTime2!=''">
                and b.end_time between #{endTime1} and #{endTime2}
@@ -1315,7 +1313,7 @@
                and co.site_id = #{req.siteId}
            </if>
            <if test="startTime1 != null and startTime1!=''">
                and co.start_time between #{startTime1} and #{startTime2}
                and co.pay_time between #{startTime1} and #{startTime2}
            </if>
            <if test="endTime1 != null and endTime2!=''">
                and co.end_time between #{endTime1} and #{endTime2}
@@ -1371,7 +1369,7 @@
            and co.site_id = #{req.siteId}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and co.start_time between #{startTime1} and #{startTime2}
            and co.pay_time between #{startTime1} and #{startTime2}
        </if>
        <if test="endTime1 != null and endTime2!=''">
            and co.end_time between #{endTime1} and #{endTime2}