From 81dc94a70de69f45f42b8ca4b702a3a372cf81ac Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Tue, 24 May 2022 09:59:07 +0800 Subject: [PATCH] 去除打印 --- src/main/java/com/moral/task/RabbitMQInsertQiandengPark.java | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/moral/task/RabbitMQInsertQiandengPark.java b/src/main/java/com/moral/task/RabbitMQInsertQiandengPark.java index 38d629d..ccaa6d5 100644 --- a/src/main/java/com/moral/task/RabbitMQInsertQiandengPark.java +++ b/src/main/java/com/moral/task/RabbitMQInsertQiandengPark.java @@ -1,6 +1,9 @@ package com.moral.task; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.moral.entity.History; +import com.moral.mapper.HistoryMapper; import com.moral.service.*; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; @@ -15,12 +18,19 @@ import org.springframework.util.ObjectUtils; import javax.annotation.Resource; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; +/** + * @program: screen_job + * @description: ������������������������������������ + * @author: lizijie + * @create: 2022-05-13 08:58 + **/ @Component public class RabbitMQInsertQiandengPark { private static transient Logger logger = LoggerFactory.getLogger(RabbitMQInsertQiandengPark.class); @@ -36,6 +46,9 @@ @Resource private HistoryHourlyService historyHourlyService; + + @Resource + private HistoryMapper historyMapper; @Resource private OrganizationRelationService organizationRelationService; @@ -88,6 +101,16 @@ devices.put("macs", macList); devices.put("yearAndMonth", yearAndMonth); List<Map<String, Object>> minutelyData = historyMinutelyService.getMinutelySensorData(devices); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String yearMonthDay = sdf.format(new Date()); + History guodu = historyMapper.selectLastDataByMac(yearMonthDay, "jsxlqxpc000001"); + History baihua = historyMapper.selectLastDataByMac(yearMonthDay, "jsxlqxpc000002"); + Map<String,Object> guoduValue = JSONObject.parseObject(guodu.getValue().toString()); + JSONObject baihuaValue = JSONObject.parseObject(baihua.getValue().toString()); + guoduValue.put("mac","jsxlqxpc000001"); + baihuaValue.put("mac","jsxlqxpc000002"); + minutelyData.add(guoduValue); + minutelyData.add(baihuaValue); XxlJobLogger.log("RabbitMQMinutelyData:" + minutelyData.size()); if (!CollectionUtils.isEmpty(minutelyData)) { for (Map<String, Object> deviceData : minutelyData) { @@ -145,6 +168,16 @@ devices.put("end", endTime); devices.put("macs", macList); List<Map<String, Object>> minutelyData = historyHourlyService.getHourlySensorData(devices); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String yearMonthDay = sdf.format(new Date()); + History guodu = historyMapper.selectLastDataByMac(yearMonthDay, "jsxlqxpc000001"); + History baihua = historyMapper.selectLastDataByMac(yearMonthDay, "jsxlqxpc000002"); + Map<String,Object> guoduValue = JSONObject.parseObject(guodu.getValue().toString()); + JSONObject baihuaValue = JSONObject.parseObject(baihua.getValue().toString()); + guoduValue.put("mac","jsxlqxpc000001"); + baihuaValue.put("mac","jsxlqxpc000002"); + minutelyData.add(guoduValue); + minutelyData.add(baihuaValue); XxlJobLogger.log("RabbitMQHourlyData:" + minutelyData.size()); if (!CollectionUtils.isEmpty(minutelyData)) { for (Map<String, Object> deviceData : minutelyData) { @@ -164,8 +197,6 @@ Map organizationIdMapNew = JSON.parseObject(params); List<Integer> parentIdListNew = (List<Integer>) organizationIdMapNew.get("orgId"); List<Integer> intersection = parentIdListNew.stream().filter(item -> parentIds.contains(item)).collect(Collectors.toList()); - System.out.println(deviceData); - System.out.println(intersection); intersection.stream().forEach(parentId -> rabbitTemplate.convertAndSend(organization_data.getName(), "QiandengPark" + "." + mac, JSON.toJSONString(deviceData))); } } @@ -180,7 +211,4 @@ ReturnT returnT = new ReturnT(500, "RabbitMQ������������������������"); return returnT; } - } - - -- Gitblit v1.8.0