|
@@ -135,139 +135,79 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryTransferByFabric" resultType="org.jeecg.modules.cost.entity.SyTransfer">
|
|
|
- select tab1.cInvName as goodsName,tab1.cFree1 as color,tab1.cCode as planCode,
|
|
|
- tab1.purchaseQuantity-tab2.jian as number
|
|
|
+ select
|
|
|
+ tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
|
|
|
+ case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number
|
|
|
from
|
|
|
(
|
|
|
- select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1,(
|
|
|
- select distinct om.cCode
|
|
|
- from UFDATA_901_2021.dbo.om_momain om
|
|
|
- join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
|
|
|
- and omi.cInvCcode like '19%' and od.csocode=rs.iordercode
|
|
|
- ) as ccode
|
|
|
- from UFDATA_901_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- GROUP BY i.cInvName,rs.cBatch,rs.cFree1,rs.iordercode
|
|
|
+ select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_901_2021.dbo.rdrecords01 rs
|
|
|
+ join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
+ where iordercode in (
|
|
|
+ select distinct od.csocode
|
|
|
+ from UFDATA_901_2021.dbo.om_momain om
|
|
|
+ join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
+ GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
)tab1
|
|
|
- join
|
|
|
+ right join
|
|
|
(
|
|
|
- select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_901_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where iordercode in (
|
|
|
- select distinct od.csocode
|
|
|
- from UFDATA_901_2021.dbo.om_momain om
|
|
|
- join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- and i.cInvName = #{goodName}
|
|
|
- GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
- )tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch and tab1.cFree1=tab2.cFree1
|
|
|
- where tab1.purchaseQuantity-tab2.jian>0
|
|
|
+ select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_901_2021.dbo.rdrecords11 rs
|
|
|
+ join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
+ where iordercode in (
|
|
|
+ select distinct od.csocode
|
|
|
+ from UFDATA_901_2021.dbo.om_momain om
|
|
|
+ join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
+ GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
+ )tab2 on tab2.cInvName=tab1.cInvName and tab2.cBatch=tab1.cBatch and tab1.cfree1=tab2.cfree1
|
|
|
+ where tab2.jian-isnull(tab1.purchaseQuantity,0) > 0
|
|
|
|
|
|
union all
|
|
|
|
|
|
- select tab1.cInvName as goodsName,tab1.cFree1 as color,tab1.cCode as planCode,
|
|
|
- tab1.purchaseQuantity-tab2.jian as number
|
|
|
+ select
|
|
|
+ tab2.cinvName as goodsName,tab2.cFree1 as color,tab2.cBatch as planCode,
|
|
|
+ case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
|
|
|
+ else tab2.jian-isnull(tab1.purchaseQuantity,0) end as number
|
|
|
from
|
|
|
(
|
|
|
- select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1,(
|
|
|
- select distinct om.cCode
|
|
|
- from UFDATA_903_2021.dbo.om_momain om
|
|
|
- join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
|
|
|
- and omi.cInvCcode like '19%' and od.csocode=rs.iordercode
|
|
|
- ) as ccode
|
|
|
- from UFDATA_903_2021.dbo.rdrecords01 rs
|
|
|
- join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- GROUP BY i.cInvName,rs.cBatch,rs.cFree1,rs.iordercode
|
|
|
+ select i.cInvName,sum(rs.iQuantity) as purchaseQuantity,rs.cBatch,rs.cFree1 from UFDATA_903_2021.dbo.rdrecords01 rs
|
|
|
+ join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
+ where iordercode in (
|
|
|
+ select distinct od.csocode
|
|
|
+ from UFDATA_903_2021.dbo.om_momain om
|
|
|
+ join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
+ GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
)tab1
|
|
|
- join
|
|
|
+ right join
|
|
|
(
|
|
|
- select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_903_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where iordercode in (
|
|
|
- select distinct od.csocode
|
|
|
- from UFDATA_903_2021.dbo.om_momain om
|
|
|
- join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- and i.cInvName = #{goodName}
|
|
|
- GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
- )tab2 on tab2.cInvName=tab1.cInvName and tab1.cBatch=tab2.cBatch and tab1.cFree1=tab2.cFree1
|
|
|
- where tab1.purchaseQuantity-tab2.jian>0
|
|
|
+ select i.cInvName,sum(rs.iQuantity) as jian,rs.cBatch,rs.cFree1 from UFDATA_903_2021.dbo.rdrecords11 rs
|
|
|
+ join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
+ where iordercode in (
|
|
|
+ select distinct od.csocode
|
|
|
+ from UFDATA_903_2021.dbo.om_momain om
|
|
|
+ join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
+ join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
+ 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
+ GROUP BY i.cInvName,rs.cBatch,rs.cFree1
|
|
|
+ )tab2 on tab2.cInvName=tab1.cInvName and tab2.cBatch=tab1.cBatch and tab1.cfree1=tab2.cfree1
|
|
|
+ where tab2.jian-isnull(tab1.purchaseQuantity,0) > 0
|
|
|
</select>
|
|
|
|
|
|
<select id="queryRemainingByFabric" resultType="org.jeecg.modules.cost.entity.SyRemaining">
|
|
|
- select tab.*,tab2.jian-tab.usageQuantity as number
|
|
|
- from
|
|
|
- (
|
|
|
- select oti.cInvName as goodsName,ot.cFree1 as color,max(om.ccode) as planCode,sum(ot.iQuantity) as usageQuantity
|
|
|
- from UFDATA_901_2021.dbo.om_momain om
|
|
|
- join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_901_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
|
- join UFDATA_901_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
- join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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.cInvName = #{goodName}
|
|
|
- and (oti.cInvCcode like '03%' or oti.cInvCcode like '04%') and oti.cInvCCode != '0399' and oti.cInvCCode != '0499'
|
|
|
- GROUP BY oti.cInvName,ot.cFree1
|
|
|
- ) tab
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvName,sum(rs.iQuantity) as jian,rs.cfree1 from UFDATA_901_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_901_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where iordercode in (
|
|
|
- select distinct od.csocode
|
|
|
- from UFDATA_901_2021.dbo.om_momain om
|
|
|
- join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_901_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- GROUP BY i.cInvName,rs.cFree1
|
|
|
- )tab2 on tab2.cInvName=tab.goodsName and tab.color=tab2.cfree1
|
|
|
-
|
|
|
- union all
|
|
|
-
|
|
|
- select tab.*,tab2.jian-tab.usageQuantity as number
|
|
|
- from
|
|
|
- (
|
|
|
- select oti.cInvName as goodsName,ot.cFree1 as color,max(om.ccode) as planCode,sum(ot.iQuantity) as usageQuantity
|
|
|
- from UFDATA_903_2021.dbo.om_momain om
|
|
|
- join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_903_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
|
- join UFDATA_903_2021.dbo.Inventory oti on oti.cInvCode=ot.cInvCode
|
|
|
- join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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.cInvName = #{goodName}
|
|
|
- and (oti.cInvCcode like '03%' or oti.cInvCcode like '04%') and oti.cInvCCode != '0399' and oti.cInvCCode != '0499'
|
|
|
- GROUP BY oti.cInvName,ot.cFree1
|
|
|
- ) tab
|
|
|
- left join
|
|
|
- (
|
|
|
- select i.cInvName,sum(rs.iQuantity) as jian,rs.cfree1 from UFDATA_903_2021.dbo.rdrecords11 rs
|
|
|
- join UFDATA_903_2021.dbo.Inventory i on rs.cInvCode=i.cInvCode
|
|
|
- where iordercode in (
|
|
|
- select distinct od.csocode
|
|
|
- from UFDATA_903_2021.dbo.om_momain om
|
|
|
- join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
- join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
- 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 (i.cInvCcode like '03%' or i.cInvCcode like '04%') and i.cInvCCode != '0399' and i.cInvCCode != '0499'
|
|
|
- GROUP BY i.cInvName,rs.cFree1
|
|
|
- )tab2 on tab2.cInvName=tab.goodsName and tab.color=tab2.cfree1
|
|
|
- </select>
|
|
|
-<!-- select oti.cInvName as goodsName,ot.cFree1 as color,max(om.ccode) as planCode,sum(ot.iQuantity) as number
|
|
|
+ select oti.cInvName as goodsName,ot.cFree1 as color,max(om.ccode) as planCode,sum(ot.iQuantity) as number
|
|
|
from UFDATA_901_2021.dbo.om_momain om
|
|
|
join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
|
join UFDATA_901_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
@@ -287,5 +227,6 @@
|
|
|
join UFDATA_903_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
|
|
|
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.cInvName = #{goodName}
|
|
|
and (oti.cInvCcode like '03%' or oti.cInvCcode like '04%') and oti.cInvCCode != '0399' and oti.cInvCCode != '0499'
|
|
|
- GROUP BY oti.cInvName,ot.cFree1-->
|
|
|
+ GROUP BY oti.cInvName,ot.cFree1
|
|
|
+ </select>
|
|
|
</mapper>
|