|
@@ -18,15 +18,15 @@
|
|
|
|
|
|
<select id="queryByCostIngredient" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
|
|
|
- case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else tab2.jian-isnull(tab1.purchaseQuantity,0) end
|
|
|
+ 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 tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
|
|
|
- else (tab2.jian-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
|
|
|
+ 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 tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else (tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
|
|
|
+ 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 oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
@@ -82,14 +82,14 @@
|
|
|
union all
|
|
|
|
|
|
select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,
|
|
|
- case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else tab2.jian-isnull(tab1.purchaseQuantity,0) end
|
|
|
+ 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 tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
|
|
|
- else (tab2.jian-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
|
|
|
+ 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 tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
- else (tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
|
|
|
+ (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 oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
@@ -161,8 +161,8 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTransferByIngredient" resultType="org.jeecg.modules.cost.entity.SyTransfer">
|
|
|
- select tab1.cInvName as goodsName,tab1.cCode as planCode,tab2.jian-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
- tab.cost as unitCost,(tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
|
+ select tab1.cInvName as goodsName,tab1.cCode as planCode,isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
+ tab.cost as unitCost,(isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
|
from
|
|
|
(
|
|
|
select oti.cInvName as goodsName,sum(pb.iCost) as cost
|
|
@@ -235,12 +235,12 @@
|
|
|
or i.cInvCCode = '0399' or i.cInvCCode = '0499')
|
|
|
GROUP BY i.cInvName,rs.cBatch
|
|
|
)tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch
|
|
|
- where tab2.jian-isnull(tab1.purchaseQuantity,0)>0
|
|
|
+ where isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0)>0
|
|
|
|
|
|
union all
|
|
|
|
|
|
- select tab1.cInvName as goodsName,tab1.cCode as planCode,tab2.jian-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
- tab.cost as unitCost,(tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
|
+ select tab1.cInvName as goodsName,tab1.cCode as planCode,isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
+ tab.cost as unitCost,(isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
|
from
|
|
|
(
|
|
|
select oti.cInvName as goodsName,sum(pb.iCost) as cost
|
|
@@ -296,7 +296,7 @@
|
|
|
or i.cInvCCode = '0399' or i.cInvCCode = '0499')
|
|
|
GROUP BY i.cInvName,rs.cBatch
|
|
|
)tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch
|
|
|
- where tab2.jian-isnull(tab1.purchaseQuantity,0)>0
|
|
|
+ where isnull(tab2.jian,0)-isnull(tab1.purchaseQuantity,0)>0
|
|
|
</select>
|
|
|
|
|
|
<select id="queryRemainingByIngredient" resultType="org.jeecg.modules.cost.entity.SyRemaining">
|