|
@@ -16,135 +16,9 @@
|
|
|
sy_cost_allocation_id = #{id}
|
|
|
</select>
|
|
|
|
|
|
- <update id="deleteTempTable101">
|
|
|
- DROP TABLE ${table};
|
|
|
- </update>
|
|
|
-
|
|
|
- <insert id="createTempTable101">
|
|
|
-
|
|
|
- CREATE TABLE ${table}(
|
|
|
- ccode varchar(50),
|
|
|
- cInvCode varchar(50),
|
|
|
- goodsName varchar(200),
|
|
|
- dosage decimal(38),
|
|
|
- usageQuantity decimal(38),
|
|
|
- supper varchar(50),
|
|
|
- rmbAmount decimal(38),
|
|
|
- usdAmount decimal(38),
|
|
|
- priceExcludingtax decimal(38),
|
|
|
- cost decimal(38)
|
|
|
- )
|
|
|
- </insert>
|
|
|
-
|
|
|
- <insert id="insertDataIntoTempTable101_101">
|
|
|
-
|
|
|
- insert into ${table} select t3.ccode as ccode,t3.cInvCode,t3.goodsName,max(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_101_2021.dbo.om_momain om
|
|
|
- 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
|
|
|
- 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
|
|
|
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 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')
|
|
|
- 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
|
|
|
-
|
|
|
- </insert>
|
|
|
-
|
|
|
- <insert id="insertDataIntoTempTable101_102">
|
|
|
-insert into ${table} select t3.ccode,t3.cInvCode,t3.goodsName,max(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_101_2021.dbo.om_momain om
|
|
|
- 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
|
|
|
- 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
|
|
|
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 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')
|
|
|
- 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;
|
|
|
- </insert>
|
|
|
-
|
|
|
- <insert id="insertDataIntoTempTable101_103">
|
|
|
-insert into ${table} select t3.ccode,t3.cInvCode,t3.goodsName,max(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_101_2021.dbo.om_momain om
|
|
|
- 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
|
|
|
- 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
|
|
|
-join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 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')
|
|
|
- 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;
|
|
|
-
|
|
|
- </insert>
|
|
|
|
|
|
<select id="queryByCostIngredient1" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
|
|
|
+ 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,
|
|
@@ -167,21 +41,19 @@ join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.
|
|
|
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.om_momain om
|
|
|
+ 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
|
|
|
+ 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
|
|
|
- join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
|
|
|
WHERE
|
|
|
om.iVerifyStateNew = 2
|
|
|
|
|
|
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) ))
|
|
|
- GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName ) AS t1
|
|
|
+ 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
|
|
@@ -212,22 +84,19 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
|
|
|
SELECT t1.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,om.ccode,oti.cInvName AS goodsName,max (ot.iUnitQuantity) AS dosage,SUM (ot.iSendQTY) AS usageQuantity
|
|
|
- FROM
|
|
|
- UFDATA_103_2021.dbo.om_momain om
|
|
|
+ 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
|
|
|
+ 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
|
|
|
- join UFDATA_103_2021.dbo.cost_allocation_accessories_view vif on om.ccode = vif.cCode and ot.cInvCode = vif.cInvCode
|
|
|
WHERE
|
|
|
om.iVerifyStateNew = 2
|
|
|
-
|
|
|
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) ))
|
|
|
- GROUP BY om.ccode,ot.cInvCode,om.ccode,oti.cInvName ) AS t1
|
|
|
+ GROUP BY om.ccode,ot.cInvCode,od.isosid,om.ccode,oti.cInvName) AS t1
|
|
|
|
|
|
left join (
|
|
|
SELECT oti.cinvName,ven.cVenAbbName AS cVenAbbName,bi.cInvCode,SUM ( bi.iSum ) AS rmbAmount,SUM ( bi.iOriSum ) AS usdAmount,
|
|
@@ -313,9 +182,105 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
|
|
|
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
|
|
|
- ${table} t4
|
|
|
+ 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,max(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,max(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,max(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},'%')
|
|
@@ -432,9 +397,12 @@ and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY !=
|
|
|
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_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%'
|
|
|
or i.cInvCCode = '0399' or i.cInvCCode = '0499' or i.cInvCCode = '0299')
|
|
|
GROUP BY i.cInvName,rs.cBatch
|