From 759594d4ae647e08181e1361b97036b037785f45 Mon Sep 17 00:00:00 2001 From: zch Date: Sat, 12 Oct 2024 10:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AF=86=E7=A0=81=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=92=B8=E6=B1=BD=E6=95=B0=E6=8D=AE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新了数据库配置文件中的密码 - 新增了一个存储过程Record_SteamPointData,用于记录蒸汽点数据 --- .../src/main/resources/application-druid.yml | 2 +- steamMY.sql | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 steamMY.sql diff --git a/os-admin/src/main/resources/application-druid.yml b/os-admin/src/main/resources/application-druid.yml index 9b6e794..99a85a3 100644 --- a/os-admin/src/main/resources/application-druid.yml +++ b/os-admin/src/main/resources/application-druid.yml @@ -8,7 +8,7 @@ spring: driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=HengTong username: sa - password: 123456 + password: haiwei@2024 # 从库数据源 slave: driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver diff --git a/steamMY.sql b/steamMY.sql new file mode 100644 index 0000000..c85a31a --- /dev/null +++ b/steamMY.sql @@ -0,0 +1,49 @@ +CREATE PROCEDURE [dbo].[Record_SteamPointData] +AS +declare @begin_time datetime +declare @end_time datetime +BEGIN + set @begin_time = DATEADD(hh, -1, GETDATE()); + set @end_time = DATEADD(hh, -0, GETDATE()); + declare @dateinfo datetime; + set @dateinfo = GETDATE(); + INSERT INTO ems_report_point_steam (monitor_code, instrument_value,begin_time,end_time,record_time) + SELECT + t1.monitor_code AS monitor_code, + CONVERT(DECIMAL(18, 2), ISNULL((t3.steam_flow-t4.steam_flow),0)) AS instrument_value, + + DATEADD(HH, -1, @dateinfo) AS begin_time, + DATEADD(HH, 0, @dateinfo) AS end_time, + CONVERT(VARCHAR(10), DATEADD(HH, -1, @dateinfo), 120) AS record_time + FROM ems_base_monitor_info t1 + LEFT JOIN ( + SELECT T1.monitor_code, T1.steam_flow,T1.collect_time + FROM ems_record_steam_instant T1 + left JOIN ( + SELECT monitor_code, MAX(collect_time) AS collect_time + FROM ems_record_steam_instant + WHERE collect_time BETWEEN DATEADD(HH, -1, @dateinfo) AND DATEADD(HH, 0, @dateinfo) + GROUP BY monitor_code) T2 + on T1.collect_time = T2.collect_time AND T1.monitor_code = T2.monitor_code + WHERE T1.collect_time BETWEEN DATEADD(HH, -1, @dateinfo) AND DATEADD(HH, 0, @dateinfo) + ) t3 ON t1.monitor_code = t3.monitor_code + + + LEFT JOIN ( + SELECT E1.monitor_code, E1.steam_flow,E1.collect_time + FROM ems_record_steam_instant E1 + JOIN ( + SELECT monitor_code, MIN(collect_time) AS collect_time + FROM ems_record_steam_instant + WHERE collect_time BETWEEN DATEADD(HH, -1, @dateinfo) AND DATEADD(HH, 0, @dateinfo) + GROUP BY monitor_code) E2 + on E1.collect_time = E2.collect_time AND E1.monitor_code = E2.monitor_code + WHERE E1.collect_time BETWEEN DATEADD(HH, -1, @dateinfo) AND DATEADD(HH, 0, @dateinfo) + )t4 ON t1.monitor_code = t4.monitor_code +END; +GO + + + + +