select
A5.NAME AS 所属组织,
A.DocNo as 单号,A3.Code as 项目号,a7.Name as 单据类型,
A.StartDate as 计划开工日,
A.CompleteDate as 计划完工日,A2.Code as 料号,A2.name as 品名,A2.SPECS as 规格 , a.ProductQty as 生产数量,TotalCompleteQty as 完工数量
from MO_MO as A
left join CBO_ItemMaster as A2 on (A.ItemMaster = A2.ID)
left join CBO_Project as A3 on (A.Project = A3.ID)
left join Base_Organization as A4 on (A.Org = A4.ID)
left join Base_Organization_Trl as a5 on (a4.ID = a5.ID)
left join MO_MODocType as a6 on (a.MODocType=a6.ID)
left join MO_MODocType_Trl as a7 on (a6.id=a7.ID)
where A7.NAME != '研发项目'  --过滤内部研发项目
and A.IsWBSTask!=1                 --过滤现场施工任务
and A.DocState != '3'              --过滤完工状态的订单
and (A7.NAME IS NOT NULL AND A7.NAME !='')
ORDER BY A.CompleteDate