From 6f1a56eb02cb6eb7848e2df6773bc5abfee11efd Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期二, 08 十月 2024 15:13:03 +0800 Subject: [PATCH] 合併代碼 --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java | 40 +++++++++++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java index d497796..d95c38f 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java @@ -36,6 +36,8 @@ import com.ruoyi.other.api.feignClient.UserSiteClient; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; +import com.ruoyi.system.api.feignClient.SysUserRoleClient; +import com.ruoyi.system.api.model.SysUserRoleVo; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -87,6 +89,9 @@ @Resource private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; + + @Resource + private SysUserRoleClient sysUserRoleClient; @@ -111,7 +116,8 @@ //非管理员需要根据角色和用户配置查询允许的站点数据 if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); - List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); + List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); + List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); data.addAll(data1); siteIds = new HashSet<>(data); } @@ -222,9 +228,10 @@ public AjaxResult delChargingPile(Integer[] ids) { //检查是否有关联数据 //接口 - long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, Arrays.asList(ids)).eq(TChargingGun::getDelFlag, 0)); + long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, Arrays.asList(ids)) + .eq(TChargingGun::getDelFlag, 0)); if(count > 0){ - return AjaxResult.error("该充电桩有关联的接口数据,删除失败!"); + return AjaxResult.error("该充电桩已添加接口,不可删除。"); } for (Integer id : ids) { TChargingPile chargingPile = this.getById(id); @@ -242,7 +249,7 @@ List<Integer> id = setAccountingStrategy.getId(); List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, id).eq(TChargingGun::getDelFlag, 0)); for (TChargingGun tChargingGun : list) { - tChargingGun.setChargingPileId(setAccountingStrategy.getAccountingStrategyId()); + tChargingGun.setAccountingStrategyId(setAccountingStrategy.getAccountingStrategyId()); } chargingGunService.updateBatchById(list); } @@ -258,7 +265,17 @@ List<TChargingGun> chargingGuns = chargingGunService.list(wrapper); // 查询充电枪信息 chargingPileVOS.forEach(item -> { - item.setChargingGunList(chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList())); + List<TChargingGun> chargingGunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList()); + for (TChargingGun chargingGun : chargingGunList) { + if(chargingGun.getStatus().equals(4)){ + // TODO 查询正在充电的单子的实时记录 + chargingGun.setSoc(100); + } + if(chargingGun.getStatus().equals(5)){ + chargingGun.setSoc(100); + } + } + item.setChargingGunList(chargingGunList); }); return chargingPileVOS; } @@ -283,7 +300,8 @@ //非管理员需要根据角色和用户配置查询允许的站点数据 if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); - List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); + List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); + List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); data.addAll(data1); siteIds = new HashSet<>(data); } @@ -344,7 +362,9 @@ chargeMonitoring.setUtilizationTrend(utilizationTrend); return chargeMonitoring; } - + + + /** * 获取充电枪各种状态汇总 * @param siteId 站点id @@ -364,7 +384,8 @@ //非管理员需要根据角色和用户配置查询允许的站点数据 if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); - List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); + List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); + List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); data.addAll(data1); siteIds = new HashSet<>(data); } @@ -411,7 +432,8 @@ //非管理员需要根据角色和用户配置查询允许的站点数据 if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); - List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); + List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); + List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); data.addAll(data1); siteIds = new HashSet<>(data); } -- Gitblit v1.7.1