| | |
| | | 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; |
| | |
| | | private IotInterfaceClient iotInterfaceClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private TFaultMessageService faultMessageService; |
| | |
| | | |
| | | @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; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void updateStatus() { |
| | | Map<String, Object> charging_gun_online = redisService.getCacheMap("charging_gun_online"); |
| | | Set<String> keySet = charging_gun_online.keySet(); |
| | | List<TChargingGun> list = new ArrayList<>(); |
| | | if(keySet.size() > 0){ |
| | | list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getDelFlag, 0).in(TChargingGun::getFullNumber, keySet)); |
| | | } |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getDelFlag, 0)); |
| | | for (TChargingGun chargingGun : list) { |
| | | Long time = (Long) charging_gun_online.get(chargingGun.getFullNumber()); |
| | | //判断设备是否真的脸1分钟(1分钟+代码中的30秒间隔处理存储) |
| | | if(null != time && System.currentTimeMillis() - time > 90000){ |
| | | 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); |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(chargingGun1.getFullNumber(), chargingGun1.getStatus()); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(chargingGun1.getFullNumber(), chargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | |
| | | //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 |
| | | TChargingPile chargingPile = this.getById(chargingGun.getChargingPileId()); |