Browse Source

面料损耗更新

fenghaifu 2 years ago
parent
commit
a746fbd9e4

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.report.entity;
 package org.jeecg.modules.report.entity;
 
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
 /**
 /**
@@ -26,4 +27,17 @@ public class FabricAssemVouchsOrgIn {
 	private String cInvIdAfter;
 	private String cInvIdAfter;
 	// 转换最终物料,用于匹配出库数据
 	// 转换最终物料,用于匹配出库数据
 	private String cInvIdFinal;
 	private String cInvIdFinal;
+	// 转换系数 转换前/转换后
+	private Double iRate;
+
+	@ApiModelProperty(value = "入库单号")
+	private  String cCode;
+	@ApiModelProperty(value = "委外订单号")
+	private  String cPlanCode;
+	@ApiModelProperty(value = "供应商分类")
+	private String  cVCName;
+	@ApiModelProperty(value = "供应商名称")
+	private  String cVenName;
+	@ApiModelProperty(value = "供应商简称")
+	private  String cVenAbbName;
 }
 }

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

@@ -57,6 +57,9 @@ public class FabricCommonIn {
 	@ApiModelProperty(value = "含税单价")
 	@ApiModelProperty(value = "含税单价")
 	private Double iPrice;
 	private Double iPrice;
 
 
+	// 转换系数 转换前/转换后
+	private Double iRate;
+
 	// 委外订单子表id
 	// 委外订单子表id
 	private Integer MODetailsID;
 	private Integer MODetailsID;
 	// 采购订单子表id
 	// 采购订单子表id

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

@@ -59,6 +59,8 @@ public class FabricCostAssist {
 	//原币金额
 	//原币金额
 	@ApiModelProperty(value = "原币金额")
 	@ApiModelProperty(value = "原币金额")
 	private  Double iOriSum;
 	private  Double iOriSum;
+	@ApiModelProperty(value = "无税金额")
+	private  Double iNoTaxMoney;
 
 
 	List<FabricCostAssistDetail> fabricCostAssistDetailList;
 	List<FabricCostAssistDetail> fabricCostAssistDetailList;
 }
 }

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

@@ -44,6 +44,8 @@ public class FabricCostInvoice {
 	//金额
 	//金额
 	@ApiModelProperty(value = "金额")
 	@ApiModelProperty(value = "金额")
 	private  Double iMoney;
 	private  Double iMoney;
+	@ApiModelProperty(value = "无税金额")
+	private  Double iNoTaxMoney;
 	//业务类型(采购/委外)
 	//业务类型(采购/委外)
 	@ApiModelProperty(value = "业务类型(采购/委外)")
 	@ApiModelProperty(value = "业务类型(采购/委外)")
 	private  String cBusType;
 	private  String cBusType;

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

@@ -20,4 +20,16 @@ public class FabricInPrice {
 	private  Integer AutoId;
 	private  Integer AutoId;
 	@ApiModelProperty(value = "含税单价")
 	@ApiModelProperty(value = "含税单价")
 	private Double iPrice;
 	private Double iPrice;
+	@ApiModelProperty(value = "入库单号")
+	private  String cCode;
+	@ApiModelProperty(value = "委外订单号")
+	private  String cPlanCode;
+	@ApiModelProperty(value = "供应商分类")
+	private String  cVCName;
+	@ApiModelProperty(value = "供应商名称")
+	private  String cVenName;
+	@ApiModelProperty(value = "供应商简称")
+	private  String cVenAbbName;
+	@ApiModelProperty(value = "单据类型")
+	private  String cBusType;
 }
 }

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

@@ -53,6 +53,9 @@ public class FabricMoOrderRK {
     // 计算过程临时用到的,累计使用数量
     // 计算过程临时用到的,累计使用数量
     private Double iTempUseSum;
     private Double iTempUseSum;
 
 
+    @ApiModelProperty(value = "无税加工费")
+    private  Double iNoTaxProcessFee;
+
     public String getInvId(){return cInvCode+cColor+cBatch;}
     public String getInvId(){return cInvCode+cColor+cBatch;}
     // 委外订单行入库详情分组
     // 委外订单行入库详情分组
     public String getGroupId(){
     public String getGroupId(){

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

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
 import org.jeecg.modules.system.util.DoubleOperation;
 import org.jeecg.modules.system.util.DoubleOperation;
+import org.jeecg.modules.system.util.oConvertUtils;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -92,6 +93,9 @@ public class FabricPoOrder {
         // 出库单根据委外订单号,物料,批号分组,用来展示明细
         // 出库单根据委外订单号,物料,批号分组,用来展示明细
         List<FabricPoOrderOut> poOrderOutGroupList = new ArrayList<>();
         List<FabricPoOrderOut> poOrderOutGroupList = new ArrayList<>();
         for (FabricPoOrderOut poOrderOut : poOrderOutList) {
         for (FabricPoOrderOut poOrderOut : poOrderOutList) {
+            if (oConvertUtils.isEmpty(poOrderOut.getCPlanCode())){
+                poOrderOut.setCPlanCode("");
+            }
             Optional<FabricPoOrderOut> findOpt = poOrderOutGroupList.stream().filter(e -> e.getGroupId().equalsIgnoreCase(poOrderOut.getGroupId())).findFirst();
             Optional<FabricPoOrderOut> findOpt = poOrderOutGroupList.stream().filter(e -> e.getGroupId().equalsIgnoreCase(poOrderOut.getGroupId())).findFirst();
             // 已有,计划号逗号分割相加,计算数量,金额,单价
             // 已有,计划号逗号分割相加,计算数量,金额,单价
             if (findOpt.isPresent()) {
             if (findOpt.isPresent()) {

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

@@ -77,6 +77,10 @@ public class FabricPoOrderIn {
 	// 计算过程临时用到的,累计使用数量
 	// 计算过程临时用到的,累计使用数量
 	private Double iTempUseSum;
 	private Double iTempUseSum;
 
 
+	//无税单价
+	@ApiModelProperty(value = "无税单价")
+	private Double iNoTaxPrice;
+
 	public String getParentId(){
 	public String getParentId(){
 		return cInvCode+cColor;
 		return cInvCode+cColor;
 	}
 	}

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

@@ -115,6 +115,7 @@
 		isnull(b.iSumBillQuantity,0) as iQuantityInvoice,
 		isnull(b.iSumBillQuantity,0) as iQuantityInvoice,
 		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)/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(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((select sum(x.iMoney)/sum(x.iPBVQuantity ) from PurBillVouchs x inner join purbillvouch y on x.PBVID =y.PBVID where x.RdsId =b.autoid),0) as iNoTaxPrice,
 		isnull(b.iSQuantity,0) as iQuantitySettle,
 		isnull(b.iSQuantity,0) as iQuantitySettle,
 		g.cVCName,f.cVenName ,f.cVenAbbName,isnull(d.cPOID,'') as cPlanCode,e.cInvCCode
 		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
 		from RdRecord01 a inner join RdRecords01 b on a.id=b.id
@@ -203,7 +204,7 @@
 	<!--委外订单-采购入库详情-->
 	<!--委外订单-采购入库详情-->
 	<select id="getOmInDetailList" resultType="org.jeecg.modules.report.entity.FabricMoOrderRK">
 	<select id="getOmInDetailList" resultType="org.jeecg.modules.report.entity.FabricMoOrderRK">
 	select cPlanCode,cCode,MODetailsID,cVCName,cVenName,cVenAbbName,cInvCCode,cInvCode,cInvName,cColor,cBatch,
 	select cPlanCode,cCode,MODetailsID,cVCName,cVenName,cVenAbbName,cInvCCode,cInvCode,cInvName,cColor,cBatch,
-		sum(iQuantityIn) as iQuantityIn,sum(iProcessFee) as iProcessFee,sum(iSQuantity) as iSQuantity,
+		sum(iQuantityIn) as iQuantityIn,sum(iProcessFee) as iProcessFee, sum(iNoTaxProcessFee) as iNoTaxProcessFee, sum(iSQuantity) as iSQuantity,
 		sum(iQuantityOut) as iQuantityOut,sum(iSumBillQuantity) as iSumBillQuantity
 		sum(iQuantityOut) as iQuantityOut,sum(iSumBillQuantity) as iSumBillQuantity
 	 from (
 	 from (
 		select isnull(a.cCode,'') as cPlanCode,z.cCode,b.MODetailsID,
 		select isnull(a.cCode,'') as cPlanCode,z.cCode,b.MODetailsID,
@@ -211,6 +212,7 @@
 			 x.cInvCode as cInvCode,y.cInvName as cInvName,isnull(x.cFree1,'') as cColor,isnull(x.cBatch,'') as cBatch,
 			 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(x.iQuantity,0) as iQuantityIn,
 			 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(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((select  sum(n.iMoney ) from  PurBillVouchs n inner join purbillvouch m on m.PBVID =n.PBVID where n.RdsId =x.autoid),0) as iNoTaxProcessFee,
 			 isnull(x.iSumBillQuantity,0) as iSumBillQuantity,isnull(x.iSQuantity,0) as iSQuantity,
 			 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,
 			 isnull((select sum(isnull(iquantity,0)) as iQuantityOut from rdrecords11 d where d.iOMoDID=b.MODetailsID),0) as iQuantityOut,
 			 y.cInvCCode
 			 y.cInvCCode
@@ -331,7 +333,7 @@
 		(
 		(
 		select  'rdrecords01' as cTableName,b.AutoId,a.cBusType,
 		select  'rdrecords01' as cTableName,b.AutoId,a.cBusType,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
-		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter
+		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter,c.iAVQuantity/c.iAVQuantity2 as iRate
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords01 b,rdrecord01 a,Vendor d, VendorClass e
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords01 b,rdrecord01 a,Vendor d, VendorClass e
 		where a.id=b.id and d.cVenCode=a.cVenCode and d.cVCCode =e.cVCCode
 		where a.id=b.id and d.cVenCode=a.cVenCode and d.cVCCode =e.cVCCode
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and b.iQuantity &lt;&gt; 0
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and b.iQuantity &lt;&gt; 0
@@ -342,7 +344,7 @@
 		) union all (
 		) union all (
 		select  'rdrecords08' as cTableName,b.AutoId,a.cBusType,
 		select  'rdrecords08' as cTableName,b.AutoId,a.cBusType,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
-		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter
+		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter,c.iAVQuantity/c.iAVQuantity2 as iRate
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords08 b,rdrecord08 a
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords08 b,rdrecord08 a
 		where a.id=b.id
 		where a.id=b.id
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and a.cbustype= '其他入库'
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and a.cbustype= '其他入库'
@@ -354,7 +356,7 @@
 		) union all (
 		) union all (
 		select  'rdrecords08' as cTableName,b.AutoId,a.cBusType,
 		select  'rdrecords08' as cTableName,b.AutoId,a.cBusType,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
 		b.cInvCode+isnull(b.cFree1,'')+isnull(b.cBatch,'') as cInvIdBefore,
-		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter
+		c.cInvCode2+c.cColor2+c.cAVBatch2 as cInvIdAfter,c.iAVQuantity/c.iAVQuantity2 as iRate
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords08 b,rdrecord08 a
 		from VIEW_FabricLoss_AssemVouchs c,rdrecords08 b,rdrecord08 a
 		where a.id=b.id
 		where a.id=b.id
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and a.cbustype = '转换入库'
 		and c.cinvcode+ccolor+cavbatch=b.cinvcode +isnull(b.cFree1,'')+isnull(b.cBatch,'') and a.cbustype = '转换入库'
@@ -369,9 +371,15 @@
 	</select>
 	</select>
 	<!-- 根据入库单子表id获取采购入库价格 -->
 	<!-- 根据入库单子表id获取采购入库价格 -->
 	<select id="getPoInPriceList" resultType="org.jeecg.modules.report.entity.FabricInPrice">
 	<select id="getPoInPriceList" resultType="org.jeecg.modules.report.entity.FabricInPrice">
-		select  b.AutoId,
+		select isnull(d.cPOID,'') as cPlanCode, a.cBusType,a.cCode,g.cVCName,f.cVenName ,f.cVenAbbName,
+		b.AutoId,
 		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)/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
 		from rdrecords01 b
+		inner join RdRecord01 a 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 Vendor f on f.cVenCode=a.cVenCode
+		inner join VendorClass g on g.cVCCode =f.cVCCode
 		where b.autoId in
 		where b.autoId in
 		<foreach  item="item" collection="autoIdList" index="index"  open="(" separator="," close=")">
 		<foreach  item="item" collection="autoIdList" index="index"  open="(" separator="," close=")">
 			#{item}
 			#{item}
@@ -508,7 +516,7 @@
 		case when a.cbustype='委外加工' then 0 else
 		case when a.cbustype='委外加工' then 0 else
 		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
 		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,
 		as iPrice,
-		isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode
+		isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate
 
 
 		from rdrecords01 b
 		from rdrecords01 b
 			inner join rdrecord01 a on  a.id=b.id
 			inner join rdrecord01 a on  a.id=b.id
@@ -523,7 +531,7 @@
 		select  b.AutoId,a.cCode, isnull(a.cdefine9,'') as cPlanCode,a.cBusType,'' as cVCName,'' as cVenName,'' as cVenAbbName,
 		select  b.AutoId,a.cCode, isnull(a.cdefine9,'') as cPlanCode,a.cBusType,'' as cVCName,'' as cVenName,'' as cVenAbbName,
 		b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvname,b.iQuantity,
 		b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvname,b.iQuantity,
 		isnull(case when a.cMaker='王行乔' then b.iPrice/b.iQuantity else b.iPrice*1.13/b.iQuantity end,0) as iPrice,
 		isnull(case when a.cMaker='王行乔' then b.iPrice/b.iQuantity else b.iPrice*1.13/b.iQuantity end,0) as iPrice,
-		0 as MODetailsID, 0 as PoDetailsID,f.cInvCCode
+		0 as MODetailsID, 0 as PoDetailsID,f.cInvCCode,1.0 as iRate
 		from rdrecords08 b
 		from rdrecords08 b
 		inner join rdrecord08 a on  a.id=b.id
 		inner join rdrecord08 a on  a.id=b.id
 		inner join Inventory  f ON b.cinvcode = f.cinvcode
 		inner join Inventory  f ON b.cinvcode = f.cinvcode
@@ -570,6 +578,24 @@
 	</select>
 	</select>
 	<!-- 获取销售出库数量 -->
 	<!-- 获取销售出库数量 -->
 	<select id="getSaleOutList" resultType="org.jeecg.modules.report.entity.FabricMoOrderCK">
 	<select id="getSaleOutList" resultType="org.jeecg.modules.report.entity.FabricMoOrderCK">
+
+		select distinct c.autoid,'' as cOmCode,c.cInvCode as cInvCodeOut,b.cInvName as cInvNameOut,
+		isnull(c.cFree1,'') as cColorOut,isnull(c.cBatch,'') as cBatchOut,c.iQuantity as iQuantityOut,
+				isnull(c.cbatchproperty9,'') as cVenAbbName
+		from rdrecords32 c inner join SO_SODetails d on c.iorderdid=d.iSOsID
+		inner join so_somain e on e.id=d.id
+		INNER JOIN Inventory b ON c.cinvcode = b.cinvcode
+		where d.id in (
+		select distinct e.id
+				from om_momain a
+				inner join OM_MODetails b on a.moid=b.moid
+				inner join rdrecords32 c on c.iorderdid  =b.isosid and b.cinvcode=c.cinvcode
+				INNER JOIN Inventory d ON c.cinvcode = d.cinvcode
+				inner join SO_SODetails e on e.iSOsID=c.isodid
+				where a.ccode like CONCAT(#{code},'%')  and a.ccode not like '%样%' and
+					(d.cInvCCode like '01%' or d.cInvCCode like '02%' or d.cInvCCode like '03%' or d.cInvCCode like '04%')
+		)
+<!--
 		select distinct c.autoid,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.cFree1,'') as cColorOut,isnull(c.cBatch,'') as cBatchOut,c.iQuantity as iQuantityOut,
 		isnull(c.cbatchproperty9,'') as cVenAbbName
 		isnull(c.cbatchproperty9,'') as cVenAbbName
@@ -579,7 +605,7 @@
 		INNER JOIN Inventory d ON c.cinvcode = d.cinvcode
 		INNER JOIN Inventory d ON c.cinvcode = d.cinvcode
 		where a.ccode like CONCAT(#{code},'%')  and a.ccode not like '%样%' and
 		where a.ccode like CONCAT(#{code},'%')  and a.ccode not like '%样%' and
 			(d.cInvCCode like '01%' or d.cInvCCode like '02%' or d.cInvCCode like '03%' or d.cInvCCode like '04%')
 			(d.cInvCCode like '01%' or d.cInvCCode like '02%' or d.cInvCCode like '03%' or d.cInvCCode like '04%')
-
+-->
 	</select>
 	</select>
 	<!--获取本次采购入库的形态转换-->
 	<!--获取本次采购入库的形态转换-->
 	<select id="getPoAssemVouchList" resultType="map">
 	<select id="getPoAssemVouchList" resultType="map">

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

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mongodb.internal.operation.FindOperation;
 import com.mongodb.internal.operation.FindOperation;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CacheConstant;
 import org.jeecg.common.constant.CacheConstant;
@@ -695,18 +696,21 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 							poOrder.getCVCName().equalsIgnoreCase(e.getCVCName()) &&
 							poOrder.getCVCName().equalsIgnoreCase(e.getCVCName()) &&
 							poOrder.getCVenAbbName().equalsIgnoreCase(e.getCVenAbbName())).findFirst();
 							poOrder.getCVenAbbName().equalsIgnoreCase(e.getCVenAbbName())).findFirst();
 			FabricCostInvoice newItem = new FabricCostInvoice();
 			FabricCostInvoice newItem = new FabricCostInvoice();
-			Double dMoney = 0.0;
+			Double dMoney = 0.0,dNoTaxMoney=0.0;
 			if (oConvertUtils.listIsNotEmpty(poOrder.getFabricPoOrderInList())){
 			if (oConvertUtils.listIsNotEmpty(poOrder.getFabricPoOrderInList())){
 				for (FabricPoOrderIn orderIn : poOrder.getFabricPoOrderInList()){
 				for (FabricPoOrderIn orderIn : poOrder.getFabricPoOrderInList()){
 					dMoney = DoubleOperation.add(dMoney, DoubleOperation.mul(orderIn.getIPrice(),orderIn.getIQuantityInvoice(),2));
 					dMoney = DoubleOperation.add(dMoney, DoubleOperation.mul(orderIn.getIPrice(),orderIn.getIQuantityInvoice(),2));
+					dNoTaxMoney = DoubleOperation.add(dNoTaxMoney, DoubleOperation.mul(orderIn.getINoTaxPrice(),orderIn.getIQuantityInvoice(),2));
 				}
 				}
 			}
 			}
 			if (findItem.isPresent()) {
 			if (findItem.isPresent()) {
 				newItem = findItem.get();
 				newItem = findItem.get();
 				newItem.setIMoney(DoubleOperation.add(newItem.getIMoney(), dMoney));
 				newItem.setIMoney(DoubleOperation.add(newItem.getIMoney(), dMoney));
+				newItem.setINoTaxMoney(DoubleOperation.add(newItem.getINoTaxMoney(), dNoTaxMoney));
 			}else{
 			}else{
 				newItem.setCBusType("普通采购");
 				newItem.setCBusType("普通采购");
 				newItem.setIMoney(dMoney);
 				newItem.setIMoney(dMoney);
+				newItem.setINoTaxMoney(dNoTaxMoney);
 				newItem.setCVCName(poOrder.getCVCName());
 				newItem.setCVCName(poOrder.getCVCName());
 				newItem.setCVenName(poOrder.getCVenName());
 				newItem.setCVenName(poOrder.getCVenName());
 				newItem.setCVenAbbName(poOrder.getCVenAbbName());
 				newItem.setCVenAbbName(poOrder.getCVenAbbName());
@@ -720,18 +724,21 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 							omOrder.getCVCName().equalsIgnoreCase(e.getCVCName()) &&
 							omOrder.getCVCName().equalsIgnoreCase(e.getCVCName()) &&
 							omOrder.getCVenAbbName().equalsIgnoreCase(e.getCVenAbbName())).findFirst();
 							omOrder.getCVenAbbName().equalsIgnoreCase(e.getCVenAbbName())).findFirst();
 			FabricCostInvoice newItem = new FabricCostInvoice();
 			FabricCostInvoice newItem = new FabricCostInvoice();
-			Double dMoney = 0.0;
+			Double dMoney = 0.0, dNoTaxMoney=0.0;
 			if (oConvertUtils.listIsNotEmpty(omOrder.getFabricMoOrderRKList())){
 			if (oConvertUtils.listIsNotEmpty(omOrder.getFabricMoOrderRKList())){
 				for (FabricMoOrderRK orderIn : omOrder.getFabricMoOrderRKList()){
 				for (FabricMoOrderRK orderIn : omOrder.getFabricMoOrderRKList()){
 					dMoney = DoubleOperation.add(dMoney, orderIn.getIProcessFee());
 					dMoney = DoubleOperation.add(dMoney, orderIn.getIProcessFee());
+					dNoTaxMoney = DoubleOperation.add(dNoTaxMoney, orderIn.getINoTaxProcessFee());
 				}
 				}
 			}
 			}
 			if (findItem.isPresent()) {
 			if (findItem.isPresent()) {
 				newItem = findItem.get();
 				newItem = findItem.get();
 				newItem.setIMoney(DoubleOperation.add(newItem.getIMoney(), dMoney));
 				newItem.setIMoney(DoubleOperation.add(newItem.getIMoney(), dMoney));
+				newItem.setINoTaxMoney(DoubleOperation.add(newItem.getINoTaxMoney(), dNoTaxMoney));
 			}else{
 			}else{
 				newItem.setCBusType("委外加工");
 				newItem.setCBusType("委外加工");
 				newItem.setIMoney(dMoney);
 				newItem.setIMoney(dMoney);
+				newItem.setINoTaxMoney(dNoTaxMoney);
 				newItem.setCVCName(omOrder.getCVCName());
 				newItem.setCVCName(omOrder.getCVCName());
 				newItem.setCVenName(omOrder.getCVenName());
 				newItem.setCVenName(omOrder.getCVenName());
 				newItem.setCVenAbbName(omOrder.getCVenAbbName());
 				newItem.setCVenAbbName(omOrder.getCVenAbbName());
@@ -766,13 +773,22 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			FabricCostInvoice findOutInvoice = findOutInvoiceOpt.get();
 			FabricCostInvoice findOutInvoice = findOutInvoiceOpt.get();
 			findOutInvoice.setIMoney(DoubleOperation.sub(findOutInvoice.getIMoney(),dMoneyYf));
 			findOutInvoice.setIMoney(DoubleOperation.sub(findOutInvoice.getIMoney(),dMoneyYf));
 		}
 		}
-
+		// 设置保存的无税金额
+		if (editData != null){
+			List<FabricCostInvoice> costInvoiceList = editData.getFabricCostInvoiceList();
+			for (FabricCostInvoice costInvoice : fabricCostInvoiceList){
+				Optional<FabricCostInvoice> findOpt = costInvoiceList.stream().filter(e->e.getId().equalsIgnoreCase(costInvoice.getId())).findFirst();
+				if (findOpt.isPresent()){
+					costInvoice.setINoTaxMoney(findOpt.get().getINoTaxMoney());
+				}
+			}
+		}
 		// 调整行
 		// 调整行
 		FabricCostInvoice adjustItem = FabricCostInvoice.getAdjustItem();
 		FabricCostInvoice adjustItem = FabricCostInvoice.getAdjustItem();
 		if (editData != null){
 		if (editData != null){
 			List<FabricCostInvoice> costInvoiceList = editData.getFabricCostInvoiceList();
 			List<FabricCostInvoice> costInvoiceList = editData.getFabricCostInvoiceList();
 			if (oConvertUtils.listIsNotEmpty(costInvoiceList)) {
 			if (oConvertUtils.listIsNotEmpty(costInvoiceList)) {
-				Optional<FabricCostInvoice> findOpt = costInvoiceList.stream().filter(e->"调整".equalsIgnoreCase(e.getCVCName())).findFirst();
+				Optional<FabricCostInvoice> findOpt = costInvoiceList.stream().filter(e->"调整".equalsIgnoreCase(e.getCVCName())).findFirst();
 				if (findOpt.isPresent()){
 				if (findOpt.isPresent()){
 					adjustItem = findOpt.get();
 					adjustItem = findOpt.get();
 				}
 				}
@@ -1207,7 +1223,6 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 							commonIn.setCVCName(rk.getCVCName());
 							commonIn.setCVCName(rk.getCVCName());
 							commonIn.setCVenName(rk.getCVenName());
 							commonIn.setCVenName(rk.getCVenName());
 							commonIn.setCVenAbbName(rk.getCVenAbbName());
 							commonIn.setCVenAbbName(rk.getCVenAbbName());
-
 						}
 						}
 					}
 					}
 				}
 				}
@@ -1235,11 +1250,18 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			for (FabricInPrice inPrice : priceList) {
 			for (FabricInPrice inPrice : priceList) {
 				for (FabricCommonIn commonIn : commonInList) {
 				for (FabricCommonIn commonIn : commonInList) {
 					Optional<FabricAssemVouchsOrgIn> findOpt = assemVouchsOrgInList.stream().filter(e ->
 					Optional<FabricAssemVouchsOrgIn> findOpt = assemVouchsOrgInList.stream().filter(e ->
-							e.getAutoId().equals(inPrice.getAutoId()) &&
+							inPrice.getAutoId().equals(e.getAutoId()) &&
 									commonIn.getInvId().equalsIgnoreCase(e.getCInvIdFinal())).findFirst();
 									commonIn.getInvId().equalsIgnoreCase(e.getCInvIdFinal())).findFirst();
 					if (findOpt.isPresent()) {
 					if (findOpt.isPresent()) {
 						commonIn.setIPrice(DoubleOperation.getScale(inPrice.getIPrice(), 4));
 						commonIn.setIPrice(DoubleOperation.getScale(inPrice.getIPrice(), 4));
 						commonIn.setCSourceInvId(findOpt.get().getCInvIdAfter());
 						commonIn.setCSourceInvId(findOpt.get().getCInvIdAfter());
+
+						commonIn.setCBusType(inPrice.getCBusType());
+						commonIn.setCCode(inPrice.getCCode());
+						commonIn.setCPlanCode(inPrice.getCPlanCode());
+						commonIn.setCVCName(inPrice.getCVCName());
+						commonIn.setCVenName(inPrice.getCVenName());
+						commonIn.setCVenAbbName(inPrice.getCVenAbbName());
 					}
 					}
 				}
 				}
 			}
 			}
@@ -1304,6 +1326,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		List<FabricPoOrder> poOrderList = ret.getFabricPoOrderList();
 		List<FabricPoOrder> poOrderList = ret.getFabricPoOrderList();
 		for (FabricPoOrder poOrder : poOrderList){
 		for (FabricPoOrder poOrder : poOrderList){
 			Double dOutSum = 0.0;
 			Double dOutSum = 0.0;
+			List<String> omVenList = new ArrayList<>(); // 委外供应商
 			if (oConvertUtils.listIsNotEmpty(poOrder.getFabricPoOrderInList())) {
 			if (oConvertUtils.listIsNotEmpty(poOrder.getFabricPoOrderInList())) {
 				for (FabricPoOrderIn orderIn : poOrder.getFabricPoOrderInList()) {
 				for (FabricPoOrderIn orderIn : poOrder.getFabricPoOrderInList()) {
 					Double dInLeft = orderIn.getIQuantity();    // 入库剩余数量
 					Double dInLeft = orderIn.getIQuantity();    // 入库剩余数量
@@ -1316,6 +1339,9 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 						if (dCurOutSum<=0){
 						if (dCurOutSum<=0){
 							continue;
 							continue;
 						}
 						}
+						if (oConvertUtils.isNotEmpty(ck.getCOmVenAbbName()) && !omVenList.contains(ck.getCOmVenAbbName())){
+							omVenList.add(ck.getCOmVenAbbName());
+						}
 						Double dRealOut = Math.min(dInLeft,dCurOutSum);// 对比入库单,本条出库数量
 						Double dRealOut = Math.min(dInLeft,dCurOutSum);// 对比入库单,本条出库数量
 						ck.setITempUseSum(DoubleOperation.add(ck.getITempUseSum(),dRealOut));// 出库累计数量
 						ck.setITempUseSum(DoubleOperation.add(ck.getITempUseSum(),dRealOut));// 出库累计数量
 						dInLeft = DoubleOperation.sub(dInLeft,dRealOut);    // 入库剩余数量
 						dInLeft = DoubleOperation.sub(dInLeft,dRealOut);    // 入库剩余数量
@@ -1326,7 +1352,8 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 					}
 					}
 				}
 				}
 			}
 			}
-			// 设置分配数量、余纱、损耗
+			// 设置分配数量、余纱、损耗、委外供应商
+			poOrder.setOmcVenAbbName(StringUtils.join(omVenList,","));
 			poOrder.setIQuantityOut(dOutSum);
 			poOrder.setIQuantityOut(dOutSum);
 			poOrder.setIQuantityLeft(DoubleOperation.sub(poOrder.getIQuantityIn(),dOutSum));
 			poOrder.setIQuantityLeft(DoubleOperation.sub(poOrder.getIQuantityIn(),dOutSum));
 			poOrder.setIQuantityLeftRate(DoubleOperation.div(poOrder.getIQuantityLeft(),poOrder.getIQuantityIn(), 4));
 			poOrder.setIQuantityLeftRate(DoubleOperation.div(poOrder.getIQuantityLeft(),poOrder.getIQuantityIn(), 4));
@@ -1350,6 +1377,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				lyysList.add(poOrderOut);
 				lyysList.add(poOrderOut);
 			}else if ("其他入库".equalsIgnoreCase(moOrderCK.getCBusType()) ||
 			}else if ("其他入库".equalsIgnoreCase(moOrderCK.getCBusType()) ||
 					"转换入库".equalsIgnoreCase(moOrderCK.getCBusType()) ||
 					"转换入库".equalsIgnoreCase(moOrderCK.getCBusType()) ||
+					oConvertUtils.isNotEmpty(moOrderCK.getCSourceInvId()) && !moOrderCK.getCSourceInvId().equalsIgnoreCase(moOrderCK.getInvOutId()) ||
 					"杂纱".equalsIgnoreCase(moOrderCK.getCInvNameOut())){
 					"杂纱".equalsIgnoreCase(moOrderCK.getCInvNameOut())){
 				qtrkList.add(poOrderOut);
 				qtrkList.add(poOrderOut);
 			}
 			}
@@ -1443,10 +1471,14 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		}
 		}
 		// 销售出库和成衣出库
 		// 销售出库和成衣出库
 		List<FabricMoOrderCK> otherOutList = new ArrayList<>();
 		List<FabricMoOrderCK> otherOutList = new ArrayList<>();
-		otherOutList.addAll(fabricLossMapper.getOmOutList19(code));// 销售出库
-		otherOutList.addAll(fabricLossMapper.getSaleOutList(code));// 成衣材料出库
+		otherOutList.addAll(fabricLossMapper.getOmOutList19(code));// 成衣材料出库
+		otherOutList.addAll(fabricLossMapper.getSaleOutList(code));// 销售出库
 		allOutList.addAll(otherOutList);
 		allOutList.addAll(otherOutList);
-		allOutList.forEach(e->e.setCSourceInvId(""));
+		allOutList.forEach(e->{
+			if (oConvertUtils.isEmpty(e.getCSourceInvId())) {
+				e.setCSourceInvId("");
+			}
+		});
 
 
 		// 获取委外订单出库物料入库详情
 		// 获取委外订单出库物料入库详情
 		if (otherOutList.size()>0) {
 		if (otherOutList.size()>0) {
@@ -1456,7 +1488,10 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			inList = getAssemVouchSourceInvId(inList);
 			inList = getAssemVouchSourceInvId(inList);
 			for (FabricCommonIn item : inList) {
 			for (FabricCommonIn item : inList) {
 				List<FabricMoOrderCK> findList = otherOutList.stream().filter(e -> e.getInvOutId().equalsIgnoreCase(item.getInvId())).collect(Collectors.toList());
 				List<FabricMoOrderCK> findList = otherOutList.stream().filter(e -> e.getInvOutId().equalsIgnoreCase(item.getInvId())).collect(Collectors.toList());
-				findList.forEach(e -> e.setCSourceInvId(item.getCSourceInvId()));
+				findList.forEach(e -> {
+					e.setCSourceInvId(item.getCSourceInvId());
+					e.setIQuantityOut(DoubleOperation.mul(e.getIQuantityOut(), item.getIRate(), 2));
+				});
 			}
 			}
 		}
 		}
 		// 入 - 出 : 出大于0 的,是转入;入大于0 的是转出
 		// 入 - 出 : 出大于0 的,是转入;入大于0 的是转出
@@ -1577,6 +1612,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			orgIn.setCInvIdFinal(commonIn.getInvId());
 			orgIn.setCInvIdFinal(commonIn.getInvId());
 			orgIn.setCInvIdAfter(commonIn.getInvId());
 			orgIn.setCInvIdAfter(commonIn.getInvId());
 			orgIn.setCBusType(commonIn.getCBusType());
 			orgIn.setCBusType(commonIn.getCBusType());
+			orgIn.setIRate(1.0);
 			assemVouchsInvIdList.add(orgIn);
 			assemVouchsInvIdList.add(orgIn);
 		}
 		}
 		// 获取物业原始入库单信息
 		// 获取物业原始入库单信息
@@ -1599,6 +1635,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 						item.setCTableName(findItem.getCTableName());
 						item.setCTableName(findItem.getCTableName());
 						item.setCInvIdAfter(findItem.getCInvIdBefore());
 						item.setCInvIdAfter(findItem.getCInvIdBefore());
 						item.setAutoId(findItem.getAutoId());
 						item.setAutoId(findItem.getAutoId());
+						item.setIRate(DoubleOperation.mul(item.getIRate(), findItem.getIRate()));
 					}
 					}
 				}
 				}
 			}
 			}
@@ -1607,6 +1644,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			Optional<FabricAssemVouchsOrgIn> findOpt = assemVouchsInvIdList.stream().filter(e->e.getCInvIdFinal().equals(commonIn.getInvId())).findFirst();
 			Optional<FabricAssemVouchsOrgIn> findOpt = assemVouchsInvIdList.stream().filter(e->e.getCInvIdFinal().equals(commonIn.getInvId())).findFirst();
 			if (findOpt.isPresent()){
 			if (findOpt.isPresent()){
 				commonIn.setCSourceInvId(findOpt.get().getCInvIdAfter());
 				commonIn.setCSourceInvId(findOpt.get().getCInvIdAfter());
+				commonIn.setIRate(findOpt.get().getIRate());
 			}
 			}
 		}
 		}