From dcd97d683792b5d47cc13966b24e3bbb92ee9854 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 11 十二月 2024 19:11:36 +0800
Subject: [PATCH] 修改安全相关功能和合作商权限功能

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 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 6e1c43e..8192ed6 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
@@ -9,21 +9,16 @@
 import com.ruoyi.account.api.model.TAppUserVipDetail;
 import com.ruoyi.account.api.vo.GetAppUserVipDetail;
 import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
-import com.ruoyi.chargingPile.api.model.Site;
-import com.ruoyi.chargingPile.api.model.TChargingGun;
-import com.ruoyi.chargingPile.api.model.TChargingPile;
-import com.ruoyi.chargingPile.api.model.TParkingLot;
+import com.ruoyi.chargingPile.api.model.*;
 import com.ruoyi.chargingPile.api.query.GetSiteList;
 import com.ruoyi.chargingPile.api.query.SiteDetailQuery;
 import com.ruoyi.chargingPile.api.query.SiteQuery;
 import com.ruoyi.chargingPile.api.vo.SiteDetailVO;
 import com.ruoyi.chargingPile.api.vo.SiteVO;
-import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO;
-import com.ruoyi.chargingPile.domain.SiteMenu;
+import com.ruoyi.chargingPile.api.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;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -39,7 +34,6 @@
 import com.ruoyi.system.api.feignClient.SysUserRoleClient;
 import com.ruoyi.system.api.model.SysUserRoleVo;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
@@ -87,6 +81,12 @@
 	private IntegrationClient integrationClient;
 	@Resource
 	private AppUserVipDetailClient vipDetailClient;
+	
+	@Resource
+	private TAccountingStrategyDetailService accountingStrategyDetailService;
+	
+	@Resource
+	private TPartnerSiteService partnerSiteService;
 	
 	
 	/**
@@ -211,6 +211,16 @@
 		if(null != one && !one.getCode().equals(site.getCode())){
 			return AjaxResult.error("站点编号重复");
 		}
+		
+		Site site1 = this.getById(site.getId());
+		if(!site1.getPartnerId().equals(site.getPartnerId())){
+			List<TPartnerSite> list = partnerSiteService.list(new LambdaQueryWrapper<TPartnerSite>().eq(TPartnerSite::getPartnerId, site1.getPartnerId()).eq(TPartnerSite::getSiteId, site.getId()));
+			for (TPartnerSite partnerSite : list) {
+				partnerSite.setPartnerId(site.getPartnerId());
+				partnerSiteService.updateById(partnerSite);
+			}
+		}
+		
 		this.updateById(site);
 		return AjaxResult.success();
 	}
@@ -293,9 +303,9 @@
 	public PageInfo<SiteVO> pageList(SiteQuery query,Integer isLogin) {
 		TAppUser appUser = null;
 		// 获取当前登录用户id
-		Long userId = tokenService.getLoginUserApplet().getUserId();
 		TAppUserVipDetail data1 = null;
 		if(isLogin == 1){
+			Long userId = tokenService.getLoginUserApplet().getUserId();
 			// 根据id查询用户信息
 			appUser = appUserClient.getUserById(userId).getData();
 			GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
@@ -396,9 +406,9 @@
 		}
 		TAppUser appUser = null;
 		// 获取当前登录用户id
-		Long userId = tokenService.getLoginUserApplet().getUserId();
 		TAppUserVipDetail data1 = null;
 		if(isLogin == 1){
+			Long userId = tokenService.getLoginUserApplet().getUserId();
 			// 根据id查询用户信息
 			appUser = appUserClient.getUserById(userId).getData();
 			GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
@@ -438,14 +448,17 @@
 		this.updateById(site);
 		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, id).eq(TChargingGun::getDelFlag, 0));
 		for (TChargingGun tChargingGun : list) {
-			tChargingGun.setAccountingStrategyId(accountingStrategyId);
+			TChargingGun tChargingGun1 = new TChargingGun();
+			tChargingGun1.setId(tChargingGun.getId());
+			tChargingGun1.setAccountingStrategyId(accountingStrategyId);
+			chargingGunService.updateById(tChargingGun1);
 		}
-		chargingGunService.updateBatchById(list);
 		
 		//下发硬件数据
+		List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailService.list(new LambdaQueryWrapper<TAccountingStrategyDetail>().eq(TAccountingStrategyDetail::getAccountingStrategyId, accountingStrategyId));
 		List<TChargingPile> list1 = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0).list();
 		for (TChargingPile tChargingPile : list1) {
-			integrationClient.setupBillingModel1(tChargingPile.getCode());
+			integrationClient.setupBillingModel1(tChargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails));
 		}
 	}
 }

--
Gitblit v1.7.1