From 792cbb986fb8c32f6bbc1638c4ae264372e7a28f Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 23 一月 2025 19:31:36 +0800
Subject: [PATCH] 新增引流接口及业务逻辑

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java |   63 ++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
index b797113..7b17c17 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
@@ -6,6 +6,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
+import com.ruoyi.chargingPile.api.feignClient.PartnerClient;
 import com.ruoyi.chargingPile.api.feignClient.SiteClient;
 import com.ruoyi.chargingPile.api.model.TParkingLot;
 import com.ruoyi.chargingPile.api.model.TParkingRecord;
@@ -30,6 +31,8 @@
 import com.ruoyi.order.api.query.TOrderInvoiceQuery;
 import com.ruoyi.order.api.vo.TCharingUserEquimentVO;
 import com.ruoyi.order.api.vo.TOrderInvoiceVO;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
@@ -69,25 +72,50 @@
     private SiteClient siteClient;
     @Resource
     private TokenService tokenService;
+    @Resource
+    private PartnerClient partnerClient;
 
-    
-    
+    @Resource
+    private SysUserClient sysUserClient;
     @RequiresPermissions(value = {"/parkingRecord"}, logical = Logical.OR)
     @ApiOperation(tags = {"后台-订单管理-停车记录"},value = "列表")
     @PostMapping(value = "/page")
     public R<Page<TParkingRecord>> page(@RequestBody ParkingRecordPageQuery query) {
         Long userid = tokenService.getLoginUser().getUserid();
+        SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
+        Integer roleType = sysUser.getRoleType();
         List<Integer> siteIds = new ArrayList<>();
 
-            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userid).getData();
-            for (GetSiteListDTO datum : data) {
-                siteIds.add(datum.getId());
+        List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userid).getData();
+        for (GetSiteListDTO datum : data) {
+            siteIds.add(datum.getId());
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }else{
+            if (roleType == 2){
+                List<Integer> integers = new ArrayList<>();
+                for (Integer siteId : siteIds) {
+                    // 校验有没有这个站点的权限
+                    List<Boolean> t1= partnerClient.parkingRecordListMenu(sysUser.getObjectId(),siteId).getData();
+
+                    Boolean b = t1.get(1);
+                    if (b){
+                        integers.add(siteId);
+                    }
+                }
+                siteIds = integers;
             }
-        List<TParkingLot> list = parkingLotService.lambdaQuery().in(!siteIds.isEmpty(), TParkingLot::getSiteId, siteIds).list();
+        }
+        if (siteIds.isEmpty()){
+            siteIds.add(-1);
+        }
+        List<TParkingLot> list = parkingLotService.lambdaQuery().in( TParkingLot::getSiteId, siteIds).list();
         List<Integer> ids = new ArrayList<>();
         for (TParkingLot tParkingLot : list) {
             ids.add(tParkingLot.getId());
         }
+
 
         String s1 = "";
         String s2 = "";
@@ -96,6 +124,7 @@
              s2 = query.getTimePeriod().split(" - ")[1];
         }
         Page<TParkingRecord> page = parkingRecordService.lambdaQuery()
+                .in(null != ids && ids.size() > 0, TParkingRecord::getParkingLotId,ids)
                 .like(query.getLicensePlate() != null, TParkingRecord::getLicensePlate, query.getLicensePlate())
                 .eq(query.getStatus() != null, TParkingRecord::getStatus, query.getStatus())
                 .eq(query.getOutParkingType() != null, TParkingRecord::getOutParkingType, query.getOutParkingType())
@@ -110,6 +139,11 @@
             record.setUid(record.getId().toString());
             if (byId!=null) {
                 record.setParkName(byId.getName());
+                if (roleType==2){
+                    List<Boolean> data1 = partnerClient.parkingRecordListMenu(sysUser.getObjectId(), byId.getSiteId()).getData();
+                    record.setAuthInfo(data1.get(0));
+                    record.setAuthOut(data1.get(1));
+                }
             }
         }
         return R.ok(page);
@@ -247,7 +281,22 @@
     public R<TParkLotRecordVO> data(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){
         //上方折线图
         TParkLotRecordVO tParkLotRecordVO = new TParkLotRecordVO();
-
+        // 查询当前登陆人按钮权限
+        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);
+        }
+        parkingRecordQueryDto.setSiteIds(siteIds);
         if (parkingRecordQueryDto.getDayType()==1) {
             List<Map<String, Object>> maps = parkingRecordService.parkingData(parkingRecordQueryDto);
 

--
Gitblit v1.7.1