diff --git a/aucma-base/src/main/resources/mapper/base/BaseDeviceParamValMapper.xml b/aucma-base/src/main/resources/mapper/base/BaseDeviceParamValMapper.xml index 7210dd9..f4ed610 100644 --- a/aucma-base/src/main/resources/mapper/base/BaseDeviceParamValMapper.xml +++ b/aucma-base/src/main/resources/mapper/base/BaseDeviceParamValMapper.xml @@ -143,9 +143,19 @@ SELECT /*+ PARALLEL(4) */ device_code, param_name, - ROW_NUMBER() OVER (PARTITION BY device_code ORDER BY NVL(record_time, collect_time) DESC) AS rn + ROW_NUMBER() OVER ( + PARTITION BY device_code + ORDER BY NVL(record_time, collect_time) DESC, + DECODE(param_name, + '机台状态-三色灯机器报警', 1, + '机台状态-三色灯机器暂停', 2, + '机台状态-三色灯机器待机', 3, + '机台状态-三色灯机器运行', 4, + 9) ASC + ) AS rn FROM base_device_param_val WHERE param_name IN ('机台状态-三色灯机器运行', '机台状态-三色灯机器暂停', '机台状态-三色灯机器待机', '机台状态-三色灯机器报警') + AND UPPER(param_value) = 'TRUE' AND collect_time >= TRUNC(SYSDATE) AND collect_time < TRUNC(SYSDATE) + 1 ), device_status AS ( @@ -181,6 +191,7 @@ ROW_NUMBER() OVER (PARTITION BY device_code ORDER BY NVL(record_time, collect_time) DESC) AS rn FROM base_device_param_val WHERE param_name IN ('机台状态-三色灯机器运行', '机台状态-三色灯机器暂停', '机台状态-三色灯机器待机','机台状态-三色灯机器报警') + AND UPPER(param_value) = 'TRUE' AND collect_time >= SYSDATE - (2/24) AND collect_time < SYSDATE ), device_status AS (