| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.redis.RedisService; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.dto.LightTaskDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightBrightnessReqInnerFrame; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | for (LightBo lightBo : listLight) { |
| | | deviceCodeList.forEach(code -> { |
| | | PoleBinding bind = bindingService.getPoleIdByMac(code); |
| | | if (bind != null&&lightBo.getDeviceCode().equals(bind.getDeviceCode())) { |
| | | if (bind != null && lightBo.getDeviceCode().equals(bind.getDeviceCode())) { |
| | | Long poleId = bind.getPoleId(); |
| | | Pole pole = poleService.getById(poleId); |
| | | lightBo.setPoleId(pole.getId()); |
| | | lightBo.setPoleCode(pole.getDeviceCode()); |
| | | lightBo.setPoleName(pole.getPoleName()); |
| | | Pole pole = poleService.getById(poleId); |
| | | lightBo.setPoleId(pole.getId()); |
| | | lightBo.setPoleCode(pole.getDeviceCode()); |
| | | lightBo.setPoleName(pole.getPoleName()); |
| | | } |
| | | } |
| | | ); |
| | |
| | | |
| | | /** |
| | | * 获取单个路灯信息 |
| | | * |
| | | * @param deviceCode 设备码 |
| | | * @return |
| | | */ |
| | |
| | | Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode)); |
| | | if (o != null) { |
| | | one.setOnlineStatus(1); |
| | | }else { |
| | | } else { |
| | | one.setOnlineStatus(0); |
| | | } |
| | | return one; |
| | |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | /** |
| | | * 单灯节能率 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<LightReportData> controlEnergySaving() { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | // List<LightBo> listLight = baseMapper.listLight(clientId, null); |
| | | // List<String> deviceCodeList = listLight.stream().map(LightBo::getDeviceCode).collect(Collectors.toList()); |
| | | |
| | | List<LightTaskDto> lightTaskDtos = SpringContextHolder.getBean(LightTaskService.class).listLightTask(null, null); |
| | | lightTaskDtos.forEach(Task -> { |
| | | |
| | | |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 解析开关灯指令 |
| | | */ |
| | | public void parseSwitchLightCommand(String command) { |
| | | char[] chars = command.toCharArray(); |
| | | if(chars.length==7){ |
| | | int hour = Integer.valueOf(command.substring(0,2)); |
| | | int min = Integer.valueOf(command.substring(2,4)); |
| | | int brightness = Integer.valueOf(command.substring(4,7)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 用户拥有的路灯 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<Light> listLight() { |
| | | List<LightBo> listLight; |
| | | if (SecurityUtils.getClientId() != null) { |
| | | listLight = baseMapper.listLight(SecurityUtils.getUserId(), null); |
| | | } else { |
| | | listLight = baseMapper.listLight(null, null); |
| | | } |
| | | List<Light> lightList = new ArrayList<>(); |
| | | for (LightBo bean : listLight) { |
| | | Light light = getLight(bean.getDeviceCode()); |
| | | lightList.add(light); |
| | | } |
| | | return lightList; |
| | | } |
| | | |
| | | } |