|
@@ -13,7 +13,7 @@
|
|
|
exists (select x.moid from om_mobody x inner join Inventory y on x.cinvcode=y.cinvcode where x.moid=om_momain.moid and
|
|
|
(y.cInvCCode like '01%' or y.cInvCCode like '02%' or y.cInvCCode like '03%' or y.cInvCCode like '04%') )
|
|
|
and
|
|
|
- exists (select x.cVenCode from Vendor x where x.cVenCode=om_momain.cVenCode and x.cVCCode='0105')
|
|
|
+ exists (select x.cVenCode from Vendor x where x.cVenCode=om_momain.cVenCode and x.cVCCode in ('0105','0107','0108'))
|
|
|
and (cCode like CONCAT(#{code},'%') and cCode not like '%样%')
|
|
|
</select>
|
|
|
<!-- 排单数量 -->
|
|
@@ -117,7 +117,9 @@
|
|
|
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,
|
|
|
- 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,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,e.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCName,
|
|
|
+ d.dPODate as dDate
|
|
|
from RdRecord01 a inner join RdRecords01 b 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
|
|
@@ -203,7 +205,7 @@
|
|
|
</select>
|
|
|
<!--委外订单-采购入库详情-->
|
|
|
<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,cInvCName,cInvCode,cInvName,cColor,cBatch,dDate,
|
|
|
sum(iQuantityIn) as iQuantityIn,sum(iProcessFee) as iProcessFee, sum(iNoTaxProcessFee) as iNoTaxProcessFee, sum(iSQuantity) as iSQuantity,
|
|
|
sum(iQuantityOut) as iQuantityOut,sum(iSumBillQuantity) as iSumBillQuantity
|
|
|
from (
|
|
@@ -215,7 +217,9 @@
|
|
|
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((select sum(isnull(iquantity,0)) as iQuantityOut from rdrecords11 d where d.iOMoDID=b.MODetailsID),0) as iQuantityOut,
|
|
|
- y.cInvCCode
|
|
|
+ y.cInvCCode,
|
|
|
+ (select top 1 cInvCName from InventoryClass n where charindex(n.cinvccode,y.cInvCCode)>0 and len(n.cinvccode)=4 order by len(n.cinvccode),n.cinvccode) as cInvCName,
|
|
|
+ a.dDate
|
|
|
FROM
|
|
|
om_momain a
|
|
|
INNER JOIN OM_MODetails b ON a.moid = b.moid
|
|
@@ -227,18 +231,20 @@
|
|
|
WHERE
|
|
|
y.cInvCCode NOT LIKE '19%'
|
|
|
AND a.cCode LIKE CONCAT(#{code},'%') and a.cCode not like '%样%'
|
|
|
- ) as t1 group by cPlanCode,cCode,MODetailsID,cVCName,cVenName,cVenAbbName,cInvCCode,cInvCode,cInvName,cColor,cBatch
|
|
|
+ ) as t1 group by cPlanCode,cCode,MODetailsID,cVCName,cVenName,cVenAbbName,cInvCCode,cInvCName,cInvCode,cInvName,cColor,cBatch,dDate
|
|
|
|
|
|
</select>
|
|
|
<!-- 获取委外订单行id,出库物料信息,出库数量 -->
|
|
|
<select id="getOmRowOutList" resultType="org.jeecg.modules.report.entity.FabricMoOrderCK">
|
|
|
- select MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cOmCode,cOmVenAbbName,sum(iQuantityOut) as iQuantityOut from
|
|
|
+ select MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cOmCode,cOmVenAbbName,cInvCNameOut,
|
|
|
+ sum(iQuantityOut) as iQuantityOut from
|
|
|
((
|
|
|
select b.MODetailsID,
|
|
|
d.cInvCode as cInvCodeOut,z.cInvName as cInvNameOut,isnull(d.cFree1,'') as cColorOut,
|
|
|
isnull(d.cBatch,'') as cBatchOut,
|
|
|
d.iQuantity-isnull(d.iSQuantity,0) as iQuantityOut,
|
|
|
- z.cInvCCode as cInvCCodeOut,a.cCode as cOmCode,x.cVenAbbName as cOmVenAbbName
|
|
|
+ z.cInvCCode as cInvCCodeOut,a.cCode as cOmCode,x.cVenAbbName as cOmVenAbbName,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,z.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCNameOut
|
|
|
FROM
|
|
|
om_momain a
|
|
|
INNER JOIN OM_MODetails b ON a.moid = b.moid
|
|
@@ -254,7 +260,9 @@
|
|
|
g.cInvCode as cInvCodeOut,z.cInvName as cInvNameOut,isnull(g.cColor,'') as cColorOut,
|
|
|
isnull(g.cBatch,'') as cBatchOut,
|
|
|
g.iQuantity as iQuantityOut,
|
|
|
- z.cInvCCode as cInvCCodeOut,a.cCode as cOmCode,x.cVenAbbName as cOmVenAbbName
|
|
|
+ z.cInvCCode as cInvCCodeOut,a.cCode as cOmCode,x.cVenAbbName as cOmVenAbbName,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,z.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCNameOut
|
|
|
+
|
|
|
FROM
|
|
|
om_momain a
|
|
|
INNER JOIN OM_MODetails b ON a.moid = b.moid
|
|
@@ -267,7 +275,7 @@
|
|
|
c.cInvCCode NOT LIKE '19%'
|
|
|
AND a.cCode LIKE CONCAT(#{code},'%') and a.cCode not like '%样%'
|
|
|
)) as t1
|
|
|
- group by MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cOmCode,cOmVenAbbName
|
|
|
+ group by MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cInvCNameOut,cOmCode,cOmVenAbbName
|
|
|
</select>
|
|
|
<!-- 获取销售订单附件 -->
|
|
|
<select id="getSoAccList" resultType="org.jeecg.modules.report.entity.AccessorItem">
|
|
@@ -467,13 +475,14 @@
|
|
|
</select>
|
|
|
<!-- 根据委外订单子表id获取委外出库信息,用于计算其他委外订单 -->
|
|
|
<select id="getOmRowOutListByDetailId" resultType="org.jeecg.modules.report.entity.FabricMoOrderCK">
|
|
|
- select MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,sum(iQuantityOut) as iQuantityOut from
|
|
|
+ select MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cInvCNameOut,sum(iQuantityOut) as iQuantityOut from
|
|
|
((
|
|
|
select b.MODetailsID,
|
|
|
d.cInvCode as cInvCodeOut,z.cInvName as cInvNameOut,isnull(d.cFree1,'') as cColorOut,
|
|
|
isnull(d.cBatch,'') as cBatchOut,
|
|
|
d.iQuantity-isnull(d.iSQuantity,0) as iQuantityOut,
|
|
|
- z.cInvCCode as cInvCCodeOut
|
|
|
+ z.cInvCCode as cInvCCodeOut,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,z.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCNameOut
|
|
|
FROM
|
|
|
om_momain a
|
|
|
inner join OM_MODetails b on a.moid = b.moid
|
|
@@ -490,7 +499,8 @@
|
|
|
d.cInvCode as cInvCodeOut,z.cInvName as cInvNameOut,isnull(d.cColor,'') as cColorOut,
|
|
|
isnull(d.cBatch,'') as cBatchOut,
|
|
|
d.iQuantity as iQuantityOut,
|
|
|
- z.cInvCCode as cInvCCodeOut
|
|
|
+ z.cInvCCode as cInvCCodeOut,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,z.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCNameOut
|
|
|
FROM
|
|
|
om_momain a
|
|
|
inner join OM_MODetails b on a.moid = b.moid
|
|
@@ -505,7 +515,7 @@
|
|
|
</foreach>
|
|
|
)
|
|
|
) as t1
|
|
|
- group by MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut
|
|
|
+ group by MODetailsID,cInvCodeOut,cInvNameOut,cColorOut,cBatchOut,cInvCCodeOut,cInvCNameOut
|
|
|
</select>
|
|
|
<!-- 根据物料id获取入库信息:采购入库、委外入库、转换入库、其他入库 -->
|
|
|
<select id="getInListByInvId" resultType="org.jeecg.modules.report.entity.FabricCommonIn">
|
|
@@ -513,13 +523,13 @@
|
|
|
(
|
|
|
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,
|
|
|
- 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
|
|
|
- as iPrice,
|
|
|
- isnull(b.iOMoDID,0) as MODetailsID,isnull(b.iPOsID,0) as PoDetailsID,f.cInvCCode,1.0 as iRate
|
|
|
+ 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
|
|
|
|
|
|
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 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
|
|
@@ -528,10 +538,29 @@
|
|
|
#{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
|
|
|
+
|
|
|
+ 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
|
|
|
+ 0 as MODetailsID, 0 as PoDetailsID,f.cInvCCode,1.0 as iRate,a.dDate
|
|
|
from rdrecords08 b
|
|
|
inner join rdrecord08 a on a.id=b.id
|
|
|
inner join Inventory f ON b.cinvcode = f.cinvcode
|
|
@@ -560,7 +589,7 @@
|
|
|
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(x.iSumBillQuantity,0) as iSumBillQuantity,isnull(x.iSQuantity,0) as iSQuantity,
|
|
|
(select sum(isnull(iquantity,0)) as iQuantityOut from rdrecords11 d where d.iOMoDID=b.MODetailsID) as iQuantityOut,
|
|
|
- y.cInvCCode
|
|
|
+ y.cInvCCode,a.dDate
|
|
|
FROM
|
|
|
om_momain a
|
|
|
INNER JOIN OM_MODetails b ON a.moid = b.moid
|
|
@@ -581,7 +610,8 @@
|
|
|
|
|
|
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
|
|
|
+ isnull(c.cbatchproperty9,'') as cVenAbbName,b.cInvCCode as cInvCCodeOut,
|
|
|
+ (select top 1 cInvCName from InventoryClass y where charindex(y.cinvccode,b.cInvCCode)>0 and len(y.cinvccode)=4 order by len(y.cinvccode),y.cinvccode) as cInvCNameOut
|
|
|
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
|