Quellcode durchsuchen

面料损耗更新

fenghaifu vor 2 Jahren
Ursprung
Commit
d139868b81

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricCostInvoice.java

@@ -78,7 +78,7 @@ public class FabricCostInvoice {
 
 	public static FabricCostInvoice getAdjustItem(){
 		FabricCostInvoice ret = new FabricCostInvoice();
-		ret.setCVCName("调整");
+		ret.setCVCName("调整");
 		ret.setCVenAbbName("");
 		ret.setCBusType("");
 		ret.setIMoney(0.0);

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

@@ -113,8 +113,8 @@
 	<select id="getPurchaseInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderIn">
 		select a.cCode,a.cBusType,b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,b.iQuantity,e.cInvName,
 		isnull(b.iSumBillQuantity,0) as iQuantityInvoice,
-		isnull(isnull((select sum(x.iSum)/sum(x.iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),b.iSum/b.iQuantity),0) as iPrice,
-		isnull(isnull((select sum(x.iSum) from PurBillVouchs  x where x.RdsId =b.autoid),b.iSum ),0) as iPurchuseMoney,
+		isnull(isnull((select sum(case when y.cexch_name='美元' then convert(decimal(18,4),isnull(x.cdefine27,'0'))*x.iPBVQuantity else x.iSum end)/sum(x.iPBVQuantity ) from PurBillVouchs x inner join purbillvouch y on x.PBVID =y.PBVID where x.RdsId =b.autoid),b.iSum/b.iQuantity),0) as iPrice,
+		isnull(isnull((select sum(case when y.cexch_name='美元' then convert(decimal(18,4),isnull(x.cdefine27,'0'))*x.iPBVQuantity else x.iSum end) from PurBillVouchs  x inner join purbillvouch y on x.PBVID =y.PBVID where x.RdsId =b.autoid),b.iSum ),0) as iPurchuseMoney,
 		isnull(b.iSQuantity,0) as iQuantitySettle,
 		g.cVCName,f.cVenName ,f.cVenAbbName,isnull(d.cPOID,'') as cPlanCode,e.cInvCCode
 		from RdRecord01 a inner join RdRecords01 b on a.id=b.id
@@ -210,7 +210,7 @@
 		d.cVCName,c.cVenName,c.cVenAbbName,
 			 x.cInvCode as cInvCode,y.cInvName as cInvName,isnull(x.cFree1,'') as cColor,isnull(x.cBatch,'') as cBatch,
 			 isnull(x.iQuantity,0) as iQuantityIn,
-			 isnull(isnull((select  sum(n.iSum) from  PurBillVouchs  n where n.RdsId =x.autoid),0),0) as iProcessFee,
+			 isnull(isnull((select  sum(case when m.cexch_name='美元' then convert(decimal(18,4),isnull(n.cdefine27,'0'))*n.iPBVQuantity else n.iSum end) from  PurBillVouchs n inner join purbillvouch m on m.PBVID =n.PBVID where n.RdsId =x.autoid),0),0) as iProcessFee,
 			 isnull(x.iSumBillQuantity,0) as iSumBillQuantity,isnull(x.iSQuantity,0) as iSQuantity,
 			 isnull((select sum(isnull(iquantity,0)) as iQuantityOut from rdrecords11 d where d.iOMoDID=b.MODetailsID),0) as iQuantityOut,
 			 y.cInvCCode
@@ -370,7 +370,7 @@
 	<!-- 根据入库单子表id获取采购入库价格 -->
 	<select id="getPoInPriceList" resultType="org.jeecg.modules.report.entity.FabricInPrice">
 		select  b.AutoId,
-		isnull(isnull((select sum(iSum)/sum(iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),b.iSum/b.iQuantity),0) as iPrice
+		isnull(isnull((select sum(case when y.cexch_name='美元' then convert(decimal(18,4),isnull(x.cdefine27,'0'))*x.iPBVQuantity else x.iSum end)/sum(x.iPBVQuantity ) from PurBillVouchs  x inner join purbillvouch y on x.PBVID =y.PBVID where x.RdsId =b.autoid),b.iSum/b.iQuantity),0) as iPrice
 		from rdrecords01 b
 		where b.autoId in
 		<foreach  item="item" collection="autoIdList" index="index"  open="(" separator="," close=")">
@@ -392,7 +392,7 @@
 	<select id="getOmInOutInfoListByDetailId" resultType="map">
 
 		select a.MODetailsID,
-		isnull((select  isnull(sum(y.iSum),0) from  rdrecords01 x inner join PurBillVouchs  y on y.RdsId =x.autoid where x.iOMoDID=a.MODetailsID),0) as iProcessFee,
+		isnull((select  isnull(sum(case when z.cexch_name='美元' then convert(decimal(18,4),isnull(y.cdefine27,'0'))*y.iPBVQuantity else y.iSum end),0) from  rdrecords01 x inner join PurBillVouchs  y on y.RdsId =x.autoid inner join purbillvouch z on z.PBVID =y.PBVID where x.iOMoDID=a.MODetailsID),0) as iProcessFee,
 		isnull((select  sum(x.iQuantity) from  rdrecords01 x where x.iOMoDID=a.MODetailsID),0) as iQuantityIn,
 		b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') as cInvIdOut,b.iQuantity as iQuantityOut
 		from OM_MODetails a
@@ -506,7 +506,7 @@
 		select  b.AutoId,a.cCode,isnull(b.cPOID,'') as cPlanCode,a.cBusType,e.cVCName,d.cVenName,d.cVenAbbName,
 		b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvName,b.iQuantity,
 		case when a.cbustype='委外加工' then 0 else
-		isnull(isnull((select sum(iSum)/sum(iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),b.iSum/b.iQuantity),0)  end
+		isnull(isnull((select sum(case when y.cexch_name='美元' then convert(decimal(18,4),isnull(x.cdefine27,'0'))*x.iPBVQuantity else x.iSum end)/sum(x.iPBVQuantity ) from PurBillVouchs  x inner join purbillvouch y on x.PBVID =y.PBVID where x.RdsId =b.autoid),b.iSum/b.iQuantity),0)  end
 		as iPrice,
 		isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode
 
@@ -549,7 +549,7 @@
 		d.cVCName,c.cVenName,c.cVenAbbName,
 			 x.cInvCode as cInvCode,y.cInvName as cInvName,isnull(x.cFree1,'') as cColor,isnull(x.cBatch,'') as cBatch,
 			 isnull(x.iQuantity,0) as iQuantityIn,
-			 isnull(isnull((select  sum(n.iSum) from  PurBillVouchs  n where n.RdsId =x.autoid),0),0) as iProcessFee,
+			 isnull(isnull((select  sum(case when m.cexch_name='美元' then convert(decimal(18,4),isnull(n.cdefine27,'0'))*n.iPBVQuantity else n.iSum end) from  PurBillVouchs n inner join purbillvouch m on m.PBVID =n.PBVID where n.RdsId =x.autoid),0),0) as iProcessFee,
 			 isnull(x.iSumBillQuantity,0) as iSumBillQuantity,isnull(x.iSQuantity,0) as iSQuantity,
 			 (select sum(isnull(iquantity,0)) as iQuantityOut from rdrecords11 d where d.iOMoDID=b.MODetailsID) as iQuantityOut,
 			 y.cInvCCode
@@ -570,7 +570,7 @@
 	</select>
 	<!-- 获取销售出库数量 -->
 	<select id="getSaleOutList" resultType="org.jeecg.modules.report.entity.FabricMoOrderCK">
-		select a.ccode as cOmCode,c.cInvCode as cInvCodeOut,d.cInvName as cInvNameOut,
+		select distinct c.autoid,a.ccode as cOmCode,c.cInvCode as cInvCodeOut,d.cInvName as cInvNameOut,
 		isnull(c.cFree1,'') as cColorOut,isnull(c.cBatch,'') as cBatchOut,c.iQuantity as iQuantityOut,
 		isnull(c.cbatchproperty9,'') as cVenAbbName
 		from om_momain a

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

@@ -740,6 +740,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		}
 		//获取委外订单运费发票金额
 		List<FabricCostInvoice> fabricCostInvoiceList3 = fabricLossMapper.getOmInvoiceMoneyYfList(code);
+		Double dMoneyYf = fabricCostInvoiceList3.stream().mapToDouble(FabricCostInvoice::getIMoney).sum();  // 运费总金额
 		fabricCostInvoiceList.addAll(fabricCostInvoiceList3);
 		// 织、染、印排序
 		fabricCostInvoiceList.forEach(e->{
@@ -759,6 +760,13 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 
 		fabricCostInvoiceList.addAll(inoutCostList);
 
+		// 第一行转出成本减去运费发票
+		Optional<FabricCostInvoice> findOutInvoiceOpt = inoutCostList.stream().filter(e->"转出成本".equalsIgnoreCase(e.getCBusType())).findFirst();
+		if (findOutInvoiceOpt.isPresent()){
+			FabricCostInvoice findOutInvoice = findOutInvoiceOpt.get();
+			findOutInvoice.setIMoney(DoubleOperation.sub(findOutInvoice.getIMoney(),dMoneyYf));
+		}
+
 		// 调整行
 		FabricCostInvoice adjustItem = FabricCostInvoice.getAdjustItem();
 		if (editData != null){