| | |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | 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.redis.service.RedisService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.IotInterfaceClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | |
| | | 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; |
| | |
| | | |
| | | @Resource |
| | | private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; |
| | | |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | |
| | | @Resource |
| | | private IotInterfaceClient iotInterfaceClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | |
| | | |
| | |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | 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); |
| | | } |
| | |
| | | if(count > 0){ |
| | | return AjaxResult.error("设备编号已存在"); |
| | | } |
| | | this.save(chargingPile); |
| | | //调用华为Iot创建设备 |
| | | AddDevice addDevice = new AddDevice(); |
| | | addDevice.setProductId("66da68d21837002b28b34ec0"); |
| | | addDevice.setNodeId(chargingPile.getCode()); |
| | | addDevice.setDeviceName(chargingPile.getName()); |
| | | addDevice.setDescription(chargingPile.getNumber().toString()); |
| | | AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData(); |
| | | if(null != deviceResp){ |
| | | int httpStatusCode = deviceResp.getHttpStatusCode(); |
| | | if(httpStatusCode == 201){ |
| | | chargingPile.setIotdDeviceId(deviceResp.getDeviceId()); |
| | | this.save(chargingPile); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | 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); |
| | | this.removeById(chargingPile); |
| | | //调用华为Iot删除设备 |
| | | if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){ |
| | | DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData(); |
| | | if(null != deviceResp && deviceResp.getHttpStatusCode() == 0){ |
| | | this.removeById(chargingPile); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | public ChargeMonitoring chargeMonitoring(Integer siteId) { |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(null == siteId){ |
| | | if(0 == siteId){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | 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); |
| | | }else{ |
| | | siteIds = null; |
| | | } |
| | | } |
| | | }else{ |
| | | siteIds.add(siteId); |
| | | } |
| | | List<Site> sites = siteService.listByIds(siteIds); |
| | | List<Site> sites = null; |
| | | if(null == siteIds){ |
| | | sites = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0)); |
| | | siteIds = sites.stream().map(Site::getId).collect(Collectors.toSet()); |
| | | }else{ |
| | | sites = siteService.listByIds(siteIds); |
| | | } |
| | | List<TChargingGun> total = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, siteIds).eq(TChargingGun::getDelFlag, 0)); |
| | | List<TChargingGun> charging = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, siteIds).eq(TChargingGun::getStatus, 4).eq(TChargingGun::getDelFlag, 0)); |
| | | BigDecimal ratedPower = total.stream().map(TChargingGun::getRatedPower).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | } |
| | | |
| | | List<String> dates = new ArrayList<>(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | for (int i = 6; i >= 0; i--) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - i); |
| | | dates.add(sdf.format(calendar.getTime())); |
| | | } |
| | |
| | | if(list.size() == 0){ |
| | | value2.add(0D); |
| | | }else{ |
| | | Double datum1 = new BigDecimal(datum).divide(new BigDecimal(list.size()).multiply(v).multiply(new BigDecimal(24))).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | Double datum1 = new BigDecimal(datum).divide(new BigDecimal(list.size()).multiply(v).multiply(new BigDecimal(24)), new MathContext(4, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | value2.add(datum1); |
| | | } |
| | | } |
| | |
| | | public ChargingGunCountMonitoring getChargingGunCountMonitoring(Integer siteId) { |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(null == siteId){ |
| | | if(0 == siteId){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | 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); |
| | | }else{ |
| | | List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0)); |
| | | siteIds = list.stream().map(Site::getId).collect(Collectors.toSet()); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | public PageInfo<ChargingGunMonitoring> getChargingGunMonitoring(GetChargingGunMonitoring query) { |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(null == query.getSiteId()){ |
| | | if(0 == query.getSiteId()){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | 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); |
| | | }else{ |
| | | List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0)); |
| | | siteIds = list.stream().map(Site::getId).collect(Collectors.toSet()); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | Integer id = gunMonitoring.getId(); |
| | | //根据订单数据查询车牌号 |
| | | TChargingOrder chargingOrder = chargingOrderClient.getOrderDetailByGunId(id).getData(); |
| | | Long appUserCarId = chargingOrder.getAppUserCarId(); |
| | | if(null != appUserCarId){ |
| | | if(null != chargingOrder){ |
| | | Long appUserCarId = chargingOrder.getAppUserCarId(); |
| | | TAppUserCar tAppUserCar = appUserCarClient.getCarByIds(Arrays.asList(appUserCarId)).getData().get(0); |
| | | gunMonitoring.setLicensePlate(tAppUserCar.getLicensePlate()); |
| | | } |
| | | |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | gunMonitoring.setChargingRatio(BigDecimal.valueOf(data.getSoc())); |
| | | gunMonitoring.setElectricQuantity(data.getCharging_degree().toString()); |
| | | gunMonitoring.setSoc(data.getSoc().toString()); |
| | | gunMonitoring.setElectricCurrent(data.getOutput_current().toString()); |
| | | gunMonitoring.setVoltage(data.getOutput_voltage().toString()); |
| | | switch (data.getHardware_fault()){ |
| | | case 1: |
| | | gunMonitoring.setFaultCause("急停按钮动作故障"); |
| | | break; |
| | | case 2: |
| | | gunMonitoring.setFaultCause("无可用整流模块"); |
| | | break; |
| | | case 3: |
| | | gunMonitoring.setFaultCause("出风口温度过高"); |
| | | break; |
| | | case 4: |
| | | gunMonitoring.setFaultCause("交流防雷故障"); |
| | | break; |
| | | case 5: |
| | | gunMonitoring.setFaultCause("交直流模块 DC20 通信中断"); |
| | | break; |
| | | case 6: |
| | | gunMonitoring.setFaultCause("绝缘检测模块 FC08 通信中断"); |
| | | break; |
| | | case 7: |
| | | gunMonitoring.setFaultCause("电度表通信中断"); |
| | | break; |
| | | case 8: |
| | | gunMonitoring.setFaultCause("读卡器通信中断"); |
| | | break; |
| | | case 9: |
| | | gunMonitoring.setFaultCause("RC10 通信中断"); |
| | | break; |
| | | case 10: |
| | | gunMonitoring.setFaultCause("风扇调速板故障"); |
| | | break; |
| | | case 11: |
| | | gunMonitoring.setFaultCause("直流熔断器故障"); |
| | | break; |
| | | case 12: |
| | | gunMonitoring.setFaultCause("高压接触器故障"); |
| | | break; |
| | | case 13: |
| | | gunMonitoring.setFaultCause("门打开"); |
| | | break; |
| | | |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | gunMonitoring.setChargingRatio(BigDecimal.valueOf(data.getSoc())); |
| | | gunMonitoring.setElectricQuantity(data.getCharging_degree().toString()); |
| | | gunMonitoring.setSoc(data.getSoc().toString()); |
| | | gunMonitoring.setElectricCurrent(data.getOutput_current().toString()); |
| | | gunMonitoring.setVoltage(data.getOutput_voltage().toString()); |
| | | switch (data.getHardware_fault()){ |
| | | case 1: |
| | | gunMonitoring.setFaultCause("急停按钮动作故障"); |
| | | break; |
| | | case 2: |
| | | gunMonitoring.setFaultCause("无可用整流模块"); |
| | | break; |
| | | case 3: |
| | | gunMonitoring.setFaultCause("出风口温度过高"); |
| | | break; |
| | | case 4: |
| | | gunMonitoring.setFaultCause("交流防雷故障"); |
| | | break; |
| | | case 5: |
| | | gunMonitoring.setFaultCause("交直流模块 DC20 通信中断"); |
| | | break; |
| | | case 6: |
| | | gunMonitoring.setFaultCause("绝缘检测模块 FC08 通信中断"); |
| | | break; |
| | | case 7: |
| | | gunMonitoring.setFaultCause("电度表通信中断"); |
| | | break; |
| | | case 8: |
| | | gunMonitoring.setFaultCause("读卡器通信中断"); |
| | | break; |
| | | case 9: |
| | | gunMonitoring.setFaultCause("RC10 通信中断"); |
| | | break; |
| | | case 10: |
| | | gunMonitoring.setFaultCause("风扇调速板故障"); |
| | | break; |
| | | case 11: |
| | | gunMonitoring.setFaultCause("直流熔断器故障"); |
| | | break; |
| | | case 12: |
| | | gunMonitoring.setFaultCause("高压接触器故障"); |
| | | break; |
| | | case 13: |
| | | gunMonitoring.setFaultCause("门打开"); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | return pageInfo.setRecords(chargingGunMonitoring); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时任务修改充电桩状态 |
| | | */ |
| | | @Override |
| | | public void updateStatus() { |
| | | List<TChargingPile> list = this.list(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getDelFlag, 0)); |
| | | List<TChargingPile> datas = new ArrayList(); |
| | | Map<String, Object> charging_pile_online = redisService.getCacheMap("charging_pile_online"); |
| | | for (TChargingPile chargingPile : list) { |
| | | Long time = (Long) charging_pile_online.get(chargingPile.getCode()); |
| | | if(null != time && System.currentTimeMillis() - time > 60000){ |
| | | chargingPile.setStatus(2); |
| | | datas.add(chargingPile); |
| | | } |
| | | } |
| | | |
| | | if(datas.size() > 0){ |
| | | this.updateBatchById(datas); |
| | | } |
| | | } |
| | | } |