|
@@ -86,49 +86,98 @@
|
|
|
</select>
|
|
|
<!-- 其他入库纱,找委外订单的材料出库单,获取物料号+批号,物料号+批号再其他入库单 -->
|
|
|
<select id="getPurchaseListOtherInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
|
|
|
- select cCode,sum(iQuantity*iPrice)/sum(iQuantity) as iPrice, sum(iQuantity) as iQuantity from
|
|
|
(
|
|
|
- SELECT
|
|
|
- a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,a.iUnitCost as iPrice
|
|
|
- FROM
|
|
|
- rdrecords11 a
|
|
|
- INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
|
- WHERE
|
|
|
- (a.cbatch is null or a.cbatch='' or a.cbatch <> '期初') and
|
|
|
- (d.cInvCCode LIKE '01%'
|
|
|
- or d.cInvCCode LIKE '02%'
|
|
|
- or d.cInvCCode LIKE '03%'
|
|
|
- or d.cInvCCode LIKE '04%')
|
|
|
- and a.comcode LIKE CONCAT(#{code},'%')
|
|
|
- AND (a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
|
|
|
- SELECT
|
|
|
+ SELECT
|
|
|
+ a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
|
|
|
+ isnull(isnull(stuff((SELECT ',' + x.cdefine9 FROM rdrecord08 x
|
|
|
+ inner join RdRecords08 y on x.id=y.id
|
|
|
+ where y.cInvCode + isnull( y.cFree1, '' ) + isnull( y.cBatch, '' )=
|
|
|
+ a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) FOR XML path('') ), 1, 1, ''),cBatch),'') as cPlanCode
|
|
|
+ FROM
|
|
|
+ rdrecords11 a
|
|
|
+ INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
|
+ WHERE
|
|
|
+ (a.cbatch is null or a.cbatch='' or a.cbatch <> '期初') and
|
|
|
+ (d.cInvCCode LIKE '01%' or d.cInvCCode LIKE '02%' or d.cInvCCode LIKE '03%' or d.cInvCCode LIKE '04%') and
|
|
|
+ a.comcode LIKE CONCAT(#{code},'%') and
|
|
|
+ a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
|
|
|
+ SELECT
|
|
|
b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
|
|
|
- FROM
|
|
|
+ FROM
|
|
|
RdRecords08 b
|
|
|
INNER JOIN rdrecord08 a ON a.id = b.ID
|
|
|
- WHERE
|
|
|
+ WHERE
|
|
|
a.cbustype = '其他入库'
|
|
|
- ) or a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
|
|
|
- select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
- cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
|
|
|
- select b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
|
|
|
- FROM
|
|
|
+ ) and
|
|
|
+ d.cinvname <> '杂纱'
|
|
|
+ ) union all (
|
|
|
+ SELECT
|
|
|
+ a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
|
|
|
+ isnull(isnull(stuff((SELECT ',' + x.cdefine9 FROM rdrecord08 x
|
|
|
+ inner join RdRecords08 y on x.id=y.id
|
|
|
+ where y.cInvCode + isnull( y.cFree1, '' ) + isnull( y.cBatch, '' ) in (
|
|
|
+ select cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
+ cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'')=a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' )
|
|
|
+ ) FOR XML path('') ), 1, 1, ''),cBatch),'') as cPlanCode
|
|
|
+ FROM
|
|
|
+ rdrecords11 a
|
|
|
+ INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
|
+ WHERE
|
|
|
+ (a.cbatch is null or a.cbatch='' or a.cbatch <> '期初') and
|
|
|
+ (d.cInvCCode LIKE '01%' or d.cInvCCode LIKE '02%' or d.cInvCCode LIKE '03%' or d.cInvCCode LIKE '04%') and
|
|
|
+ a.comcode LIKE CONCAT(#{code},'%') and
|
|
|
+ a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) IN (
|
|
|
+ select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
+ cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
|
|
|
+ select b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
|
|
|
+ FROM
|
|
|
+ RdRecords08 b
|
|
|
+ INNER JOIN rdrecord08 a ON a.id = b.ID
|
|
|
+ WHERE
|
|
|
+ a.cbustype = '其他入库'
|
|
|
+ )
|
|
|
+ ) and
|
|
|
+ a.cInvCode + isnull( a.cFree1, '' ) + isnull( a.cBatch, '' ) not IN (
|
|
|
+ SELECT
|
|
|
+ b.cInvCode + isnull( b.cFree1, '' ) + isnull( b.cBatch, '' )
|
|
|
+ FROM
|
|
|
RdRecords08 b
|
|
|
INNER JOIN rdrecord08 a ON a.id = b.ID
|
|
|
- WHERE
|
|
|
+ WHERE
|
|
|
a.cbustype = '其他入库'
|
|
|
- )
|
|
|
- ) or d.cinvname='杂纱'
|
|
|
- )
|
|
|
- ) as t1 group by cCode
|
|
|
+ ) and
|
|
|
+ d.cinvname <> '杂纱'
|
|
|
+ ) union all (
|
|
|
+ SELECT
|
|
|
+ a.comcode as cCode,isnull(a.iSQuantity,a.iquantity) as iQuantity,isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,'杂纱' as cPlanCode
|
|
|
+ FROM
|
|
|
+ rdrecords11 a
|
|
|
+ INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
|
+ WHERE
|
|
|
+ (a.cbatch is null or a.cbatch='' or a.cbatch <> '期初') and
|
|
|
+ (d.cInvCCode LIKE '01%' or d.cInvCCode LIKE '02%' or d.cInvCCode LIKE '03%' or d.cInvCCode LIKE '04%') and
|
|
|
+ a.comcode LIKE CONCAT(#{code},'%') and
|
|
|
+ d.cinvname='杂纱'
|
|
|
+ )
|
|
|
</select>
|
|
|
<!-- 来源余纱,找委外订单的材料出库单,获取物料号+批号。如果物料号+批号在形态转换单中,取转换前物料+批号。判断物料+批号,是否在其他采购入库里 -->
|
|
|
<select id="getPurchaseListOtherPurInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
|
|
|
- select cCode,sum(iPrice)/count(iPrice) as iPrice, sum(iQuantity) as iQuantity from
|
|
|
(
|
|
|
SELECT
|
|
|
a.comcode as cCode,case when a.iSQuantity is null or a.iSQuantity=0 then a.iquantity else a.iSQuantity end as iQuantity,
|
|
|
- a.iUnitCost as iPrice
|
|
|
+ isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
|
|
|
+ case when a.cBatch is not null and a.cBatch='期初' then '期初'
|
|
|
+ else
|
|
|
+ isnull(stuff((
|
|
|
+ select ','+x.cPOID from RdRecords01 u
|
|
|
+ inner join RdRecord01 v on u.id=v.id
|
|
|
+ inner join PO_Podetails w on u.iPOsID =w.ID
|
|
|
+ inner join PO_Pomain x on w.POID =x.POID
|
|
|
+ where x.cPOID not like CONCAT(#{code},'%') and v.cbustype='普通采购' and
|
|
|
+ u.cinvcode+isnull(u.cfree1,'')+isnull(u.cbatch,'') = a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'')
|
|
|
+ FOR XML path('')
|
|
|
+ ), 1, 1, ''),'')
|
|
|
+ end as cPlanCode
|
|
|
FROM
|
|
|
rdrecords11 a
|
|
|
INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
@@ -136,40 +185,69 @@
|
|
|
(d.cInvCCode LIKE '01%'
|
|
|
or d.cInvCCode LIKE '02%'
|
|
|
or d.cInvCCode LIKE '03%'
|
|
|
- or d.cInvCCode LIKE '04%')
|
|
|
- and a.comcode LIKE CONCAT(#{code},'%')
|
|
|
- and d.cInvName<>'杂纱'
|
|
|
- and (
|
|
|
- a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
|
|
|
- select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
- inner join RdRecord01 a on a.id=b.id
|
|
|
- inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
- inner join PO_Pomain d on c.POID =d.POID
|
|
|
- where d.cPOID not like CONCAT(#{code},'%') and a.cbustype='普通采购'
|
|
|
- ) and a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') not in (
|
|
|
- select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
- inner join RdRecord01 a on a.id=b.id
|
|
|
- inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
- inner join PO_Pomain d on c.POID =d.POID
|
|
|
- where d.cPOID like CONCAT(#{code},'%') and a.cbustype='普通采购'
|
|
|
- )
|
|
|
- or a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
|
|
|
- select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
- cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
|
|
|
- select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
- inner join RdRecord01 a on a.id=b.id
|
|
|
- inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
- inner join PO_Pomain d on c.POID =d.POID
|
|
|
- where d.cPOID not like CONCAT(#{code},'%') and a.cbustype='普通采购')
|
|
|
- and cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') not in (
|
|
|
- select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
- inner join RdRecord01 a on a.id=b.id
|
|
|
- inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
- inner join PO_Pomain d on c.POID =d.POID
|
|
|
- where d.cPOID like CONCAT(#{code},'%') and a.cbustype='普通采购')
|
|
|
+ or d.cInvCCode LIKE '04%') and
|
|
|
+ a.comcode LIKE 'SYM738%' and
|
|
|
+ d.cInvName <> '杂纱' and
|
|
|
+ a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
|
|
|
+ select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
+ inner join RdRecord01 a on a.id=b.id
|
|
|
+ inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
+ inner join PO_Pomain d on c.POID =d.POID
|
|
|
+ where d.cPOID not like CONCAT(#{code},'%') and a.cbustype='普通采购'
|
|
|
+ ) and
|
|
|
+ a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') not in (
|
|
|
+ select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
+ inner join RdRecord01 a on a.id=b.id
|
|
|
+ inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
+ inner join PO_Pomain d on c.POID =d.POID
|
|
|
+ where d.cPOID like CONCAT(#{code},'%') and a.cbustype='普通采购'
|
|
|
+ )
|
|
|
+ ) union all (
|
|
|
+ SELECT
|
|
|
+ a.comcode as cCode,case when a.iSQuantity is null or a.iSQuantity=0 then a.iquantity else a.iSQuantity end as iQuantity,
|
|
|
+ isnull(a.iUnitCost,0) as iPrice,isnull(a.cBatch,'') as cBatch,
|
|
|
+ case when a.cBatch is not null and a.cBatch='期初' then '期初'
|
|
|
+ else
|
|
|
+ isnull(stuff((
|
|
|
+ select ','+x.cPOID from RdRecords01 u
|
|
|
+ inner join RdRecord01 v on u.id=v.id
|
|
|
+ inner join PO_Podetails w on u.iPOsID =w.ID
|
|
|
+ inner join PO_Pomain x on w.POID =x.POID
|
|
|
+ where x.cPOID not like CONCAT(#{code},'%') and v.cbustype='普通采购' and
|
|
|
+ u.cinvcode+isnull(u.cfree1,'')+isnull(u.cbatch,'') in (
|
|
|
+ select cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
+ cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'')=a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'')
|
|
|
)
|
|
|
+
|
|
|
+ FOR XML path('')
|
|
|
+ ), 1, 1, ''),'')
|
|
|
+ end as cPlanCode
|
|
|
+ FROM
|
|
|
+ rdrecords11 a
|
|
|
+ INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
|
|
|
+ WHERE
|
|
|
+ (d.cInvCCode LIKE '01%'
|
|
|
+ or d.cInvCCode LIKE '02%'
|
|
|
+ or d.cInvCCode LIKE '03%'
|
|
|
+ or d.cInvCCode LIKE '04%') and
|
|
|
+ a.comcode LIKE CONCAT(#{code},'%') and
|
|
|
+ d.cInvName <> '杂纱' and
|
|
|
+ a.cInvCode+isnull(a.cFree1,'')+isnull(a.cbatch,'') in (
|
|
|
+ select cInvCode2+isnull(cColor2,'')+isnull(cAVBatch2,'') from VIEW_FabricLoss_AssemVouchs where
|
|
|
+ cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') in (
|
|
|
+ select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
+ inner join RdRecord01 a on a.id=b.id
|
|
|
+ inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
+ inner join PO_Pomain d on c.POID =d.POID
|
|
|
+ where d.cPOID not like CONCAT(#{code},'%') and a.cbustype='普通采购')
|
|
|
+ and cInvCode+isnull(cColor,'')+isnull(cAVBatch,'') not in (
|
|
|
+ select b.cinvcode+isnull(b.cfree1,'')+isnull(b.cbatch,'') from RdRecords01 b
|
|
|
+ inner join RdRecord01 a on a.id=b.id
|
|
|
+ inner join PO_Podetails c on b.iPOsID =c.ID
|
|
|
+ inner join PO_Pomain d on c.POID =d.POID
|
|
|
+ where d.cPOID like CONCAT(#{code},'%') and a.cbustype='普通采购')
|
|
|
)
|
|
|
- ) as t1 group by cCode
|
|
|
+ )
|
|
|
</select>
|
|
|
<!--获取所有委外订单 cComUnitCode : 计量单位,02(PCS)根,04(M)米-->
|
|
|
<select id="getOmOrderListAll" resultType="org.jeecg.modules.report.entity.FabricOMOrder">
|