| | |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.io.File; |
| | |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void savePoleLightemit(PoleLightemitEntity poleLightemit) { |
| | | boolean save = this.save(poleLightemit); |
| | | // 绑定灯杆 |
| | |
| | | if (save && poleLightemit.getStreetlightId() != null) { |
| | | PoleBindingParam poleBindingParam = new PoleBindingParam(); |
| | | poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode()); |
| | | poleBindingParam.setDeviceType(1); |
| | | poleBindingParam.setDeviceType(10); |
| | | poleBindingParam.setDeviceName(poleLightemit.getLightemitName()); |
| | | poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | |
| | | if (SpringContextHolder.getBean(PoleService.class).getById(poleLightemit.getStreetlightId()) == null) { |
| | | throw new BusinessException("灯杆不存在"); |
| | | } |
| | | boolean b = poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | } |
| | | |
| | | /** |
| | |
| | | public boolean deletePoleLightemit(List<Long> ledIds) { |
| | | |
| | | List<PoleLightemitEntity> poleLightemitEntities = listByIds(ledIds); |
| | | if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) { |
| | | if (poleLightemitEntities != null && poleLightemitEntities.size() == 0) { |
| | | throw new BusinessException("设备不存在"); |
| | | } |
| | | |
| | |
| | | list().forEach( |
| | | xiXun -> { |
| | | RedisDeviceStatus deviceStatus = new RedisDeviceStatus(); |
| | | deviceStatus.setDeviceId(xiXun.getLightemitControlCode()); |
| | | boolean ledOnLine = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode()); |
| | | if (ledOnLine) { |
| | | deviceStatus.setStatus(0); |
| | | } else { |
| | | deviceStatus.setStatus(1); |
| | | } |
| | | redisUtils.set(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode(), deviceStatus); |
| | | redisUtils.set(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode(), JSON.toJSONString(deviceStatus)); |
| | | // redisUtils.delete(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode()); |
| | | } |
| | | ); |
| | | } |