Browse Source

面料损耗更新

fenghaifu 2 years ago
parent
commit
e7c353c19c

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricPoOrderIn.java

@@ -30,6 +30,9 @@ public class FabricPoOrderIn {
 	//存货编码
 	@ApiModelProperty(value = "存货编码")
 	private  String cInvCode;
+	//存货名称
+	@ApiModelProperty(value = "存货名称")
+	private  String cInvName;
 	//颜色
 	@ApiModelProperty(value = "颜色")
 	private String cColor;

+ 7 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/xml/FabricLossMapper.xml

@@ -165,7 +165,7 @@
 		(
 		SELECT
 			a.comcode as cCode,case when a.iSQuantity is null or a.iSQuantity=0 then a.iquantity else a.iSQuantity end as iQuantity,
-			isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
+			isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,a.cInvCode,isnull(a.cFree1,'') as cColor,
 			case when a.cBatch is not null and a.cBatch='期初' then '期初'
 			else
 				isnull(stuff((
@@ -205,7 +205,7 @@
 		) union all (
 		SELECT
 			a.comcode as cCode,case when a.iSQuantity is null or a.iSQuantity=0 then a.iquantity else a.iSQuantity end as iQuantity,
-			isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
+			isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,a.cInvCode,isnull(a.cFree1,'') as cColor,
 			case when a.cBatch is not null and a.cBatch='期初' then '期初'
 			else
 				isnull(stuff((
@@ -359,13 +359,14 @@
 	</select>
 	<!--获取本次采购入库单,含发票和结算数据-->
 	<select id="getPurchaseInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderIn">
-		select a.cCode,a.cBusType,b.cInvCode,b.cFree1 as cColor,b.cBatch,b.iQuantity,
+		select a.cCode,a.cBusType,b.cInvCode,b.cFree1 as cColor,b.cBatch,b.iQuantity,e.cInvName,
 		isnull((select sum(iPBVQuantity ) from PurBillVouchs x where x.RdsId =b.autoid),0) as iQuantityInvoice,
-		isnull((select sum(iSum)/sum(iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),0) as iPrice,
+		isnull(isnull((select sum(iSum)/sum(iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),b.iSum/b.iQuantity),0) as iPrice,
 		isnull((select sum(iSVQuantity) from PurSettleVouchs  x where x.iRdsID=b.autoid),0) as iQuantitySettle
 		from RdRecord01 a inner join RdRecords01 b on a.id=b.id
 		inner join PO_Podetails c on  b.iposid=c.id
 		inner join PO_Pomain d on d.poid=c.poid
+		inner join Inventory e on b.cinvcode=e.cinvcode
 		where d.cPOID like CONCAT(#{code},'%')
 	</select>
 	<!--获取费用支出-->
@@ -630,7 +631,7 @@
 			select f.cBusType,f.cCode,g.cVenName,g.cVenAbbName,
 			e.cInvCode,isnull(e.cFree1,'') as cColor,isnull(e.cBatch,'') as cBatch,
 			e.iQuantity,
-			isnull((select sum(iSum) from PurBillVouchs  x where x.RdsId =e.autoid and f.cbustype='普通采购'),0) as iPurchuseMoney,
+			isnull(isnull((select sum(iSum) from PurBillVouchs  x where x.RdsId =e.autoid and f.cbustype='普通采购'),iSum ),0) as iPurchuseMoney,
 			e.iOMoDID as MODetailsID
 			from rdrecords01 e
 				inner join rdrecord01 f on e.id=f.id
@@ -682,7 +683,7 @@
 	select e.autoid,f.cBusType,f.cCode,g.cVenName,g.cVenAbbName,
 		e.cInvCode,isnull(e.cFree1,'') as cColor,isnull(e.cBatch,'') as cBatch,
 		e.iQuantity,
-		isnull((select sum(iSum) from PurBillVouchs  x where x.RdsId =e.autoid and f.cbustype='普通采购'),0) as iPurchuseMoney,
+		isnull(isnull((select sum(iSum) from PurBillVouchs  x where x.RdsId =e.autoid and f.cbustype='普通采购'),iSum ),0) as iPurchuseMoney,
 		e.iOMoDID as MODetailsID,
 		(select top 1  x.cInvCode2+isnull(x.cColor2,'')+isnull(x.cAVBatch2,'') from
 				VIEW_FabricLoss_AssemVouchs x where

+ 18 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/service/impl/FabricLossServiceImpl.java

@@ -691,8 +691,25 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			BigDecimal bdVal = new BigDecimal(fabricPoOrderLyys.getIQuantityIn());
 			fabricPoOrderLyys.setIQuantityIn(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 		}
-		// 单价数量保留位数、计划号处理
+		// 获取委外订单出库物料的入库物料信息:包含采购入库、委外入库
+		List<Map<String,Object>> rowInList = fabricLossMapper.getOmRowInList(code);
+		List<Map<String,Object>> rowInListWithAV = fabricLossMapper.getOmRowInListWithAV(code);
+		rowInList.addAll(rowInListWithAV);
+		List<Map<String,Object>> purchuseInList = rowInList.stream().filter(e->"普通采购".equals(e.get("cBusType").toString())).collect(Collectors.toList());
+
+		// 单价数量保留位数、计划号处理,根据委外处理的出库物料重新设置价格
 		for (FabricPoOrderOut item : fabricPoOrderOutListGroup){
+
+			Optional<Map<String,Object>> findInOpt = purchuseInList.stream().filter(e->
+					e.get("cInvCode").equals(item.getCInvCode()) &&
+					e.get("cColor").equals(item.getCColor()) &&
+					e.get("cBatch").equals(item.getCBatch())).findFirst();
+			if (findInOpt.isPresent()){
+				Map<String,Object> findIn = findInOpt.get();
+				item.setIPrice(oConvertUtils.getDouble(findIn.get("iPurchuseMoney").toString(), 0)/oConvertUtils.getDouble(findIn.get("iQuantity").toString(),0));
+				item.setIMoney(item.getIPrice()*item.getIQuantity());
+			}
+
 			BigDecimal bdVal = new BigDecimal(item.getIPrice());
 			item.setIPrice(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 			bdVal = new BigDecimal(item.getIQuantity());