| 
					
				 | 
			
			
				@@ -1,58 +1,136 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <?xml version="1.0" encoding="UTF-8"?> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <mapper namespace="org.jeecg.modules.scas.mapper.DyeLossMapper"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="querySelect" resultType="org.jeecg.modules.scas.entity.DyeLoss" parameterType="org.jeecg.modules.scas.dto.DyeLossDto"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select * from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (select	ROW_NUMBER() OVER(ORDER BY OM_MOMain.moid) index1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Inventory.cinvcode,--物料编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Inventory.cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MODetails.cfree1 color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cVenName cVenName,--供应商 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MOMain.cCode cCode,--订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MODetails.iQuantity,--订单数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iReceivedQTY iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --(select sum(iQuantity) from rdrecords01 where OM_MODetails.MODetailsID=rdrecords01.iOMoDID) iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		iMaterialSendQty iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		--(select sum(iQuantity) from rdrecords11 where OM_MODetails.MODetailsID=rdrecords11.iOMoDID) iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		(1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from OM_MOMain 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="true"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and  Vendor.cVCCode='0105'--染厂 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="code!=null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and cCode=#{code} -- 订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="venName!=null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and cVenName=#{venName} -- 供应商名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="orderType!=null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and iOrderType=#{orderType} --订单类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="planLotNumber!=null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and cPlanLotNumber=#{planLotNumber} --计划单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if  test="isosid!=null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and isosid=#{isosid} --销售订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) p	--计划时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where p.index1>=${pageNo*pageSize-pageSize} and p.index1<=${pageSize*pageNo} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <select id="selectPage" resultType="org.jeecg.modules.scas.entity.DyeLoss" > 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    select * from( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         d.cinvcode,--物料编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         d.cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         b.cfree1 color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         cVenName cVenName,--供应商 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         a.cCode cCode,--订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        b.iQuantity iQuantity,--订单数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(iReceivedQTY, 0 ) iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(iMaterialSendQty, 0 ) iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(g.iMSQuantity, 0 ) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL((1-iReceivedQTY/NULLIF(g.iMSQuantity,0))*100,0) dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        b.iQuantity,--订单数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iReceivedQTY iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iMaterialSendQty iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where b.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where b.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         from OM_MOMain a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join OM_MODetails b on b.moid=a.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join Vendor c on c.cVenCode=a.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join Inventory d on b.cInvCode=d.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join SO_SODetails e on e.iSOsID =b.iSOsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join OM_MatSettleVouch f on  b.MODetailsID =f.MODetailsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join OM_MatSettleVouchs g on g.msid=f.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-       ${ew.customSqlSegment} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         ${ew.customSqlSegment})p--染厂 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select  id="selectSum" resultType="org.jeecg.modules.scas.entity.DyeLoss"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --染损报表合计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select  sum(OM_MODetails.iQuantity) iQuantity2, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				sum(iReceivedQTY) iQuantity3,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				sum(iMaterialSendQty) iMSQuantity,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				sum(iMSQuantity) dyeLossRate--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from OM_MOMain 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where Vendor.cVCCode='0105' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <select id="selectVendor"  resultType="org.jeecg.modules.scas.entity.DyeLoss" parameterType="java.lang.String">--选择供应商按物料分组展现每个物料的染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			cInvName+' '+color cInvNameColor,--物料和颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            --(iMSQuantity/iQuantity2)*100 dyeLossRate--合格率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            (1-(iQuantity2/NULLIF(iMSQuantity,0)))*100 dyeLossRate--染损率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            iQuantity2,--入库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            (1-(iQuantity2/iMSQuantity)) dyeLossRate--染损数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         (select Inventory.cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				OM_MODetails.cfree1 color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sum(iReceivedQTY) iQuantity2,--入库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            sum(iMSQuantity) iMSQuantity--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sum(iMSQuantity) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sum(1-(iReceivedQTY/iMSQuantity)) dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         from OM_MOMain 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				left join OM_MatSettleVouch on  OM_MODetails.MODetailsID=OM_MatSettleVouch.MODetailsID--绑定委外订单子表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where Vendor.cVCCode='0105' and  OM_MatSettleVouchs.cRdBusType='委外发料' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where Vendor.cVCCode='0105' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				AND cVenName=#{value} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				GROUP BY Inventory.cInvName,OM_MODetails.cfree1)p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				GROUP BY Inventory.cInvName)p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <select id="selectCInvName"  resultType="org.jeecg.modules.scas.entity.DyeLoss">--按供应商分组展现每个供应商的染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        select 	cVenName,--供应商名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			    (1-(iQuantity2/NULLIF(iMSQuantity,0)))*100 dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		select 	cVenName,--供应商名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				iQuantity2,--入库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				(1-(iQuantity2/iMSQuantity)) dyeLossRate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         from ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cVenName,--供应商名称 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,33 +141,45 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            left join OM_MatSettleVouch on  OM_MODetails.MODetailsID=OM_MatSettleVouch.MODetailsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where Vendor.cVCCode='0105' and  OM_MatSettleVouchs.cRdBusType='委外发料' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where Vendor.cVCCode='0105' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         GROUP BY cVenName) p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     <select id="excel" resultType="org.jeecg.modules.scas.entity.DyeLoss"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    select 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        d.cinvcode,--物料编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        d.cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        b.cfree1 color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        select * from 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (select	ROW_NUMBER() OVER(ORDER BY OM_MOMain.moid) index1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Inventory.cinvcode,--物料编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Inventory.cInvName,--物料名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MODetails.cfree1 color,--颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         cVenName cVenName,--供应商 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        a.cCode cCode,--订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        b.iQuantity iQuantity,--订单数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(iReceivedQTY, 0 ) iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(iMaterialSendQty, 0 ) iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL(g.iMSQuantity, 0 ) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ISNULL((1-iReceivedQTY/NULLIF(g.iMSQuantity,0))*100,0) dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        from OM_MOMain a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join OM_MODetails b on b.moid=a.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join Vendor c on c.cVenCode=a.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join Inventory d on b.cInvCode=d.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join SO_SODetails e on e.iSOsID =b.iSOsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join OM_MatSettleVouch f on  b.MODetailsID =f.MODetailsID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        left join OM_MatSettleVouchs g on g.msid=f.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        where c.cVCCode='0105' and  g.cRdBusType='委外发料' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MOMain.cCode cCode,--订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OM_MODetails.iQuantity,--订单数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        iReceivedQTY iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --(select sum(iQuantity) from rdrecords01 where OM_MODetails.MODetailsID=rdrecords01.iOMoDID) iQuantity2,--采购入库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		iMaterialSendQty iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		--(select sum(iQuantity) from rdrecords11 where OM_MODetails.MODetailsID=rdrecords11.iOMoDID) iQuantity3,--材料出库数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		(1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from OM_MOMain 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        --left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where Vendor.cVCCode='0105' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) p	--计划时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |