Browse Source

成本报表 辅料查询空指针

liuchaohui 2 years ago
parent
commit
ae29de649b

+ 18 - 18
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationIngredientMapper.xml

@@ -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">

+ 5 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -277,9 +277,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                 Ingredient.setSyTransfers(transferlist);
             }
             //若转入数量不为0则给转入数据对象赋值
-            if(0!=Ingredient.getIngredientsRemainingQuantity().compareTo(BigDecimal.ZERO)){
-                List<SyRemaining> remaininglist  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
-                Ingredient.setSyRemaining(remaininglist);
+            if(Ingredient.getIngredientsRemainingQuantity()!=null){
+                if(0!=Ingredient.getIngredientsRemainingQuantity().compareTo(BigDecimal.ZERO)){
+                    List<SyRemaining> remaininglist  = syCostAllocationIngredientMapper.queryRemainingByIngredient(plannum,Ingredient.getGoodsName());
+                    Ingredient.setSyRemaining(remaininglist);
+                }
             }
             //辅料含税成本 美元
             if(Ingredient.getUsdAmount()!=null){