From 45ece9986a39a01081fab9b224966e1f297d383d Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 06 Jan 2022 13:40:20 +0800 Subject: [PATCH] 修改建表mac字段长度 --- src/main/resources/mapper/AlarmMapper.xml | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/resources/mapper/AlarmMapper.xml b/src/main/resources/mapper/AlarmMapper.xml index 7a7c6b0..e58a8b6 100644 --- a/src/main/resources/mapper/AlarmMapper.xml +++ b/src/main/resources/mapper/AlarmMapper.xml @@ -3,15 +3,27 @@ <mapper namespace="com.moral.mapper.AlarmMapper"> <select id="getAlarmData" resultType="java.util.LinkedHashMap"> SELECT - mac - <foreach collection="sensorKeys" open="," separator="," item="sensorKey"> - 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} WHERE 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"> @@ -25,7 +37,7 @@ <update id="createTable"> CREATE TABLE IF NOT EXISTS `alarm_${yearAndMonth}` ( - `mac` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `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