-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from romfabbro/db_update_conf
Db update conf
- Loading branch information
Showing
10 changed files
with
323 additions
and
14 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
Back/database/Pipe/DB_Mother/095_Change_Order_Of_MoniStatus_In_Indiv_Grid.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
UPDATE [EcoReleve_ECWP].[dbo].[ModuleGrids] | ||
SET GridOrder = 35 | ||
WHERE GridRender = 1 AND Name = 'Monitoring_Status' | ||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('95_Change_Order_Of_MoniStatus_In_Indiv_Grid',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
UPDATE f SET InputType = 'GridFormEditor',Options = '{"protocoleType":'+Options+',"nbFixedCol":0,"delFirst":0,"showLines":0}' | ||
FROM [ModuleForms] f | ||
where Options in (214,222) and InputType like '%listof%' and module_id = 1 | ||
|
||
Update f SET FieldSizeDisplay= 3, FieldSizeEdit = 3 | ||
FROM ModuleForms f | ||
WHERE TypeObj = 222 and module_id = 1 | ||
AND Name = 'sampled' | ||
|
||
Update f SET FieldSizeDisplay= 5, FieldSizeEdit = 5 | ||
FROM ModuleForms f | ||
WHERE TypeObj = 222 and module_id = 1 | ||
AND Name = 'Measured_by' | ||
|
||
|
||
Update f SET FieldSizeDisplay= 4, FieldSizeEdit = 4 | ||
FROM ModuleForms f | ||
WHERE TypeObj = 222 and module_id = 1 | ||
AND Name = 'Egg_code' | ||
|
||
|
||
|
||
Update f SET FieldSizeDisplay= 4, FieldSizeEdit = 4 | ||
FROM ModuleForms f | ||
WHERE TypeObj = 214 and module_id = 1 | ||
AND Name = 'frequency' | ||
|
||
Update f SET FieldSizeDisplay= 5, FieldSizeEdit = 5 | ||
FROM ModuleForms f | ||
WHERE TypeObj = 214 and module_id = 1 | ||
AND Name in ('sex','age','signal') | ||
|
||
|
||
Update f SET Options = 2010086 | ||
FROM ModuleForms f | ||
WHERE module_id = 1 and TypeObj = 231 and Name = 'sex' | ||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('95_Up_Conf_protcole',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
15 changes: 15 additions & 0 deletions
15
Back/database/Pipe/DB_Mother/096_ecoReleve_Sensor_Up_type_argos.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
ALTER TABLE [ecoReleve_Sensor].[dbo].[T_argosgps] | ||
ALTER COLUMN [type] varchar (20) not NULL | ||
GO | ||
|
||
UPDATE [ecoReleve_Sensor].[dbo].[T_argosgps] SET type = 'argos' | ||
WHERE type ='arg' | ||
GO | ||
|
||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('96_ecoReleve_Sensor_Up_type_argos',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
112 changes: 112 additions & 0 deletions
112
Back/database/Pipe/DB_Mother/097_Up_SP_validate_ALL_RFID.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
|
||
|
||
ALTER PROCEDURE [dbo].[sp_validate_ALL_rfid] | ||
@freq int, | ||
@user int, | ||
@nb_insert int OUTPUT, | ||
@error int OUTPUT, | ||
@exist int OUTPUT | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
DECLARE @data_to_insert table ( PK_id int | ||
, FK_ind int | ||
, FK_Sensor int | ||
, chip_code varchar(10) | ||
, date_ datetime | ||
, lat decimal(9,5) | ||
, lon decimal(9,5) | ||
,ele int | ||
,freq int ); | ||
Declare @data_duplicate table ( | ||
PK_id int | ||
|
||
); | ||
|
||
-- Gather not validated data. | ||
WITH data AS ( | ||
SELECT ID | ||
, FK_Sensor | ||
, chip_code | ||
, date_ | ||
,validated | ||
,checked | ||
, FK_MonitoredSite | ||
, ROW_NUMBER() OVER (PARTITION BY FK_Sensor, chip_code, CONVERT(DATE, date_), DATEPART(hour, date_), DATEPART(minute, date_)/@freq ORDER BY date_) as r | ||
FROM VRfidData_With_equipSite where checked = 0 | ||
) | ||
INSERT INTO @data_to_insert | ||
( PK_id | ||
, FK_Sensor | ||
, chip_code | ||
, date_ | ||
, lat | ||
, lon | ||
,freq | ||
,ele) | ||
SELECT data.ID | ||
, data.FK_Sensor | ||
, data.chip_code | ||
, data.date_ | ||
, lat | ||
, lon | ||
,@freq | ||
,ele | ||
FROM data | ||
JOIN MonitoredSitePosition p | ||
ON p.FK_MonitoredSite = data.FK_MonitoredSite AND p.StartDate <= data.date_ | ||
WHERE not exists (SELECT * FROM MonitoredSitePosition p1 | ||
WHERE p.FK_MonitoredSite = p1.FK_MonitoredSite AND p1.StartDate > p.StartDate AND p1.StartDate <= data.date_ ) | ||
and data.FK_MonitoredSite is not null AND data.r = 1 AND data.validated = 0 and data.checked=0; | ||
|
||
UPDATE d SET FK_ind = iv.FK_Individual | ||
FROM @data_to_insert d | ||
JOIN IndividualDynPropValue iv | ||
ON d.chip_code = iv.ValueString AND iv.FK_IndividualDynProp = 7 AND iv.StartDate <= d.date_ | ||
WHERE NOT EXISTS ( | ||
SELECT * FROM IndividualDynPropValue iv2 | ||
WHERE iv.FK_Individual = iv2.FK_IndividualDynProp AND iv.FK_IndividualDynProp = iv2.FK_IndividualDynProp | ||
AND iv2.StartDate > iv.StartDate AND iv2.StartDate <= d.date_) | ||
|
||
insert into @data_duplicate | ||
SELECT d.PK_id | ||
FROM @data_to_insert d JOIN Individual_Location loc | ||
ON d.FK_ind = loc.FK_Individual and d.date_ = loc.Date and d.FK_Sensor = loc.FK_Sensor | ||
|
||
-- Insert only the first chip lecture per RFID, per individual, per hour. | ||
INSERT INTO Individual_Location (creator, FK_Sensor, FK_Individual, type_, Date, lat, lon, creationDate,FK_Region,ELE,OriginalData_ID) | ||
SELECT @user, FK_Sensor, FK_ind, 'rfid', date_, lat, lon, CURRENT_TIMESTAMP,NULL,ele,'T_rfid_'+CONVERT(Varchar,d.PK_id) | ||
FROM @data_to_insert d WHERE d.PK_id NOT IN (SELECT * FROM @data_duplicate) | ||
|
||
|
||
|
||
-- Update inserted data. | ||
UPDATE VRfidData_With_equipSite SET validated = 1 , frequency= @freq | ||
WHERE VRfidData_With_equipSite.ID IN (SELECT PK_id FROM @data_to_insert); | ||
UPDATE VRfidData_With_equipSite SET checked = 1 Where checked = 0 | ||
|
||
|
||
|
||
SELECT @nb_insert = COUNT(*) FROM @data_to_insert where PK_id not in (select * from @data_duplicate) | ||
Select @exist = Count (*) from @data_duplicate | ||
SELECT @error = @@ERROR | ||
|
||
RETURN | ||
END | ||
|
||
|
||
|
||
|
||
GO | ||
|
||
|
||
|
||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('97_Up_SP_validate_ALL_RFID',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
113 changes: 113 additions & 0 deletions
113
Back/database/Pipe/DB_Mother/098_Up_SP_validate_RFID.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
|
||
|
||
ALTER PROCEDURE [dbo].[sp_validate_rfid] | ||
@IdEquip int, | ||
@freq int, | ||
@user int, | ||
@nb_insert int OUTPUT, | ||
@error int OUTPUT, | ||
@exist int OUTPUT | ||
AS | ||
BEGIN | ||
-- SET NOCOUNT ON added to prevent extra result sets from | ||
-- interfering with SELECT statements. | ||
SET NOCOUNT ON; | ||
|
||
DECLARE @data_to_insert table ( PK_id int | ||
, FK_ind int | ||
, FK_Sensor int | ||
, chip_code varchar(10) | ||
, date_ datetime | ||
, lat decimal(9,5) | ||
, lon decimal(9,5) | ||
,ele int | ||
,freq int ); | ||
Declare @data_duplicate table ( | ||
PK_id int | ||
|
||
); | ||
|
||
-- Gather not validated data. | ||
WITH data AS ( | ||
SELECT ID | ||
, FK_Sensor | ||
, chip_code | ||
, date_ | ||
,validated | ||
,checked | ||
, FK_MonitoredSite | ||
, ROW_NUMBER() OVER (PARTITION BY FK_Sensor, chip_code, CONVERT(DATE, date_), DATEPART(hour, date_), DATEPART(minute, date_)/@freq ORDER BY date_) as r | ||
FROM VRfidData_With_equipSite where equipID = @IdEquip | ||
) | ||
INSERT INTO @data_to_insert | ||
( PK_id | ||
, FK_Sensor | ||
, chip_code | ||
, date_ | ||
, lat | ||
, lon | ||
,freq | ||
,ele) | ||
SELECT data.ID | ||
, data.FK_Sensor | ||
, data.chip_code | ||
, data.date_ | ||
, lat | ||
, lon | ||
,@freq | ||
,ele | ||
FROM data | ||
JOIN MonitoredSitePosition p | ||
ON p.FK_MonitoredSite = data.FK_MonitoredSite AND p.StartDate <= data.date_ | ||
WHERE not exists (SELECT * FROM MonitoredSitePosition p1 | ||
WHERE p.FK_MonitoredSite = p1.FK_MonitoredSite AND p1.StartDate > p.StartDate AND p1.StartDate <= data.date_ ) | ||
and data.FK_MonitoredSite is not null AND data.r = 1 AND data.validated = 0 and data.checked=0; | ||
|
||
UPDATE d SET FK_ind = iv.FK_Individual | ||
FROM @data_to_insert d | ||
JOIN IndividualDynPropValue iv | ||
ON d.chip_code = iv.ValueString AND iv.FK_IndividualDynProp = 7 AND iv.StartDate <= d.date_ | ||
WHERE NOT EXISTS ( | ||
SELECT * FROM IndividualDynPropValue iv2 | ||
WHERE iv.FK_Individual = iv2.FK_IndividualDynProp AND iv.FK_IndividualDynProp = iv2.FK_IndividualDynProp | ||
AND iv2.StartDate > iv.StartDate AND iv2.StartDate <= d.date_) | ||
|
||
insert into @data_duplicate | ||
SELECT d.PK_id | ||
FROM @data_to_insert d JOIN Individual_Location loc | ||
ON d.FK_ind = loc.FK_Individual and d.date_ = loc.Date and d.FK_Sensor = loc.FK_Sensor | ||
|
||
-- Insert only the first chip lecture per RFID, per individual, per hour. | ||
INSERT INTO Individual_Location (creator, FK_Sensor, FK_Individual, type_, Date, lat, lon, creationDate,FK_Region,ELE,OriginalData_ID) | ||
SELECT @user, FK_Sensor, FK_ind, 'rfid', date_, lat, lon, CURRENT_TIMESTAMP,dbo.fn_GetRegionFromLatLon(lat,lon),ele,'T_rfid_'+CONVERT(Varchar,d.PK_id) | ||
FROM @data_to_insert d WHERE d.PK_id NOT IN (SELECT * FROM @data_duplicate) | ||
|
||
|
||
|
||
-- Update inserted data. | ||
UPDATE VRfidData_With_equipSite SET validated = 1 , frequency= @freq | ||
WHERE VRfidData_With_equipSite.ID IN (SELECT PK_id FROM @data_to_insert); | ||
UPDATE VRfidData_With_equipSite SET checked = 1 Where equipID = @IdEquip | ||
|
||
|
||
|
||
SELECT @nb_insert = COUNT(*) FROM @data_to_insert where PK_id not in (select * from @data_duplicate) | ||
Select @exist = Count (*) from @data_duplicate | ||
SELECT @error = @@ERROR | ||
|
||
RETURN | ||
END | ||
|
||
|
||
|
||
GO | ||
|
||
|
||
|
||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('98_Up_SP_validate_RFID',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
11 changes: 11 additions & 0 deletions
11
Back/database/Pipe/DB_Mother/099_Up_Individual_Location_OriginalDataID_withRFID.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
UPDATE l SET OriginalData_ID = 'T_rfid_'+CONVERT(VARCHAR,r.ID) | ||
FROM Individual_Location l | ||
JOIN ecoReleve_Sensor.dbo.T_rfid r ON l.FK_Sensor = r.FK_Sensor AND l.Date = r.date_ | ||
WHERE l.OriginalData_ID is null and type_ = 'rfid' | ||
GO | ||
|
||
|
||
INSERT INTO [dbo].[TVersion] (TVer_FileName,TVer_Date,TVer_DbName) VALUES ('99_Up_Individual_Location_OriginalDataID_withRFID',GETDATE(),(SELECT db_name())) | ||
|
||
|
||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.