|
@@ -528,63 +528,69 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getInListByInvId" resultType="org.jeecg.modules.report.entity.FabricCommonIn">
|
|
|
-
|
|
|
+ select * from (
|
|
|
(
|
|
|
- select b.AutoId,a.cCode,isnull(b.cPOID,'') as cPlanCode,a.cBusType,e.cVCName,d.cVenName,d.cVenAbbName,
|
|
|
- b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvName,b.iQuantity,
|
|
|
- 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(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate,h.dPODate as dDate,
|
|
|
- isnull(b.iSumBillQuantity,0) as iQuantityInvoice,
|
|
|
- isnull(b.iSQuantity,0) as iQuantitySettle
|
|
|
-
|
|
|
- from rdrecords01 b
|
|
|
- inner join rdrecord01 a on a.id=b.id
|
|
|
+ select 1 as type,b.AutoId,a.cCode,isnull(b.cPOID,'') as cPlanCode,a.cBusType,e.cVCName,d.cVenName,d.cVenAbbName,
|
|
|
+ b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvName,b.iQuantity,
|
|
|
+ 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(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate,h.dPODate as
|
|
|
+ dDate,
|
|
|
+ isnull(b.iSumBillQuantity,0) as iQuantityInvoice,
|
|
|
+ isnull(b.iSQuantity,0) as iQuantitySettle
|
|
|
+
|
|
|
+ from rdrecords01 b
|
|
|
+ inner join rdrecord01 a on a.id=b.id
|
|
|
inner join PO_Podetails g on b.iposid=g.id
|
|
|
- inner join PO_Pomain h on h.POID =g.POID
|
|
|
+ inner join PO_Pomain h on h.POID =g.POID
|
|
|
inner join Vendor d on d.cVenCode=a.cVenCode
|
|
|
inner join VendorClass e on d.cVCCode =e.cVCCode
|
|
|
- inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
- where b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
- <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- ) union all
|
|
|
- (
|
|
|
- select b.AutoId,a.cCode,isnull(b.cPOID,'') as cPlanCode,a.cBusType,e.cVCName,d.cVenName,d.cVenAbbName,
|
|
|
- b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvName,b.iQuantity,
|
|
|
- 0 as iPrice,
|
|
|
- isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate,h.dDate,
|
|
|
- 0 as iQuantityInvoice,
|
|
|
- 0 as iQuantitySettle
|
|
|
- from rdrecords01 b
|
|
|
- inner join rdrecord01 a on a.id=b.id
|
|
|
- inner join OM_MODetails g on b.iOMoDID=g.MODetailsID
|
|
|
- inner join om_momain h on h.moid =g.moid
|
|
|
- inner join Vendor d on d.cVenCode=a.cVenCode
|
|
|
- inner join VendorClass e on d.cVCCode =e.cVCCode
|
|
|
- inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
- where b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
- <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- )
|
|
|
- union all (
|
|
|
- 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,
|
|
|
- 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,1.0 as iRate,a.dDate,
|
|
|
- 0 as iQuantityInvoice,
|
|
|
- 0 as iQuantitySettle
|
|
|
- from rdrecords08 b
|
|
|
- inner join rdrecord08 a on a.id=b.id
|
|
|
- inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
- where b.iQuantity<>0 and a.cbustype <> '调拨入库' and
|
|
|
- b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
- <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
+ inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
+ where b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
+ <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ ) union all
|
|
|
+ (
|
|
|
+ select 2 as type,b.AutoId,a.cCode,isnull(b.cPOID,'') as cPlanCode,a.cBusType,e.cVCName,d.cVenName,d.cVenAbbName,
|
|
|
+ b.cInvCode,isnull(b.cFree1,'') as cColor,isnull(b.cBatch,'') as cBatch,f.cInvName,b.iQuantity,
|
|
|
+ 0 as iPrice,
|
|
|
+ isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate,h.dDate,
|
|
|
+ 0 as iQuantityInvoice,
|
|
|
+ 0 as iQuantitySettle
|
|
|
+ from rdrecords01 b
|
|
|
+ inner join rdrecord01 a on a.id=b.id
|
|
|
+ inner join OM_MODetails g on b.iOMoDID=g.MODetailsID
|
|
|
+ inner join om_momain h on h.moid =g.moid
|
|
|
+ inner join Vendor d on d.cVenCode=a.cVenCode
|
|
|
+ inner join VendorClass e on d.cVCCode =e.cVCCode
|
|
|
+ inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
+ where b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
+ <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ union all (
|
|
|
+ select 3 as type,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,
|
|
|
+ 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,1.0 as iRate,a.dDate,
|
|
|
+ 0 as iQuantityInvoice,
|
|
|
+ 0 as iQuantitySettle
|
|
|
+ from rdrecords08 b
|
|
|
+ inner join rdrecord08 a on a.id=b.id
|
|
|
+ inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
|
+ where b.iQuantity<>0 and a.cbustype <> '调拨入库' and
|
|
|
+ b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
|
|
|
+ <foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
|
|
|
- )
|
|
|
+ )
|
|
|
+ ) as t1 order by type, PoDetailsID,MODetailsID, AutoId
|
|
|
|
|
|
|
|
|
</select>
|