Update from Sync Service
This commit is contained in:
103
附件/2026/个人知识库/数据库/合肥董铺水库中间数据.md
Executable file
103
附件/2026/个人知识库/数据库/合肥董铺水库中间数据.md
Executable file
@@ -0,0 +1,103 @@
|
||||
```sql
|
||||
USE [ZHDMTProj]
|
||||
GO
|
||||
|
||||
```
|
||||
/****** Object: StoredProcedure [dbo].[sp_ZHDMTProjProcedure20190615] Script Date: 2019/6/14 14:28:33 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
```sql
|
||||
CREATE proc [dbo].[sp_ZHDMTProjProcedure20190615]
|
||||
```
|
||||
(
|
||||
@stationName nvarchar(500),
|
||||
@dt datetime,
|
||||
@endDate datetime
|
||||
)
|
||||
as --declare @dt datetime --时间
|
||||
```sql
|
||||
declare @gpsindex numeric(18,2) --GPSIndex
|
||||
declare @rand float --随机数
|
||||
declare @count int --计数
|
||||
```
|
||||
--declare @GPSINDEX1 bigint
|
||||
```sql
|
||||
declare @adatetime1 datetime
|
||||
```
|
||||
--declare @endDate datetime; --结束时间
|
||||
```sql
|
||||
declare @X1 float
|
||||
declare @Y1 float
|
||||
declare @H1 float
|
||||
declare @DX1 float
|
||||
declare @DY1 float
|
||||
declare @DH1 float
|
||||
declare @DX0 float
|
||||
declare @DY0 float
|
||||
declare @DH0 float
|
||||
declare @X0 float
|
||||
declare @Y0 float
|
||||
declare @H0 float
|
||||
declare @SELECT_SQL1 nvarchar(500)
|
||||
declare @INSERT_SQL1 nvarchar(500)
|
||||
```
|
||||
吴 卓山 于 2019-06-14 14:28 修改
|
||||
--set @dt = '2018-05-22 09:08:00.000';
|
||||
--set @endDate= '2018-12-13 11:19:00.000';
|
||||
--select @X1 = X,@Y1 = Y,@H1 = Height,@DX1=dltaX,@DY1=dltaY,@DH1=dltaH from MYB1_RTK where aDatetime = @dt
|
||||
|
||||
```sql
|
||||
SELECT @X0 =[Sx] , @Y0=[Sy] , @H0 =[Sh] --去station表拿基准
|
||||
FROM [ZHDMTProj].[dbo].[station] where sName=@stationName
|
||||
|
||||
|
||||
SET @SELECT_SQL1='SELECT top 1 @DX0=dltaX , @DY0=dltaY , @DH0 =dltaH
|
||||
FROM [ZHDMTProj].[dbo].'+ @stationName+' order by aDatetime desc';
|
||||
EXEC sp_executesql @SELECT_SQL1, N'@DX0 float out,@DY0 float out,@DH0 float out,@stationName nvarchar(500)',@DX0 out,@DY0 out,@DH0 out,@stationName
|
||||
|
||||
```
|
||||
--求出基准坐标
|
||||
--set @X0=@X1-@DX1
|
||||
--set @Y0=@Y1-@DY1
|
||||
--set @H0=@H1-@DH1
|
||||
```sql
|
||||
select @X0,@Y0,@H0
|
||||
```
|
||||
while(@dt < @endDate) begin
|
||||
```sql
|
||||
set @gpsindex = convert(bigint, datediff(ss, '1970-01-01 00:00:00', @dt))*1000 + datepart(ms,@dt)
|
||||
SET @DX1 = @DX0+(rand()*-2 + 1.2)
|
||||
SET @DY1 =@DY0+ (rand()*-2 +1.2)
|
||||
SET @DH1 =@DH0+(rand()*-2 + 1.2)
|
||||
SET @X1 = @X0+ @DX1/1000
|
||||
SET @Y1 = @Y0+ @DY1/1000
|
||||
SET @H1 = @H0+ @DH1/1000
|
||||
SET @adatetime1 = DATEADD(S,@gpsindex/1000,'1970-01-01 00:00:00')
|
||||
BEGIN TRY SET @INSERT_SQL1=' insert into [ZHDMTProj].[dbo].'+ @stationName+'
|
||||
```
|
||||
([GPSIndex],[aDatetime],[X],[Y],[Height],[dltaX],[dltaY],[dltaH])
|
||||
VALUES(@gpsindex,@adatetime1,@X1,@Y1,@H1,@DX1,@DY1,@DH1)'
|
||||
|
||||
```sql
|
||||
EXEC sp_executesql @INSERT_SQL1,
|
||||
```
|
||||
N'@gpsindex bigint,@adatetime1 datetime,@X1 float,@Y1 float,@H1 float,@DX1 float,@DY1 float,@DH1 float'
|
||||
,@gpsindex,@adatetime1,@X1,@Y1,@H1,@DX1,@DY1,@DH1
|
||||
|
||||
--insert into [ZHDMTProj].[dbo].LY03([GPSIndex],[aDatetime],[X],[Y],[Height],[dltaX],[dltaY],[dltaH])VALUES(@gpsindex,@adatetime1,@X1,@Y1,@H1,@DX1,@DY1,@DH1) END TRY
|
||||
BEGIN
|
||||
CATCH END CATCH
|
||||
--****************
|
||||
```sql
|
||||
set @count = @count + 1
|
||||
set @dt = DATEADD(HOUR,1,@dt) --每次递增5min
|
||||
```
|
||||
end
|
||||
|
||||
|
||||
GO
|
||||
Reference in New Issue
Block a user