| | |
| | | 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 |
| | |
| | | * @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); |
| | | |
| | |
| | | |
| | | 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) { |
| | |
| | | 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()); |
| | |
| | | CommonPage commonPage = CommonPage.restPage(lightReportDataBos); |
| | | commonPage.setTotal(stringCommonPage.getTotal()); |
| | | commonPage.setTotalPage(stringCommonPage.getTotalPage()); |
| | | commonPage.setPageNum(pageNo); |
| | | |
| | | return commonPage; |
| | | } |