| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.common.file.config.FileProperties; |
| | |
| | | import com.sandu.common.util.ResUtils; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5LightDataEnum; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.bo.LightReportDataBo; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | |
| | | import java.io.File; |
| | | import java.sql.Wrapper; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | |
| | | BeanUtils.copyProperties(heartBeatDataPackage, lightReportData); |
| | | lightReportData.setDeviceCode(deviceName); |
| | | |
| | | //单灯数据保存到缓存里 |
| | | RedisUtils.getBean().set(A5LightDataEnum.LIGHT_HEART_BEAT.getCode() + deviceName, lightReportData); |
| | | |
| | | return save(lightReportData); |
| | | } |
| | | |
| | |
| | | * @param keyword 关键词 |
| | | * @param deviceCode 设备码 |
| | | */ |
| | | public List<LightReportDataBo> listReportData(int pageNo, int pageSize, String keyword, String deviceCode) { |
| | | PageHelper.startPage(pageNo, pageSize); |
| | | //为null的话是超管 |
| | | if (SecurityUtils.getClientId() == null) { |
| | | return baseMapper.listReportData(keyword, deviceCode); |
| | | } else { |
| | | return baseMapper.listReportDataByUserid(keyword, deviceCode, SecurityUtils.getUserId()); |
| | | public CommonPage listReportData(int pageNo, int pageSize, String keyword, String deviceCode) { |
| | | |
| | | List<LightReportDataBo> lightReportDataBos = new ArrayList<>(pageSize); |
| | | |
| | | CommonPage<String> stringCommonPage = SpringContextHolder.getBean(LightService.class).listDeviceCode(pageNo, pageSize); |
| | | List<String> macList = stringCommonPage.getList(); |
| | | if (CollUtil.isEmpty(macList)) { |
| | | return new CommonPage(); |
| | | } |
| | | |
| | | for (String macCode : macList) { |
| | | try { |
| | | LightReportData lightReportData |
| | | = JSON.parseObject(RedisUtils.getBean().get(A5LightDataEnum.LIGHT_HEART_BEAT.getCode() + macCode), LightReportData.class); |
| | | |
| | | LightReportDataBo lightReportDataBo = new LightReportDataBo(); |
| | | if (lightReportData != null) { |
| | | BeanUtils.copyProperties(lightReportData, lightReportDataBo); |
| | | } |
| | | |
| | | Pole pole = SpringContextHolder.getBean(PoleService.class).getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, macCode)); |
| | | if (pole != null) { |
| | | lightReportDataBo.setPoleName(pole.getPoleName()); |
| | | } |
| | | lightReportDataBos.add(lightReportDataBo); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | CommonPage commonPage = CommonPage.restPage(lightReportDataBos); |
| | | commonPage.setTotal(stringCommonPage.getTotal()); |
| | | commonPage.setTotalPage(stringCommonPage.getTotalPage()); |
| | | |
| | | return commonPage; |
| | | } |
| | | |
| | | @SneakyThrows |