|  | @@ -20,7 +20,7 @@
 | 
											
												
													
														|  |      <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,min(s.iTaxUnitPrice) as soPrice,'101' as pkOrg,
 |  |           SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,'101' as pkOrg,
 | 
											
												
													
														|  |              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, 
 |  | 
 | 
											
												
													
														|  | 
 |  | +            STRING_AGG(ss.cSOCode,',') as garmentContractno,max(de.cDepName) as department,
 | 
											
												
													
														|  |              max(cc.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 |  |              max(cc.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 | 
											
												
													
														|  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 |  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 | 
											
												
													
														|  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 |  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 | 
											
										
											
												
													
														|  | @@ -51,7 +51,7 @@
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,'103' as pkOrg,
 |  |          SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,'103' as pkOrg,
 | 
											
												
													
														|  |              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, 
 |  | 
 | 
											
												
													
														|  | 
 |  | +            STRING_AGG(ss.cSOCode,',') as garmentContractno,max(de.cDepName) as department,
 | 
											
												
													
														|  |              max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 |  |              max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 | 
											
												
													
														|  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 |  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 | 
											
												
													
														|  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 |  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 | 
											
										
											
												
													
														|  | @@ -89,7 +89,7 @@
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,'103' as pkOrg,
 |  |          SELECT max(ss.iExchRate) as exchangeRate,min(s.iTaxUnitPrice) as soPrice,'103' as pkOrg,
 | 
											
												
													
														|  |              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, 
 |  | 
 | 
											
												
													
														|  | 
 |  | +            STRING_AGG(ss.cSOCode,',') as garmentContractno,max(de.cDepName) as department,
 | 
											
												
													
														|  |              max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 |  |              max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 | 
											
												
													
														|  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 |  |              max(ss.iTaxRate) as taxrate,max(ss.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal, 
 | 
											
												
													
														|  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 |  |              sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity    
 | 
											
										
											
												
													
														|  | @@ -162,6 +162,53 @@
 | 
											
												
													
														|  |          inner JOIN UFDATA_101_2021.dbo.Customer cu ON ss1.cCusCode = cu.cCusCode
 |  |          inner JOIN UFDATA_101_2021.dbo.Customer cu ON ss1.cCusCode = cu.cCusCode
 | 
											
												
													
														|  |          WHERE cc.cCusCode in ('0001') and ss.cCusCode in ('T020001') and c.cInvCcode like '19%' GROUP BY v.cVenAbbName
 |  |          WHERE cc.cCusCode in ('0001') and ss.cCusCode in ('T020001') and c.cInvCcode like '19%' GROUP BY v.cVenAbbName
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    /* UNION ALL
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +             SELECT max(ss1.iExchRate) as exchangeRate,min(s1.iTaxUnitPrice) as soPrice,'103' as pkOrg,
 | 
											
												
													
														|  | 
 |  | +            max(o.omCode) as planNum,max(s1.cdefine22) as poStyleNum,max(pe.cPersonName) as exportSales,
 | 
											
												
													
														|  | 
 |  | +            max(ss1.cSOCode) as garmentContractno,max(de.cDepName) as department,
 | 
											
												
													
														|  | 
 |  | +            max(cu.cCusAbbName) as customerShortame,v.cVenAbbName as processUnit,
 | 
											
												
													
														|  | 
 |  | +            max(ss1.iTaxRate) as taxrate,max(ss1.cMaker) as preparedBy,sum(s.iNatSum) as salesordersLocaltotal,
 | 
											
												
													
														|  | 
 |  | +            sum(s.iSum) as salesrrdersOriginaltotal,sum(o.iQuantity) as planQuantity
 | 
											
												
													
														|  | 
 |  | +        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
 | 
											
												
													
														|  | 
 |  | +                     om.cCode AS omCode, od.csoordercode,
 | 
											
												
													
														|  | 
 |  | +                     om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
 | 
											
												
													
														|  | 
 |  | +                     om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity
 | 
											
												
													
														|  | 
 |  | +                     FROM
 | 
											
												
													
														|  | 
 |  | +                     UFDATA_103_2021.dbo.OM_MOMain om
 | 
											
												
													
														|  | 
 |  | +                     inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
 | 
											
												
													
														|  | 
 |  | +                        inner JOIN (select MOID,max(iSendQTY) as iSendQTY from UFDATA_103_2021.dbo.OM_MOMaterials GROUP BY MOID) ot on ot.MOID=om.MOID
 | 
											
												
													
														|  | 
 |  | +                           WHERE
 | 
											
												
													
														|  | 
 |  | +                     om.iVerifyStateNew = 2  and om.cCode like CONCAT('SYE604','%')
 | 
											
												
													
														|  | 
 |  | +                     and (om.cCloser is null or ( (od.iReceivedQTY is not null or od.iReceivedQTY != 0) and (ot.iSendQTY is not null or ot.iSendQTY !=0) )or om.cCloser='asuser')
 | 
											
												
													
														|  | 
 |  | +                     ) o ON a.isosid  = o.isosid AND a.cInvCode = o.cInvCode
 | 
											
												
													
														|  | 
 |  | +        inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
 | 
											
												
													
														|  | 
 |  | +        inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
 | 
											
												
													
														|  | 
 |  | +        inner JOIN UFDATA_103_2021.dbo.Person  pe ON b.cPersonCode = pe.cPersonCode
 | 
											
												
													
														|  | 
 |  | +        inner JOIN UFDATA_103_2021.dbo.Department de ON b.cDepCode = de.cDepCode
 | 
											
												
													
														|  | 
 |  | +        inner JOIN UFDATA_103_2021.dbo.Customer cc ON b.cCusCode = cc.cCusCode
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_102_2021.dbo.PO_Pomain f on f.cPOID=o.csoordercode
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_102_2021.dbo.po_podetails g on g.POID=f.POID and g.ivouchrowno=a.iRowNo
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_102_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_102_2021.dbo.so_somain ss on ss.id=s.id
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				left join UFDATA_101_2021.dbo.PO_Pomain f1 on f1.cPOID=ss.csocode
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_101_2021.dbo.po_podetails g1 on g1.POID=f1.POID and g1.ivouchrowno=s.iRowNo
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_101_2021.dbo.SO_SODetails s1 on s1.iSOsID=g1.iorderdid
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_101_2021.dbo.so_somain ss1 on ss1.id=s1.id
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        left join UFDATA_101_2021.dbo.Person j on j.cPersonCode=ss1.cPersonCode
 | 
											
												
													
														|  | 
 |  | +        left JOIN UFDATA_101_2021.dbo.Customer cu ON ss1.cCusCode = cu.cCusCode
 | 
											
												
													
														|  | 
 |  | +       -- WHERE cc.cCusCode in ('0001') and ss.cCusCode in ('T020001') and c.cInvCcode like '19%'
 | 
											
												
													
														|  | 
 |  | +				GROUP BY v.cVenAbbName;
 | 
											
												
													
														|  | 
 |  | +*/
 | 
											
												
													
														|  |      </select>
 |  |      </select>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -212,17 +259,27 @@ select omi.cInvName as cInvName,sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSu
 | 
											
												
													
														|  |      <select id="querySalerIauantity" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">
 |  |      <select id="querySalerIauantity" resultType="org.jeecg.modules.cost.entity.SyCostAllocation">
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  select t.salerIquantity from (
 |  |  select t.salerIquantity from (
 | 
											
												
													
														|  | -select sum(iquantity) as salerIquantity from UFDATA_101_2021.dbo.SO_SODetails where csocode = #{csocode}
 |  | 
 | 
											
												
													
														|  | 
 |  | +select sum(iquantity) as salerIquantity from UFDATA_101_2021.dbo.SO_SODetails where csocode in
 | 
											
												
													
														|  | 
 |  | +<foreach collection="csocode" item="value" index="index" open="(" separator="," close=")">
 | 
											
												
													
														|  | 
 |  | +#{value}
 | 
											
												
													
														|  | 
 |  | +</foreach>
 | 
											
												
													
														|  |  union all
 |  |  union all
 | 
											
												
													
														|  |  select sum(iquantity) as salerIquantity from UFDATA_102_2021.dbo.SO_SODetails a
 |  |  select sum(iquantity) as salerIquantity from UFDATA_102_2021.dbo.SO_SODetails a
 | 
											
												
													
														|  |  		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
 |  |  		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
 | 
											
												
													
														|  |  	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
 |  |  	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
 | 
											
												
													
														|  | - WHERE b.cCusCode not in ('0001','T020001') and a.csocode = #{csocode}
 |  | 
 | 
											
												
													
														|  | 
 |  | + WHERE b.cCusCode not in ('0001','T020001') and a.csocode in
 | 
											
												
													
														|  | 
 |  | +<foreach collection="csocode" item="value" index="index" open="(" separator="," close=")">
 | 
											
												
													
														|  | 
 |  | +#{value}
 | 
											
												
													
														|  | 
 |  | +</foreach>
 | 
											
												
													
														|  |  union all
 |  |  union all
 | 
											
												
													
														|  |  select sum(iquantity) as salerIquantity from UFDATA_103_2021.dbo.SO_SODetails a
 |  |  select sum(iquantity) as salerIquantity from UFDATA_103_2021.dbo.SO_SODetails a
 | 
											
												
													
														|  |  		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
 |  |  		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
 | 
											
												
													
														|  |  	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
 |  |  	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
 | 
											
												
													
														|  | - WHERE b.cCusCode not in ('0001','T020001') and a.csocode = #{csocode}
 |  | 
 | 
											
												
													
														|  | 
 |  | + WHERE b.cCusCode not in ('0001','T020001')
 | 
											
												
													
														|  | 
 |  | + and a.csocode in
 | 
											
												
													
														|  | 
 |  | +<foreach collection="csocode" item="value" index="index" open="(" separator="," close=")">
 | 
											
												
													
														|  | 
 |  | +    #{value}
 | 
											
												
													
														|  | 
 |  | +</foreach>
 | 
											
												
													
														|  |  ) as t where t.salerIquantity is not null
 |  |  ) as t where t.salerIquantity is not null
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      </select>
 |  |      </select>
 |