From 88ac2574d89aed7c28b9c0370b19b8bb2d0364eb Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 07 一月 2025 19:02:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java |  409 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 325 insertions(+), 84 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index 05e93fc..e450b99 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -12,10 +12,7 @@
 import com.ruoyi.account.api.feignClient.AppUserClient;
 import com.ruoyi.account.api.model.TAppUserCar;
 import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
-import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
-import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
-import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient;
-import com.ruoyi.chargingPile.api.feignClient.SiteClient;
+import com.ruoyi.chargingPile.api.feignClient.*;
 import com.ruoyi.chargingPile.api.model.Site;
 import com.ruoyi.chargingPile.api.model.TChargingGun;
 import com.ruoyi.chargingPile.api.model.TChargingPile;
@@ -25,6 +22,8 @@
 import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
 import com.ruoyi.common.core.web.domain.BasePojo;
 import com.ruoyi.common.redis.service.RedisService;
+import com.ruoyi.common.security.annotation.Logical;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -55,6 +54,8 @@
 import com.ruoyi.payment.api.feignClient.AliPaymentClient;
 import com.ruoyi.payment.api.feignClient.WxPaymentClient;
 import com.ruoyi.payment.api.vo.AliQueryOrder;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -137,6 +138,12 @@
     
     @Resource
     private TOrderInvoiceService invoiceService;
+    @Resource
+    private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient;
+    
+    
+    
+    
 
     /**
      * 远程调用 增加管理后台赠送会员记录
@@ -169,19 +176,90 @@
         }
         return R.ok();
     }
+
+    
+    @RequiresPermissions(value = {"/invoiceManagement/select_order", "/paymentOrder/order"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/pay/order/list")
     @ApiOperation(value = "列表", tags = {"管理后台-支付订单-订单信息"})
     public R<PageInfo<PayOrderDto>> payOrderList(@RequestBody PayOrderQueryDto payOrderQueryDto) {
-        return chargingOrderService.payOrderQuery(payOrderQueryDto);
+        Integer pageCurr = payOrderQueryDto.getPageCurr();
+        Integer pageSize = payOrderQueryDto.getPageSize();
+        payOrderQueryDto.setPageCurr(1);
+        payOrderQueryDto.setPageSize(10000999);
+        PageInfo<PayOrderDto> data = chargingOrderService.payOrderQuery(payOrderQueryDto).getData();
+        List<PayOrderDto> res = new ArrayList<>();
+        // 查询当前登陆人按钮权限
+        SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
+        Integer roleType = sysUser.getRoleType();
+        Long userId = tokenService.getLoginUser().getUserid();
+        //如果没传siteId,获取当前登陆人所有的siteIds
+        List<Integer> siteIds = new ArrayList<>();
+        if (userId != null){
+            List<GetSiteListDTO> data2 = siteClient.getSiteListByUserId(userId).getData();
+            for (GetSiteListDTO datum : data2) {
+                siteIds.add(datum.getId());
+            }
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }
+
+        for (PayOrderDto record : data.getRecords()) {
+            if (record.getType() == 1){
+                TChargingOrder byId = chargingOrderService.getById(record.getId());
+                record.setSiteId(byId.getSiteId());
+            }
+            if (record.getType()==4){
+                Integer siteId=parkingLotClient.getSiteIdByOrderId(Long.valueOf(record.getId())).getData();
+                if (siteId!=null){
+                    record.setSiteId(siteId);
+                }
+            }
+            if (roleType==1||(record.getType()!=1&&record.getType()!=4)){
+                res.add(record);
+                continue;
+            }
+            if (roleType==2 && (record.getType()==1||record.getType()==4) && siteIds.contains(record.getSiteId())){
+                res.add(record);
+            }
+
+        }
+        List<PayOrderDto> res1 = testing5(res.size(), pageCurr, pageSize, res);
+        data.setTotal(res.size());
+        data.setRecords(res1);
+        return R.ok(data);
     }
+    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;
+}
     @ResponseBody
     @PostMapping(value = "/pay/order/refund")
     @ApiOperation(value = "退款", tags = {"管理后台-支付订单-订单信息"})
     public R refund(@RequestBody PayOrderRefundDto payOrderQueryDto) {
         return chargingOrderService.payRefund(payOrderQueryDto);
     }
-
+    
+    
+    @RequiresPermissions(value = {"/paymentOrder/order"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/pay/order/pay/detail")
     @ApiOperation(value = "支付信息", tags = {"管理后台-支付订单-订单信息"})
@@ -310,19 +388,83 @@
 
         return R.ok(list);
     }
-
-
-
+    
+    
+    
+    @RequiresPermissions(value = {"/paymentOrder/refund"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/pay/order/refund/list")
     @ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"})
     public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) {
-        R<PageInfo<TChargingOrderRefund>> refundList = chargingOrderService.getRefundList(chargingRefundDto);
-        for (TChargingOrderRefund record : refundList.getData().getRecords()) {
-            record.setUid(record.getId().toString());
-        }
-        return refundList;
+        Integer pageCurr = chargingRefundDto.getPageCurr();
+        Integer pageSize = chargingRefundDto.getPageSize();
+//        R<PageInfo<TChargingOrderRefund>> refundList = chargingOrderService.getRefundList(chargingRefundDto);
+        chargingRefundDto.setPageCurr(1);
+        chargingRefundDto.setPageSize(199999999);
+        R<PageInfo<TChargingOrderRefund>> refundList1 = chargingOrderService.getRefundList(chargingRefundDto);
+        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 (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }
+        // 查询当前登陆人按钮权限
+        SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
+        Integer roleType = sysUser.getRoleType();
+        List<TChargingOrderRefund> tChargingOrderRefunds = new ArrayList<>();
+        for (TChargingOrderRefund record : refundList1.getData().getRecords()) {
+            if (roleType==1){
+                tChargingOrderRefunds.add(record);
+                continue;
+            }
+            if (record.getType()!=1){
+                tChargingOrderRefunds.add(record);
+            }
+            TChargingOrder byId = chargingOrderService.getById(record.getOrderId());
+            record.setUid(record.getId().toString());
+            if (byId==null){
+                continue;
+            }
+            if (roleType==2&&siteIds.contains(byId.getSiteId())){
+
+                tChargingOrderRefunds.add(record);
+            }
+        }
+        PageInfo<TChargingOrderRefund> data = refundList1.getData();
+
+        List<TChargingOrderRefund> res1 = testing4(tChargingOrderRefunds.size(), pageCurr, pageSize, tChargingOrderRefunds);
+        data.setTotal(tChargingOrderRefunds.size());
+        data.setRecords(res1);
+        return refundList1;
+
+    }
+    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);
+        //获取集合下标初始值
+        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;
     }
     @ResponseBody
     @PostMapping(value = "/pay/order/refund/list1")
@@ -331,12 +473,13 @@
         return chargingOrderService.getRefundList(chargingRefundDto);
 
     }
-
-
-
-
-
-
+    
+    
+    
+    
+    
+    
+    @RequiresPermissions(value = {"/chargingPileOrder"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/chargingOrder")
     @ApiOperation(value = "充电桩订单列表", tags = {"管理后台-订单管理"})
@@ -346,7 +489,9 @@
         TCharingOrderVO res = chargingOrderService.chargingOrder(dto);
         return AjaxResult.success(res);
     }
-
+    
+    
+    @RequiresPermissions(value = {"/chargingPileOrder/monitoring_record"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/chargingOrderInfo")
     @ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
@@ -485,6 +630,11 @@
     @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)){
+            return AjaxResult.error("权限不足");
+        }
         MyChargingOrderInfo myChargingOrderInfo = chargingOrderService.getMyChargingOrderInfo(id);
         return AjaxResult.success(myChargingOrderInfo);
     }
@@ -548,21 +698,10 @@
      */
     @ResponseBody
     @PostMapping(value = "/chargingOrderALICallback")
-    public void chargingOrderALICallback(@RequestBody AliQueryOrder aliQueryOrder, HttpServletResponse response) {
-        try {
-            String out_trade_no = aliQueryOrder.getOutTradeNo();
-            String transaction_id = aliQueryOrder.getTradeNo();
-            String attach = aliQueryOrder.getPassbackParams();
-            AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
-            if (ajaxResult.isSuccess()) {
-                PrintWriter writer = response.getWriter();
-                writer.println("success");
-                writer.flush();
-                writer.close();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+    public void chargingOrderALICallback(@RequestParam("out_trade_no") String out_trade_no,
+                                         @RequestParam("transaction_id") String transaction_id,
+                                         @RequestParam("attach") String attach) {
+        chargingOrderService.chargingOrderCallback(2, out_trade_no, transaction_id, attach);
     }
     
     
@@ -641,13 +780,21 @@
     }
     
     
+//    @PostMapping("/endChargeBillingCharge1")
+//    public void endChargeBillingCharge1(@RequestBody TransactionRecordMessageVO vo){
+//        log.info("-------------------停止充电返回账单后计算费用及修改业务状态-------------------:" + vo);
+//        chargingOrderService.endChargeBillingCharge1(vo);
+//    }
     
-
+    
+    
+    
+    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/six/charge")
     @ApiOperation(value = "电站收入分析", tags = {"后台-数据分析-平台收入分析"})
     public R<List<SixChargingDto>> charge(Integer siteId) {
-        Long userId = SecurityUtils.getUserId();
+        Long userId = tokenService.getLoginUser().getUserid();
         //如果没传siteId,获取当前登陆人所有的siteIds
         List<Integer> siteIds = new ArrayList<>();
         if (siteId==null){
@@ -657,6 +804,9 @@
             }
         }else {
             siteIds.add(siteId);
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
         }
         LocalDate sixBefore = PreviousSixMonths.get();
         //通过siteIds进行sql查询统计
@@ -691,12 +841,13 @@
 
         return months;
     }
-
+    
+    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/six/circle")
     @ApiOperation(value = "电站收入占比", tags = {"后台-数据分析-平台收入分析"})
     public R<List<SixCircleDto>> circle() {
-        Long userId = SecurityUtils.getUserId();
+        Long userId = tokenService.getLoginUser().getUserid();
         //获取当前登录的siteIds
         List<Integer> siteIds = new ArrayList<>();
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
@@ -705,7 +856,9 @@
             }
         //进行统计groupBySiteId
         LocalDate sixBefore = PreviousSixMonths.get();
-
+            if (siteIds.isEmpty()){
+                siteIds.add(-1);
+            }
         List<SixCircleDto> sixCircleDtos = chargingOrderService.circle(siteIds,sixBefore);
         for (SixCircleDto sixCircleDto : sixCircleDtos) {
             Site site = siteClient.getSiteByIds(Arrays.asList(sixCircleDto.getSiteId())).getData().get(0);
@@ -714,8 +867,9 @@
         return R.ok(sixCircleDtos);
 
     }
-
-
+    
+    
+    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/six/shop")
     @ApiOperation(value = "购物收入", tags = {"后台-数据分析-平台收入分析"})
@@ -751,7 +905,9 @@
 
         return months;
     }
-
+    
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/work/shop")
     @ApiOperation(value = "购物收入", tags = {"后台-工作台"})
@@ -761,7 +917,8 @@
         List<Map<String,Object >> shopData =  shoppingOrderService.getData(statisticsQueryDto);
         return R.ok(shopData);
     }
-
+    
+    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/six/vip")
     @ApiOperation(value = "vip收入", tags = {"后台-数据分析-平台收入分析"})
@@ -771,14 +928,27 @@
         List<SixVipDto> vipDtos =  vipOrderService.sixBefore(sixBefore);
         return R.ok(vipDtos);
     }
-
+    
+    
+    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/six/total")
     @ApiOperation(value = "底部数据分类", tags = {"后台-数据分析-平台收入分析"})
     public R<Map<String,Object>> total() {
         //count近6个月的数据
         LocalDate sixBefore = PreviousSixMonths.get();
-        Map<String,Object>  map = chargingOrderService.countAll(sixBefore);
+        Long userId = tokenService.getLoginUser().getUserid();
+        //获取当前登录的siteIds
+        List<Integer> siteIds = new ArrayList<>();
+        List<GetSiteListDTO> data9 = siteClient.getSiteListByUserId(userId).getData();
+        for (GetSiteListDTO datum : data9) {
+            siteIds.add(datum.getId());
+        }
+        //进行统计groupBySiteId
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }
+        Map<String,Object>  map = chargingOrderService.countAll(sixBefore,siteIds);
         BigDecimal data = parkingLotClient.getRecordAmount(sixBefore).getData();
         if (map ==null){
             map = new HashMap<String,Object>();
@@ -795,19 +965,59 @@
     }
 
     @Resource
-    private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient;
+    private PartnerClient partnerClient;
+    @Resource
+    private SysUserClient sysUserClient;
+    @RequiresPermissions(value = {"/chargeOrderMonitoring"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/watch/chargingOrder")
     @ApiOperation(value = "监控订单", tags = {"管理后台-订单管理"})
     public R watchChargingOrder(@RequestBody MongoChargingOrderQuery mongoChargingOrderQuery) {
-
+        Long userid = tokenService.getLoginUser().getUserid();
+        SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
+        Integer roleType = sysUser.getRoleType();
+        List<Integer> siteIds = new ArrayList<>();
+        if (mongoChargingOrderQuery.getSiteId()==null){
+            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userid).getData();
+            for (GetSiteListDTO datum : data) {
+                siteIds.add(datum.getId());
+            }
+        }else {
+            siteIds.add(mongoChargingOrderQuery.getSiteId());
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }else{
+            if (roleType == 2){
+                List<Integer> integers = new ArrayList<>();
+                for (Integer siteId : siteIds) {
+                    // 校验有没有这个站点的权限
+                    List<Boolean> t1= partnerClient.watchChargingOrder(sysUser.getObjectId(),siteId).getData();
+                    Boolean b = t1.get(1);
+                    if (b){
+                        integers.add(siteId);
+                    }
+                }
+                siteIds = integers;
+            }
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }
+        mongoChargingOrderQuery.setSiteIds(siteIds);
         mongoChargingOrderQuery.setPageSize(10);
         R<UploadRealTimeMonitoringPageData> all = uploadRealTimeMonitoringDataClient.getAll(mongoChargingOrderQuery);
         UploadRealTimeMonitoringPageData data1 = all.getData();
 
         List<ChargingOrderAndUploadRealTimeMonitoringDataDto> dtos = new ArrayList<>();
         Map<String,ChargingOrderVO> map  = new HashMap<>();
+
         for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data1.getRecords()) {
+            if (roleType==2){
+                List<Boolean> data = partnerClient.watchChargingOrder(sysUser.getObjectId(), uploadRealTimeMonitoringData.getSiteId()).getData();
+                uploadRealTimeMonitoringData.setAuthInfo(data.get(0));
+                uploadRealTimeMonitoringData.setAuthDelete(data.get(1));
+            }
             ChargingOrderAndUploadRealTimeMonitoringDataDto dataDto = new ChargingOrderAndUploadRealTimeMonitoringDataDto();
             ChargingOrderQuery dto = new ChargingOrderQuery();
             dto.setCode(uploadRealTimeMonitoringData.getTransaction_serial_number());
@@ -846,9 +1056,9 @@
 
         return R.ok(page);
     }
-
-
-
+    
+    
+    @RequiresPermissions(value = {"/chargeOrderMonitoring/del"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/watch/deletes")
     @ApiOperation(value = "监控订单-删除", tags = {"管理后台-订单管理"})
@@ -875,18 +1085,18 @@
         return R.ok(chargingOrderService.getOne(Wrappers.lambdaQuery(TChargingOrder.class)
                 .eq(TChargingOrder::getCode,code)));
     }
-
-
-
-
-
+    
+    
+    
+    
+    @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) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -895,6 +1105,7 @@
         }else {
             siteIds.add(statisticsQueryDto.getSiteId());
         }
+        if (siteIds.isEmpty())siteIds.add(-1);
         TCharingOrderMapVO tCharingOrderMapVO = new TCharingOrderMapVO();
 
 
@@ -1118,7 +1329,7 @@
     public R<TCharingOrderPowerMapVO> power(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) {
         List<Integer> siteIds = new ArrayList<>();
         if (statisticsQueryDto.getSiteId() == null) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1140,17 +1351,32 @@
         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){
+        Long userId = tokenService.getLoginUser().getUserid();
+
+        List<Integer> siteIds = new ArrayList<>();
+        if (statisticsQueryDto.getSiteId()==null){
+            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
+            for (GetSiteListDTO datum : data) {
+                siteIds.add(datum.getId());
+            }
+        }else {
+            siteIds.add(statisticsQueryDto.getSiteId());
+        }
+        if (siteIds.isEmpty())siteIds.add(-1);
+        statisticsQueryDto.setSiteIds(siteIds);
+        
 
         TCharingUserMapVO tCharingUserMapVO = new TCharingUserMapVO();
         //上方折现
         if (statisticsQueryDto.getDayType()==1){
-        List<Map<String,Object>> map = chargingOrderService.usersDay();
+        List<Map<String,Object>> map = chargingOrderService.usersDay(statisticsQueryDto);
 
             List<Map<String, Object>> charMap = new ArrayList<>();
             // 生成从 "00:00" 到 "23:00" 的时间数据
@@ -1280,11 +1506,13 @@
             brands.add(objectMap.get("vehicle_brand").toString());
         }
 
-        Long count = chargingOrderService.countCar(brands);
-        Map<String, Object> others = new HashMap<>();
-        others.put("vehicle_brand","其他");
-        others.put("counts",count);
-        carBrandMap.add(others);
+        if (carBrandMap.size()>=5) {
+            Long count = chargingOrderService.countCar(brands);
+            Map<String, Object> others = new HashMap<>();
+            others.put("vehicle_brand", "其他");
+            others.put("counts", count);
+            carBrandMap.add(others);
+        }
         //本地车数量
         Map<String,Object> localCarMap = chargingOrderService.countLocalCar();
 
@@ -1298,13 +1526,16 @@
         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) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1341,14 +1572,16 @@
         //流量
         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) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1477,14 +1710,16 @@
         // 格式化为两位小数
         return Double.parseDouble(DF.format(average));
     }
-
+    
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/work/charge")
     @ApiOperation(value = "上方充电数据统计", tags = {"管理后台-工作台"})
     public R<TCharingWorkVO> workCharge(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) {
         List<Integer> siteIds = new ArrayList<>();
         if (statisticsQueryDto.getSiteId() == null) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1520,16 +1755,17 @@
         tCharingWorkVO.setTotalChargingCapacity(totalChargingCapacity);
         return R.ok(tCharingWorkVO);
     }
-
-
-
+    
+    
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/work/chargeDetail")
     @ApiOperation(value = "运营情况", tags = {"管理后台-工作台"})
     public R workCharge(@RequestBody ChargingDetailQueryDto statisticsQueryDto) {
         List<Integer> siteIds = new ArrayList<>();
         if (statisticsQueryDto.getSiteId() == null) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1644,17 +1880,18 @@
         }
         return null;
     }
-
-
-
-
+    
+    
+    
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @PostMapping(value = "/work/use")
     @ApiOperation(value = "利用率", tags = {"管理后台-工作台"})
     public R workUse(@RequestBody ChargingDetailQueryDto statisticsQueryDto) {
         List<Integer> siteIds = new ArrayList<>();
         if (statisticsQueryDto.getSiteId() == null) {
-            Long userId = SecurityUtils.getUserId();
+            Long userId = tokenService.getLoginUser().getUserid();
             //获取当前登录的siteIds
             List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
             for (GetSiteListDTO datum : data) {
@@ -1706,8 +1943,9 @@
 
 
     }
-
     
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/work/shopOrder")
     @ApiOperation(value = "购物订单统计", tags = {"管理后台-工作台"})
@@ -1719,7 +1957,9 @@
         counts.add(count1);
         return R.ok(counts);
     }
-
+    
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/work/invoice")
     @ApiOperation(value = "开票统计", tags = {"管理后台-工作台"})
@@ -1731,7 +1971,8 @@
         counts.add(count1);
         return R.ok(counts);
     }
-
+    
+    @RequiresPermissions(value = {"/workbench"}, logical = Logical.OR)
     @ResponseBody
     @GetMapping(value = "/work/users/count")
     @ApiOperation(value = "用户数量", tags = {"管理后台-工作台"})

--
Gitblit v1.7.1