FROM (SELECT Item.EquipmentInItemId AS ID,EQ.ProjectId,P.ProjectCode,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName,EQ.UnitId,Unit.UnitName,Item.SpecialEquipmentId
,SPE.SpecialEquipmentName,Item.SizeModel,Item.OwnerCheck,Item.CertificateNum,Item.IsUsed,EQ.CompileDate,'特种设备' AS EQType
FROM InApproveManager_EquipmentInItem AS Item
LEFT JOIN InApproveManager_EquipmentIn AS EQ ON EQ.EquipmentInId = Item.EquipmentInId
LEFT JOIN Base_SpecialEquipment AS SPE ON Item.SpecialEquipmentId = SPE.SpecialEquipmentId
LEFT JOIN Base_Project AS P ON EQ.ProjectId = P.ProjectId
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = EQ.UnitId WHERE (P.ProjectAttribute is null or P.ProjectAttribute = 'GONGCHENG') and (P.isDelete is null or P.isDelete =0)
UNION ALL SELECT Item.GeneralEquipmentInItemId AS ID,EQ.ProjectId,P.ProjectCode,P.ProjectName + ( select top 1 case when ProjectState2 is null then '' when ProjectState2 !=3 then '<span style=""color:red"" >'+ ConstText+'<span/>' else ''end from Sys_Const where GroupId ='ProjectState' and (ProjectState2 is null or ProjectState2=ConstValue )) ProjectName,EQ.UnitId,Unit.UnitName,Item.SpecialEquipmentId
,SPE.SpecialEquipmentName,Item.SizeModel,Item.OwnerCheck,Item.CertificateNum,Item.IsUsed,EQ.CompileDate,'一般设备' AS EQType
FROM InApproveManager_GeneralEquipmentInItem AS Item
LEFT JOIN InApproveManager_GeneralEquipmentIn AS EQ ON EQ.GeneralEquipmentInId = Item.GeneralEquipmentInId
LEFT JOIN Base_SpecialEquipment AS SPE ON Item.SpecialEquipmentId = SPE.SpecialEquipmentId
LEFT JOIN Base_Project AS P ON EQ.ProjectId = P.ProjectId
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = EQ.UnitId WHERE (P.ProjectAttribute is null or P.ProjectAttribute = 'GONGCHENG') and (P.isDelete is null or P.isDelete =0) ) V