| | |
| | | String gun_code = vo.getGun_code(); |
| | | //0:正常,1:故障,2=插枪 |
| | | Integer status = vo.getStatus(); |
| | | Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", (pile_code + gun_code)); |
| | | //小于3秒才处理数据,防止频繁查询数据 |
| | | // if(null != time && (System.currentTimeMillis() - time) < 3000){ |
| | | // return; |
| | | // } |
| | | TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != tChargingGun){ |
| | | //写入缓存数据,用于充电桩对接服务中限制频率 |
| | | redisTemplate.opsForHash().put("charging_gun_online", tChargingGun.getFullNumber(), System.currentTimeMillis()); |
| | | |
| | | |
| | | TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId()); |
| | | //枪处于离线或者故障,返回状态为正常,则修改其状态 |
| | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/realTimeUpdateChargingPileStatus") |
| | | public void realTimeUpdateChargingPileStatus(@RequestBody UpdateChargingPileStatusVo vo){ |
| | | String pile_code = vo.getPile_code(); |
| | | String gun_code = vo.getGun_code(); |
| | | //0:离线,1:故障,2:空闲,3:充电 |
| | | Integer status = vo.getStatus(); |
| | | TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != tChargingGun){ |
| | | TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId()); |
| | | Site site = siteService.getById(tChargingGun.getSiteId()); |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(getStatus(status, vo.getInsertionStatus())); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | tChargingGun.setStatus(tChargingGun1.getStatus()); |
| | | threadPoolExecutor.execute(()->{ |
| | | //上传成都监管 |
| | | chengDuJianGuanClient.notificationStationStatus(tChargingGun.getId()); |
| | | }); |
| | | if(site.getIsOpenSynchronization() == 1){ |
| | | threadPoolExecutor.execute(()->{ |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | pushConnectorStatus(tChargingGun); |
| | | }); |
| | | } |
| | | |
| | | if(tChargingGun1.getStatus() == 7){ |
| | | TFaultMessage faultMessage = new TFaultMessage(); |
| | | faultMessage.setSiteId(chargingPile.getSiteId()); |
| | | faultMessage.setChargingPileId(chargingPile.getId()); |
| | | faultMessage.setChargingGunId(tChargingGun.getId()); |
| | | faultMessage.setStatus(2); |
| | | faultMessage.setDownTime(LocalDateTime.now()); |
| | | faultMessage.setCreateTime(LocalDateTime.now()); |
| | | faultMessage.setDelFlag(false); |
| | | faultMessage.setContent("设备故障"); |
| | | faultMessageService.save(faultMessage); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private Integer getStatus(Integer status, Integer insertionStatus){ |
| | | switch (status){ |
| | | case 0: |
| | | return 1; |
| | | case 1: |
| | | return 7; |
| | | case 2: |
| | | return 0 == insertionStatus ? 2 : 3; |
| | | case 3: |
| | | return 0 == insertionStatus ? 2 : 4; |
| | | default: |
| | | return 7; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getAllPile") |