| | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.dto.DeviceStatus; |
| | | import com.sandu.ximon.admin.dto.WaterQualityDataDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A1Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame; |
| | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.DeviceStateEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.param.*; |
| | | import com.sandu.ximon.admin.redis.LightKey; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.admin.utils.response.VnnoxResult; |
| | | import com.sandu.ximon.admin.vo.PoleBindVO; |
| | | import com.sandu.ximon.dao.bo.BroadcastTerminalV2EntityBo; |
| | | import com.sandu.ximon.dao.bo.MonitorBo; |
| | | import com.sandu.ximon.dao.domain.LedPlayerEntity; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleBinding; |
| | | import com.sandu.ximon.dao.domain.PoleGroupRelation; |
| | | import com.sandu.ximon.dao.bo.*; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.mapper.PoleMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private final PoleBindingService poleBindingService; |
| | | private final PoleGroupRelationService groupRelationService; |
| | | private final ClientService clientService; |
| | | private final PoleMapper poleMapper; |
| | | |
| | | public boolean addPole(PoleParam param) { |
| | | Pole pole = new Pole(); |
| | | BeanUtils.copyProperties(param, pole); |
| | | pole.setPoleCode(generatePoleCode()); |
| | | pole.setDeviceType(-1); |
| | | return save(pole); |
| | | } |
| | | |
| | |
| | | */ |
| | | public Map<String, Integer> poleCount() { |
| | | Map<String, Integer> result = new HashMap<>(); |
| | | List<Pole> list = new ArrayList<>(); |
| | | LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>(); |
| | | if (SecurityUtils.getClientId() == null) { |
| | | wrapper = Wrappers.lambdaQuery(Pole.class); |
| | |
| | | }); |
| | | } |
| | | //灯杆 |
| | | list = list(wrapper); |
| | | List<Pole> list = list(wrapper); |
| | | List<Pole> poles = isOnLine(list); |
| | | result.put("poleOnlineCount", poles.size()); |
| | | result.put("poleTotalCount", list.size()); |
| | |
| | | result.put("novaTotalCount", ledPlayerEntities.size()); |
| | | |
| | | //ip音柱 |
| | | number = 0; |
| | | BroadcastTerminalV2Param broadcastTerminalV2Param = new BroadcastTerminalV2Param(); |
| | | broadcastTerminalV2Param.setBindingState(2); |
| | | broadcastTerminalV2Param.setWorkState(-1); |
| | | List<BroadcastTerminalV2EntityBo> broadcastTerminalList = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, broadcastTerminalV2Param); |
| | | number = 0; |
| | | broadcastTerminalV2Param.setWorkState(2); |
| | | List<BroadcastTerminalV2EntityBo> broadcastTerminalList |
| | | = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalList(null, broadcastTerminalV2Param); |
| | | for (BroadcastTerminalV2EntityBo bean : broadcastTerminalList) { |
| | | if (bean.getStatus() == 1 || bean.getStatus() == 0) { |
| | | number++; |
| | |
| | | } |
| | | result.put("broadcastOnlineCount", number); |
| | | result.put("broadcastTotalCount", broadcastTerminalList.size()); |
| | | number = 0; |
| | | |
| | | //摄像头 |
| | | number = 0; |
| | | MonitorParam monitorParam = new MonitorParam(); |
| | | monitorParam.setEquipmentState(2); |
| | | monitorParam.setBindingState(2); |
| | |
| | | result.put("monitorTotalCount", monitorBos.size()); |
| | | |
| | | //单灯 |
| | | number = 0; |
| | | List<Light> lights = SpringContextHolder.getBean(LightService.class).listLight(); |
| | | for (Light light : lights) { |
| | | if (light.getOnlineStatus() == 1) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("LightOnlineCount", number); |
| | | result.put("LightTotalCount", lights.size()); |
| | | |
| | | //充电桩 |
| | | number = 0; |
| | | List<C3ChargingBo> c3mChargings = SpringContextHolder.getBean(C3ChargingService.class).getC3ChargingListByKeyword(null, null); |
| | | for (C3ChargingBo c3ChargingBo : c3mChargings) { |
| | | if (c3ChargingBo.getStatusBit() != 0) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("C3ChargingOnlineCount", number); |
| | | result.put("C3ChargingTotalCount", c3mChargings.size()); |
| | | |
| | | |
| | | //大气 |
| | | number = 0; |
| | | List<AirEquipmentBo> airEquipments = SpringContextHolder.getBean(AirEquipmentService.class).listAirEquipmentByKeyword(null, null); |
| | | for (AirEquipmentBo airEquipmentBo : airEquipments) { |
| | | if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT.getCode() + airEquipmentBo.getMac()) != null) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("AirEquipmentOnlineCount", number); |
| | | result.put("AirEquipmentTotalCount", airEquipments.size()); |
| | | //大气(农耕) |
| | | number = 0; |
| | | List<AirEquipmentNongGengBo> airEquipmentNongGengBos = SpringContextHolder.getBean(AirEquipmentNongGengService.class).listAirEquipmentByKeyword(null, null); |
| | | for (AirEquipmentNongGengBo airEquipmentNongGengBo : airEquipmentNongGengBos) { |
| | | if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG.getCode() + airEquipmentNongGengBo.getMac()) != null) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("AirEquipmentNongGengOnlineCount", number); |
| | | result.put("AirEquipmentNongGengTotalCount", airEquipmentNongGengBos.size()); |
| | | //水质 |
| | | number = 0; |
| | | List<WaterQualityEquipmentBo> waterQualityEquipments |
| | | = SpringContextHolder.getBean(WaterQualityEquipmentService.class).listWaterQualityEquipmentByKeyword(null, null); |
| | | |
| | | for (WaterQualityEquipmentBo waterQualityEquipmentBo : waterQualityEquipments) { |
| | | WaterQualityDataDto waterQualityDataDto |
| | | = SpringContextHolder.getBean(WaterQualityDataService.class).getWaterQualityDataInfo(waterQualityEquipmentBo.getWaterQualityEquipmentCode()); |
| | | if (waterQualityDataDto != null) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("WaterQualityEquipmentOnlineCount", number); |
| | | result.put("WaterQualityEquipmentTotalCount", waterQualityEquipments.size()); |
| | | //灯杆倾斜 |
| | | number = 0; |
| | | List<LightPoleHeeling> lightPoleHeelings |
| | | = SpringContextHolder.getBean(LightPoleHeelingService.class).listLightPoleHeelingByKeyword(null, null); |
| | | |
| | | for (LightPoleHeeling lightPoleHeeling : lightPoleHeelings) { |
| | | if (RedisUtils.getBean().get(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + lightPoleHeeling.getMac()) != null) { |
| | | number++; |
| | | } |
| | | } |
| | | result.put("LightPoleHeelingOnlineCount", number); |
| | | result.put("LightPoleHeelingTotalCount", lightPoleHeelings.size()); |
| | | |
| | | //熙讯 |
| | | List<PoleLightemitEntity> poleLightemitEntities = SpringContextHolder.getBean(PoleLightemitService.class).listLed(null, false); |
| | | List<PoleLightemitEntity> poleLightemitEntityOnlineList = SpringContextHolder.getBean(PoleLightemitService.class).ledOnline(poleLightemitEntities); |
| | | |
| | | result.put("XiXunOnlineCount", poleLightemitEntityOnlineList.size()); |
| | | result.put("XiXunTotalCount", poleLightemitEntities.size()); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public List<Pole> queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) { |
| | | |
| | | List<Pole> list = new ArrayList<>(); |
| | | LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>(); |
| | | if (SecurityUtils.getClientId() == null) { |
| | |
| | | public Pole getPoleByMac(Long poleId) { |
| | | Pole one = getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId)); |
| | | ArrayList<String> macs = new ArrayList<>(); |
| | | |
| | | macs.add(one.getDeviceCode()); |
| | | List<DeviceStatus> deviceStatuses = listStatusByDeviceCode(macs); |
| | | if (deviceStatuses.get(0).getStatus() == 0) { |
| | | if (one.getDeviceCode() == null || one.getDeviceType() == null || one.getDeviceType() == -1) { |
| | | one.setOnLineState("虚拟灯杆"); |
| | | } else if (deviceStatuses.get(0).getStatus() == 0) { |
| | | one.setOnLineState("离线"); |
| | | } else if (deviceStatuses.get(0).getStatus() == 1) { |
| | | one.setOnLineState("在线"); |
| | |
| | | } |
| | | return one; |
| | | } |
| | | |
| | | // /** |
| | | // * 用户总单灯节能率 |
| | | // */ |
| | | // public Double getPoleEnergy() { |
| | | // Double energy = 0.0; |
| | | // |
| | | // |
| | | // return energy; |
| | | // } |
| | | |
| | | |
| | | public boolean updateDeviceCode(Long poleId) { |
| | | return poleMapper.updateDeviceCode(poleId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送大气监测数据到novaLED |
| | | */ |
| | | public boolean pushAirDataToXiXun(Long poleId) { |
| | | Pole pole = getById(poleId); |
| | | PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3)); |
| | | PoleBinding xixun = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 10)); |
| | | if (pole == null) { |
| | | throw new BusinessException("灯杆不存在"); |
| | | } |
| | | if (air == null) { |
| | | throw new BusinessException("未绑定大气监测设备"); |
| | | } |
| | | if (xixun == null) { |
| | | throw new BusinessException("未绑定xixun设备"); |
| | | } |
| | | //获取大气监测数据 |
| | | A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId); |
| | | //推送数据 |
| | | return SpringContextHolder.getBean(XiXunPlayerService.class).pushWeather(xixun.getDeviceCode(), data, pole); |
| | | } |
| | | |
| | | /** |
| | | * 推送大气监测数据到novaLED |
| | | */ |
| | | public VnnoxResult pushAirDataToNova(Long poleId) { |
| | | Pole pole = getById(poleId); |
| | | PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3)); |
| | | PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1)); |
| | | LedPlayerEntity LED = SpringContextHolder.getBean(LedPlayerEntityService.class).getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, nova.getDeviceCode())); |
| | | if (pole == null) { |
| | | throw new BusinessException("灯杆不存在"); |
| | | } |
| | | if (air == null) { |
| | | throw new BusinessException("未绑定大气监测设备"); |
| | | } |
| | | if (nova == null) { |
| | | throw new BusinessException("未绑定nova设备"); |
| | | } |
| | | //获取大气监测数据 |
| | | A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId); |
| | | //推送数据 |
| | | return SpringContextHolder.getBean(VnnoxService.class).publishWaterData(LED.getPlayerId(), data); |
| | | } |
| | | |
| | | |
| | | } |