|  | @@ -41,7 +41,7 @@ select
 | 
	
		
			
				|  |  |  		select vim.goodsName as goodsName,sum(vim.unitConsumption) as unitConsumption,sum(vim.planQuantity) as planQuantity,
 | 
	
		
			
				|  |  |  		sum(vim.usageQuantity) as usageQuantity from UFDATA_103_2021.dbo.VIEW_FabricLoss_Cost_Cloth vif
 | 
	
		
			
				|  |  |  		join(
 | 
	
		
			
				|  |  | -		select oti.cInvName as goodsName,sum(ot.iUnitQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,case when oti.cInvName like '%圆带%' and max(om.cCode) like '%SYM764%' then replace(oti.cInvName,' ','') +' ' + isnull(ot.cFree1,'') else oti.cInvName +' ' + isnull(ot.cFree1,'') end as cInvName,
 | 
	
		
			
				|  |  | +		select oti.cInvName as goodsName,sum(ot.iQuantity)/sum(od.iQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,case when oti.cInvName like '%圆带%' and max(om.cCode) like '%SYM764%' then replace(oti.cInvName,' ','') +' ' + isnull(ot.cFree1,'') else oti.cInvName +' ' + isnull(ot.cFree1,'') end as cInvName,
 | 
	
		
			
				|  |  |  		sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_101_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -106,7 +106,7 @@ select
 | 
	
		
			
				|  |  |  		select vim.goodsName as goodsName,sum(vim.unitConsumption) as unitConsumption,sum(vim.planQuantity) as planQuantity,
 | 
	
		
			
				|  |  |  		sum(vim.usageQuantity) as usageQuantity from UFDATA_103_2021.dbo.VIEW_FabricLoss_Cost_Cloth vif
 | 
	
		
			
				|  |  |  		join(
 | 
	
		
			
				|  |  | -		select oti.cInvName as goodsName,sum(ot.iUnitQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,case when oti.cInvName like '%圆带%' then replace(oti.cInvName,' ','') +' ' + isnull(ot.cFree1,'') else oti.cInvName +' ' + isnull(ot.cFree1,'') end as cInvName,
 | 
	
		
			
				|  |  | +		select oti.cInvName as goodsName,sum(ot.iQuantity)/sum(od.iQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,case when oti.cInvName like '%圆带%' then replace(oti.cInvName,' ','') +' ' + isnull(ot.cFree1,'') else oti.cInvName +' ' + isnull(ot.cFree1,'') end as cInvName,
 | 
	
		
			
				|  |  |  		sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_103_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -170,7 +170,7 @@ select
 | 
	
		
			
				|  |  |  		)/tab3.purchaseQuantity,0) as loss
 | 
	
		
			
				|  |  |  		from
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  | -		select oti.cInvName as goodsName,sum(ot.iUnitQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,
 | 
	
		
			
				|  |  | +		select oti.cInvName as goodsName,sum(ot.iQuantity)/sum(od.iQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,
 | 
	
		
			
				|  |  |  		sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_101_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -231,7 +231,7 @@ select
 | 
	
		
			
				|  |  |  		)/tab3.purchaseQuantity,0) as loss
 | 
	
		
			
				|  |  |  		from
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  | -		select oti.cInvName as goodsName,sum(ot.iUnitQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,
 | 
	
		
			
				|  |  | +		select oti.cInvName as goodsName,sum(ot.iQuantity)/sum(od.iQuantity) as unitConsumption,sum(ot.iQuantity) as planQuantity,
 | 
	
		
			
				|  |  |  		sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_103_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -383,12 +383,10 @@ select
 | 
	
		
			
				|  |  |  <!--	多发少发链接-->
 | 
	
		
			
				|  |  |  	<select id="querypilosityFewer" parameterType="java.lang.String" resultType="org.jeecg.modules.cost.entity.SyCostAllocationFabric">
 | 
	
		
			
				|  |  |  select
 | 
	
		
			
				|  |  | -		tab.planQuantity as planQuantity,tab.color, tab.goodsName,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,(isnull(tab1.purchaseQuantity,0) - tab.planQuantity) as pilosityFewer
 | 
	
		
			
				|  |  | +		tab.planQuantity as planQuantity,tab.color, tab.goodsName,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,(isnull(tab.usageQuantity,0) - tab.planQuantity) as pilosityFewer
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		from
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  | -		select vim.color as color,max(vim.goodsName) as goodsName,sum(vim.planQuantity) as planQuantity,sum(vim.usageQuantity) as usageQuantity,max(vim.cInvName) as cInvName from UFDATA_103_2021.dbo.VIEW_FabricLoss_Cost_Cloth vif
 | 
	
		
			
				|  |  | -		join(
 | 
	
		
			
				|  |  |  		select ot.cFree1 as color,max(oti.cInvName) as cInvName,max(oti.cInvName)+ ' '+ ot.cFree1 as goodsName,sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_101_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -397,9 +395,6 @@ select
 | 
	
		
			
				|  |  |  		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
 | 
	
		
			
				|  |  |  		WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%' and om.cCode like CONCAT(#{code},'%') and oti.cInvName = #{goodName}
 | 
	
		
			
				|  |  |  		GROUP BY ot.cFree1
 | 
	
		
			
				|  |  | -		) vim on vim.goodsName = vif.cInvName
 | 
	
		
			
				|  |  | -		where trim(vif.cSOCode) like CONCAT(#{code},'%') and vif.cSOCode not like '%样%'
 | 
	
		
			
				|  |  | -		GROUP BY vim.color
 | 
	
		
			
				|  |  |  		) tab
 | 
	
		
			
				|  |  |  		left join
 | 
	
		
			
				|  |  |  	 (
 | 
	
	
		
			
				|  | @@ -421,12 +416,11 @@ select
 | 
	
		
			
				|  |  |  		union all
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		select
 | 
	
		
			
				|  |  | -		tab.planQuantity as planQuantity,tab.color, tab.goodsName,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,(isnull(tab1.purchaseQuantity,0) - tab.planQuantity) as pilosityFewer
 | 
	
		
			
				|  |  | +		tab.planQuantity as planQuantity,tab.color, tab.goodsName,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,(isnull(tab.usageQuantity,0) - tab.planQuantity) as pilosityFewer
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		from
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  | -		select vim.color as color,max(vim.goodsName) as goodsName,sum(vim.planQuantity) as planQuantity,sum(vim.usageQuantity) as usageQuantity,max(vim.cInvName) as cInvName from UFDATA_103_2021.dbo.VIEW_FabricLoss_Cost_Cloth vif
 | 
	
		
			
				|  |  | -		join(
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		select ot.cFree1 as color,max(oti.cInvName) as cInvName,max(oti.cInvName)+ ' '+ ot.cFree1 as goodsName,sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
 | 
	
		
			
				|  |  |  		from UFDATA_103_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
	
		
			
				|  | @@ -435,9 +429,6 @@ select
 | 
	
		
			
				|  |  |  		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
 | 
	
		
			
				|  |  |  		WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%' and om.cCode like CONCAT(#{code},'%') and oti.cInvName = #{goodName}
 | 
	
		
			
				|  |  |  		GROUP BY ot.cFree1
 | 
	
		
			
				|  |  | -		) vim on vim.goodsName = vif.cInvName
 | 
	
		
			
				|  |  | -		where trim(vif.cSOCode) like CONCAT(#{code},'%') and vif.cSOCode not like '%样%'
 | 
	
		
			
				|  |  | -		GROUP BY vim.color
 | 
	
		
			
				|  |  |  		) tab
 | 
	
		
			
				|  |  |  		left join
 | 
	
		
			
				|  |  |  	 (
 |