<if test="taskBeExecutePostIDs==null or taskBeExecutePostIDs==''">
(
SELECT COUNT(*) FROM (SELECT record.*,
(SELECT COUNT(*) FROM ${enterpriseCode}.sys_mobilizepostrecord record_temp WHERE record_temp.CreateTime>record.CreateTime AND record.EmpID =record_temp.EmpID
AND date_format(record_temp.CreateTime,'%Y-%m-%d') < date_format(#{startTime},'%Y-%m-%d')) count,
c.isEnable,
c.empLeaveDate
FROM ${enterpriseCode}.sys_mobilizepostrecord record left join ${enterpriseCode}.sys_emp c on c.EmpID = record.EmpID
WHERE date_format(record.CreateTime,'%Y-%m-%d') < date_format(#{startTime},'%Y-%m-%d'))
aa WHERE aa.PostID IN (SELECT PostID FROM ${enterpriseCode}.sys_post WHERE pPostID = a.postID) AND
aa.count =0 AND (aa.isEnable = 'true' OR
(aa.isEnable='false' AND date_format(aa.empLeaveDate,'%Y-%m-%d') > date_format(#{startTime},'%Y-%m-%d') ))) lowerEmpCount
</if>
<if test="taskBeExecutePostIDs!=null and taskBeExecutePostIDs!=''">
(
SELECT COUNT(*) FROM (SELECT record.*,
(SELECT COUNT(*) FROM ${enterpriseCode}.sys_mobilizepostrecord record_temp WHERE record_temp.CreateTime>record.CreateTime AND record.EmpID =record_temp.EmpID
AND date_format(record_temp.CreateTime,'%Y-%m-%d') < date_format(#{startTime},'%Y-%m-%d')) count,
c.isEnable,
c.empLeaveDate
FROM ${enterpriseCode}.sys_mobilizepostrecord record left join ${enterpriseCode}.sys_emp c on c.EmpID = record.EmpID
WHERE date_format(record.CreateTime,'%Y-%m-%d') < date_format(#{startTime},'%Y-%m-%d'))
aa WHERE FIND_IN_SET(aa.PostID,#{taskBeExecutePostIDs}) AND
aa.count =0 AND (aa.isEnable = 'true' OR
(aa.isEnable='false' AND date_format(aa.empLeaveDate,'%Y-%m-%d') > date_format(#{startTime},'%Y-%m-%d') ))) lowerEmpCount
</if>
FROM ${enterpriseCode}.scoretask b
LEFT JOIN ${enterpriseCode}.empDetail_view a ON FIND_IN_SET(a.PostID,b.TaskExecutePostIDs)
WHERE b.ScoreTaskID=#{scoreTaskID} AND a.PostID IS NOT NULL AND a.PostID != ''
<if test="empID!=null and empID!=''">
AND FIND_IN_SET(a.EmpID,#{empID})
</if>
) aa
LEFT JOIN (
SELECT * FROM
${enterpriseCode}.scorebill_view WHERE DATE_FORMAT(BillTime, '%Y-%m-%d') >= DATE_FORMAT(#{startTime},
'%Y-%m-%d')
AND DATE_FORMAT(BillTime, '%Y-%m-%d') <= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
AND IsStable = 'false' AND isEnable = 'true') c ON aa.EmpID = c.DrawerID
<if test="taskBeExecutePostIDs==null or taskBeExecutePostIDs==''">
AND c.DraweeID IN (SELECT EmpID FROM ${enterpriseCode}.sys_emp WHERE PostID IN (SELECT PostID FROM
${enterpriseCode}.sys_post
WHERE pPostID IN (SELECT PostID FROM ${enterpriseCode}.sys_emp WHERE FIND_IN_SET(EmpID,aa.EmpID))) AND
isEnable ='true'
AND PostID IS NOT NULL AND PostID != '')
</if>
<if test="taskBeExecutePostIDs!=null and taskBeExecutePostIDs!=''">
AND c.DraweeID IN (SELECT EmpID FROM ${enterpriseCode}.sys_emp WHERE isEnable ='true' AND