|
@@ -28,11 +28,12 @@
|
|
|
,iNoTaxMoney as priceExcludingtax
|
|
|
,0 as ingredientsTransferQuantity
|
|
|
FROM dbo.VIEW_FabricLoss_Cost_Assist
|
|
|
- where cPoid like CONCAT(#{code},'%') and
|
|
|
+ where cPoid like CONCAT('%',#{code},'%') and
|
|
|
(cVenAbbName !='宁波森语' and cVenAbbName !='马菲羊')
|
|
|
</select>-->
|
|
|
|
|
|
<select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
+
|
|
|
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
|
|
@@ -55,173 +56,161 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
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
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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(本币单价) as cost from(
|
|
|
+
|
|
|
+ select OMMO.计划单号,ommo.ccode,ommo.cVenAbbName,OMMO.cInvCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,入库数量,
|
|
|
+ POPO1.cVenAbbName AS supper,popo1.iOriSum as usdAmount,POPO1.iSum as rmbAmount,popo1.iNoTaxMoney as priceExcludingtax,
|
|
|
+ popo1.原币单价,POPO1.本币单价,POPO1.iQuantityIn AS 购入数量,POPO1.iQuantityInvoice AS 发票数量,
|
|
|
+ popo1.iQuantitySettle as 结算数量
|
|
|
+ from
|
|
|
+ (
|
|
|
+ SELECT OMMO.计划单号,ommo.ccode,OMMO.cVenAbbName,OMMO.cInvCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,ISNULL(入库数量,0) AS 入库数量
|
|
|
+ FROM
|
|
|
+ (select #{code} AS 计划单号,ommo.ccode,'101' AS 账套,Vendor.cVenAbbName,inv_z.cInvCode,inv_z.cInvCCode,
|
|
|
+ inv_z.cInvName as goodsName,avg(ommoms.iUnitQuantity) as dosage,sum(ommoms.iSendQTY) as usageQuantity
|
|
|
+ from
|
|
|
+ UFDATA_101_2021.dbo.OM_MOMaterials ommoms inner join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=ommoms.MoDetailsID
|
|
|
+ inner join UFDATA_101_2021.dbo.om_momain ommo on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv_c on inv_c.cInvCode=ommos.cInvCode
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv_z on inv_z.cInvCode=ommoms.cInvCode
|
|
|
+ inner join UFDATA_101_2021.dbo.Vendor on vendor.cVenCode=ommo.cVenCode
|
|
|
+ where left(inv_c.cInvCCode,2)='19' and (left(inv_z.cInvCCode,2) not in ('02','03','04') or inv_z.cInvCCode in ('0299','0399','0499'))
|
|
|
+ and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser'
|
|
|
+ group by Vendor.cVenAbbName,inv_z.cInvCode,inv_z.cInvName,inv_z.cInvCCode,ommo.ccode) as ommo left join
|
|
|
+ (
|
|
|
+ select #{code} AS 计划单号,'101' AS 账套,inv.cInvCode,inv.cInvName,popo.cVenCode,sum(isnull(popos.iReceivedQTY,0)+isnull(popos.iArrQTY,0))AS 入库数量
|
|
|
+ from
|
|
|
+ UFDATA_101_2021.dbo.po_pomain popo inner join UFDATA_101_2021.dbo.PO_Podetails popos on popo.POID=popos.POID
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv on inv.cInvCode=popos.cInvCode
|
|
|
+ where popo.cPOID like CONCAT('%',#{code},'%') and (left(inv.cInvCCode,2) not in ('02','03','04') or inv.cInvCCode in ('0299','0399','0499'))
|
|
|
+ and isnull(popos.cbCloser,'asuser')='asuser'
|
|
|
+ group by inv.cInvCode,inv.cInvName,popo.cVenCode) as popo on
|
|
|
+ popo.计划单号=ommo.计划单号 and popo.cInvCode=ommo.cInvCode
|
|
|
+ WHERE (OMMO.cInvCCode not in ('0299','0399','0499') or ISNULL(popo.cVenCode,0)!='T020001')
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT OMMO.计划单号,OMMO.CCODE , cVenAbbName,OMMO.cInvCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,NULL AS 入库数量
|
|
|
+ FROM
|
|
|
+ (select #{code} AS 计划单号,ommo.ccode,Vendor.cVenAbbName,inv_z.cInvCode,inv_z.cInvCCode,inv_z.cInvName as goodsName,
|
|
|
+ avg(ommoms.iUnitQuantity) as dosage,sum(ommoms.iSendQTY) as usageQuantity
|
|
|
+ from
|
|
|
+ UFDATA_103_2021.dbo.OM_MOMaterials ommoms inner join UFDATA_103_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=ommoms.MoDetailsID
|
|
|
+ inner join UFDATA_103_2021.dbo.om_momain ommo on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv_c on inv_c.cInvCode=ommos.cInvCode
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv_z on inv_z.cInvCode=ommoms.cInvCode
|
|
|
+ inner join UFDATA_103_2021.dbo.Vendor on vendor.cVenCode=ommo.cVenCode
|
|
|
+ where left(inv_c.cInvCCode,2)='19' and (left(inv_z.cInvCCode,2) not in ('02','03','04') or inv_z.cInvCCode in ('0299','0399','0499'))
|
|
|
+ and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser'
|
|
|
+ group by ommo.ccode,inv_z.cInvCode,inv_z.cInvName,inv_z.cInvCCode,Vendor.cVenAbbName)
|
|
|
+ AS OMMO LEFT JOIN
|
|
|
+ (SELECT #{code} AS 计划单号,OMMO.cVenCode,OMMO.CCODE FROM UFDATA_103_2021.dbo.om_momain ommo inner join UFDATA_103_2021.dbo.OM_MODetails ommos on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv on inv.cInvCode=ommos.cInvCode WHERE INV.cInvCCode IN ('0299','0399','0499')
|
|
|
+ and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser')
|
|
|
+ AS POPO ON POPO.cVenCode=OMMO.cInvCode AND POPO.计划单号=OMMO.计划单号
|
|
|
+ WHERE POPO.cCode IS NULL
|
|
|
+
|
|
|
+ ) AS OMMO
|
|
|
+ left join (select #{code} as 计划单号, cVenAbbName,cInvCode,sum(iOriSum) as iOriSum,sum(iSum) as iSum,
|
|
|
+ sum(iNoTaxMoney) as iNoTaxMoney,sum(iQuantityIn) as iQuantityIn,sum(iQuantityInvoice) as iQuantityInvoice,
|
|
|
+ sum(iQuantitySettle) as iQuantitySettle
|
|
|
+ ,(CASE WHEN sum(iQuantityIn)!=0 THEN round(sum(iOriSum)/sum(iQuantityIn),5) ELSE 0 END) AS 原币单价
|
|
|
+ ,(CASE WHEN sum(iQuantityIn)!=0 THEN round(sum(iSum)/sum(iQuantityIn),5) ELSE 0 END) AS 本币单价
|
|
|
+ from VIEW_FabricLoss_Cost_Assist
|
|
|
+ where cPoid like CONCAT('%',#{code},'%') and cVenAbbName!='宁波森语'
|
|
|
+ group by cVenAbbName,cInvCode)
|
|
|
+ AS POPO1 ON POPO1.cInvCode=OMMO.cInvCode
|
|
|
+
|
|
|
+ ) 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
|
|
|
+ WHERE cPoid LIKE CONCAT('%',#{code},'%') AND (cVenAbbName != '宁波森语' AND cVenAbbName != '马菲羊') and a.iQuantityIn>0
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ <select id="queryByCostIngredient2" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
+ select OMMO.计划单号 ,ommo.cVenAbbName,OMMO.cInvCode goodsCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,入库数量,
|
|
|
+ POPO1.cVenAbbName AS supper,popo1.iOriSum as usdAmount,POPO1.iSum as rmbAmount,popo1.iNoTaxMoney as priceExcludingtax,
|
|
|
+ popo1.原币单价,POPO1.本币单价 cost,POPO1.iQuantityIn AS purchaseQuantity,POPO1.iQuantityInvoice AS 发票数量,
|
|
|
+ case when isnull(iQuantityIn,0)-isnull(usageQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else isnull(iQuantityIn,0)-isnull(usageQuantity,0) end as ingredientsRemainingQuantity,
|
|
|
+ case when isnull(usageQuantity,0)-isnull(iQuantityIn,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else isnull(usageQuantity,0)-isnull(iQuantityIn,0) end as ingredientsTransferQuantity,
|
|
|
+ case when isnull(usageQuantity,0)-isnull(iQuantityIn,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else (isnull(usageQuantity,0)-isnull(iQuantityIn,0))*isnull(POPO1.本币单价,0) end as transferCost,
|
|
|
+ case when iQuantityIn = 0 then '0'
|
|
|
+ when (iQuantityIn-usageQuantity)/iQuantityIn <![CDATA[<=]]> 0 then '0'
|
|
|
+ else (iQuantityIn-usageQuantity)/iQuantityIn end as loss,
|
|
|
+ popo1.iQuantitySettle as 结算数量
|
|
|
+ from
|
|
|
+ (
|
|
|
+ SELECT OMMO.计划单号,OMMO.cVenAbbName,OMMO.cInvCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,ISNULL(入库数量,0) AS 入库数量
|
|
|
+ FROM
|
|
|
+ (select #{code} AS 计划单号,'101' AS 账套,Vendor.cVenAbbName,inv_z.cInvCode,inv_z.cInvCCode,
|
|
|
+ inv_z.cInvName as goodsName,avg(ommoms.iUnitQuantity) as dosage,sum(ommoms.iSendQTY) as usageQuantity
|
|
|
+ from
|
|
|
+ UFDATA_101_2021.dbo.OM_MOMaterials ommoms inner join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=ommoms.MoDetailsID
|
|
|
+ inner join UFDATA_101_2021.dbo.om_momain ommo on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv_c on inv_c.cInvCode=ommos.cInvCode
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv_z on inv_z.cInvCode=ommoms.cInvCode
|
|
|
+ inner join UFDATA_101_2021.dbo.Vendor on vendor.cVenCode=ommo.cVenCode
|
|
|
+ where left(inv_c.cInvCCode,2)='19' and (left(inv_z.cInvCCode,2) not in ('02','03','04') or inv_z.cInvCCode in ('0299','0399','0499'))
|
|
|
+ and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser'
|
|
|
+ group by Vendor.cVenAbbName,inv_z.cInvCode,inv_z.cInvName,inv_z.cInvCCode) as ommo left join
|
|
|
+ (select #{code} AS 计划单号,'101' AS 账套,inv.cInvCode,inv.cInvName,popo.cVenCode,sum(isnull(popos.iReceivedQTY,0)+isnull(popos.iArrQTY,0))AS 入库数量
|
|
|
+ from
|
|
|
+ UFDATA_101_2021.dbo.po_pomain popo inner join UFDATA_101_2021.dbo.PO_Podetails popos on popo.POID=popos.POID
|
|
|
+ inner join UFDATA_101_2021.dbo.Inventory inv on inv.cInvCode=popos.cInvCode
|
|
|
+ where popo.cPOID like CONCAT('%',#{code},'%') and (left(inv.cInvCCode,2) not in ('02','03','04') or inv.cInvCCode in ('0299','0399','0499'))
|
|
|
+ and isnull(popos.cbCloser,'asuser')='asuser'
|
|
|
+ group by inv.cInvCode,inv.cInvName,popo.cVenCode) as popo on
|
|
|
+ popo.计划单号=ommo.计划单号 and popo.cInvCode=ommo.cInvCode
|
|
|
+ WHERE (OMMO.cInvCCode not in ('0299','0399','0499') or ISNULL(popo.cVenCode,0)!='T020001' or 入库数量=0)
|
|
|
+ UNION ALL
|
|
|
+ SELECT OMMO.计划单号,OMMO.CCODE,OMMO.cInvCode,cInvCCode,OMMO.goodsName,OMMO.dosage,OMMO.usageQuantity,NULL AS 入库数量
|
|
|
+ FROM
|
|
|
+ (select #{code} AS 计划单号,ommo.ccode,inv_z.cInvCode,inv_z.cInvCCode,inv_z.cInvName as goodsName,
|
|
|
+ avg(ommoms.iUnitQuantity) as dosage,sum(ommoms.iSendQTY) as usageQuantity
|
|
|
+ from
|
|
|
+ UFDATA_103_2021.dbo.OM_MOMaterials ommoms inner join UFDATA_103_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=ommoms.MoDetailsID
|
|
|
+ inner join UFDATA_103_2021.dbo.om_momain ommo on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv_c on inv_c.cInvCode=ommos.cInvCode
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv_z on inv_z.cInvCode=ommoms.cInvCode
|
|
|
+ inner join UFDATA_103_2021.dbo.Vendor on vendor.cVenCode=ommo.cVenCode
|
|
|
+ where left(inv_c.cInvCCode,2)='19' and (left(inv_z.cInvCCode,2) not in ('02','03','04') -- or inv_z.cInvCCode in ('0299','0399','0499')
|
|
|
+
|
|
|
+ )and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser'
|
|
|
+ group by ommo.ccode,inv_z.cInvCode,inv_z.cInvName,inv_z.cInvCCode) AS OMMO
|
|
|
+ LEFT JOIN (SELECT #{code} AS 计划单号,OMMO.cVenCode,OMMO.CCODE FROM UFDATA_103_2021.dbo.om_momain ommo inner join UFDATA_103_2021.dbo.OM_MODetails ommos on ommo.MOID=ommos.MOID
|
|
|
+ inner join UFDATA_103_2021.dbo.Inventory inv on inv.cInvCode=ommos.cInvCode WHERE INV.cInvCCode IN ('0299','0399','0499')
|
|
|
+ and ommo.ccode like CONCAT('%',#{code},'%') and isnull(ommos.cbCloser,'asuser')='asuser') AS POPO
|
|
|
+ ON POPO.cVenCode=OMMO.cInvCode AND POPO.计划单号=OMMO.计划单号
|
|
|
+ WHERE POPO.cCode IS NULL
|
|
|
+ ) AS OMMO
|
|
|
+ left join (select #{code} as 计划单号, cVenAbbName,cInvCode,sum(iOriSum) as iOriSum,sum(iSum) as iSum,
|
|
|
+ sum(iNoTaxMoney) as iNoTaxMoney,sum(iQuantityIn) as iQuantityIn,sum(iQuantityInvoice) as iQuantityInvoice
|
|
|
+ ,sum(iQuantitySettle) as iQuantitySettle
|
|
|
+ ,(CASE WHEN sum(iQuantityIn)!=0 THEN round(sum(iOriSum)/sum(iQuantityIn),5) ELSE 0 END) AS 原币单价
|
|
|
+ ,(CASE WHEN sum(iQuantityIn)!=0 THEN round(sum(iSum)/sum(iQuantityIn),5) ELSE 0 END) AS 本币单价
|
|
|
+ from VIEW_FabricLoss_Cost_Assist
|
|
|
+ where cPoid like CONCAT('%',#{code},'%') and cVenAbbName!='宁波森语'
|
|
|
+ group by cVenAbbName,cInvCode)
|
|
|
+ AS POPO1 ON POPO1.cInvCode=OMMO.cInvCode
|
|
|
+ </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-->
|
|
@@ -257,7 +246,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- om.iVerifyStateNew = 2-->
|
|
|
|
|
|
<!-- AND omi.cInvCcode LIKE '19%'-->
|
|
|
-<!-- AND om.cCode LIKE CONCAT(#{code},'%')-->
|
|
|
+<!-- 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,-->
|
|
@@ -281,7 +270,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- where pom.cPOID like CONCAT('%',#{code},'%')-->
|
|
|
<!-- GROUP BY bi.cInvCode,pod.iorderdid,ven.cVenAbbName-->
|
|
|
<!-- ) AS t2-->
|
|
|
<!-- on-->
|
|
@@ -293,7 +282,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- ) 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},'%')-->
|
|
|
+<!-- where trim(vif.cCode) like CONCAT('%',#{code},'%')-->
|
|
|
<!-- )-->
|
|
|
<!-- GROUP BY t4.cInvCode,t4.goodsName-->
|
|
|
|
|
@@ -309,7 +298,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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 om.cPOID LIKE CONCAT('%',#{code},'%')-->
|
|
|
<!-- ) and r.cBusType = '普通采购'-->
|
|
|
<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
<!-- UNION ALL-->
|
|
@@ -322,7 +311,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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 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-->
|
|
@@ -336,7 +325,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- 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-->
|
|
@@ -370,7 +359,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- and om.cCode LIKE CONCAT('%',#{code},'%')-->
|
|
|
<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
<!-- ) as t1,-->
|
|
|
<!-- (-->
|
|
@@ -401,7 +390,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- and om.cCode LIKE CONCAT('%',#{code},'%')-->
|
|
|
<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
<!-- ) as t1-->
|
|
|
<!-- left join (-->
|
|
@@ -418,7 +407,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- 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-->
|
|
|
|
|
@@ -435,7 +424,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- and om.cCode LIKE CONCAT('%',#{code},'%')-->
|
|
|
<!-- group by om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName-->
|
|
|
<!-- ) as t1,-->
|
|
|
<!-- (-->
|
|
@@ -452,13 +441,13 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- 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},'%')-->
|
|
|
+<!-- where trim(vif.cCode) like CONCAT('%',#{code},'%')-->
|
|
|
<!-- )-->
|
|
|
<!-- GROUP BY t4.cInvCode,t4.goodsName-->
|
|
|
|
|
@@ -474,7 +463,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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 om.cPOID LIKE CONCAT('%',#{code},'%')-->
|
|
|
<!-- ) and r.cBusType = '普通采购'-->
|
|
|
<!-- GROUP BY i.cInvCode,i.cInvName-->
|
|
|
<!-- UNION ALL-->
|
|
@@ -487,7 +476,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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 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-->
|
|
@@ -501,7 +490,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
<!-- 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},'%')-->
|
|
|
+<!-- 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-->
|
|
@@ -547,7 +536,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
GROUP BY pod.cInvCode,pod.iorderdid
|
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
|
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%'
|
|
|
+ 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
|
|
@@ -562,7 +551,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
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 om.cPOID like CONCAT('%',#{code},'%')
|
|
|
)
|
|
|
GROUP BY i.cInvCode,i.cInvName,rs.cBatch
|
|
|
)tab1 on tab1.cInvName=tab.goodsName
|
|
@@ -577,7 +566,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
JOIN UFDATA_103_2021.dbo.OM_MOMaterials ot ON ot.MoDetailsID= od.MODetailsID
|
|
|
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},'%')
|
|
|
+ and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
|
|
|
and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
|
|
|
|
|
|
) and (i.cInvCcode like '05%' or i.cInvCcode like '06%' or i.cInvCcode like '07%'
|
|
@@ -606,7 +595,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
|
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%'
|
|
|
+ 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
|
|
@@ -621,7 +610,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
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 om.cPOID like CONCAT('%',#{code},'%')
|
|
|
)
|
|
|
GROUP BY i.cInvCode,i.cInvName,rs.cBatch
|
|
|
)tab1 on tab1.cInvName=tab.goodsName
|
|
@@ -635,7 +624,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
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},'%')
|
|
|
+ and omi.cInvCcode like '19%' and om.cCode like CONCAT('%',#{code},'%')
|
|
|
) and (i.cInvCcode like '05%' or i.cInvCcode like '06%' or i.cInvCcode like '07%'
|
|
|
or i.cInvCCode = '0399' or i.cInvCCode = '0499' or i.cInvCCode = '0299')
|
|
|
GROUP BY i.cInvName,rs.cBatch
|
|
@@ -674,7 +663,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
GROUP BY pod.cInvCode,pod.iorderdid
|
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
|
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%'
|
|
|
+ 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')
|
|
|
|
|
|
GROUP BY oti.cInvName
|
|
@@ -695,7 +684,7 @@ SELECT case when (a.iQuantityIn-b.usageQuantity)/a.iQuantityIn <![CDATA[<=]
|
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
|
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%'
|
|
|
+ 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')
|
|
|
|
|
|
GROUP BY oti.cInvName
|