select a.Site,a.ObjectID,b.ObjectDesc,b.FamilyID,b.GroupID,1 as qtyAll,case WHEN a.Status='已完工' then 1 else 0 end as qtyFinished, case WHEN a.Status='未开工' then 1 else 0 end as qtyUnFinishied, case WHEN a.Status='已取消' then 1 else 0 end as qtycancelled
from eam_workOrder a left join eam_object b on a.Site=b.Site and a.ObjectID =b.ObjectID
<where>
<iftest="query.site != null and query.site != ''">
AND site = #{query.site}
<iftest="query.site != null and query.site != ''">
AND a.site = #{query.site}
</if>
<iftest="query.objectID != null and query.objectID != ''">
<iftest="query.objectID != null and query.objectID != ''">
AND a.ObjectID like '%' + #{query.objectID} +'%'
</if>
<iftest="query.objectDesc != null and query.objectDesc != ''">
AND b.ObjectDesc like '%' + #{query.objectDesc} +'%'
</if>
<iftest="query.familyID != null and query.familyID != ''">
<iftest="query.familyID != null and query.familyID != ''">
AND b.FamilyID like '%' + #{query.familyID}+'%'
</if>
<iftest="query.groupID != null and query.groupID != ''">
<iftest="query.groupID != null and query.groupID != ''">
AND b.GroupID = #{query.groupID}
</if>
<iftest="query.startDate != null ">
<iftest="query.functionType != null and query.functionType != ''">