|
@@ -16,293 +16,498 @@
|
|
|
sy_cost_allocation_id = #{id}
|
|
|
</select>
|
|
|
|
|
|
+<!-- <select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
+ SELECT cPoid,
|
|
|
+ cAccount
|
|
|
+ ,cVenAbbName AS supper
|
|
|
+ ,cInvCode
|
|
|
+ ,cInvName as goodsName
|
|
|
+ ,iQuantityIn as purchaseQuantity
|
|
|
+ ,iSum as rmbAmount
|
|
|
+ ,iOriSum as usdAmount
|
|
|
+ ,iNoTaxMoney as priceExcludingtax
|
|
|
+ ,0 as ingredientsTransferQuantity
|
|
|
+ FROM dbo.VIEW_FabricLoss_Cost_Assist
|
|
|
+ where cPoid like CONCAT(#{code},'%') and
|
|
|
+ (cVenAbbName !='宁波森语' and cVenAbbName !='马菲羊')
|
|
|
+ </select>-->
|
|
|
|
|
|
<select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
|
|
|
- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) end
|
|
|
- as ingredientsTransferQuantity,
|
|
|
- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
|
|
|
- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
|
|
|
- as ingredientsRemainingQuantity,
|
|
|
- (tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,
|
|
|
- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
|
|
|
- from
|
|
|
- (
|
|
|
-
|
|
|
- select t4.cInvCode,t4.goodsName,max(t4.dosage) as dosage,sum(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from(
|
|
|
- SELECT t3.ccode,t3.cInvCode,t3.goodsName,t3.cVenAbbName AS supper,avg( t3.dosage ) AS dosage,SUM ( t3.usageQuantity ) AS usageQuantity,
|
|
|
-
|
|
|
- SUM ( t3.rmbAmount ) AS rmbAmount,SUM ( t3.usdAmount ) AS usdAmount,SUM ( t3.priceExcludingtax ) AS priceExcludingtax,
|
|
|
- SUM ( t3.totalCost )/sum(totalSum) AS cost
|
|
|
- FROM(
|
|
|
- SELECT t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.totalCost,t2.totalSum
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT ot.cInvCode,od.isosid,om.ccode,oti.cInvName AS goodsName,SUM (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
|
|
|
- FROM UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
- join UFDATA_103_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
- JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.moid= od.moid
|
|
|
- JOIN UFDATA_103_2021.dbo.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
- JOIN UFDATA_103_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= ot.cInvCode
|
|
|
- JOIN UFDATA_103_2021.dbo.Inventory omi ON omi.cInvCode= od.cInvCode
|
|
|
- WHERE
|
|
|
- om.iVerifyStateNew = 2
|
|
|
-
|
|
|
- AND omi.cInvCcode LIKE '19%'
|
|
|
- AND om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
|
|
|
-
|
|
|
- left join (SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
|
|
|
- SUM ( bi.iMoney ) AS priceExcludingtax,sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum
|
|
|
- FROM
|
|
|
- UFDATA_103_2021.dbo.om_momain pom
|
|
|
- JOIN UFDATA_103_2021.dbo.OM_MODetails pod ON pod.MOID = pom.MOID
|
|
|
- JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.MODetailsID
|
|
|
- JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID
|
|
|
- JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode
|
|
|
- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode
|
|
|
- GROUP BY bi.cInvCode,pod.isosid,ven.cVenAbbName
|
|
|
- union all
|
|
|
- SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.iorderdid as isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
|
|
|
- SUM ( bi.iMoney ) AS priceExcludingtax,sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum
|
|
|
- FROM
|
|
|
- UFDATA_103_2021.dbo.PO_Pomain pom
|
|
|
- JOIN UFDATA_103_2021.dbo.PO_Podetails pod ON pod.POID = pom.POID
|
|
|
- JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.ID
|
|
|
- JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID
|
|
|
- JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode
|
|
|
- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode
|
|
|
-
|
|
|
- where pom.cPOID like CONCAT(#{code},'%')
|
|
|
- GROUP BY bi.cInvCode,pod.iorderdid,ven.cVenAbbName
|
|
|
- ) AS t2
|
|
|
- on
|
|
|
- t1.cInvCode= t2.cInvCode
|
|
|
- AND t2.isosid= t1.isosid
|
|
|
- ) t3
|
|
|
- GROUP BY
|
|
|
- t3.ccode,t3.cInvCode,t3.goodsName,t3.cVenAbbName
|
|
|
- ) t4
|
|
|
- where t4.cInvCode not in(
|
|
|
- select cInvCode from UFDATA_103_2021.dbo.cost_allocation_fabric_view vif
|
|
|
- where trim(vif.cCode) like CONCAT(#{code},'%')
|
|
|
- )
|
|
|
- GROUP BY t4.cInvCode,t4.goodsName
|
|
|
-
|
|
|
- ) tab
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_103_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- join UFDATA_103_2021.dbo.rdrecord01 r on rs.ID = r.ID
|
|
|
- where cPOID in (
|
|
|
- select om.cPOID
|
|
|
- from UFDATA_103_2021.dbo.PO_POmain om
|
|
|
- join UFDATA_103_2021.dbo.PO_PODetails od on om.POID=od.POID
|
|
|
- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.cVerifier is not null
|
|
|
- and om.cPOID LIKE CONCAT(#{code},'%')
|
|
|
- ) and r.cBusType = '普通采购'
|
|
|
- GROUP BY i.cInvCode,i.cInvName
|
|
|
- UNION ALL
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_103_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- join UFDATA_103_2021.dbo.rdrecord01 r on rs.ID = r.ID
|
|
|
- where cPOID in (
|
|
|
- select om.cCode
|
|
|
- from UFDATA_103_2021.dbo.om_momain om
|
|
|
- join UFDATA_103_2021.dbo.OM_MODetails od on om.MOID=od.MOID
|
|
|
- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.cVerifier is not null
|
|
|
- and om.cCode like CONCAT(#{code},'%')
|
|
|
- ) and r.cBusType = '委外加工'
|
|
|
- GROUP BY i.cInvCode,i.cInvName
|
|
|
- )tab1 on tab1.cInvName=tab.goodsName and tab1.cInvCode=tab.cInvCode
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as jian from UFDATA_103_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where comcode in (
|
|
|
- select distinct om.cCode
|
|
|
- from UFDATA_103_2021.dbo.om_momain om
|
|
|
- join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2
|
|
|
- and omi.cInvCcode like '19%' and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- )
|
|
|
- GROUP BY i.cInvCode,i.cInvName--,rs.cBatch
|
|
|
- )tab2 on tab2.cInvName=tab.goodsName and tab2.cInvCode=tab.cInvCode
|
|
|
-
|
|
|
- union all
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
|
|
|
- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) end
|
|
|
- as ingredientsTransferQuantity,
|
|
|
- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
|
|
|
- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
|
|
|
- as ingredientsRemainingQuantity,
|
|
|
- (tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
|
|
|
- from
|
|
|
- (
|
|
|
-
|
|
|
- select t4.cInvCode,max(t4.goodsName) as goodsName,max(t4.dosage) as dosage,max(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from (
|
|
|
- select t3.ccode as ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
-
|
|
|
- select t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
-
|
|
|
- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
- and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
- ) as t1,
|
|
|
- (
|
|
|
- select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
- from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
- join UFDATA_101_2021.dbo.PurBillVouchs bi on bi.iPOsID=pod.ID
|
|
|
- join UFDATA_101_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
- join UFDATA_101_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=pod.cInvCode
|
|
|
- where pom.cVenCode != 'T010001' and pom.cVenCode != 'T020001'
|
|
|
- GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t1.isosid = t2.iorderdid
|
|
|
- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
|
|
|
-
|
|
|
- union all
|
|
|
-
|
|
|
- select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
-
|
|
|
- select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
-
|
|
|
- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
- and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
- ) as t1
|
|
|
- left join (
|
|
|
- select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
- from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
- join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
|
|
|
-
|
|
|
- join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=hy.did
|
|
|
- join UFDATA_102_2021.dbo.PO_Pomain pm on pd.POID = pm.POID
|
|
|
- join UFDATA_102_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID
|
|
|
- join UFDATA_102_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
- join UFDATA_102_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
- join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
- where pm.cVenCode != 'T020001' and pom.cpoid LIKE CONCAT(#{code},'%')
|
|
|
- GROUP BY bi.cInvCode,pod.iorderdid) as t2 on t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
|
|
|
- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
|
|
|
-
|
|
|
- union all
|
|
|
- select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
-
|
|
|
- select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
-
|
|
|
- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
- and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
- ) as t1,
|
|
|
- (
|
|
|
- select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
- from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
- join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
|
|
|
-
|
|
|
- join UFDATA_103_2021.dbo.OM_MODetails pd on pd.isosid=hy.did
|
|
|
- join UFDATA_103_2021.dbo.OM_MOMain pm on pd.MOID = pm.MOID
|
|
|
- left join UFDATA_103_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.MODetailsID
|
|
|
- left join UFDATA_103_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
- join UFDATA_103_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
- join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
- where pom.cpoid LIKE CONCAT(#{code},'%')
|
|
|
- GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
|
|
|
- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
|
|
|
- ) t4
|
|
|
- where t4.cInvCode not in(
|
|
|
- select cInvCode from UFDATA_103_2021.dbo.cost_allocation_fabric_view vif
|
|
|
- where trim(vif.cCode) like CONCAT(#{code},'%')
|
|
|
- )
|
|
|
- GROUP BY t4.cInvCode,t4.goodsName
|
|
|
-
|
|
|
- ) tab
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_101_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- join UFDATA_101_2021.dbo.rdrecord01 r on rs.ID = r.ID
|
|
|
- where cPOID in (
|
|
|
- select om.cPOID
|
|
|
- from UFDATA_101_2021.dbo.PO_POmain om
|
|
|
- join UFDATA_101_2021.dbo.PO_PODetails od on om.POID=od.POID
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.cVerifier is not null
|
|
|
- and om.cPOID LIKE CONCAT(#{code},'%')
|
|
|
- ) and r.cBusType = '普通采购'
|
|
|
- GROUP BY i.cInvCode,i.cInvName
|
|
|
- UNION ALL
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_101_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- join UFDATA_101_2021.dbo.rdrecord01 r on rs.ID = r.ID
|
|
|
- where cPOID in (
|
|
|
- select om.cCode
|
|
|
- from UFDATA_101_2021.dbo.om_momain om
|
|
|
- join UFDATA_101_2021.dbo.OM_MODetails od on om.MOID=od.MOID
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.cVerifier is not null
|
|
|
- and om.cCode like CONCAT(#{code},'%')
|
|
|
- ) and r.cBusType = '委外加工'
|
|
|
- GROUP BY i.cInvCode,i.cInvName
|
|
|
- )tab1 on tab1.cInvName=tab.goodsName and tab1.cInvCode=tab.cInvCode
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as jian from UFDATA_101_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where comcode in (
|
|
|
- select distinct om.cCode
|
|
|
- from UFDATA_101_2021.dbo.om_momain om
|
|
|
- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2
|
|
|
- and omi.cInvCcode like '19%' and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
- )
|
|
|
- GROUP BY i.cInvCode,i.cInvName
|
|
|
- )tab2 on tab2.cInvName=tab.goodsName and tab2.cInvCode=tab.cInvCode
|
|
|
-
|
|
|
-
|
|
|
- </select>
|
|
|
+SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]]> 0 then '0'
|
|
|
+ else (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn end as loss
|
|
|
+ ,a.cVenAbbName AS supper
|
|
|
+ ,a.cInvCode as goodsCode
|
|
|
+ ,a.cInvName as goodsName
|
|
|
+ ,isnull(a.iQuantityIn,0) as purchaseQuantity
|
|
|
+ ,a.iSum as rmbAmount
|
|
|
+ ,a.iOriSum as usdAmount
|
|
|
+ ,case when isnull(a.iQuantityIn,0)-isnull(b.usageQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else isnull(a.iQuantityIn,0)-isnull(b.usageQuantity,0) end as ingredientsRemainingQuantity
|
|
|
+ ,a.iNoTaxMoney as priceExcludingtax
|
|
|
+ ,case when isnull(b.usageQuantity,0)-isnull(a.iQuantityIn,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else isnull(b.usageQuantity,0)-isnull(a.iQuantityIn,0) end as ingredientsTransferQuantity
|
|
|
+ ,case when isnull(b.usageQuantity,0)-isnull(a.iQuantityIn,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else (isnull(b.usageQuantity,0)-isnull(a.iQuantityIn,0))*isnull(b.cost,0) end as transferCost,*
|
|
|
+ FROM dbo.VIEW_FabricLoss_Cost_Assist a
|
|
|
+ inner join
|
|
|
+ (
|
|
|
+
|
|
|
+ select t5.cInvCode,t5.goodsName,sum(t5.dosage) as dosage,sum(t5.usageQuantity) as usageQuantity,
|
|
|
+ STRING_AGG(t5.supper,',') as supper,sum(t5.rmbAmount) as rmbAmount,sum(t5.usdAmount) as usdAmount,
|
|
|
+ sum(t5.priceExcludingtax) as priceExcludingtax,sum(t5.cost) as cost from (
|
|
|
+ select t4.cInvCode,t4.ccode,t4.goodsName,max(t4.dosage) as dosage,max(t4.usageQuantity) as usageQuantity,
|
|
|
+ STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,
|
|
|
+ sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from(
|
|
|
+ SELECT t3.ccode,t3.cInvCode,t3.goodsName,avg( t3.dosage ) AS dosage,
|
|
|
+ SUM ( t3.usageQuantity ) AS usageQuantity,t3.cVenAbbName AS supper,
|
|
|
+ SUM ( t3.rmbAmount ) AS rmbAmount,SUM ( t3.usdAmount ) AS usdAmount,
|
|
|
+ SUM ( t3.priceExcludingtax ) AS priceExcludingtax,
|
|
|
+ SUM ( t3.totalCost )/sum(totalSum) AS cost
|
|
|
+ FROM(
|
|
|
+ SELECT t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,
|
|
|
+ t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.totalCost,t2.totalSum
|
|
|
+ FROM
|
|
|
+ (SELECT ot.cInvCode,od.isosid,om.ccode,oti.cInvName AS goodsName,
|
|
|
+ SUM (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
|
|
|
+ FROM UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
+ join UFDATA_103_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.moid= od.moid
|
|
|
+ JOIN UFDATA_103_2021.dbo.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= ot.cInvCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.Inventory omi ON omi.cInvCode= od.cInvCode
|
|
|
+ WHERE om.iVerifyStateNew = 2
|
|
|
+ AND omi.cInvCcode LIKE '19%'
|
|
|
+ AND om.cCode LIKE CONCAT(#{code},'%')
|
|
|
+ GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
|
|
|
+ left join (
|
|
|
+ SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.isosid,SUM ( bi.iSum ) AS rmbAmount,
|
|
|
+ SUM ( bi.iOriSum ) AS usdAmount,SUM ( bi.iMoney ) AS priceExcludingtax,
|
|
|
+ sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum
|
|
|
+ FROM
|
|
|
+ UFDATA_103_2021.dbo.om_momain pom
|
|
|
+ JOIN UFDATA_103_2021.dbo.OM_MODetails pod ON pod.MOID = pom.MOID
|
|
|
+ JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.MODetailsID
|
|
|
+ JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID
|
|
|
+ JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode
|
|
|
+ GROUP BY bi.cInvCode,pod.isosid,ven.cVenAbbName
|
|
|
+ union all
|
|
|
+ SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.iorderdid as isosid,SUM ( bi.iSum ) AS rmbAmount,
|
|
|
+ SUM ( bi.iOriSum ) AS usdAmount,SUM ( bi.iMoney ) AS priceExcludingtax,
|
|
|
+ sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum
|
|
|
+ FROM UFDATA_103_2021.dbo.PO_Pomain pom
|
|
|
+ JOIN UFDATA_103_2021.dbo.PO_Podetails pod ON pod.POID = pom.POID
|
|
|
+ JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.ID
|
|
|
+ JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID
|
|
|
+ JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode
|
|
|
+ JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode
|
|
|
+
|
|
|
+ where pom.cPOID like CONCAT(#{code},'%')
|
|
|
+ GROUP BY bi.cInvCode,pod.iorderdid,ven.cVenAbbName
|
|
|
+ ) AS t2
|
|
|
+ on
|
|
|
+ t1.cInvCode= t2.cInvCode
|
|
|
+ AND t2.isosid= t1.isosid
|
|
|
+ ) t3
|
|
|
+ GROUP BY
|
|
|
+ t3.ccode,t3.cInvCode,t3.goodsName,t3.cVenAbbName
|
|
|
+ union all
|
|
|
+
|
|
|
+ select t3.ccode as ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,
|
|
|
+ max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,
|
|
|
+ sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
+ select t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,
|
|
|
+ t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (
|
|
|
+ select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,
|
|
|
+ sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
+ from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
+ join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
+ join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
+ JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
+ and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
+ group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
+ ) as t1,
|
|
|
+ (
|
|
|
+ select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
+ bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
+ ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
+ from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
+ join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
+ join UFDATA_101_2021.dbo.PurBillVouchs bi on bi.iPOsID=pod.ID
|
|
|
+ join UFDATA_101_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
+ join UFDATA_101_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=pod.cInvCode
|
|
|
+ where pom.cVenCode != 'T010001' and pom.cVenCode != 'T020001'
|
|
|
+ GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t1.isosid = t2.iorderdid
|
|
|
+ ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
+
|
|
|
+ select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
+
|
|
|
+ from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
+ join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
+ join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
+ JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
+ and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
+ group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
+ ) as t1
|
|
|
+ left join (
|
|
|
+ select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
+ bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
+ ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
+ from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
+ join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
+ join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
|
|
|
+
|
|
|
+ join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=hy.did
|
|
|
+ join UFDATA_102_2021.dbo.PO_Pomain pm on pd.POID = pm.POID
|
|
|
+ join UFDATA_102_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID
|
|
|
+ join UFDATA_102_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
+ join UFDATA_102_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
+ join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
+ where pm.cVenCode != 'T020001' and pom.cpoid LIKE CONCAT(#{code},'%')
|
|
|
+ GROUP BY bi.cInvCode,pod.iorderdid) as t2 on t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
|
|
|
+ ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName
|
|
|
+
|
|
|
+ union all
|
|
|
+ select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (
|
|
|
+
|
|
|
+ select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
|
+
|
|
|
+ from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif
|
|
|
+ join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode
|
|
|
+ join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode
|
|
|
+ JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
+ join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
+ and om.cCode LIKE CONCAT(#{code},'%')
|
|
|
+ group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName
|
|
|
+ ) as t1,
|
|
|
+ (
|
|
|
+ select max(ven.cVenAbbName) as cVenAbbName,
|
|
|
+ bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
|
|
|
+ ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
|
|
|
+ from UFDATA_101_2021.dbo.PO_Pomain pom
|
|
|
+ join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
+ join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid
|
|
|
+
|
|
|
+ join UFDATA_103_2021.dbo.OM_MODetails pd on pd.isosid=hy.did
|
|
|
+ join UFDATA_103_2021.dbo.OM_MOMain pm on pd.MOID = pm.MOID
|
|
|
+ left join UFDATA_103_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.MODetailsID
|
|
|
+ left join UFDATA_103_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID
|
|
|
+ join UFDATA_103_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode
|
|
|
+ join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
+ where pom.cpoid LIKE CONCAT(#{code},'%')
|
|
|
+ GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid
|
|
|
+ ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName) t4
|
|
|
+ GROUP BY t4.cInvCode,t4.goodsName,t4.ccode) t5
|
|
|
+ GROUP BY t5.cInvCode,t5.goodsName
|
|
|
+ ) b
|
|
|
+ on a.cinvcode=b.cinvcode and a.cinvname=b.goodsname
|
|
|
+
|
|
|
+ WHERE cPoid LIKE CONCAT(#{code},'%') AND (cVenAbbName != '宁波森语' AND cVenAbbName != '马菲羊') and a.iQuantityIn>0
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- <select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">-->
|
|
|
+<!-- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,-->
|
|
|
+<!-- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0-->
|
|
|
+<!-- else isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) end-->
|
|
|
+<!-- as ingredientsTransferQuantity,-->
|
|
|
+<!-- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity-->
|
|
|
+<!-- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end-->
|
|
|
+<!-- as ingredientsRemainingQuantity,-->
|
|
|
+<!-- (tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,-->
|
|
|
+<!-- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0-->
|
|
|
+<!-- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost-->
|
|
|
+<!-- from-->
|
|
|
+<!-- (-->
|
|
|
+
|
|
|
+<!-- select t4.cInvCode,t4.goodsName,max(t4.dosage) as dosage,sum(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from(-->
|
|
|
+<!-- SELECT t3.ccode,t3.cInvCode,t3.goodsName,t3.cVenAbbName AS supper,avg( t3.dosage ) AS dosage,SUM ( t3.usageQuantity ) AS usageQuantity,-->
|
|
|
+
|
|
|
+<!-- SUM ( t3.rmbAmount ) AS rmbAmount,SUM ( t3.usdAmount ) AS usdAmount,SUM ( t3.priceExcludingtax ) AS priceExcludingtax,-->
|
|
|
+<!-- SUM ( t3.totalCost )/sum(totalSum) AS cost-->
|
|
|
+<!-- FROM(-->
|
|
|
+<!-- SELECT t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.totalCost,t2.totalSum-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- (-->
|
|
|
+<!-- SELECT ot.cInvCode,od.isosid,om.ccode,oti.cInvName AS goodsName,SUM (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity-->
|
|
|
+<!-- FROM UFDATA_103_2021.dbo.cost_allocation_accessories_view vif-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.om_momain om on om.ccode = vif.cCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.moid= od.moid-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID and ot.cInvCode = vif.cInvCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= ot.cInvCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Inventory omi ON omi.cInvCode= od.cInvCode-->
|
|
|
+<!-- WHERE-->
|
|
|
+<!-- om.iVerifyStateNew = 2-->
|
|
|
+
|
|
|
+<!-- AND omi.cInvCcode LIKE '19%'-->
|
|
|
+<!-- AND om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1-->
|
|
|
+
|
|
|
+<!-- left join (SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,-->
|
|
|
+<!-- SUM ( bi.iMoney ) AS priceExcludingtax,sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- UFDATA_103_2021.dbo.om_momain pom-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.OM_MODetails pod ON pod.MOID = pom.MOID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.MODetailsID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode-->
|
|
|
+<!-- GROUP BY bi.cInvCode,pod.isosid,ven.cVenAbbName-->
|
|
|
+<!-- union all-->
|
|
|
+<!-- SELECT ven.cVenAbbName AS cVenAbbName,bi.cInvCode,pod.iorderdid as isosid,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,-->
|
|
|
+<!-- SUM ( bi.iMoney ) AS priceExcludingtax,sum ( bi.iCost*bi.iPBVQuantity) AS totalCost ,sum ( bi.iPBVQuantity) AS totalSum-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- UFDATA_103_2021.dbo.PO_Pomain pom-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.PO_Podetails pod ON pod.POID = pom.POID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.PurBillVouchs bi ON bi.iPOsID= pod.ID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.PurBillVouch bm ON bm.PBVID= bi.PBVID-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Vendor ven ON bm.cVenCode = ven.cVenCode-->
|
|
|
+<!-- JOIN UFDATA_103_2021.dbo.Inventory oti ON oti.cInvCode= pod.cInvCode-->
|
|
|
+
|
|
|
+<!-- where pom.cPOID like CONCAT(#{code},'%')-->
|
|
|
+<!-- GROUP BY bi.cInvCode,pod.iorderdid,ven.cVenAbbName-->
|
|
|
+<!-- ) AS t2-->
|
|
|
+<!-- on-->
|
|
|
+<!-- t1.cInvCode= t2.cInvCode-->
|
|
|
+<!-- AND t2.isosid= t1.isosid-->
|
|
|
+<!-- ) t3-->
|
|
|
+<!-- GROUP BY-->
|
|
|
+<!-- t3.ccode,t3.cInvCode,t3.goodsName,t3.cVenAbbName-->
|
|
|
+<!-- ) t4-->
|
|
|
+<!-- where t4.cInvCode not in(-->
|
|
|
+<!-- select cInvCode from UFDATA_103_2021.dbo.cost_allocation_fabric_view vif-->
|
|
|
+<!-- where trim(vif.cCode) like CONCAT(#{code},'%')-->
|
|
|
+<!-- )-->
|
|
|
+<!-- GROUP BY t4.cInvCode,t4.goodsName-->
|
|
|
+
|
|
|
+<!-- ) tab-->
|
|
|
+<!-- left join-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_103_2021.dbo.rdrecords01 rs-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.rdrecord01 r on rs.ID = r.ID-->
|
|
|
+<!-- where cPOID in (-->
|
|
|
+<!-- select om.cPOID-->
|
|
|
+<!-- from UFDATA_103_2021.dbo.PO_POmain om-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.PO_PODetails od on om.POID=od.POID-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.cVerifier is not null-->
|
|
|
+<!-- and om.cPOID LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- ) and r.cBusType = '普通采购'-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
+<!-- UNION ALL-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_103_2021.dbo.rdrecords01 rs-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.rdrecord01 r on rs.ID = r.ID-->
|
|
|
+<!-- where cPOID in (-->
|
|
|
+<!-- select om.cCode-->
|
|
|
+<!-- from UFDATA_103_2021.dbo.om_momain om-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.OM_MODetails od on om.MOID=od.MOID-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.cVerifier is not null-->
|
|
|
+<!-- and om.cCode like CONCAT(#{code},'%')-->
|
|
|
+<!-- ) and r.cBusType = '委外加工'-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
+<!-- )tab1 on tab1.cInvName=tab.goodsName and tab1.cInvCode=tab.cInvCode-->
|
|
|
+<!-- left join-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as jian from UFDATA_103_2021.dbo.rdrecords11 rs-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- where comcode in (-->
|
|
|
+<!-- select distinct om.cCode-->
|
|
|
+<!-- from UFDATA_103_2021.dbo.om_momain om-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.iVerifyStateNew = 2-->
|
|
|
+<!-- and omi.cInvCcode like '19%' and om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- )-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName--,rs.cBatch-->
|
|
|
+<!-- )tab2 on tab2.cInvName=tab.goodsName and tab2.cInvCode=tab.cInvCode-->
|
|
|
+
|
|
|
+<!-- union all-->
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<!-- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,-->
|
|
|
+<!-- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0-->
|
|
|
+<!-- else isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) end-->
|
|
|
+<!-- as ingredientsTransferQuantity,-->
|
|
|
+<!-- case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity-->
|
|
|
+<!-- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end-->
|
|
|
+<!-- as ingredientsRemainingQuantity,-->
|
|
|
+<!-- (tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,case when isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0-->
|
|
|
+<!-- else (isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost-->
|
|
|
+<!-- from-->
|
|
|
+<!-- (-->
|
|
|
+
|
|
|
+<!-- select t4.cInvCode,max(t4.goodsName) as goodsName,max(t4.dosage) as dosage,max(t4.usageQuantity) as usageQuantity,STRING_AGG(t4.supper,',') as supper,sum(t4.rmbAmount) as rmbAmount,sum(t4.usdAmount) as usdAmount,sum(t4.priceExcludingtax) as priceExcludingtax,sum(t4.cost) as cost from (-->
|
|
|
+<!-- select t3.ccode as ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (-->
|
|
|
+
|
|
|
+<!-- select t1.ccode as ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity-->
|
|
|
+
|
|
|
+<!-- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode-->
|
|
|
+<!-- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'-->
|
|
|
+<!-- and om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
+<!-- ) as t1,-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select max(ven.cVenAbbName) as cVenAbbName,-->
|
|
|
+<!-- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount-->
|
|
|
+<!-- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.PO_Pomain pom-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PurBillVouchs bi on bi.iPOsID=pod.ID-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=pod.cInvCode-->
|
|
|
+<!-- where pom.cVenCode != 'T010001' and pom.cVenCode != 'T020001'-->
|
|
|
+<!-- GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t1.isosid = t2.iorderdid-->
|
|
|
+<!-- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName-->
|
|
|
+
|
|
|
+<!-- union all-->
|
|
|
+
|
|
|
+<!-- select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (-->
|
|
|
+
|
|
|
+<!-- select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity-->
|
|
|
+
|
|
|
+<!-- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode-->
|
|
|
+<!-- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'-->
|
|
|
+<!-- and om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
+<!-- ) as t1-->
|
|
|
+<!-- left join (-->
|
|
|
+<!-- select max(ven.cVenAbbName) as cVenAbbName,-->
|
|
|
+<!-- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount-->
|
|
|
+<!-- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.PO_Pomain pom-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid-->
|
|
|
+
|
|
|
+<!-- join UFDATA_102_2021.dbo.PO_Podetails pd on pd.iorderdid=hy.did-->
|
|
|
+<!-- join UFDATA_102_2021.dbo.PO_Pomain pm on pd.POID = pm.POID-->
|
|
|
+<!-- join UFDATA_102_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID-->
|
|
|
+<!-- join UFDATA_102_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID-->
|
|
|
+<!-- join UFDATA_102_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode-->
|
|
|
+<!-- join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode-->
|
|
|
+<!-- where pm.cVenCode != 'T020001' and pom.cpoid LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- GROUP BY bi.cInvCode,pod.iorderdid) as t2 on t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid-->
|
|
|
+<!-- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName-->
|
|
|
+
|
|
|
+<!-- union all-->
|
|
|
+<!-- select t3.ccode,t3.cInvCode,t3.goodsName,avg(t3.dosage) as dosage,sum(t3.usageQuantity) as usageQuantity,max(t3.cVenAbbName) as supper,sum(t3.rmbAmount) as rmbAmount,sum(t3.usdAmount) as usdAmount,sum(t3.priceExcludingtax) as priceExcludingtax,sum(t3.iCost) as cost from (-->
|
|
|
+
|
|
|
+<!-- select t1.ccode,t1.cInvCode,t1.goodsName,t1.dosage,t1.usageQuantity,t2.cVenAbbName,t2.rmbAmount,t2.usdAmount,t2.priceExcludingtax,t2.iCost from (select ot.cInvCode,od.isosid,om.ccode,oti.cInvName as goodsName,sum(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity-->
|
|
|
+
|
|
|
+<!-- from UFDATA_103_2021.dbo.cost_allocation_accessories_view vif-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.om_momain om on om.ccode = vif.cCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID and ot.cInvCode = vif.cInvCode-->
|
|
|
+<!-- JOIN UFDATA_101_2021.dbo.Vendor v ON om.cVenCode= v.cVenCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'-->
|
|
|
+<!-- and om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
+<!-- ) as t1,-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select max(ven.cVenAbbName) as cVenAbbName,-->
|
|
|
+<!-- bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount-->
|
|
|
+<!-- ,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.PO_Pomain pom-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID = pom.POID-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.HY_DZ_K7_SYNERGISMLOGDID hy on pod.id = hy.predid-->
|
|
|
+
|
|
|
+<!-- join UFDATA_103_2021.dbo.OM_MODetails pd on pd.isosid=hy.did-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.OM_MOMain pm on pd.MOID = pm.MOID-->
|
|
|
+<!-- left join UFDATA_103_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.MODetailsID-->
|
|
|
+<!-- left join UFDATA_103_2021.dbo.PurBillVouch bm on bm.PBVID=bi.PBVID-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Vendor ven on bm.cVenCode = ven.cVenCode-->
|
|
|
+<!-- join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode-->
|
|
|
+<!-- where pom.cpoid LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- GROUP BY bi.cInvCode,pod.iorderdid) as t2 where t1.cInvCode=t2.cInvCode and t2.iorderdid=t1.isosid-->
|
|
|
+<!-- ) t3 GROUP BY t3.ccode,t3.cInvCode,t3.goodsName-->
|
|
|
+<!-- ) t4-->
|
|
|
+<!-- where t4.cInvCode not in(-->
|
|
|
+<!-- select cInvCode from UFDATA_103_2021.dbo.cost_allocation_fabric_view vif-->
|
|
|
+<!-- where trim(vif.cCode) like CONCAT(#{code},'%')-->
|
|
|
+<!-- )-->
|
|
|
+<!-- GROUP BY t4.cInvCode,t4.goodsName-->
|
|
|
+
|
|
|
+<!-- ) tab-->
|
|
|
+<!-- left join-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_101_2021.dbo.rdrecords01 rs-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.rdrecord01 r on rs.ID = r.ID-->
|
|
|
+<!-- where cPOID in (-->
|
|
|
+<!-- select om.cPOID-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.PO_POmain om-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.PO_PODetails od on om.POID=od.POID-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.cVerifier is not null-->
|
|
|
+<!-- and om.cPOID LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- ) and r.cBusType = '普通采购'-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
+<!-- UNION ALL-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as purchaseQuantity from UFDATA_101_2021.dbo.rdrecords01 rs-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.rdrecord01 r on rs.ID = r.ID-->
|
|
|
+<!-- where cPOID in (-->
|
|
|
+<!-- select om.cCode-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.om_momain om-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MODetails od on om.MOID=od.MOID-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.cVerifier is not null-->
|
|
|
+<!-- and om.cCode like CONCAT(#{code},'%')-->
|
|
|
+<!-- ) and r.cBusType = '委外加工'-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
+<!-- )tab1 on tab1.cInvName=tab.goodsName and tab1.cInvCode=tab.cInvCode-->
|
|
|
+<!-- left join-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select i.cInvCode,i.cInvName,sum(rs.iQuantity) as jian from UFDATA_101_2021.dbo.rdrecords11 rs-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode-->
|
|
|
+<!-- where comcode in (-->
|
|
|
+<!-- select distinct om.cCode-->
|
|
|
+<!-- from UFDATA_101_2021.dbo.om_momain om-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid-->
|
|
|
+<!-- join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode-->
|
|
|
+<!-- WHERE om.iVerifyStateNew = 2-->
|
|
|
+<!-- and omi.cInvCcode like '19%' and om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- )-->
|
|
|
+<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
+<!-- )tab2 on tab2.cInvName=tab.goodsName and tab2.cInvCode=tab.cInvCode-->
|
|
|
+
|
|
|
+
|
|
|
+<!-- </select>-->
|
|
|
|
|
|
|
|
|
<!-- 辅料转入数量链接方法-->
|
|
@@ -471,7 +676,7 @@
|
|
|
WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
|
or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
|
|
|
- and oti.cInvName = #{goodName}
|
|
|
+
|
|
|
GROUP BY oti.cInvName
|
|
|
|
|
|
union all
|
|
@@ -492,7 +697,7 @@
|
|
|
WHERE om.iVerifyStateNew = 2 and omi.cInvCcode like '19%'
|
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
|
or oti.cInvCcode like '07%' or oti.cInvCCode = '0399' or oti.cInvCCode = '0499')
|
|
|
- and oti.cInvName = #{goodName}
|
|
|
+
|
|
|
GROUP BY oti.cInvName
|
|
|
</select>
|
|
|
</mapper>
|