|
@@ -17,7 +17,10 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryByCostIngredient" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
|
|
|
- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,isnull(tab1.purchaseQuantity,0)-tab2.jian as ingredientsTransferQuantity,
|
|
|
+ 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
|
|
|
+ as ingredientsTransferQuantity,
|
|
|
tab.usageQuantity-isnull(tab1.purchaseQuantity,0) as ingredientsRemainingQuantity,
|
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
|
from
|
|
@@ -74,7 +77,10 @@
|
|
|
|
|
|
union all
|
|
|
|
|
|
- select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,isnull(tab1.purchaseQuantity,0)-tab2.jian as ingredientsTransferQuantity,
|
|
|
+ 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
|
|
|
+ as ingredientsTransferQuantity,
|
|
|
tab.usageQuantity-isnull(tab1.purchaseQuantity,0) as ingredientsRemainingQuantity,
|
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
|
from
|
|
@@ -149,7 +155,7 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTransferByIngredient" resultType="org.jeecg.modules.cost.entity.SyTransfer">
|
|
|
- select tab1.cInvName as goodsName,tab1.cCode as planCode,tab1.purchaseQuantity-tab2.jian as number,
|
|
|
+ select tab1.cInvName as goodsName,tab1.cCode as planCode,tab2.jian-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
tab.cost as unitCost,(purchaseQuantity-tab2.jian)*tab.cost as cost
|
|
|
from
|
|
|
(
|
|
@@ -225,7 +231,7 @@
|
|
|
|
|
|
union all
|
|
|
|
|
|
- select tab1.cInvName as goodsName,tab1.cCode as planCode,tab1.purchaseQuantity-tab2.jian as number,
|
|
|
+ select tab1.cInvName as goodsName,tab1.cCode as planCode,tab2.jian-isnull(tab1.purchaseQuantity,0) as number,
|
|
|
tab.cost as unitCost,(purchaseQuantity-tab2.jian)*tab.cost as cost
|
|
|
from
|
|
|
(
|