From 21dbee73f1310f6c57efdc70982d58e354154183 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 31 十月 2024 09:33:59 +0800
Subject: [PATCH] merge

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
index 8228a4c..6bd9fe3 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -18,6 +18,7 @@
 import com.ruoyi.chargingPile.domain.SiteMenu;
 import com.ruoyi.chargingPile.mapper.SiteMapper;
 import com.ruoyi.chargingPile.service.*;
+import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.ServletUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
@@ -88,6 +89,7 @@
 	 * @param siteList
 	 * @return
 	 */
+
 	@Override
 	public PageInfo<GetSiteListDTO> getSiteList(GetSiteList siteList) {
 		Set<Integer> ids = null;
@@ -95,12 +97,15 @@
 		SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
 		Integer roleType = sysUser.getRoleType();
 		Integer objectId = sysUser.getObjectId();
+		R<Integer> admin = sysUserClient.isAdmin(SecurityUtils.getUserId());
 		//合作商
 		if(roleType == 2){
 			ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
 		}else{
 			//非管理员需要根据角色和用户配置查询允许的站点数据
-			if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
+			//改用roleId=1来判断
+			if(admin.getData()!=1){
+//			if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
 				List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
 				List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData();
 				if(data2.size() > 0){
@@ -134,12 +139,14 @@
 		SysUser sysUser = sysUserClient.getSysUser(userId).getData();
 		Integer roleType = sysUser.getRoleType();
 		Integer objectId = sysUser.getObjectId();
+		R<Integer> admin = sysUserClient.isAdmin(SecurityUtils.getUserId());
+
 		//合作商
 		if(roleType == 2){
 			ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
 		}else{
 			//非管理员需要根据角色和用户配置查询允许的站点数据
-			if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
+			if(admin.getData()!=1){
 				List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
 				List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData();
 				List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData();
@@ -328,9 +335,15 @@
 		}
 		// 查询所有的停车场的站点id
 		List<TParkingLot> list = parkingLotService.list();
-		List<Integer> siteIds = list.stream().map(TParkingLot::getSiteId).collect(Collectors.toList());
+		List<Integer> siteIds = list.stream().map(TParkingLot::getSiteId).distinct().collect(Collectors.toList());
 		if(!CollectionUtils.isEmpty(ids) && !CollectionUtils.isEmpty(siteIds)){
-			ids.addAll(siteIds);
+			Iterator<Integer> iterator = ids.iterator();
+			while (iterator.hasNext()){
+				Integer next = iterator.next();
+				if(siteIds.contains(next)){
+					iterator.remove();
+				}
+			}
 		}
 		return this.baseMapper.getSiteListParkLot(ids);
 	}
@@ -394,7 +407,7 @@
 		Site site = this.getById(id);
 		site.setAccountingStrategyId(accountingStrategyId);
 		this.updateById(site);
-		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, id).eq(TChargingGun::getDelFlag, 0));
+		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, id).eq(TChargingGun::getDelFlag, 0));
 		for (TChargingGun tChargingGun : list) {
 			tChargingGun.setAccountingStrategyId(accountingStrategyId);
 		}

--
Gitblit v1.7.1