| | |
| | | package com.ruoyi.chargingPile.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.dto.SendMessageDTO; |
| | | import com.ruoyi.account.api.feignClient.AppUserCarClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO; |
| | | 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.TFaultMessage; |
| | | import com.ruoyi.chargingPile.api.model.*; |
| | | import com.ruoyi.chargingPile.api.query.BatchSetAccountingStrategy; |
| | | import com.ruoyi.chargingPile.api.query.PageChargingPileList; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingGunVO; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingPileVO; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.api.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.ChargeMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingGunCountMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingGunMonitoring; |
| | |
| | | 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.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.IntegrationClient; |
| | | import com.ruoyi.integration.api.feignClient.IotInterfaceClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.feignClient.*; |
| | | import com.ruoyi.integration.api.model.QrCodeDelivery; |
| | | 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.integration.api.vo.ShowDeviceResp; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private TChargingGunService chargingGunService; |
| | | |
| | | @Resource |
| | | private TCECClient tcecClient; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | |
| | | private IotInterfaceClient iotInterfaceClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private TFaultMessageService faultMessageService; |
| | |
| | | @Resource |
| | | private IntegrationClient integrationClient; |
| | | |
| | | @Resource |
| | | private TAccountingStrategyDetailService accountingStrategyDetailService; |
| | | |
| | | @Resource |
| | | private SendMessageClient sendMessageClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private TChargingPileNotificationService chargingPileNotificationService; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取充电桩列表数据 |
| | | * @param page |
| | |
| | | public PageInfo<PageChargingPileListDTO> pageChargingPileList(PageChargingPileList page) { |
| | | Set<Integer> siteIds = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | //合作商 |
| | |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_PILE); |
| | | }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(); |
| | |
| | | return AjaxResult.error("设备编号已存在"); |
| | | } |
| | | //调用华为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); |
| | | ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(chargingPile.getCode()).getData(); |
| | | if(null == showDeviceResp){ |
| | | //调用华为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()); |
| | | }else{ |
| | | log.error("华为创建设备失败" + JSON.toJSONString(deviceResp)); |
| | | return AjaxResult.error("华为创建设备失败"); |
| | | } |
| | | }else{ |
| | | log.error("华为创建设备失败" + JSON.toJSONString(deviceResp)); |
| | | return AjaxResult.error("华为创建设备失败"); |
| | | } |
| | | }else{ |
| | | chargingPile.setIotdDeviceId(showDeviceResp.getDeviceId()); |
| | | } |
| | | this.save(chargingPile); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | if(null != one && !one.getId().equals(chargingPile.getId())){ |
| | | return AjaxResult.error("设备编号已存在"); |
| | | } |
| | | TChargingPile tChargingPile = this.getById(chargingPile.getId()); |
| | | //桩号不相同,需要重新绑定设备 |
| | | if(!tChargingPile.getCode().equals(chargingPile.getCode())){ |
| | | ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(tChargingPile.getCode()).getData(); |
| | | if(null != showDeviceResp){ |
| | | DeleteDeviceResp deleteDeviceResp = iotInterfaceClient.deleteDevice(tChargingPile.getCode()).getData(); |
| | | if(null == deleteDeviceResp){ |
| | | return AjaxResult.error("删除设备异常,请查看华为设备管理"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(tChargingPile.getCode()).getData(); |
| | | if(null == showDeviceResp){ |
| | | //调用华为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()); |
| | | }else{ |
| | | log.error("华为创建设备失败" + JSON.toJSONString(deviceResp)); |
| | | return AjaxResult.error("华为创建设备失败"); |
| | | } |
| | | }else{ |
| | | return AjaxResult.error("华为创建设备失败"); |
| | | } |
| | | } |
| | | this.updateById(chargingPile); |
| | | |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); |
| | | for (TChargingGun chargingGun : list) { |
| | | TChargingGun chargingGun1 = new TChargingGun(); |
| | | chargingGun1.setId(chargingGun.getId()); |
| | | chargingGun1.setFullNumber(chargingPile.getCode() + chargingGun.getCode()); |
| | | chargingGun1.setSiteId(chargingPile.getSiteId()); |
| | | chargingGunService.updateById(chargingGun1); |
| | | |
| | | //下发硬件充电二维码 |
| | | String code_prefix = "https://mxcd.zhinenganguan.com?No="; |
| | | QrCodeDelivery qrCodeDelivery = new QrCodeDelivery(); |
| | | qrCodeDelivery.setCharging_pile_code(chargingPile.getCode()); |
| | | qrCodeDelivery.setCharging_gun_code(chargingGun.getCode()); |
| | | qrCodeDelivery.setCode_format(1); |
| | | qrCodeDelivery.setPrefix_length(code_prefix.length()); |
| | | qrCodeDelivery.setCode_prefix(code_prefix); |
| | | qrCodeDelivery.setQr_code(code_prefix + chargingPile.getCode() + chargingGun.getCode()); |
| | | sendMessageClient.qrCodeDelivery(qrCodeDelivery); |
| | | } |
| | | tcecClient.superviseNotificationStationInfo(chargingPile.getSiteId()); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | TChargingPile chargingPile = this.getById(id); |
| | | //调用华为Iot删除设备 |
| | | if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){ |
| | | DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData(); |
| | | if(null != deviceResp && deviceResp.getHttpStatusCode() == 0){ |
| | | this.removeById(chargingPile); |
| | | ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(chargingPile.getCode()).getData(); |
| | | if(null != showDeviceResp){ |
| | | DeleteDeviceResp deleteDeviceResp = iotInterfaceClient.deleteDevice(chargingPile.getCode()).getData(); |
| | | if(null == deleteDeviceResp || (deleteDeviceResp.getHttpStatusCode() != 200 && deleteDeviceResp.getHttpStatusCode() != 201 && deleteDeviceResp.getHttpStatusCode() != 204)){ |
| | | return AjaxResult.error("删除设备异常,请查看华为设备管理"); |
| | | } |
| | | chargingPile.setIotdDeviceId(""); |
| | | } |
| | | |
| | | } |
| | | this.removeById(chargingPile); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | 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.setAccountingStrategyId(setAccountingStrategy.getAccountingStrategyId()); |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setAccountingStrategyId(setAccountingStrategy.getAccountingStrategyId()); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | } |
| | | chargingGunService.updateBatchById(list); |
| | | Integer accountingStrategyId = setAccountingStrategy.getAccountingStrategyId(); |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailService.list(new LambdaQueryWrapper<TAccountingStrategyDetail>() |
| | | .eq(TAccountingStrategyDetail::getAccountingStrategyId, accountingStrategyId).orderByAsc(TAccountingStrategyDetail::getStartTime)); |
| | | //下发硬件更新计费模板 |
| | | for (TChargingPile chargingPile : this.listByIds(id)) { |
| | | integrationClient.setupBillingModel1(chargingPile.getCode()); |
| | | List<TChargingPile> tChargingPiles = this.listByIds(id); |
| | | for (TChargingPile chargingPile : tChargingPiles) { |
| | | integrationClient.setupBillingModel1(chargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails)); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<TChargingPileVO> getChargingGunList(Integer siteId,Integer type) { |
| | | List<TChargingPileVO> chargingPileVOS = this.baseMapper.getChargingGunList(siteId); |
| | | LambdaQueryWrapper<TChargingGun> wrapper = new LambdaQueryWrapper<>(); |
| | | if(Objects.nonNull(type)){ |
| | | wrapper.eq(TChargingGun::getChargeMode, type); |
| | | } |
| | | wrapper.eq(TChargingGun::getSiteId, siteId); |
| | | List<TChargingGun> chargingGuns = chargingGunService.list(wrapper); |
| | | // 查询充电枪信息 |
| | | chargingPileVOS.forEach(item -> { |
| | | List<TChargingGun> chargingGunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : chargingGunList) { |
| | | if(chargingGun.getStatus().equals(4)){ |
| | | // 查询正在充电的单子的实时记录 |
| | | TChargingOrder chargingOrder = chargingOrderClient.getOrderDetailByGunId(chargingGun.getId()).getData(); |
| | | if(Objects.nonNull(chargingOrder)){ |
| | | UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | chargingGun.setSoc(uploadRealTimeMonitoringData.getSoc()); |
| | | }else { |
| | | Set<Integer> collect = chargingGuns.stream().map(TChargingGun::getChargingPileId).collect(Collectors.toSet()); |
| | | List<TChargingPileVO> chargingPileVOS = new ArrayList<>(); |
| | | if(collect.size() > 0){ |
| | | List<TChargingPile> tChargingPiles = this.baseMapper.selectBatchIds(collect); |
| | | for (TChargingPile tChargingPile : tChargingPiles) { |
| | | TChargingPileVO vo = new TChargingPileVO(); |
| | | List<TChargingGun> chargingGunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(tChargingPile.getId())).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : chargingGunList) { |
| | | if(chargingGun.getStatus().equals(4)){ |
| | | // 查询正在充电的单子的实时记录 |
| | | TChargingOrder chargingOrder = chargingOrderClient.getOrderDetailByGunId(chargingGun.getId()).getData(); |
| | | if(Objects.nonNull(chargingOrder)){ |
| | | UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | if(null != uploadRealTimeMonitoringData){ |
| | | chargingGun.setSoc(uploadRealTimeMonitoringData.getSoc()); |
| | | }else{ |
| | | chargingGun.setSoc(0); |
| | | } |
| | | }else { |
| | | chargingGun.setSoc(100); |
| | | } |
| | | } |
| | | if(chargingGun.getStatus().equals(5)){ |
| | | chargingGun.setSoc(100); |
| | | } |
| | | } |
| | | if(chargingGun.getStatus().equals(5)){ |
| | | chargingGun.setSoc(100); |
| | | } |
| | | vo.setChargingGunList(chargingGunList); |
| | | vo.setId(tChargingPile.getId()); |
| | | vo.setCode(tChargingPile.getCode()); |
| | | vo.setName(tChargingPile.getName()); |
| | | vo.setNumber(tChargingPile.getNumber()); |
| | | chargingPileVOS.add(vo); |
| | | |
| | | } |
| | | item.setChargingGunList(chargingGunList); |
| | | }); |
| | | } |
| | | return chargingPileVOS; |
| | | } |
| | | |
| | |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(0 == siteId){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | if(2 == roleType){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_FACILITY_MONITORING); |
| | | }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(); |
| | |
| | | chargeTrend.put("value", value1); |
| | | chargeMonitoring.setChargeTrend(chargeTrend); |
| | | |
| | | //每日利用率=当日充电度数/(总桩数量*桩总功率*24小时) |
| | | //每日利用率=当日充电度数/(桩总功率*24小时) |
| | | List<TChargingPile> list = this.list(new LambdaQueryWrapper<TChargingPile>().in(TChargingPile::getSiteId, siteIds).eq(TChargingPile::getDelFlag, 0)); |
| | | BigDecimal v = list.stream().map(TChargingPile::getRatedPower).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_EVEN); |
| | | List<Double> data = chargingOrderAccountingStrategyClient.getDailyChargingDegree(6, siteIds).getData(); |
| | | List<Double> value2 = new ArrayList<>(); |
| | | BigDecimal multiply = v.multiply(new BigDecimal(24)); |
| | | for (Double datum : data) { |
| | | if(list.size() == 0){ |
| | | value2.add(0D); |
| | | }else{ |
| | | 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(); |
| | | Double datum1 = new BigDecimal(datum).divide(multiply, new MathContext(4, RoundingMode.HALF_EVEN)) |
| | | .multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | value2.add(datum1); |
| | | } |
| | | } |
| | |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(0 == siteId){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | if(2 == roleType){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_FACILITY_MONITORING); |
| | | }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(); |
| | |
| | | //获取当前登录账户的站点权限数据 |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if(0 == query.getSiteId()){ |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | R<Integer> admin = sysUserClient.isAdmin(tokenService.getLoginUser().getUserid()); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | if(2 == roleType){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_FACILITY_MONITORING); |
| | | }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(); |
| | |
| | | if(status == 5 || status == 6){ |
| | | gunMonitoring.setStatus(3); |
| | | } |
| | | if(status == 4){ |
| | | if(status == 4 || status == 7){ |
| | | Integer id = gunMonitoring.getId(); |
| | | TChargingOrder chargingOrder = chargingOrderClient.getOrderDetailByGunId(id).getData(); |
| | | if(null != chargingOrder){ |
| | |
| | | if(null != appUserCarId){ |
| | | TAppUserCar tAppUserCar = appUserCarClient.getCarByIds(Arrays.asList(appUserCarId)).getData().get(0); |
| | | gunMonitoring.setLicensePlate(tAppUserCar.getLicensePlate()); |
| | | }else{ |
| | | gunMonitoring.setLicensePlate(chargingOrder.getPlateNum()); |
| | | } |
| | | |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | |
| | | } |
| | | } |
| | | } |
| | | //test |
| | | // if (status==1||status==7){ |
| | | // TFaultMessage one = faultMessageService.lambdaQuery().eq(TFaultMessage::getChargingGunId, gunMonitoring.getId()).orderByDesc(TFaultMessage::getCreateTime).last("limit 1").one(); |
| | | // if (one!=null) { |
| | | // gunMonitoring.setFaultCause(one.getContent()); |
| | | // } |
| | | // } |
| | | } |
| | | return pageInfo.setRecords(chargingGunMonitoring); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void updateStatus() { |
| | | List<TChargingPile> list = this.list(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getDelFlag, 0)); |
| | | 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){ |
| | | TChargingPile chargingPile1 = new TChargingPile(); |
| | | chargingPile1.setId(chargingPile.getId()); |
| | | chargingPile1.setStatus(2); |
| | | this.updateById(chargingPile1); |
| | | List<TChargingGun> list1 = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId())); |
| | | for (TChargingGun chargingGun : list1) { |
| | | TChargingGun chargingGun1 = new TChargingGun(); |
| | | chargingGun1.setId(chargingGun.getId()); |
| | | chargingGun1.setStatus(1); |
| | | chargingGunService.updateById(chargingGun1); |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getDelFlag, 0)); |
| | | for (TChargingGun chargingGun : list) { |
| | | Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", chargingGun.getFullNumber()); |
| | | //判断设备是否真的离线3分钟(2分钟+代码中的60秒间隔处理存储) |
| | | if(null != time && System.currentTimeMillis() - time > 180000){ |
| | | TChargingGun chargingGun1 = new TChargingGun(); |
| | | chargingGun1.setId(chargingGun.getId()); |
| | | chargingGun1.setStatus(1); |
| | | chargingGunService.updateById(chargingGun1); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(chargingGun1.getFullNumber(), chargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | |
| | | //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 |
| | | TChargingPile chargingPile = this.getById(chargingGun.getChargingPileId()); |
| | | List<TChargingGun> list1 = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); |
| | | int size = list1.stream().filter(s -> s.getStatus() == 1 || s.getStatus() == 7).collect(Collectors.toList()).size(); |
| | | if(chargingPile.getStatus() == 1 && list1.size() == size){ |
| | | TChargingPile chargingPile1 = new TChargingPile(); |
| | | chargingPile1.setId(chargingGun.getChargingPileId()); |
| | | chargingPile1.setStatus(2); |
| | | this.updateById(chargingPile1); |
| | | } |
| | | |
| | | //添加记录 |
| | | TFaultMessage faultMessage = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingPile.getId()) |
| | | .eq(TFaultMessage::getStatus, 1).eq(TFaultMessage::getDelFlag, 0).isNull(TFaultMessage::getEndTime)); |
| | | TFaultMessage faultMessage = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingGun.getChargingPileId()) |
| | | .eq(TFaultMessage::getChargingGunId, chargingGun.getId()).eq(TFaultMessage::getStatus, 1).eq(TFaultMessage::getDelFlag, 0).isNull(TFaultMessage::getEndTime)); |
| | | if(null == faultMessage){ |
| | | faultMessage = new TFaultMessage(); |
| | | faultMessage.setSiteId(chargingPile.getSiteId()); |
| | | faultMessage.setChargingPileId(chargingPile.getId()); |
| | | faultMessage.setSiteId(chargingGun.getSiteId()); |
| | | faultMessage.setChargingPileId(chargingGun.getChargingPileId()); |
| | | faultMessage.setChargingGunId(chargingGun.getId()); |
| | | faultMessage.setStatus(1); |
| | | faultMessage.setDownTime(LocalDateTime.now()); |
| | | faultMessage.setCreateTime(LocalDateTime.now()); |
| | | faultMessage.setDelFlag(false); |
| | | faultMessage.setContent("设备离线"); |
| | | faultMessageService.save(faultMessage); |
| | | |
| | | // 发送故障短信 |
| | | Site site = siteService.getById(faultMessage.getSiteId()); |
| | | String siteName = site.getName(); |
| | | SendMessageDTO sendMessageDTO = new SendMessageDTO(); |
| | | sendMessageDTO.setPhone(site.getPhone()); |
| | | sendMessageDTO.setSite(site.getName()); |
| | | sendMessageDTO.setChargeGun(chargingPile.getNumber() + ""); |
| | | sendMessageDTO.setType(3); |
| | | String result = appUserClient.sendMessage(sendMessageDTO).getData(); |
| | | if(siteName.length()>10){ |
| | | siteName = siteName.substring(0,10); |
| | | } |
| | | chargingPileNotificationService.saveData(4,faultMessage.getSiteId(),faultMessage.getChargingPileId(),site.getPhone(),"检测到"+siteName+"..."+chargingPile.getNumber()+"号桩设备离线,请及时查看处理!"); |
| | | } |
| | | } |
| | | } |