zengtx %!s(int64=2) %!d(string=hai) anos
pai
achega
b9e7aa2168

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

@@ -18,22 +18,23 @@
 
 	<select id="queryByCostShipdetail" resultType="org.jeecg.modules.cost.entity.SyCostAllocationShipdetail">
 	select t.* from (
-					select sbv.cDefine10 AS invoiceNum,CONVERT(varchar(50), min(sbv.dDate), 23) as outdata,sum(pbv.iQuantity) as shipQuantity,sbv.iExchRate AS exchangeRate,sbv.cSOCode AS orderNum,max(pbv.cdefine22) AS poStyleNum,max(pbv.cDefine28) AS smallPo,max(sbv.exportUnitPrice) AS exportUnitPrice,sum(sbv.exportPrice) as exportPrice,sum(sbv.rmbAmount) as rmbAmount,
-case when max(sbv.cexch_name)='人民币' then max(pbv.iOriTaxCost) else round(max(pbv.iOriTaxCost)*sbv.iExchRate,4) end as procesUnitPricermb,
+					select sbv.cDefine10 AS invoiceNum,CONVERT(varchar(50), min(sbv.dDate), 23) as outdata,sum(pbv.iQuantity) as shipQuantity,pbv.cExchRate AS exchangeRate,sbv.cSOCode AS orderNum,max(pbv.cdefine22) AS poStyleNum,max(pbv.cDefine28) AS smallPo,max(sbv.exportUnitPrice) AS exportUnitPrice,sum(sbv.exportPrice) as exportPrice,sum(sbv.rmbAmount) as rmbAmount,
+case when max(sbv.cexch_name)='人民币' then max(pbv.iOriTaxCost) else round(max(pbv.iOriTaxCost)*pbv.cExchRate,4) end as procesUnitPricermb,
 			case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end as procesUnitPriceusd,
-				case when max(sbv.cexch_name)='人民币' then max(pbv.iOriTaxCost) else round(max(pbv.iOriTaxCost)*sbv.iExchRate,4) end * sum(pbv.iQuantity) as processCost,
+		sum(pbv.processCost) as processCost,
 			case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end * sum(pbv.iQuantity) as processCostUsd,
 			max(v.cVenName) AS processUnit
 
 from
-(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode
+(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode,max(pbv.cExchRate) as cExchRate,sum(pbvs.iSum) as processCost
 from UFDATA_101_2021.dbo.PurBillVouchs pbvs left join UFDATA_101_2021.dbo.PurBillVouch pbv
 on pbv.PBVID=pbvs.PBVID
 left join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=pbvs.iPOsID
 left join UFDATA_101_2021.dbo.om_momain ommo on ommo.moid=ommos.moid
 left join UFDATA_101_2021.dbo.SO_SODetails sd on sd.iSOsID = ommos.isosid
-group by pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,ommo.ccode,ommo.cVenCode
-having ommo.ccode like CONCAT(#{code},'%') AND pbv.cBusType='委外加工') as pbv
+	left join UFDATA_101_2021.dbo.Inventory inv on pbvs.cInvCode = inv.cInvCode
+group by pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,inv.cInvCCode,ommo.ccode,ommo.cVenCode
+having ommo.ccode like CONCAT(#{code},'%') AND pbv.cBusType='委外加工' and inv.cInvCCode like '19%') as pbv
 left join
 -- 根据外销发票号 加物料编码以及自由项组合计算 销售发票合计数量
 (select sbv.cDefine10,sum(sbvs.iQuantity) as iQuantity,sbvs.cInvCode,sbvs.cFree1,sbvs.cFree2,min(sbv.dDate) as dDate,max(sbv.iExchRate) as iExchRate,sbv.cSOCode as cSOCode,max(sbvs.iTaxUnitPrice) AS exportUnitPrice,sum(sbvs.iSum) as exportPrice,sum(sbvs.iNatSum) as rmbAmount,max(sbv.cexch_name) as cexch_name
@@ -41,24 +42,24 @@ from UFDATA_101_2021.dbo.SaleBillVouchs sbvs  left join UFDATA_101_2021.dbo.Sale
 group by  sbv.cDefine10,sbvs.cInvCode,sbvs.cFree1,sbvs.cFree2,sbv.cSOCode
 ) as sbv on sbv.cInvCode=pbv.cInvCode and sbv.cFree1=pbv.cFree1 and sbv.cFree2=pbv.cFree2 and pbv.iQuantity=sbv.iQuantity -- 自由项+合计数量做匹配
 LEFT JOIN UFDATA_101_2021.dbo.Vendor v ON pbv.cVenCode= v.cVenCode
-GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
+GROUP BY sbv.cDefine10,pbv.cExchRate,sbv.cSOCode
 
 		 union all
 
 		 SELECT
 			sh.cDefine10 AS invoiceNum,
 			CONVERT(varchar(50), min(sh.dDate), 23) as outdata ,
-			sum(shs.iQuantity) as shipQuantity,
-			sh.iExchRate AS exchangeRate,
+		  sum(shs.iQuantity) as shipQuantity,
+			so.cExchRate AS exchangeRate,
 			sh.cSOCode AS orderNum,
 			max(so.cdefine22) AS poStyleNum,
 			max(so.cDefine28) AS smallPo,
 			max(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			sum(shs.iSum) as exportPrice,
 			sum(iNatSum) as rmbAmount,
-			case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb,
+			case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*so.cExchRate,4) end as procesUnitPricermb,
 			case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
-				case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost,
+				case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*so.cExchRate,4) end * sum(shs.iQuantity) as processCost,
 			case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
 			v.cVenName AS processUnit
 		FROM
@@ -67,12 +68,14 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 			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
 		JOIN (
-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
+			 SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
 					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
 									 SELECT max(om.cexch_name) as cexch,
+								
+									 max(pb.cExchRate) as cExchRate,
 									 od.csoordercode as csoordercode,
 									 max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
 									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
@@ -80,8 +83,10 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
 									 left join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=od.MODetailsID
+									 left join UFDATA_103_2021.dbo.PurBillVouch pb  on bi.PBVID =pb.PBVID 
+									 	left join UFDATA_103_2021.dbo.Inventory inv on bi.cInvCode = inv.cInvCode
 									 WHERE
-									 om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%') 
+									 om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%') and inv.cInvCCode like '19%'
 									 GROUP BY od.csoordercode
 									 ) o ON a.csocode = o.csoordercode 
 						inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
@@ -95,25 +100,25 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 						GROUP BY s.iSOsID
 			) so ON so.iSOsID = rd.iorderdid
 		LEFT JOIN UFDATA_102_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,so.cExchRate,sh.cSOCode,c.cInvName, v.cVenName
 
 		union all
 
 		SELECT
 		sh.cDefine10 AS invoiceNum,
 		CONVERT(varchar(50), min(sh.dDate), 23) as outdata ,
-		sum(shs.iQuantity) as shipQuantity,
-		sh.iExchRate AS exchangeRate,
+	  sum(shs.iQuantity) as shipQuantity,
+		so.cExchRate AS exchangeRate,
 		sh.cSOCode AS orderNum,
 		max(so.cdefine22) AS poStyleNum,
 		max(so.cDefine28) AS smallPo,
 		max(shs.iTaxUnitPrice) AS exportUnitPrice ,
 		sum(shs.iSum) as exportPrice,
 		sum(iNatSum) as rmbAmount,
-		case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*sh.iExchRate,4) end as procesUnitPricermb,
+		case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*so.cExchRate,4) end as procesUnitPricermb,
 		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
 
-			case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*sh.iExchRate,4) end * sum(shs.iQuantity) as processCost,
+		case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*so.cExchRate,4) end * sum(shs.iQuantity) as processCost,
 		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
 		v.cVenName AS processUnit
 		 FROM
@@ -122,12 +127,14 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 			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
 		  JOIN (
-			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
+			 SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
 					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
 									 SELECT max(om.cexch_name) as cexch,
+									
+									 max(pb.cExchRate) as cExchRate,
 									 od.csoordercode as csoordercode,
 									 max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
 									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
@@ -135,8 +142,10 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
 									 left join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=od.MODetailsID
+									  left join UFDATA_103_2021.dbo.PurBillVouch pb  on bi.PBVID =pb.PBVID 
+										left join UFDATA_103_2021.dbo.Inventory inv on bi.cInvCode = inv.cInvCode
 									 WHERE
-									 om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%') 
+									 om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%') and inv.cInvCCode like '19%'
 									 GROUP BY od.csoordercode
 									 ) o ON a.csocode = o.csoordercode 
 						inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
@@ -150,7 +159,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 						GROUP BY s.iSOsID
 			) so ON so.iSOsID = rd.iorderdid
 		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,so.cExchRate,sh.cSOCode,c.cInvName, v.cVenName
 
 		 ) t order by t.outdata
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/xml/SyShippingDetailsMapper.xml

@@ -84,7 +84,7 @@ a.end_customer) as endCustomer,
     b.order_remarks as orderRemarks,b.price_remarks as priceRemarks,b.order_change_description as orderChangeDescription,b.pre_completion_date as preCompletionDate,
     b.sales_type_text as salesTypeText,b.customer_name as customerName,b.exchange_rate as exchangeRate,a.whole_order_total as wholeOrderTotal,
     b.declaration_elements as declarationElements,b.number_of_sets as numberOfSets,a.chinese_name as chineseName,b.account as account,b.supplier as supplier,
-    b.garment_factory as garmentFactory,b.elements_id as elementsId,b.coding_rules as codingRules,b.colour as colour,b.group_id as groupId,
+    b.garment_factory as garmentFactory,b.elements_id as elementsId,GROUP_CONCAT(DISTINCT b.coding_rules) as codingRules,b.colour as colour,b.group_id as groupId,
     FROM_UNIXTIME(left(b.d_arrive_date,10),'%Y-%m-%d') as arrivalDate
      from sy_shipping_details a
 left join sy_shipping_details_item b

+ 4 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/service/impl/SyShippingOrderServiceImpl.java

@@ -726,7 +726,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     map.put("iVTid", "57");
                     map.put("cvencode", rmb.get("freightForwarder"));
                     map.put("cSysBarCode", "||SA09|"+cCode);
-                    listmap.add(map);
+
 
 
                     //添加子表信息
@@ -746,6 +746,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     maps.put("irowno", "1");//行号
                     maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
                     if(imoney >= 1){
+                        listmap.add(map);
                         listmaps.add(maps);
                     }
 
@@ -787,7 +788,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     map.put("iVTid", "57");//单据模板号
                     map.put("cvencode", usd.get("freightForwarder"));
                     map.put("cSysBarCode", "||SA09|"+cCode);
-                    listmap.add(map);
+
 
                     //添加子表信息
                     Map<String, Object> maps = new HashMap<>();
@@ -804,6 +805,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     maps.put("ID", id);
                     maps.put("irowno", "1");//行号
                     if(imoney >= 1){
+                        listmap.add(map);
                         listmaps.add(maps);
                     }