| 
					
				 | 
			
			
				@@ -17,6 +17,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	<select id="queryByCostShipdetail" resultType="org.jeecg.modules.cost.entity.SyCostAllocationShipdetail"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		select t.* from ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			sh.cDefine10 AS invoiceNum, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			CONVERT(varchar(50), min(sh.dDate), 23) as outdata , 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -28,10 +29,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			avg(shs.iTaxUnitPrice) AS exportUnitPrice , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			sum(shs.iSum) as exportPrice, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			sum(iNatSum) as rmbAmount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.procesUnitPriceusd) as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.procesUnitPriceusd)*sh.iExchRate as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.procesUnitPricermb) * sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.procesUnitPriceusd) * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then avg(so.procesUnitPriceusd) else round(avg(so.procesUnitPriceusd)*sh.iExchRate,4) end as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then round(avg(so.procesUnitPriceusd)/sh.iExchRate,4) else avg(so.procesUnitPriceusd) end as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				case when max(so.cexch)='人民币' then avg(so.procesUnitPriceusd) else round(avg(so.procesUnitPriceusd)*sh.iExchRate,4) end* sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then round(avg(so.procesUnitPriceusd)/sh.iExchRate,4) else avg(so.procesUnitPriceusd) end * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			v.cVenName AS processUnit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			UFDATA_101_2021.dbo.SaleBillVouch sh 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,10 +41,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				supplierCode,s.iSOsID,s.id ,o.procesUnitPriceusd,o.procesUnitPricermb,o.iPBVQuantity,s.cdefine22,s.cDefine28 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				o.supplierCode,s.iSOsID,s.id ,o.procesUnitPriceusd,o.procesUnitPricermb,o.iPBVQuantity,o.cexch as cexch,s.cdefine22,s.cDefine28 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 FROM UFDATA_101_2021.dbo.SO_SODetails s 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					SELECT max(om.cexch_name) as cexch, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iTax) as iTax,sum(od.iNatTax) as iNatTax 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 ,min(od.iNatUnitPrice) as procesUnitPricermb,min(bi.iOriTaxCost ) as procesUnitPriceusd,count(1) as iPBVQuantity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					FROM UFDATA_101_2021.dbo.OM_MOMain om 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -69,10 +70,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			avg(shs.iTaxUnitPrice) AS exportUnitPrice , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			sum(shs.iSum) as exportPrice, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			sum(iNatSum) as rmbAmount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.iOriTaxCost) as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			avg(so.iOriTaxCost) * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			v.cVenName AS processUnit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			UFDATA_102_2021.dbo.SaleBillVouch sh 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -80,12 +81,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						FROM  UFDATA_103_2021.dbo.SO_SODetails a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						inner JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									 SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									 SELECT max(om.cexch_name) as cexch, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 max(od.csoordercode) as csoordercode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -123,10 +124,11 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		avg(shs.iTaxUnitPrice) AS exportUnitPrice , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		sum(shs.iSum) as exportPrice, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		sum(iNatSum) as rmbAmount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		avg(so.iOriTaxCost) as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		avg(so.iOriTaxCost) * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end as procesUnitPriceusd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		v.cVenName AS processUnit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			UFDATA_101_2021.dbo.SaleBillVouch sh 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -134,12 +136,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LEFT JOIN UFDATA_101_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		  JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						FROM  UFDATA_103_2021.dbo.SO_SODetails a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						inner JOIN ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									 SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									 SELECT max(om.cexch_name) as cexch, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 max(od.csoordercode) as csoordercode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -162,7 +164,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						GROUP BY s.iSOsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			) so ON so.iSOsID = rd.iorderdid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName ) t order by t.outdata 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	</select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </mapper> 
			 |