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/resources/mapper/AlarmMapper.xml | 40 ++++++++++++++++++++++------------------
1 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/main/resources/mapper/AlarmMapper.xml b/src/main/resources/mapper/AlarmMapper.xml
index 210ab59..e58a8b6 100644
--- a/src/main/resources/mapper/AlarmMapper.xml
+++ b/src/main/resources/mapper/AlarmMapper.xml
@@ -1,25 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.AlarmMapper">
- <select id="getAvgAlarmData" resultType="java.util.LinkedHashMap">
+ <select id="getAlarmData" resultType="java.util.LinkedHashMap">
SELECT
- a.mac,
- max(a.state) state
- <foreach collection="sensorKeys" open="," separator="," item="sensorKey">
- AVG(a.json->'$.${sensorKey}[0]') AS '${sensorKey}'
- </foreach>
+ json_search ( json, 'all', '1' ) '1',
+ json_search ( json, 'all', '2' ) '2',
+ json_search ( json, 'all', '3' ) '3'
FROM
- alarm_${yearAndMonth} a
+ alarm_${yearAndMonth}
WHERE
- a.time >= #{start}
- AND a.time <![CDATA[<]]> #{end}
- AND a.mac in
- <foreach collection="macs" open="(" separator="," close=")"
- item="mac">
- #{mac}
- </foreach>
- group by
- a.mac
+ time >= #{start}
+ AND time <![CDATA[<]]> #{end}
+ AND mac =#{mac}
+ </select>
+
+ <select id="getMacs" resultType="java.lang.String">
+ SELECT
+ mac
+ FROM
+ alarm_${yearAndMonth}
+ where
+ time >= #{start}
+ AND time <![CDATA[<]]> #{end}
+ GROUP BY
+ mac
</select>
<insert id="insertAlarmDaily">
@@ -32,8 +36,8 @@
</insert>
<update id="createTable">
- CREATE TABLE `alarm_${yearAndMonth}` (
- `mac` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
+ CREATE TABLE IF NOT EXISTS `alarm_${yearAndMonth}` (
+ `mac` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
`json` json DEFAULT NULL,
`state` int(2) DEFAULT NULL,
`time` datetime DEFAULT NULL,
--
Gitblit v1.8.0