| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class TChargingPileServiceImpl extends ServiceImpl<TChargingPileMapper, TChargingPile> implements TChargingPileService { |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void updateStatus() { |
| | | 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()); |
| | | //判断设备是否真的离线5分钟 |
| | | //查询出redis集合汇总符合条件的数据 |
| | | Set keys = redisTemplate.opsForHash().keys("charging_gun_online"); |
| | | List<String> fullNumbers = new ArrayList<>(); |
| | | keys.forEach(key -> { |
| | | Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", key); |
| | | if(null != time && System.currentTimeMillis() - time > 300000){ |
| | | log.info("设备编号:{}已离线", key); |
| | | log.info("间隔时间", System.currentTimeMillis() - time); |
| | | fullNumbers.add(key.toString()); |
| | | } |
| | | }); |
| | | if(fullNumbers.size() == 0){ |
| | | return; |
| | | } |
| | | |
| | | //处理符合条件的数据,修改设备状态 |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getFullNumber, fullNumbers).eq(TChargingGun::getDelFlag, 0)); |
| | | for (TChargingGun chargingGun : list) { |
| | | TChargingGun chargingGun1 = new TChargingGun(); |
| | | chargingGun1.setId(chargingGun.getId()); |
| | | chargingGun1.setStatus(1); |
| | |
| | | siteName = siteName.substring(0,10); |
| | | } |
| | | chargingPileNotificationService.saveData(4,faultMessage.getSiteId(),faultMessage.getChargingPileId(),site.getPhone(),"检测到"+siteName+"..."+chargingPile.getNumber()+"号桩设备离线,请及时查看处理!"); |
| | | } |
| | | } |
| | | } |
| | | } |