From fa16c6b352312b5b50145d4c2708f13a05467e79 Mon Sep 17 00:00:00 2001 From: zch Date: Tue, 9 Jun 2026 15:29:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DSQL=20Server=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E8=A7=84=E5=88=99=E5=86=B2=E7=AA=81=E5=B9=B6=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E5=BC=82=E5=B8=B8=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 COLLATE DATABASE_DEFAULT 解决 SQL Server JOIN 和 COALESCE 排序规则冲突 - 排除位移异常标记值 9999999.0000 - 修正湿度有效范围上限为 99 - 修正位移字段名为 displacement - 收紧温度过滤范围为 0-79 --- .../ems/record/RecordIotenvInstantMapper.xml | 58 ++++----- .../ems/report/DisplacementBoardMapper.xml | 39 ++++-- .../mapper/ems/report/TempBoardMapper.xml | 119 ++++++++++-------- .../ems/report/VibrationBoardMapper.xml | 32 ++++- 4 files changed, 153 insertions(+), 95 deletions(-) diff --git a/ruoyi-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml b/ruoyi-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml index 0be44a4..3c01c11 100644 --- a/ruoyi-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml +++ b/ruoyi-ems/src/main/resources/mapper/ems/record/RecordIotenvInstantMapper.xml @@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" noise, concentration, vibration_speed, - vibration_displacement, + displacement as vibration_displacement, vibration_acceleration, vibration_temp, collectTime, @@ -136,12 +136,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -403,10 +403,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT t1.objid, t1.monitorId, t1.temperature, t1.humidity, t1.illuminance, t1.noise, t1.concentration, t1.vibration_speed, t1.vibration_displacement, t1.vibration_acceleration, t1.vibration_temp, t1.collectTime, t1.recodeTime, - COALESCE(ebmi.monitor_name, t1.monitorId) AS monitor_name, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t1.monitorId COLLATE DATABASE_DEFAULT) AS monitor_name, t1.monitorId AS monitor_code FROM ${tableName} t1 - LEFT JOIN ems_base_monitor_info ebmi ON t1.monitorId = ebmi.monitor_code + LEFT JOIN ems_base_monitor_info ebmi ON t1.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT INNER JOIN ( SELECT monitorId, MAX(objid) as max_objid FROM ${tableName} @@ -425,10 +425,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT t.objid, t.monitorId, t.temperature, t.humidity, t.illuminance, t.noise, t.concentration, t.vibration_speed, t.vibration_displacement, t.vibration_acceleration, t.vibration_temp, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitor_name, - t.monitorId AS monitor_code + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitor_name, + t.monitorId AS monitor_code FROM ${tableName} t - LEFT JOIN ems_base_monitor_info ebmi ON t.monitorId = ebmi.monitor_code + LEFT JOIN ems_base_monitor_info ebmi ON t.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT AND t.monitorId IN @@ -459,10 +459,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" t1.objid, t1.monitorId, t1.temperature, t1.humidity, t1.illuminance, t1.noise, t1.concentration, t1.vibration_speed, t1.vibration_displacement, t1.vibration_acceleration, t1.vibration_temp, t1.collectTime, t1.recodeTime, - COALESCE(ebmi.monitor_name, t1.monitorId) AS monitor_name, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t1.monitorId COLLATE DATABASE_DEFAULT) AS monitor_name, t1.monitorId AS monitor_code FROM ${tableName} t1 - LEFT JOIN ems_base_monitor_info ebmi ON t1.monitorId = ebmi.monitor_code + LEFT JOIN ems_base_monitor_info ebmi ON t1.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT INNER JOIN ( SELECT monitorId, time_slot, MAX(recodeTime) AS max_time FROM ( @@ -485,7 +485,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) as time_slot, t.recodeTime FROM ${tableName} t - LEFT JOIN ems_base_monitor_info ebmi2 ON t.monitorId = ebmi2.monitor_code + LEFT JOIN ems_base_monitor_info ebmi2 ON t.monitorId COLLATE DATABASE_DEFAULT = ebmi2.monitor_code COLLATE DATABASE_DEFAULT AND t.monitorId = #{recordIotenvInstant.monitorId} @@ -501,7 +501,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (t.temperature IS NULL OR t.temperature BETWEEN 0 AND 79) - AND (t.humidity IS NULL OR t.humidity BETWEEN 0 AND 79) + AND (t.humidity IS NULL OR t.humidity BETWEEN 0 AND 99) AND (t.noise IS NULL OR t.noise BETWEEN 0 AND 79) @@ -537,10 +537,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" t.objid, t.monitorId, t.temperature, t.humidity, t.illuminance, t.noise, t.concentration, t.vibration_speed, t.vibration_displacement, t.vibration_acceleration, t.vibration_temp, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) as monitor_name, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) as monitor_name, t.monitorId as monitor_code FROM ${tableName} t - LEFT JOIN ems_base_monitor_info ebmi ON t.monitorId = ebmi.monitor_code + LEFT JOIN ems_base_monitor_info ebmi ON t.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT @@ -562,7 +562,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND (t.temperature IS NULL OR t.temperature BETWEEN 0 AND 79) - AND (t.humidity IS NULL OR t.humidity BETWEEN 0 AND 79) + AND (t.humidity IS NULL OR t.humidity BETWEEN 0 AND 99) AND (t.noise IS NULL OR t.noise BETWEEN 0 AND 79) diff --git a/ruoyi-ems/src/main/resources/mapper/ems/report/DisplacementBoardMapper.xml b/ruoyi-ems/src/main/resources/mapper/ems/report/DisplacementBoardMapper.xml index 2c0bdd8..25918a1 100644 --- a/ruoyi-ems/src/main/resources/mapper/ems/report/DisplacementBoardMapper.xml +++ b/ruoyi-ems/src/main/resources/mapper/ems/report/DisplacementBoardMapper.xml @@ -36,10 +36,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" t.displacement AS vibration_displacement, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitor_name, + + + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitor_name, + + + COALESCE(ebmi.monitor_name, t.monitorId) AS monitor_name, + + t.monitorId AS monitor_code + + + + + t.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT + + + t.monitorId = ebmi.monitor_code + + + + t.recodeTime >= #{query.beginRecordTime} @@ -83,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + AND t.displacement != 9999999.0000 SELECT * @@ -99,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -137,7 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) AS rn FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -153,14 +176,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" collectTime, recodeTime FROM sampled - + WHERE rn = 1 ORDER BY monitorId ASC, recodeTime ASC, objid ASC SELECT * @@ -170,7 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -183,6 +207,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WITH sampled AS ( @@ -206,7 +231,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) AS rn FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 diff --git a/ruoyi-ems/src/main/resources/mapper/ems/report/TempBoardMapper.xml b/ruoyi-ems/src/main/resources/mapper/ems/report/TempBoardMapper.xml index 59be08e..b5c6eb6 100644 --- a/ruoyi-ems/src/main/resources/mapper/ems/report/TempBoardMapper.xml +++ b/ruoyi-ems/src/main/resources/mapper/ems/report/TempBoardMapper.xml @@ -13,19 +13,30 @@ t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName - + INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON + + + t.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT + + + t.monitorId = ebmi.monitor_code + + AND ebmi.monitor_type IN (5, 6) - + - AND t.temperature IS NOT NULL + AND t.temperature BETWEEN 0 AND 79 @@ -57,7 +68,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -80,7 +91,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -122,7 +133,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -146,7 +157,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -170,7 +181,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -197,7 +208,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -223,7 +234,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -248,7 +259,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -273,7 +284,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -299,7 +310,7 @@ WITH all_data AS ( SELECT t.monitorId, t.temperature, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -327,7 +338,7 @@ SELECT FORMAT(t.collectTime, 'yyyy-MM-dd HH:mm:00') AS statTime, t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, ROUND(AVG(t.temperature), 2) AS avgTemp, COUNT(*) AS sampleCount FROM ${tableName} t @@ -338,7 +349,7 @@ GROUP BY FORMAT(t.collectTime, 'yyyy-MM-dd HH:mm:00'), t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY statTime @@ -349,7 +360,7 @@ SELECT FORMAT(t.collectTime, 'yyyy-MM-dd HH:00:00') AS statTime, t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, ROUND(AVG(t.temperature), 2) AS avgTemp, ROUND(MAX(t.temperature), 2) AS maxTemp, ROUND(MIN(t.temperature), 2) AS minTemp, @@ -362,7 +373,7 @@ GROUP BY FORMAT(t.collectTime, 'yyyy-MM-dd HH:00:00'), t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY statTime @@ -394,7 +405,7 @@ AS statTime, t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, ROUND(AVG(t.temperature), 2) AS avgTemp FROM ${tableName} t @@ -421,7 +432,7 @@ , t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY statTime, monitorId @@ -499,7 +510,7 @@ WITH base AS ( SELECT t.monitorId, t.temperature, t.collectTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -606,7 +617,7 @@ SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, t.temperature, t.collectTime, 'LOW_TEMP' AS anomalyType @@ -679,7 +690,7 @@ WITH base AS ( SELECT t.monitorId, t.temperature, t.collectTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -723,7 +734,7 @@ WITH base AS ( SELECT t.monitorId, t.temperature, t.collectTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName FROM ${tableName} t @@ -783,7 +794,7 @@ SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, ROUND(AVG(t.temperature), 2) AS avgTemp FROM ${tableName} t @@ -815,7 +826,7 @@ - GROUP BY t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + GROUP BY t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY avgTemp DESC @@ -824,7 +835,7 @@ @@ -842,7 +853,7 @@ WITH today_avg AS ( SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, AVG(t.temperature) AS avgTemp FROM ${tableName} t @@ -850,13 +861,13 @@ t.collectTime >= #{todayStartTime} AND t.collectTime < #{todayEndTime} - GROUP BY t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + GROUP BY t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ), yesterday_avg AS ( SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, AVG(t.temperature) AS avgTemp FROM ${tableName} t @@ -864,7 +875,7 @@ t.collectTime >= #{yesterdayStartTime} AND t.collectTime < #{yesterdayEndTime} - GROUP BY t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + GROUP BY t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ) SELECT t.monitorId, t.monitorName, @@ -895,7 +906,7 @@ FROM ( SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, MAX(t.temperature) AS maxTemp, MIN(t.temperature) AS minTemp, SUM(t.temperature) AS sumTemp, @@ -906,7 +917,7 @@ - GROUP BY t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + GROUP BY t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ) sub GROUP BY sub.monitorId, sub.monitorName @@ -917,7 +928,7 @@ @@ -960,7 +971,7 @@ SELECT t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, COUNT(*) AS actualCount, #{expectedCount} AS expectedCount, ROUND(CAST(COUNT(*) AS FLOAT) / #{expectedCount}, 4) AS completenessRate @@ -1063,7 +1074,7 @@ - GROUP BY t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + GROUP BY t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY completenessRate ASC @@ -1072,7 +1083,7 @@ @@ -1158,7 +1169,7 @@ AS statBucket, t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, ROUND(AVG(t.temperature), 2) AS avgTemp FROM ${tableName} t @@ -1178,7 +1189,7 @@ DATEADD(MINUTE, DATEDIFF(MINUTE, 0, t.collectTime), 0) , - t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ) sub ORDER BY statTime, monitorId @@ -1189,7 +1200,7 @@ @@ -1216,7 +1227,7 @@ ELSE '>=30' END AS tempBucket, t.monitorId, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitorName, + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitorName, COUNT(*) AS sampleCount FROM ${tableName} t @@ -1232,7 +1243,7 @@ WHEN t.temperature < 30 THEN '25-30' ELSE '>=30' END, - t.monitorId, COALESCE(ebmi.monitor_name, t.monitorId) + t.monitorId, COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) ORDER BY tempBucket, monitorId @@ -1242,7 +1253,7 @@ diff --git a/ruoyi-ems/src/main/resources/mapper/ems/report/VibrationBoardMapper.xml b/ruoyi-ems/src/main/resources/mapper/ems/report/VibrationBoardMapper.xml index 354d68c..0486b4e 100644 --- a/ruoyi-ems/src/main/resources/mapper/ems/report/VibrationBoardMapper.xml +++ b/ruoyi-ems/src/main/resources/mapper/ems/report/VibrationBoardMapper.xml @@ -49,10 +49,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" t.vibration_temp, t.collectTime, t.recodeTime, - COALESCE(ebmi.monitor_name, t.monitorId) AS monitor_name, + + + COALESCE(ebmi.monitor_name COLLATE DATABASE_DEFAULT, t.monitorId COLLATE DATABASE_DEFAULT) AS monitor_name, + + + COALESCE(ebmi.monitor_name, t.monitorId) AS monitor_name, + + t.monitorId AS monitor_code + + + + + t.monitorId COLLATE DATABASE_DEFAULT = ebmi.monitor_code COLLATE DATABASE_DEFAULT + + + t.monitorId = ebmi.monitor_code + + + + SELECT * @@ -138,7 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -178,7 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) AS rn FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -211,6 +231,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT * @@ -220,7 +241,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10 @@ -233,6 +254,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WITH sampled AS ( @@ -256,7 +278,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) AS rn FROM ${tableName} t INNER JOIN ems_base_monitor_info ebmi - ON t.monitorId = ebmi.monitor_code + ON AND ebmi.monitor_type = 10