[Stacomir-commits] r308 - pkg/stacomir/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 16 13:24:41 CET 2017


Author: legrand
Date: 2017-03-16 13:24:41 +0100 (Thu, 16 Mar 2017)
New Revision: 308

Modified:
   pkg/stacomir/R/BilanAnnuels.r
Log:


Modified: pkg/stacomir/R/BilanAnnuels.r
===================================================================
--- pkg/stacomir/R/BilanAnnuels.r	2017-03-16 12:07:17 UTC (rev 307)
+++ pkg/stacomir/R/BilanAnnuels.r	2017-03-16 12:24:41 UTC (rev 308)
@@ -119,7 +119,7 @@
 			diff<-new("BilanAnnuels")
 			diff at data=reqdiff at query	
 			
-			#If there are some operations whith year of date_debut different to the year of date_fin we need to find these operations
+			# If there are some operations whith year of date_debut different to the year of date_fin we need to find these operations
 			# and apply on it the overlaps function to separate fish that arrive during the first year from the all
 			#If we don't have operation on two years we apply the simple sum per year
 			if (diff at data$ope_dic_identifiant==diff at data$ope_dic_identifiant & diff at data$annee_debut!=diff at data$annee_fin){
@@ -129,6 +129,7 @@
 				sch<-get("sch",envir=envir_stacomi) # "iav."
 				assign("sch","iav.",envir_stacomi)
 				
+				# we select operation with different years between the beginning and the end of the operation
 				reqdiffan at sql= paste("select *, extract(year  from ope_date_debut) as annee 
 								FROM  ",get("sch",envir=envir_stacomi),"t_operation_ope  join ",get("sch",envir=envir_stacomi),"t_lot_lot on lot_ope_identifiant=ope_identifiant 
 								where ope_dic_identifiant in('5','6','12') 
@@ -144,7 +145,33 @@
 			reqdiffan<-stacomirtools::connect(reqdiffan)
 			diffan<-new("BilanAnnuels")
 			diffan at data=reqdiffan at query
+			
+			# we select all the other operations (without difference of years)
+			reqssdiffan=new("RequeteODBC")
+			reqssdiffan at baseODBC<-get("baseODBC", envir=envir_stacomi)
+			#Pour Marion
+			sch<-get("sch",envir=envir_stacomi) # "iav."
+			assign("sch","iav.",envir_stacomi)
+			
+			reqssdiffan at sql= paste("select *, extract(year  from ope_date_debut) as annee 
+							FROM  ",get("sch",envir=envir_stacomi),"t_operation_ope  join ",get("sch",envir=envir_stacomi),"t_lot_lot on lot_ope_identifiant=ope_identifiant 
+							where ope_dic_identifiant in('5','6','12') 
+							and extract(year from ope_date_debut)>=1996 
+							and	 extract(year from ope_date_fin)<=2015 
+							and ope_dic_identifiant in ('5','6','12') 
+							and lot_tax_code in ('2038') 
+							and lot_std_code in ('AGG','AGJ') 
+							and lot_lot_identifiant is null 
+							and extract(year from ope_date_debut)=extract(year from ope_date_fin) 
+							order by ope_dic_identifiant,annee; ",sep="")
+			reqssdiffan at sql<-stringr::str_replace_all(reqssdiffan at sql,"[\r\n\t]" , "")
+			reqssdiffan<-stacomirtools::connect(reqssdiffan)
+			ssdiffan<-new("BilanAnnuels")
+			ssdiffan at data=reqssdiffan at query
+			
+			# we merge the two dataset together
 		}
+		#If we have dc and years with no difference in the years of start and end for the same operation we calculate the "classical" sum by year
 		else {
 			
 			



More information about the Stacomir-commits mailing list