| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.gson.Gson; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.NginxConfigBean; |
| | | 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.utils.Constant; |
| | | import com.sandu.ximon.admin.utils.FileUtil; |
| | | import com.sandu.ximon.admin.utils.HtmlTemplateUtils; |
| | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | | * 熙讯设备 |
| | | */ |
| | | @Service |
| | | @EnableCaching |
| | | public class PoleLightemitService extends BaseServiceImpl<PoleLightemitEntityMapper, PoleLightemitEntity> { |
| | | |
| | | @Autowired |
| | | private PoleBindingService poleBindingService; |
| | | // @Autowired |
| | | // PoleStreetlightLightemitService poleStreetlightLightemitService; |
| | | |
| | |
| | | } |
| | | */ |
| | | |
| | | /* public void ledOnlineCheck(List<PoleLightemitEntity> list) { |
| | | |
| | | for(PoleLightemitEntity poleLightemitEntity : list){ |
| | | public List<PoleLightemitEntity> ledOnline(List<PoleLightemitEntity> list) { |
| | | List<PoleLightemitEntity> onLineList = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | if (poleLightemitEntity.getIsOpen()) { |
| | | onLineList.add(poleLightemitEntity); |
| | | } |
| | | } |
| | | }*/ |
| | | return onLineList; |
| | | } |
| | | |
| | | |
| | | public void ledOnlineCheck(List<PoleLightemitEntity> list) { |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | public PoleLightemitEntity getLedByLightControlCode(String lightControlCode) { |
| | | PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode)); |
| | | if(xiXun==null){ |
| | | return null; |
| | | } |
| | | String isScreenOpen = lightemitUtils.getIsScreenOpen(xiXun.getLightemitControlCode()); |
| | | if(isScreenOpen.contains("true")){ |
| | | xiXun.setIsOpen(true); |
| | | } |
| | | xiXun.setIsOpen(false); |
| | | return xiXun; |
| | | } |
| | | |
| | | |
| | | public void savePoleLightemit(PoleLightemitEntity poleLightemit) { |
| | | boolean save = this.save(poleLightemit); |
| | | // 绑定灯杆 |
| | | |
| | | if(save&&poleLightemit.getStreetlightId()!=null){ |
| | | System.out.println("-------------"); |
| | | if (save && poleLightemit.getStreetlightId() != null) { |
| | | PoleBindingParam poleBindingParam = new PoleBindingParam(); |
| | | poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode()); |
| | | poleBindingParam.setDeviceType(1); |
| | | poleBindingParam.setDeviceName(poleLightemit.getLightemitName()); |
| | | poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | } |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | | |
| | | |
| | | public void updatePoleLightemit(Long ledId,PoleLightemitEntity poleLightemit) { |
| | | public void updatePoleLightemit(Long ledId, PoleLightemitEntity poleLightemit) { |
| | | PoleLightemitEntity byId = getById(ledId); |
| | | if(byId==null){ |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到LED屏"); |
| | | } |
| | | poleLightemit.setLightemitId(ledId); |
| | | boolean b = this.updateById(poleLightemit); |
| | | // 绑定灯杆 |
| | | |
| | | if(b&&poleLightemit.getStreetlightId()!=null){ |
| | | System.out.println("-------------"); |
| | | if (b && poleLightemit.getStreetlightId() != null) { |
| | | //先删除绑定关系 |
| | | poleBindingService.unBindPole(null, poleLightemit.getLightemitControlCode()); |
| | | //再绑定 |
| | | PoleBindingParam poleBindingParam = new PoleBindingParam(); |
| | | poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode()); |
| | | poleBindingParam.setDeviceType(1); |
| | | poleBindingParam.setDeviceName(poleLightemit.getLightemitName()); |
| | | poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam); |
| | | } |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | | |
| | | public boolean deletePoleLightemit(List<Long> ledIds) { |
| | | |
| | | List<PoleLightemitEntity> poleLightemitEntities = listByIds(ledIds); |
| | | |
| | | // 删除设备绑定 |
| | | if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) { |
| | | for (PoleLightemitEntity poleLightemitEntitie : poleLightemitEntities) { |
| | | if (poleLightemitEntitie.getLightemitControlCode() != null) { |
| | | //删除绑定关系//先删除绑定关系 |
| | | poleBindingService.unBindPole(poleLightemitEntitie.getLightemitControlCode()); |
| | | } |
| | | } |
| | | } |
| | | //删除设备 |
| | | boolean b = removeByIds(ledIds); |
| | | |
| | | // 绑定灯杆 |
| | | |
| | | // if(b&&byId.getStreetlightId()!=null){ |
| | | // //删除绑定关系 |
| | | // System.out.println("-------------"); |
| | | // } |
| | | return b; |
| | | // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId()); |
| | | } |
| | |
| | | public void setVolume(String lightemitControlCode, Integer volume) { |
| | | lightemitUtils.setVoiume(lightemitControlCode, volume); |
| | | } |
| | | /* |
| | | 根据led屏编码设置音量 |
| | | */ |
| | | |
| | | @Async("taskExecutor") |
| | | public void setBrightness(String lightemitControlCode, Integer brightness) { |
| | | lightemitUtils.setBrightness(lightemitControlCode, brightness); |
| | | } |
| | | |
| | | |
| | | |
| | | // public List<PoleLightemitEntity> listOfStreetlight(String streetlightId) { |