|
@@ -3,88 +3,107 @@
|
|
|
<mapper namespace="org.jeecg.modules.productionScheduleReport.mapper.ProductionScheduleMapper">
|
|
|
|
|
|
<select id="selectByPage" resultType="org.jeecg.modules.productionScheduleReport.entity.ProductionSchedule">
|
|
|
- select -- top 100
|
|
|
- c.cDepName -- 部门
|
|
|
- ,d.cPersonName -- 业务员
|
|
|
- ,a.cSOCode -- 销售订单号
|
|
|
- ,p.PlanCode planCode-- 计划单号
|
|
|
- ,e.cCusName -- 客户
|
|
|
- ,a.cDefine12 -- 成衣加工厂
|
|
|
- ,b.cInvCode -- 存货编码
|
|
|
- ,f.cInvName -- 存货名称
|
|
|
- ,b.cDefine22 itemNumber -- 款号
|
|
|
- ,b.cFree1 color-- 颜色
|
|
|
- ,min(a.dPreDateBT) dPreDateBT -- 交期
|
|
|
- ,sum(b.iQuantity) iQuantity --订单数量
|
|
|
- ,sum(b.iTaxUnitPrice) iTaxUnitPrice -- 原币含税单价
|
|
|
- ,sum(b.iSum) total_sum -- 总额(原币)
|
|
|
- ,sum(b.iNatSum/b.iQuantity) bb_price -- 单价(本币)
|
|
|
- ,sum(b.iNatSum) iNatSum -- 总额(本币)
|
|
|
- ,sum(b.icostsum) icostsum -- 实际发票成本
|
|
|
- ,sum(b.foutquantity) foutquantity --已出库数量
|
|
|
- ,sum(b.iKPQuantity) iKPQuantity --累计开票数量
|
|
|
- ,sum(b.iKPMoney) iKPMoney -- 累计开票金额
|
|
|
- ,f.pictureGUid pictureId -- 图片id
|
|
|
- ,min(a.dDate) dDate -- 单据日期
|
|
|
- from SO_SOMain a
|
|
|
- left join SO_SODetails b on a.id = b.id
|
|
|
|
|
|
- left join mps_netdemand m on a.cSOCode = m.SoCode and m.OrgDemSeq = b.iRowNo
|
|
|
- left join mps_plancode p on m.ProjectId = p.plancodeid
|
|
|
+select t.* from (
|
|
|
+SELECT max(o.omCode) as planCode,max(c.PictureGUID) as pictureId,
|
|
|
+ max(ss.csocode) as cSOCode,max(de.cDepName) as cDepName,max(pe.cPersonName) as cPersonName,max(s.icostsum) as icostsum,
|
|
|
+ max(v.cVenName) as cDefine12,max(s.cInvCode) as cInvCode,max(s.cInvName) as cInvName,max(s.cdefine22) as itemNumber,
|
|
|
+ max(s.cFree1) as color,max(s.dPreDate) as dPreDateBT,sum(s.iQuantity) as iQuantity,max(s.iTaxUnitPrice) as iTaxUnitPrice,
|
|
|
+ sum(s.iSum) as totalSum,max(s.iNatUnitPrice) as bbPrice,max(s.iNatSum) as iNatSum,sum(s.foutquantity) as foutquantity,sum(s.iKPQuantity) as iKPQuantity
|
|
|
+ FROM UFDATA_901_2021.dbo.SO_SODetails s
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.SO_SOMain ss on ss.ID= s.ID
|
|
|
+ inner JOIN (
|
|
|
+ SELECT
|
|
|
+ om.cCode AS omCode,
|
|
|
+ om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
|
|
|
+ om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity
|
|
|
+ FROM
|
|
|
+ UFDATA_901_2021.dbo.OM_MOMain om
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
|
+ WHERE
|
|
|
+ om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
|
|
|
+
|
|
|
+ ) o ON s.isosid = o.isosid AND s.cInvCode = o.cInvCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Inventory c on c.cInvCode=s.cInvCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Person pe ON ss.cPersonCode = pe.cPersonCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Department de ON ss.cDepCode = de.cDepCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Customer cc ON ss.cCusCode = cc.cCusCode
|
|
|
+ ${ew.customSqlSegment} and c.cInvCcode like '19%'
|
|
|
+ GROUP BY v.cVenName
|
|
|
+ union all
|
|
|
+
|
|
|
+ SELECT max(o.omCode) as planCode,max(c.PictureGUID) as pictureId,
|
|
|
+ max(ss.csocode) as cSOCode,max(de.cDepName) as cDepName,max(pe.cPersonName) as cPersonName,max(s.icostsum) as icostsum,
|
|
|
+ max(v.cVenName) as cDefine12,max(s.cInvCode) as cInvCode,max(s.cInvName) as cInvName,max(s.cdefine22) as itemNumber,
|
|
|
+ max(s.cFree1) as color,max(s.dPreDate) as dPreDateBT,sum(s.iQuantity) as iQuantity,max(s.iTaxUnitPrice) as iTaxUnitPrice,
|
|
|
+ sum(s.iSum) as totalSum,max(s.iNatUnitPrice) as bbPrice,max(s.iNatSum) as iNatSum,sum(s.foutquantity) as foutquantity,sum(s.iKPQuantity) as iKPQuantity
|
|
|
+ FROM UFDATA_903_2021.dbo.SO_SODetails a
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
|
+ inner JOIN (
|
|
|
+ SELECT
|
|
|
+ om.cCode AS omCode, od.csoordercode,
|
|
|
+ om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
|
|
|
+ om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity
|
|
|
+ FROM
|
|
|
+ UFDATA_903_2021.dbo.OM_MOMain om
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
|
+ WHERE
|
|
|
+ om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
|
|
|
+ ) o ON a.isosid = o.isosid AND a.cInvCode = o.cInvCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Person pe ON b.cPersonCode = pe.cPersonCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Department de ON b.cDepCode = de.cDepCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Customer cc ON b.cCusCode = cc.cCusCode
|
|
|
+ inner join UFDATA_902_2021.dbo.PO_Pomain f on f.cPOID=o.csoordercode
|
|
|
+ inner join UFDATA_902_2021.dbo.po_podetails g on g.POID=f.POID
|
|
|
+ inner join UFDATA_902_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
|
|
|
+ inner join UFDATA_902_2021.dbo.so_somain ss on ss.id=s.id
|
|
|
+ inner join UFDATA_902_2021.dbo.Person j on j.cPersonCode=ss.cPersonCode
|
|
|
+ inner JOIN UFDATA_902_2021.dbo.Customer cu ON ss.cCusCode = cu.cCusCode
|
|
|
+ ${ew.customSqlSegment} and cc.cCusCode in ('T020001','0001') and ss.cCusCode not in ('T020001','0001')
|
|
|
+ and c.cInvCcode like '19%'
|
|
|
+ GROUP BY v.cVenName
|
|
|
|
|
|
- left join Department c on c.cDepCode = a.cDepCode
|
|
|
- left join person d on d.cPersonCode = a.cPersonCode
|
|
|
- left join Customer e on e.cCusCode = a.cCusCode
|
|
|
- left join Inventory f on f.cInvCode = b.cInvCode
|
|
|
+ union all
|
|
|
|
|
|
- ${ew.customSqlSegment} and p.plancode is not null
|
|
|
+ SELECT max(o.omCode) as planCode,max(c.PictureGUID) as pictureId,
|
|
|
+ max(ss.csocode) as cSOCode,max(de.cDepName) as cDepName,max(pe.cPersonName) as cPersonName,max(s.icostsum) as icostsum,
|
|
|
+ max(v.cVenName) as cDefine12,max(s.cInvCode) as cInvCode,max(s.cInvName) as cInvName,max(s.cdefine22) as itemNumber,
|
|
|
+ max(s.cFree1) as color,max(s.dPreDate) as dPreDateBT,sum(s.iQuantity) as iQuantity,max(s.iTaxUnitPrice) as iTaxUnitPrice,
|
|
|
+ sum(s.iSum) as totalSum,max(s.iNatUnitPrice) as bbPrice,max(s.iNatSum) as iNatSum,sum(s.foutquantity) as foutquantity,sum(s.iKPQuantity) as iKPQuantity
|
|
|
+ FROM UFDATA_903_2021.dbo.SO_SODetails a
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
|
+ inner JOIN (
|
|
|
+ SELECT
|
|
|
+ om.cCode AS omCode, od.csoordercode,
|
|
|
+ om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
|
|
|
+ om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity
|
|
|
+ FROM
|
|
|
+ UFDATA_903_2021.dbo.OM_MOMain om
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
|
+ WHERE
|
|
|
+ om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser')
|
|
|
+ ) o ON a.isosid = o.isosid AND a.cInvCode = o.cInvCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Person pe ON b.cPersonCode = pe.cPersonCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Department de ON b.cDepCode = de.cDepCode
|
|
|
+ inner JOIN UFDATA_903_2021.dbo.Customer cc ON b.cCusCode = cc.cCusCode
|
|
|
+ inner join UFDATA_901_2021.dbo.PO_Pomain f on f.cPOID=o.csoordercode
|
|
|
+ inner join UFDATA_901_2021.dbo.po_podetails g on g.POID=f.POID
|
|
|
+ inner join UFDATA_901_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
|
|
|
+ inner join UFDATA_901_2021.dbo.so_somain ss on ss.id=s.id
|
|
|
+ inner join UFDATA_901_2021.dbo.Person j on j.cPersonCode=ss.cPersonCode
|
|
|
+ inner JOIN UFDATA_901_2021.dbo.Customer cu ON ss.cCusCode = cu.cCusCode
|
|
|
+ ${ew.customSqlSegment} and cc.cCusCode in ('T020001','0001') and ss.cCusCode not in ('T020001','0001') and c.cInvCcode like '19%'
|
|
|
+
|
|
|
+ GROUP BY v.cVenName ) t
|
|
|
|
|
|
- group by
|
|
|
- c.cDepName -- 部门
|
|
|
- ,d.cPersonName -- 业务员
|
|
|
- ,a.cSOCode -- 销售订单号
|
|
|
- ,e.cCusName -- 客户
|
|
|
- ,a.cDefine12 -- 成衣加工厂
|
|
|
- ,b.cInvCode -- 存货编码
|
|
|
- ,f.cInvName -- 存货名称
|
|
|
- ,b.cDefine22 -- 款号
|
|
|
- ,b.cFree1-- 颜色
|
|
|
- ,f.pictureGUid -- 图片id
|
|
|
- ,p.PlanCode
|
|
|
</select>
|
|
|
<select id="selectByPageXXXXX" resultType="org.jeecg.modules.productionScheduleReport.entity.ProductionSchedule">
|
|
|
|
|
|
- select --top 100
|
|
|
- c.cDepName -- 部门
|
|
|
- ,d.cPersonName -- 业务员
|
|
|
- ,a.cSOCode -- 销售订单号
|
|
|
- ,a.cSOCode planCode-- 计划单号
|
|
|
- ,e.cCusName -- 客户
|
|
|
- ,a.cDefine12 -- 成衣加工厂
|
|
|
- ,b.cInvCode -- 存货编码
|
|
|
- ,f.cInvName -- 存货名称
|
|
|
- ,b.cDefine22 itemNumber -- 款号
|
|
|
- ,b.cFree1 color-- 颜色
|
|
|
- ,a.dPreDateBT -- 交期
|
|
|
- ,b.iQuantity --订单数量
|
|
|
- ,b.iTaxUnitPrice -- 原币含税单价
|
|
|
- ,b.iSum total_sum -- 总额(原币)
|
|
|
- ,b.iNatSum/b.iQuantity bb_price -- 单价(本币)
|
|
|
- ,b.iNatSum -- 总额(本币)
|
|
|
- ,b.icostsum -- 实际发票成本
|
|
|
- ,b.foutquantity --已出库数量
|
|
|
- ,b.iKPQuantity --累计开票数量
|
|
|
- ,b.iKPMoney -- 累计开票金额
|
|
|
- ,f.pictureGUid pictureId -- 图片id
|
|
|
- ,a.dDate dDate -- 单据日期
|
|
|
- from SO_SOMain a
|
|
|
- left join SO_SODetails b on a.id = b.id
|
|
|
- left join Department c on c.cDepCode = a.cDepCode
|
|
|
- left join person d on d.cPersonCode = a.cPersonCode
|
|
|
- left join Customer e on e.cCusCode = a.cCusCode
|
|
|
- left join Inventory f on f.cInvCode = b.cInvCode
|
|
|
- ${ew.customSqlSegment}
|
|
|
-
|
|
|
</select>
|
|
|
|
|
|
<select id="selectPicture" resultType="org.jeecg.modules.productionScheduleReport.entity.ProductionSchedule">
|