Pu Zhibing
4 天以前 db0b7644a9a5a62ac2da3cf571fee41bb8b6974f
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -1,28 +1,33 @@
package com.ruoyi.chargingPile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
import com.ruoyi.account.api.model.TAppUser;
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.utils.ServletUtils;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.elutong.model.*;
import com.ruoyi.integration.api.feignClient.ELuTongClient;
import com.ruoyi.integration.api.feignClient.IntegrationClient;
import com.ruoyi.integration.api.feignClient.TCECClient;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.api.feignClient.RoleSiteClient;
import com.ruoyi.other.api.feignClient.UserSiteClient;
@@ -31,13 +36,18 @@
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.feignClient.SysUserRoleClient;
import com.ruoyi.system.api.model.SysUserRoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -69,12 +79,25 @@
   @Resource
   private AppUserClient appUserClient;
   @Resource
   private VipClient vipClient;
   @Resource
   private SysUserRoleClient sysUserRoleClient;
   @Resource
   private TParkingLotService parkingLotService;
   @Resource
   private IntegrationClient integrationClient;
   @Resource
   private AppUserVipDetailClient vipDetailClient;
   @Resource
   private TAccountingStrategyDetailService accountingStrategyDetailService;
   @Resource
   private TPartnerSiteService partnerSiteService;
   @Resource
   private TCECClient tcecClient;
   @Resource ELuTongClient eLuTongClient;
   
   
   /**
@@ -82,19 +105,22 @@
    * @param siteList
    * @return
    */
   @Override
   public PageInfo<GetSiteListDTO> getSiteList(GetSiteList siteList) {
      Set<Integer> ids = null;
      //校验合作商权限
      SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
      SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
      Integer roleType = sysUser.getRoleType();
      Integer objectId = sysUser.getObjectId();
      R<Integer> admin = sysUserClient.isAdmin(tokenService.getLoginUser().getUserid());
      //合作商
      if(roleType == 2){
         ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
      }else{
         //非管理员需要根据角色和用户配置查询允许的站点数据
         if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
         //改用roleId=1来判断
         if(admin.getData()!=1){
            List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
            List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData();
            if(data2.size() > 0){
@@ -118,6 +144,8 @@
   }
   @Override
   public PageInfo<GetSiteListDTO> getSiteList1(Long userId) {
      GetSiteList siteList = new GetSiteList();
@@ -128,12 +156,14 @@
      SysUser sysUser = sysUserClient.getSysUser(userId).getData();
      Integer roleType = sysUser.getRoleType();
      Integer objectId = sysUser.getObjectId();
      R<Integer> admin = sysUserClient.isAdmin(tokenService.getLoginUser().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();
@@ -174,9 +204,176 @@
      }
      site.setMark(0);
      this.save(site);
      if(StringUtils.isNotEmpty(site.getSerAreaCode())){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
         threadPoolExecutor.execute(()->{
            StationInfoReq stationInfoReq = new StationInfoReq();
            stationInfoReq.setOperatorId("91510903906171535D");
            stationInfoReq.setStationId(site.getId().toString());
            OperatorInfo operatorInfo = new OperatorInfo();
            operatorInfo.setOperatorId("91510903906171535D");
            operatorInfo.setOperatorName("四川明星新能源科技有限公司");
            operatorInfo.setOperatorTel1("18683346252");
            operatorInfo.setOperatorTel2("13982508784");
            operatorInfo.setOperatorRegAddress("遂宁市船山区渠河南路18号");
            stationInfoReq.setOperatorInfo(operatorInfo);
            List<StationInfo> stationInfos = new ArrayList<>();
            stationInfos.add(buildStationInfo(site));
            stationInfoReq.setItemSize(stationInfos.size());
            stationInfoReq.setStationInfos(stationInfos);
            R r = eLuTongClient.pushStationInfo(stationInfoReq);
            if(200 != r.getCode()){
               System.out.println(r.getMsg());
            }
         });
      }
      return AjaxResult.success();
   }
   private StationInfo buildStationInfo(Site site){
      StationInfo stationInfo = new StationInfo();
      stationInfo.setSerAreaCode(site.getSerAreaCode());
      stationInfo.setOperatorId("91510903906171535D");
      stationInfo.setStationId(site.getId().toString());
      stationInfo.setStationName(site.getName());
      stationInfo.setStationMode("CD");
      stationInfo.setAreaCode(site.getDistrictsCode());
      stationInfo.setServiceTel(site.getServicePhone());
      switch (site.getSiteType()){
         case 0:
            stationInfo.setStationType(255);
            break;
         case 1:
            stationInfo.setStationType(1);
            break;
         case 2:
            stationInfo.setStationType(50);
            break;
         case 3:
            stationInfo.setStationType(100);
            break;
         case 4:
            stationInfo.setStationType(101);
            break;
         case 5:
            stationInfo.setStationType(102);
            break;
         case 6:
            stationInfo.setStationType(103);
            break;
      }
      switch (site.getStatus()){
         case 3:
            stationInfo.setStationStatus(5);
            break;
         case 2:
            stationInfo.setStationStatus(6);
            break;
         case 1:
            stationInfo.setStationStatus(50);
            break;
      }
      stationInfo.setParkNums(site.getParkingSpace());
      stationInfo.setStationLng(Double.parseDouble(site.getLon()));
      stationInfo.setStationLat(Double.parseDouble(site.getLat()));
      stationInfo.setSiteGuide(site.getGuide());
      switch (site.getConstructionSite()){
         case 1:
            stationInfo.setConstruction(1);
            break;
         case 2:
            stationInfo.setConstruction(2);
            break;
         case 3:
            stationInfo.setConstruction(3);
            break;
         case 4:
            stationInfo.setConstruction(4);
            break;
         case 5:
            stationInfo.setConstruction(5);
            break;
         case 6:
            stationInfo.setConstruction(6);
            break;
         case 7:
            stationInfo.setConstruction(7);
            break;
         case 8:
            stationInfo.setConstruction(8);
            break;
         case 9:
            stationInfo.setConstruction(9);
            break;
         case 10:
            stationInfo.setConstruction(10);
            break;
         case 11:
            stationInfo.setConstruction(11);
            break;
         case 0:
            stationInfo.setConstruction(255);
            break;
      }
      if(StringUtils.isNotEmpty(site.getImgUrl())){
         stationInfo.setPictures(Arrays.asList(site.getImgUrl().split(",")));
      }
      stationInfo.setMatchCars(site.getVehicleDescription());
      stationInfo.setBusineHours(site.getStartServiceTime() + " - " + site.getEndServiceTime());
      stationInfo.setEquipmentInfos(buildEquipmentInfo(site));
      return stationInfo;
   }
   private List<EquipmentInfo> buildEquipmentInfo(Site site){
      List<TChargingPile> list = chargingPileService.list(new LambdaQueryWrapper<TChargingPile>()
            .eq(TChargingPile::getSiteId, site.getId()).eq(TChargingPile::getDelFlag, 0));
      return new ArrayList<EquipmentInfo>(){{
         for (TChargingPile chargingPile : list) {
            EquipmentInfo equipmentInfo = new EquipmentInfo();
            equipmentInfo.setEquipmentId(chargingPile.getId().toString());
            equipmentInfo.setEquipmentName(chargingPile.getName());
            equipmentInfo.setManufacturerId(chargingPile.getManufacturerCode());
            equipmentInfo.setManufacturerName(chargingPile.getManufacturer());
            equipmentInfo.setEquipmentModel(chargingPile.getEquipmentType());
            if(null != chargingPile.getProductionDate()){
               equipmentInfo.setProductionDate(chargingPile.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            }
            equipmentInfo.setEquipmentType(0 == chargingPile.getType() ? 5 : chargingPile.getType());
            if(StringUtils.isNotEmpty(chargingPile.getEquipmentLng())){
               equipmentInfo.setEquipmentLng(Double.parseDouble(chargingPile.getEquipmentLng()));
            }
            if(StringUtils.isNotEmpty(chargingPile.getEquipmentLat())){
               equipmentInfo.setEquipmentLat(Double.parseDouble(chargingPile.getEquipmentLat()));
            }
            equipmentInfo.setPower(chargingPile.getRatedPower().doubleValue());
            equipmentInfo.setConnectorInfos(buildConnectorInfo(chargingPile));
            add(equipmentInfo);
         }
      }};
   }
   private List<ConnectorInfo> buildConnectorInfo(TChargingPile chargingPile){
      List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>()
            .eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0));
      return new ArrayList<ConnectorInfo>(){{
         for (TChargingGun chargingGun : list) {
            ConnectorInfo connectorInfo = new ConnectorInfo();
            connectorInfo.setConnectorId(chargingGun.getId().toString());
            connectorInfo.setConnectorName(chargingGun.getName());
            connectorInfo.setConnectorType(0 == chargingGun.getType() ? 6 : chargingGun.getType());
            connectorInfo.setVoltageUpperLimits(chargingGun.getUpperRatedVoltage().intValue());
            connectorInfo.setVoltageLowerLimits(chargingGun.getLowerLimitOfRatedVoltage().intValue());
            connectorInfo.setCurrent(chargingGun.getRatedCurrent().intValue());
            connectorInfo.setPower(chargingGun.getRatedPower().doubleValue());
            connectorInfo.setParkNo(chargingGun.getParkingNumber());
            connectorInfo.setNationalStandard(Integer.parseInt(chargingGun.getNationalStandard()));
            add(connectorInfo);
         }
      }};
   }
   
   /**
    * 编辑站点
@@ -193,7 +390,41 @@
      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);
      tcecClient.superviseNotificationStationInfo(site.getId());
      if(StringUtils.isNotEmpty(site.getSerAreaCode())){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
         threadPoolExecutor.execute(()->{
            StationInfoReq stationInfoReq = new StationInfoReq();
            stationInfoReq.setOperatorId("91510903906171535D");
            stationInfoReq.setStationId(site.getId().toString());
            OperatorInfo operatorInfo = new OperatorInfo();
            operatorInfo.setOperatorId("91510903906171535D");
            operatorInfo.setOperatorName("四川明星新能源科技有限公司");
            operatorInfo.setOperatorTel1("18683346252");
            operatorInfo.setOperatorTel2("13982508784");
            operatorInfo.setOperatorRegAddress("遂宁市船山区渠河南路18号");
            stationInfoReq.setOperatorInfo(operatorInfo);
            List<StationInfo> stationInfos = new ArrayList<>();
            stationInfos.add(buildStationInfo(site));
            stationInfoReq.setItemSize(stationInfos.size());
            stationInfoReq.setStationInfos(stationInfos);
            R r = eLuTongClient.pushStationInfo(stationInfoReq);
            if(200 != r.getCode()){
               System.out.println(r.getMsg());
            }
         });
      }
      return AjaxResult.success();
   }
   
@@ -232,12 +463,12 @@
      if(StringUtils.isEmpty(site.getAddress())){
         return AjaxResult.error("详细地址不能为空");
      }
      if(StringUtils.isEmpty(site.getLon()) || StringUtils.isEmpty(site.getLat())){
         return AjaxResult.error("地图位置不能为空");
      }
      if(StringUtils.isEmpty(site.getPhone())){
         return AjaxResult.error("站点电话不能为空");
      }
//      if(StringUtils.isEmpty(site.getLon()) || StringUtils.isEmpty(site.getLat())){
//         return AjaxResult.error("地图位置不能为空");
//      }
//      if(StringUtils.isEmpty(site.getPhone())){
//         return AjaxResult.error("站点电话不能为空");
//      }
      if(StringUtils.isEmpty(site.getServicePhone())){
         return AjaxResult.error("服务电话不能为空");
      }
@@ -247,6 +478,56 @@
      if(null == site.getSort()){
         return AjaxResult.error("排序不能为空");
      }
//      if(StringUtils.isEmpty(site.getAreaCodeCountryside())){
//         return AjaxResult.error("充换电站所在县以下行政区划代码不能为空");
//      }
//      if(null == site.getStationClassification()){
//         return AjaxResult.error("请选择站点分类");
//      }
//      if(null == site.getGeneralApplicationType()){
//         return AjaxResult.error("请选择通用类型");
//      }
//      if(null == site.getParkType()){
//         return AjaxResult.error("请选择停车费类型");
//      }
//      if(null == site.getRoundTheClock()){
//         return AjaxResult.error("请选择是否7*24h营业");
//      }
//      if (site.getStationClassification()!=1&& (!org.springframework.util.StringUtils.hasLength(site.getSwapMatchCars()))){
//         return AjaxResult.error("服务车型描述不能为空");
//      }
//      if(null == site.getElectricityType()){
//         return AjaxResult.error("请选择电费类型");
//      }
//      if(null == site.getBusinessExpandType()){
//         return AjaxResult.error("请选择报装类型");
//      }
//      if(null == site.getCapacity()){
//         return AjaxResult.error("报装电源容量不能为空");
//      }
//      if(null == site.getRatedPower()){
//         return AjaxResult.error("站点额定总功率不能为空");
//      }
//      if(StringUtils.isEmpty(site.getOfficialRunTime())){
//         return AjaxResult.error("请选择正式投运时间");
//      }
//      if(null == site.getPeriodFee()){
//         return AjaxResult.error("请选择峰谷时分");
//      }
//      if(null == site.getVideoMonitor()){
//         return AjaxResult.error("请选择视频监控配套情况");
//      }
//      if(StringUtils.isEmpty(site.getEquipmentOwnerName())){
//         return AjaxResult.error("设备所属方名称不能为空");
//      }
//      if(null == site.getSupplyType()){
//         return AjaxResult.error("请选择供电类型");
//      }
//      if(site.getSupplyType()==1){
//         if (StringUtils.isEmpty(site.getResidentNo())){
//            return AjaxResult.error("供电局用户编号不能为空");
//         }
//      }
      return AjaxResult.success();
   }
   
@@ -259,9 +540,10 @@
   public AjaxResult delSite(Integer[] ids) {
      //查询是否有关联数据
      //充电桩
      long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getSiteId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0));
      long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().in(TChargingPile::getSiteId, Arrays.asList(ids))
            .eq(TChargingPile::getDelFlag, 0));
      if(count1 > 0){
         return AjaxResult.error("该站点有关联充电桩,删除失败!");
         return AjaxResult.error("该站点已添加充电桩,不可删除。");
      }
      for (Integer id : ids) {
         Site site = this.getById(id);
@@ -273,21 +555,33 @@
   @Override
   public PageInfo<SiteVO> pageList(SiteQuery query,Integer isLogin) {
      TAppUser appUser = null;
      // 获取当前登录用户id
      TAppUserVipDetail data1 = null;
      if(isLogin == 1){
         // 获取当前登录用户id
         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();
         if(Objects.nonNull(vip) && vip.getType() == 2){
            list.forEach(item -> {
               item.setVipElectrovalence(vip.getDiscount().multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
            });
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         if(Objects.nonNull(data1)){
            String vipJson = data1.getVipJson();
            TVip vip = JSON.parseObject(vipJson, TVip.class);
            if(Objects.nonNull(vip) && vip.getType() == 2){
               list.forEach(item -> {
                  if(Objects.nonNull(vip.getDiscount())){
                     item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
                  }
               });
            }
         }
      }
      pageInfo.setRecords(list);
@@ -295,15 +589,15 @@
   }
   @Override
   public SiteDetailVO getDetailById(Integer siteId) {
      return this.baseMapper.getDetailById(siteId);
   public SiteDetailVO getDetailById(SiteDetailQuery query) {
      return this.baseMapper.getDetailById(query);
   }
   @Override
   public List<Site> getSiteListParkLot() {
      Set<Integer> ids = null;
      //校验合作商权限
      SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
      SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
      Integer roleType = sysUser.getRoleType();
      Integer objectId = sysUser.getObjectId();
      //合作商
@@ -311,7 +605,7 @@
         ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
      }else{
         //非管理员需要根据角色和用户配置查询允许的站点数据
         if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
         if(!SecurityUtils.isAdmin(tokenService.getLoginUser().getUserid())){
            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();
@@ -321,9 +615,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);
   }
@@ -332,7 +632,7 @@
   public List<Site> getSiteListGun() {
      Set<Integer> ids = null;
      //校验合作商权限
      SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData();
      SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
      Integer roleType = sysUser.getRoleType();
      Integer objectId = sysUser.getObjectId();
      //合作商
@@ -340,7 +640,7 @@
         ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
      }else{
         //非管理员需要根据角色和用户配置查询允许的站点数据
         if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
         if(!SecurityUtils.isAdmin(tokenService.getLoginUser().getUserid())){
            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();
@@ -352,24 +652,36 @@
   }
   @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();
      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();
      }
      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(vip) && vip.getType() == 2){
            list.forEach(item -> {
               item.setVipElectrovalence(vip.getDiscount().multiply(item.getElectrovalence()));
            });
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         if(Objects.nonNull(data1)){
            String vipJson = data1.getVipJson();
            TVip vip = JSON.parseObject(vipJson, TVip.class);
            if(Objects.nonNull(vip) && vip.getType() == 2){
               list.forEach(item -> {
                  item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
               });
            }
         }
      }
      return list;
@@ -387,10 +699,22 @@
      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);
         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(), JSON.toJSONString(accountingStrategyDetails));
      }
      //推送三方平台
      tcecClient.notificationStationChange(Arrays.asList(id));
   }
}