|
@@ -109,4 +109,76 @@
|
|
|
GROUP BY i.cInvName,rs.cBatch
|
|
|
)tab2 on tab2.cInvName=tab.goodsName
|
|
|
</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
|
|
|
+ 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
|
|
|
+ )tab1
|
|
|
+ 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
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ select tab1.cInvName as goodsName,tab1.cFree1 as color,tab1.cCode as planCode,
|
|
|
+ tab1.purchaseQuantity-tab2.jian 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
|
|
|
+ )tab1
|
|
|
+ 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>
|
|
|
</mapper>
|