2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-04-29 f02ad2926c2b5a2576e75c2cd6611862e9ec8cea
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -37,10 +37,9 @@
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;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
 * @author chenjiantian
@@ -60,10 +59,22 @@
     * @return 是否成功
     */
    public boolean saveReportData(String deviceName, A5LightHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) {
//        LightReportData lightReportData = RedisUtils.getBean().get(A5LightDataEnum.LIGHT_HEART_BEAT.getCode() + deviceName, LightReportData.class);
        String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss"));
        LightReportData lightReportData = new LightReportData();
        if (lightReportData == null) {
            lightReportData = new LightReportData();
            lightReportData.setCreateTime(format);
        }
        //todo
        lightReportData.setCreateTime(format);
        BeanUtils.copyProperties(heartBeatDataPackage, lightReportData);
        lightReportData.setDeviceCode(deviceName);
        lightReportData.setUpdateTime(format);
        //单灯数据保存到缓存里
        RedisUtils.getBean().set(A5LightDataEnum.LIGHT_HEART_BEAT.getCode() + deviceName, lightReportData);
@@ -90,10 +101,10 @@
        List<LightReportDataBo> lightReportDataBos = new ArrayList<>(pageSize);
        CommonPage<String> stringCommonPage = SpringContextHolder.getBean(LightService.class).listDeviceCode(pageNo, pageSize);
        CommonPage<String> stringCommonPage = SpringContextHolder.getBean(LightService.class).listDeviceCode(pageNo, pageSize, keyword, deviceCode);
        List<String> macList = stringCommonPage.getList();
        if (CollUtil.isEmpty(macList)) {
            return  new CommonPage();
            return new CommonPage();
        }
        for (String macCode : macList) {
@@ -105,7 +116,7 @@
                if (lightReportData != null) {
                    BeanUtils.copyProperties(lightReportData, lightReportDataBo);
                }
                lightReportDataBo.setDeviceCode(macCode);
                Pole pole = SpringContextHolder.getBean(PoleService.class).getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, macCode));
                if (pole != null) {
                    lightReportDataBo.setPoleName(pole.getPoleName());
@@ -120,6 +131,7 @@
        CommonPage commonPage = CommonPage.restPage(lightReportDataBos);
        commonPage.setTotal(stringCommonPage.getTotal());
        commonPage.setTotalPage(stringCommonPage.getTotalPage());
        commonPage.setPageNum(pageNo);
        return commonPage;
    }