- <select id="getDetailData" parameterType="java.util.Map" resultType="java.util.Map">
- SELECT aa.*,DATE_FORMAT(#{startTime},'%Y-%m-%d')startTime,
- DATE_FORMAT(#{endTime},'%Y-%m-%d') endTime,
- aa.averageRewardScore rewardScore,
- aa.averageReduceScore reduceScore,
- SUM(IF (c.DraweeScore > 0,c.DraweeScore,0)) realRewardScore,
- SUM(IF (c.DraweeScore < 0, abs(c.DraweeScore),0)) realReduceScore,
- COUNT(DISTINCT CASE WHEN c.DraweeScore > 0 AND c.DraweeScore IS NOT NULL THEN c.DraweeID END ) realRewardNum
- FROM
- (SELECT a.EmpID empID, a.EmpName empName, a.OrgName orgName, a.EmpNo empNo, a.postName,
- b.AverageReduceScore averageReduceScore,b.ScoreTaskDesc scoreTaskDesc,
- b.AverageRewardScore averageRewardScore, b.LowestRewardScore lowestRewardScore,b.scoreTaskID scoreTaskID,
- <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
- FIND_IN_SET(PostID,#{taskBeExecutePostIDs})
- AND PostID IS NOT NULL AND PostID != '')
- </if>
- GROUP BY aa.empID
- ORDER BY realRewardScore desc
- </select>
复制代码 |