| | |
| | | @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){ |
| | | for (TChargingPile data : datas) { |
| | | TFaultMessage faultMessage = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, data.getId()) |
| | | 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); |
| | | } |
| | | |
| | | //添加记录 |
| | | TFaultMessage faultMessage = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingPile.getId()) |
| | | .eq(TFaultMessage::getStatus, 1).eq(TFaultMessage::getDelFlag, 0).isNull(TFaultMessage::getEndTime)); |
| | | if(null == faultMessage){ |
| | | faultMessage = new TFaultMessage(); |
| | | faultMessage.setSiteId(data.getSiteId()); |
| | | faultMessage.setChargingPileId(data.getId()); |
| | | faultMessage.setSiteId(chargingPile.getSiteId()); |
| | | faultMessage.setChargingPileId(chargingPile.getId()); |
| | | faultMessage.setStatus(1); |
| | | faultMessage.setDownTime(LocalDateTime.now()); |
| | | faultMessage.setCreateTime(LocalDateTime.now()); |
| | |
| | | faultMessageService.save(faultMessage); |
| | | } |
| | | } |
| | | this.updateBatchById(datas); |
| | | } |
| | | } |
| | | } |