Browse Source

陈本分配

zengtx 2 years ago
parent
commit
d52b03a2d9

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

@@ -190,6 +190,10 @@ public class SyCostAllocation implements Serializable {
     @ExcelCollection(name="汇率")
     @ExcelCollection(name="汇率")
     @ApiModelProperty(value = "汇率")
     @ApiModelProperty(value = "汇率")
     private BigDecimal exchangeRate;
     private BigDecimal exchangeRate;
+    @TableField(exist = false)
+    @ExcelCollection(name="销售单价")
+    @ApiModelProperty(value = "销售单价")
+    private BigDecimal soPrice;
 
 
     /**供应商事故单美金金额*/
     /**供应商事故单美金金额*/
     @ApiModelProperty(value = "供应商事故单美金金额")
     @ApiModelProperty(value = "供应商事故单美金金额")

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

@@ -244,7 +244,7 @@ select
 
 
 		from
 		from
 		(
 		(
-		select ot.cFree1 as color,max(oti.cInvName) as goodsName,sum(ot.iQuantity) as planQuantity
+		select ot.cFree1 as color,max(oti.cInvName) as goodsName,sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
 		from UFDATA_101_2021.dbo.om_momain om
 		from UFDATA_101_2021.dbo.om_momain om
 		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 		join UFDATA_101_2021.dbo.OM_MODetails od on om.moid=od.moid
 		join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
 		join UFDATA_101_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
@@ -278,7 +278,7 @@ select
 
 
 		from
 		from
 		(
 		(
-		select ot.cFree1 as color,max(oti.cInvName) as goodsName,sum(ot.iQuantity) as planQuantity
+		select ot.cFree1 as color,max(oti.cInvName) as goodsName,sum(ot.iQuantity) as planQuantity,sum(ot.iSendQTY) as usageQuantity
 		from UFDATA_103_2021.dbo.om_momain om
 		from UFDATA_103_2021.dbo.om_momain om
 		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
 		join UFDATA_103_2021.dbo.OM_MODetails od on om.moid=od.moid
 		join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
 		join UFDATA_103_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID

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

@@ -38,11 +38,11 @@
 				join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
 				join UFDATA_103_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
 				join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
 				join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
 				left join (
 				left join (
-						SELECT p.cInvCode,p.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
+						SELECT bi.cInvCode,p.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
 									,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
 									,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
 						from UFDATA_103_2021.dbo.PO_Podetails p      
 						from UFDATA_103_2021.dbo.PO_Podetails p      
 						join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID 
 						join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=p.ID 
-						GROUP BY p.cInvCode,p.iorderdid 
+						GROUP BY bi.cInvCode,p.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 				WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%' 
 				WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%' 
 							and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%' 
 							and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%' 
@@ -113,7 +113,7 @@
 						union all
 						union all
 
 
 						 select
 						 select
-						pod.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
+						bi.cInvCode,pod.iorderdid,sum(bi.iSum) as rmbAmount,sum(bi.iOriSum) as usdAmount
 						,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
 						,sum(bi.iMoney) as priceExcludingtax,max(bi.iCost) as iCost
 						 from UFDATA_101_2021.dbo.PO_Pomain pom
 						 from UFDATA_101_2021.dbo.PO_Pomain pom
 						 join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
 						 join UFDATA_101_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
@@ -123,7 +123,7 @@
 						 join UFDATA_102_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
 						 join UFDATA_102_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
 						 join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
 						 join UFDATA_102_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
 						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
 						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
-						 GROUP BY pod.cInvCode,pod.iorderdid
+						 GROUP BY bi.cInvCode,pod.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 				WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
 				WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
 							and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
 							and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'

+ 9 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationMapper.xml

@@ -18,7 +18,7 @@
     </select>
     </select>
 
 
     <select id="queryByCostHead" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">
     <select id="queryByCostHead" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">
-        SELECT max(ss.iExchRate) as exchangeRate,
+        SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales,
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales,
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(cc.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
             max(cc.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
@@ -48,7 +48,7 @@
         
         
         union all  
         union all  
         
         
-        SELECT max(ss.iExchRate) as exchangeRate,
+        SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales, 
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales, 
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
             max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
@@ -85,7 +85,7 @@
         
         
         union all  
         union all  
         
         
-        SELECT max(ss.iExchRate) as exchangeRate,
+        SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales, 
             max(o.omCode) as planNum,max(s.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales, 
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(ss.cSOCode) as garmentContractno,max(de.cDepName) as department, 
             max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
             max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,min(sh.dDate) as outdata,
@@ -125,32 +125,35 @@
 
 
 
 
 	select t.iOriSum as fabriccostIncludestax,t.iNotOriMoney as fabriccostNotincludestax, t.cExchRate as fabriccostIncludestaxUsd from (
 	select t.iOriSum as fabriccostIncludestax,t.iNotOriMoney as fabriccostNotincludestax, t.cExchRate as fabriccostIncludestaxUsd from (
-	select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,4)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)*max(pb.cExchRate)) as cExchRate from UFDATA_101_2021.dbo.PO_Pomain pm
+	select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,4)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)/max(so.iExchRate)) as cExchRate from UFDATA_101_2021.dbo.PO_Pomain pm
 	join UFDATA_101_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_101_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_101_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_101_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_101_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_101_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
 	join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
+		join UFDATA_102_2021.dbo.SO_SOMain so on pd.csoordercode = so.csocode
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	 and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 	 and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 
 
 	UNION ALL
 	UNION ALL
 
 
-select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,2)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)*max(pb.cExchRate)) as cExchRate from UFDATA_102_2021.dbo.PO_Pomain pm
+select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,2)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)/max(so.iExchRate)) as cExchRate from UFDATA_102_2021.dbo.PO_Pomain pm
 	join UFDATA_102_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_102_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_102_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_102_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_102_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_102_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_102_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
 	join UFDATA_102_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
+		join UFDATA_102_2021.dbo.SO_SOMain so on pd.csoordercode = so.csocode
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	 and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 	 and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 
 
 		UNION ALL
 		UNION ALL
 
 
 
 
-select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,4)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)*max(pb.cExchRate)) as cExchRate from UFDATA_103_2021.dbo.PO_Pomain pm
+select sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSum/1.13,4)) as iNotOriMoney,CONVERT(DECIMAL(38,2),sum(pbs.iOriSum)/max(so.iExchRate)) as cExchRate from UFDATA_103_2021.dbo.PO_Pomain pm
 	join UFDATA_103_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_103_2021.dbo.PO_Podetails pd on pm.POID = pd.POID
 	join UFDATA_103_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_103_2021.dbo.PurBillVouchs pbs on pd.ID = pbs.iPOsID
 	join UFDATA_103_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_103_2021.dbo.PurBillVouch pb on pb.PBVID  = pbs.PBVID
 	join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
 	join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=pd.cInvCode
+		join UFDATA_102_2021.dbo.SO_SOMain so on pd.csoordercode = so.csocode
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	where pm.cPOID like CONCAT(#{code},'%') and (omi.cInvCcode like '03%' or omi.cInvCcode like '04%') and omi.cInvCCode != '0399' and omi.cInvCCode != '0499' and omi.cInvCCode != '0299'
 	and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 	and omi.cInvCCode != '07'and omi.cInvCCode != '06'and omi.cInvCCode != '05' and pb.cVenCode not in('T010001','T020001')
 		) t where t.iOriSum is not null
 		) t where t.iOriSum is not null

+ 21 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationShipdetailMapper.xml

@@ -17,6 +17,7 @@
 	</select>
 	</select>
 
 
 	<select id="queryByCostShipdetail" resultType="org.jeecg.modules.cost.entity.SyCostAllocationShipdetail">
 	<select id="queryByCostShipdetail" resultType="org.jeecg.modules.cost.entity.SyCostAllocationShipdetail">
+		select t.* from (
 		SELECT
 		SELECT
 			sh.cDefine10 AS invoiceNum,
 			sh.cDefine10 AS invoiceNum,
 			CONVERT(varchar(50), min(sh.dDate), 23) as outdata ,
 			CONVERT(varchar(50), min(sh.dDate), 23) as outdata ,
@@ -28,10 +29,10 @@
 			avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			sum(shs.iSum) as exportPrice,
 			sum(shs.iSum) as exportPrice,
 			sum(iNatSum) as rmbAmount,
 			sum(iNatSum) as rmbAmount,
-			avg(so.procesUnitPriceusd) as procesUnitPriceusd,
-			avg(so.procesUnitPriceusd)*sh.iExchRate as procesUnitPricermb,
-			avg(so.procesUnitPricermb) * sum(shs.iQuantity) as processCost,
-			avg(so.procesUnitPriceusd) * sum(shs.iQuantity) as processCostUsd,
+			case when max(so.cexch)='人民币' then avg(so.procesUnitPriceusd) else round(avg(so.procesUnitPriceusd)*sh.iExchRate,4) end as procesUnitPricermb,
+			case when max(so.cexch)='人民币' then round(avg(so.procesUnitPriceusd)/sh.iExchRate,4) else avg(so.procesUnitPriceusd) end as procesUnitPriceusd,
+				case when max(so.cexch)='人民币' then avg(so.procesUnitPriceusd) else round(avg(so.procesUnitPriceusd)*sh.iExchRate,4) end* sum(shs.iQuantity) as processCost,
+			case when max(so.cexch)='人民币' then round(avg(so.procesUnitPriceusd)/sh.iExchRate,4) else avg(so.procesUnitPriceusd) end * sum(shs.iQuantity) as processCostUsd,
 			v.cVenName AS processUnit
 			v.cVenName AS processUnit
 		 FROM
 		 FROM
 			UFDATA_101_2021.dbo.SaleBillVouch sh
 			UFDATA_101_2021.dbo.SaleBillVouch sh
@@ -40,10 +41,10 @@
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 			JOIN (
 			JOIN (
 			 SELECT
 			 SELECT
-				supplierCode,s.iSOsID,s.id ,o.procesUnitPriceusd,o.procesUnitPricermb,o.iPBVQuantity,s.cdefine22,s.cDefine28
+				o.supplierCode,s.iSOsID,s.id ,o.procesUnitPriceusd,o.procesUnitPricermb,o.iPBVQuantity,o.cexch as cexch,s.cdefine22,s.cDefine28
 			 FROM UFDATA_101_2021.dbo.SO_SODetails s
 			 FROM UFDATA_101_2021.dbo.SO_SODetails s
 			 JOIN (
 			 JOIN (
-					SELECT
+					SELECT max(om.cexch_name) as cexch,
 			 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iTax) as iTax,sum(od.iNatTax) as iNatTax
 			 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iTax) as iTax,sum(od.iNatTax) as iNatTax
 			 ,min(od.iNatUnitPrice) as procesUnitPricermb,min(bi.iOriTaxCost ) as procesUnitPriceusd,count(1) as iPBVQuantity
 			 ,min(od.iNatUnitPrice) as procesUnitPricermb,min(bi.iOriTaxCost ) as procesUnitPriceusd,count(1) as iPBVQuantity
 					FROM UFDATA_101_2021.dbo.OM_MOMain om
 					FROM UFDATA_101_2021.dbo.OM_MOMain om
@@ -69,10 +70,10 @@
 			avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			sum(shs.iSum) as exportPrice,
 			sum(shs.iSum) as exportPrice,
 			sum(iNatSum) as rmbAmount,
 			sum(iNatSum) as rmbAmount,
-			avg(so.iOriTaxCost) as procesUnitPriceusd,
-			avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb,
-			avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost,
-			avg(so.iOriTaxCost) * sum(shs.iQuantity) as processCostUsd,
+			case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb,
+			case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end as procesUnitPriceusd,
+				case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost,
+			case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
 			v.cVenName AS processUnit
 			v.cVenName AS processUnit
 		FROM
 		FROM
 			UFDATA_102_2021.dbo.SaleBillVouch sh
 			UFDATA_102_2021.dbo.SaleBillVouch sh
@@ -80,12 +81,12 @@
 			LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
 			LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
 			LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 			LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		JOIN (
 		JOIN (
-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,
+			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
 						inner JOIN (
-									 SELECT
+									 SELECT max(om.cexch_name) as cexch,
 									 max(od.csoordercode) as csoordercode,
 									 max(od.csoordercode) as csoordercode,
 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
@@ -123,10 +124,11 @@
 		avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 		avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 		sum(shs.iSum) as exportPrice,
 		sum(shs.iSum) as exportPrice,
 		sum(iNatSum) as rmbAmount,
 		sum(iNatSum) as rmbAmount,
-		avg(so.iOriTaxCost) as procesUnitPriceusd,
-		avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb,
-		avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost,
-		avg(so.iOriTaxCost) * sum(shs.iQuantity) as processCostUsd,
+		case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb,
+		case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end as procesUnitPriceusd,
+
+			case when max(so.cexch)='人民币' then avg(so.iOriTaxCost) else round(avg(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost,
+		case when max(so.cexch)='人民币' then round(avg(so.iOriTaxCost)/sh.iExchRate,4) else avg(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
 		v.cVenName AS processUnit
 		v.cVenName AS processUnit
 		 FROM
 		 FROM
 			UFDATA_101_2021.dbo.SaleBillVouch sh
 			UFDATA_101_2021.dbo.SaleBillVouch sh
@@ -134,12 +136,12 @@
 			LEFT JOIN UFDATA_101_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
 			LEFT JOIN UFDATA_101_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		  JOIN (
 		  JOIN (
-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,
+			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
 						inner JOIN (
-									 SELECT
+									 SELECT max(om.cexch_name) as cexch,
 									 max(od.csoordercode) as csoordercode,
 									 max(od.csoordercode) as csoordercode,
 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
 									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
 									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
@@ -162,7 +164,7 @@
 						GROUP BY s.iSOsID
 						GROUP BY s.iSOsID
 			) so ON so.iSOsID = rd.iorderdid
 			) so ON so.iSOsID = rd.iorderdid
 		LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode
 		LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode
-		group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName
+		group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName ) t order by t.outdata
 
 
 	</select>
 	</select>
 </mapper>
 </mapper>

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

@@ -206,7 +206,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             syCostAllocation.setFabriccostNotincludestax(new BigDecimal(fabricLoss1.getFabricCostInvoiceList().stream().
             syCostAllocation.setFabriccostNotincludestax(new BigDecimal(fabricLoss1.getFabricCostInvoiceList().stream().
                     filter(item->item.getINoTaxMoney()!=null).mapToDouble(FabricCostInvoice::getINoTaxMoney).sum()));
                     filter(item->item.getINoTaxMoney()!=null).mapToDouble(FabricCostInvoice::getINoTaxMoney).sum()));
             //美元面料含税成本和不含税成本
             //美元面料含税成本和不含税成本
-            syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostNotincludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
+            syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
             syCostAllocation.setFabriccostNotincludestaxUsd(syCostAllocation.getFabriccostNotincludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
             syCostAllocation.setFabriccostNotincludestaxUsd(syCostAllocation.getFabriccostNotincludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
         }else{
         }else{
             //根据计划号查找该计划号下所有采购发票含税金额和不含税金额(不含税金额 = 含税金额/1.13)
             //根据计划号查找该计划号下所有采购发票含税金额和不含税金额(不含税金额 = 含税金额/1.13)
@@ -317,8 +317,8 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
             List<SyCostAllocationFabric> pilosityFeweList = syCostAllocationFabricMapper.querypilosityFewer(plannum,Fabric.getGoodsName());
             Fabric.setPilosityFewerList(pilosityFeweList);
             Fabric.setPilosityFewerList(pilosityFeweList);
 
 
-            //多发少发 = 购入数量-计划数量
-            Fabric.setPilosityFewer(Fabric.getPurchaseQuantity().subtract(Fabric.getPlanQuantity()));
+            //多发少发 = 使用数量-计划数量
+            Fabric.setPilosityFewer(Fabric.getUsageQuantity().subtract(Fabric.getPlanQuantity()));
         }
         }
 
 
 
 
@@ -338,33 +338,31 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                     Ingredient.setSyRemaining(remaininglist);
                     Ingredient.setSyRemaining(remaininglist);
                 }
                 }
             }
             }
-            //辅料含税成本 美元和人民币
+            //辅料成本 美元和人民币
             if(Ingredient.getUsdAmount()!=null){
             if(Ingredient.getUsdAmount()!=null){
                 if(syCostAllocation.getExcipiencostIncludestax()==null){
                 if(syCostAllocation.getExcipiencostIncludestax()==null){
                     syCostAllocation.setExcipiencostIncludestax(BigDecimal.ZERO);
                     syCostAllocation.setExcipiencostIncludestax(BigDecimal.ZERO);
                     syCostAllocation.setExcipiencostIncludestaxUsd(BigDecimal.ZERO);
                     syCostAllocation.setExcipiencostIncludestaxUsd(BigDecimal.ZERO);
                 }
                 }
-                syCostAllocation.setExcipiencostIncludestax(Ingredient.getUsdAmount().add(syCostAllocation.getExcipiencostIncludestax()));
-                syCostAllocation.setExcipiencostIncludestaxUsd(syCostAllocation.getExcipiencostIncludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
+                syCostAllocation.setExcipiencostIncludestax(Ingredient.getRmbAmount().add(syCostAllocation.getExcipiencostIncludestax()));
+                syCostAllocation.setExcipiencostIncludestaxUsd(Ingredient.getUsdAmount().add(syCostAllocation.getExcipiencostIncludestaxUsd()));
 
 
-            }else {
-                syCostAllocation.setExcipiencostIncludestax(BigDecimal.ZERO);
-                syCostAllocation.setExcipiencostIncludestaxUsd(BigDecimal.ZERO);
             }
             }
             //辅料不含税成本 美元和人民币
             //辅料不含税成本 美元和人民币
-            if(Ingredient.getPriceExcludingtax()!=null){
-                if(syCostAllocation.getExcipiencostNotincludestax()==null){
-                    syCostAllocation.setExcipiencostNotincludestax(BigDecimal.ZERO);
-                    syCostAllocation.setExcipiencostNotincludestaxUsd(BigDecimal.ZERO);
-                }
-                syCostAllocation.setExcipiencostNotincludestax(Ingredient.getPriceExcludingtax().add(syCostAllocation.getExcipiencostNotincludestax()));
-                syCostAllocation.setExcipiencostNotincludestaxUsd(syCostAllocation.getExcipiencostNotincludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
-
-            }else {
-                syCostAllocation.setExcipiencostNotincludestax(BigDecimal.ZERO);
-                syCostAllocation.setExcipiencostNotincludestaxUsd(BigDecimal.ZERO);
-            }
+//            if(Ingredient.getPriceExcludingtax()!=null){
+//                if(syCostAllocation.getExcipiencostNotincludestax()==null){
+//                    syCostAllocation.setExcipiencostNotincludestax(BigDecimal.ZERO);
+//                    syCostAllocation.setExcipiencostNotincludestaxUsd(BigDecimal.ZERO);
+//                }
+//                syCostAllocation.setExcipiencostNotincludestax(Ingredient.getPriceExcludingtax().add(syCostAllocation.getExcipiencostNotincludestax()));
+//                syCostAllocation.setExcipiencostNotincludestaxUsd(syCostAllocation.getExcipiencostNotincludestax().divide(syCostAllocation.getExchangeRate(),2,BigDecimal.ROUND_HALF_UP));
+//
+//            }
         }
         }
+        //辅料不含税成本 美元和人民币
+            //   syCostAllocation.setExcipiencostNotincludestax(syCostAllocation.getExcipiencostIncludestax().divide(new BigDecimal(1.13),2,BigDecimal.ROUND_HALF_UP));
+            //    syCostAllocation.setExcipiencostNotincludestaxUsd(syCostAllocation.getExcipiencostIncludestaxUsd().divide(new BigDecimal(1.13),2,BigDecimal.ROUND_HALF_UP));
+
 
 
         //发运
         //发运
         List<SyCostAllocationShipdetail> Shipdetails = syCostAllocationShipdetailMapper.queryByCostShipdetail(plannum);
         List<SyCostAllocationShipdetail> Shipdetails = syCostAllocationShipdetailMapper.queryByCostShipdetail(plannum);
@@ -414,8 +412,11 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         //短出数
         //短出数
         if(syCostAllocation.getActualShipquantity()!=null && syCostAllocation.getPlanQuantity()!=null){
         if(syCostAllocation.getActualShipquantity()!=null && syCostAllocation.getPlanQuantity()!=null){
             syCostAllocation.setShortseveral(syCostAllocation.getPlanQuantity().subtract(syCostAllocation.getActualShipquantity()));
             syCostAllocation.setShortseveral(syCostAllocation.getPlanQuantity().subtract(syCostAllocation.getActualShipquantity()));
+            //短出货值
+            syCostAllocation.setShortvalue(syCostAllocation.getShortseveral().multiply(syCostAllocation.getSoPrice()).multiply(syCostAllocation.getExchangeRate()));
+
         }
         }
-        
+
         //事故单
         //事故单
         List<SyCostAllocationAccident> syCostAllocationAccident = syCostAllocationAccidentMapper.queryByCostAccident(plannum);
         List<SyCostAllocationAccident> syCostAllocationAccident = syCostAllocationAccidentMapper.queryByCostAccident(plannum);
         syCostAllocation.setSyCostAllocationAccidentList(syCostAllocationAccident);
         syCostAllocation.setSyCostAllocationAccidentList(syCostAllocationAccident);