| | |
| | | import com.sandu.ximon.admin.config.RealtimeServerBean; |
| | | import com.sandu.ximon.admin.entity.*; |
| | | import com.sandu.ximon.admin.param.PoleBindingParam; |
| | | import com.sandu.ximon.admin.redis.DeviceRedisKey; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.*; |
| | | import com.sandu.ximon.admin.vo.EquipmentInfomation; |
| | | import com.sandu.ximon.admin.vo.RedisDeviceStatus; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | LedSFileService xiXunFileService; |
| | | |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | |
| | | } |
| | | |
| | | |
| | | @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("设备不存在"); |
| | | } |
| | | |
| | |
| | | Map map = JSON.parseObject(requestBody, Map.class); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 向Redis中存入设备状态 |
| | | */ |
| | | public void setCacheData() { |
| | | 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(), JSON.toJSONString(deviceStatus)); |
| | | // redisUtils.delete(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode()); |
| | | } |
| | | ); |
| | | } |
| | | } |