luodangjia
2024-11-04 e0fc8f7e2230b51e3bbe8dea43790cf11b7170e9
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -9,10 +9,7 @@
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;
@@ -87,6 +84,9 @@
   private IntegrationClient integrationClient;
   @Resource
   private AppUserVipDetailClient vipDetailClient;
   @Resource
   private TAccountingStrategyDetailService accountingStrategyDetailService;
   
   
   /**
@@ -293,21 +293,22 @@
   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();
         getAppUserVipDetail.setAppUserId(userId);
         getAppUserVipDetail.setVipId(appUser.getVipId());
         R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
         data1 = appUserVipDetail.getData();
      }
      PageInfo<SiteVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
      List<SiteVO> list = this.baseMapper.pageList(query,pageInfo);
      if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
         // 查询会员信息
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
         getAppUserVipDetail.setAppUserId(userId);
         getAppUserVipDetail.setVipId(appUser.getVipId());
         R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
         TAppUserVipDetail data1 = appUserVipDetail.getData();
         if(Objects.nonNull(data1)){
            String vipJson = data1.getVipJson();
            TVip vip = JSON.parseObject(vipJson, TVip.class);
@@ -388,25 +389,28 @@
   }
   @Override
   public List<SiteVO> getMapSiteList(SiteQuery query) {
   public List<SiteVO> getMapSiteList(SiteQuery query,Integer isLogin) {
      if(StringUtils.isEmpty(query.getLon()) || StringUtils.isEmpty(query.getLat())){
         return new ArrayList<>();
      }
      TAppUser appUser = null;
      // 获取当前登录用户id
      Long userId = tokenService.getLoginUserApplet().getUserId();
      // 根据id查询用户信息
      TAppUser appUser = appUserClient.getUserById(userId).getData();
      List<SiteVO> list = this.baseMapper.getMapSiteList(query);
      if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
         // 查询会员信息
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
      TAppUserVipDetail data1 = null;
      if(isLogin == 1){
         Long userId = tokenService.getLoginUserApplet().getUserId();
         // 根据id查询用户信息
         appUser = appUserClient.getUserById(userId).getData();
         GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
         getAppUserVipDetail.setAppUserId(userId);
         getAppUserVipDetail.setVipId(appUser.getVipId());
         R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
         TAppUserVipDetail data1 = appUserVipDetail.getData();
         data1 = appUserVipDetail.getData();
      }
      List<SiteVO> list = this.baseMapper.getMapSiteList(query);
      if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
         // 查询会员信息
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         if(Objects.nonNull(data1)){
            String vipJson = data1.getVipJson();
            TVip vip = JSON.parseObject(vipJson, TVip.class);
@@ -434,14 +438,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));
      }
   }
}