Переглянути джерело

薪酬统计修改和排序

shenhao 3 роки тому
батько
коміт
62e11eccdc

+ 14 - 9
src/main/java/com/ssj/statistics/dao/impl/StatisticsQueryImpl.java

@@ -156,21 +156,26 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
         sql.append("SELECT a.teacher_id,a.teacher_name,a.`subject`,a.all_subject,a.correct_nums,a.overtime_nums,a.not_correct_nums,a.not_comment_nums,a.repeat_nums,a.error_nums,\n");
         sql.append("floor(100*(a.total- a.error_nums-a.not_correct_nums)/a.total) as accuracy,a.calculate_date,a.total as total_nums\n");
         sql.append("from (\n");
-        sql.append("SELECT t12.name as teacher_name,t.teacher_id,t.`subject`,t12.course_name as all_subject,count(if((t.is_mark in (0,2) and t.is_feedback=1) or t.is_mark in (1,3),true,NULL)) as correct_nums, \n");
-        sql.append("count(if((t.is_feedback=1 or t.is_mark in (1,3)) and (DATE_FORMAT(t.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t11.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n" +
-                " or (DATE_FORMAT(t.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t11.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t.create_time,'%Y-%m-%d'),' 23:59:59')),true,null)) as overtime_nums,\n");
+        sql.append("SELECT t.name as teacher_name,t.teacher_id,t.`subject`,t.course_name as all_subject,count(if((t.is_mark in (0,2) and t.is_feedback=1) or t.is_mark in (1,3),true,NULL)) as correct_nums, \n");
+        sql.append("count(if((t.is_feedback=1 or t.is_mark in (1,3)) and (DATE_FORMAT(t.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n" +
+                " or (DATE_FORMAT(t.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t.create_time,'%Y-%m-%d'),' 23:59:59')),true,null)) as overtime_nums,\n");
         sql.append("count(1) as total,\n");
-        sql.append("DATE_FORMAT(t.create_time,'%Y-%m-%d') as calculate_date,\n");
+        sql.append("DATE_FORMAT(t.calculate_date,'%Y-%m-%d') as calculate_date,\n");
         sql.append("count(if(t.is_feedback=0 and t.is_mark in (0,2),true,null)) as not_correct_nums,\n");
         sql.append("count(if(t.is_mark=10,true,null)) as not_comment_nums,\n");
         sql.append("count(if(t.is_mark=15,true,null)) as repeat_nums,\n");
-        sql.append("count(if(t11.is_check_error=1,true,null)) as error_nums\n");
+        sql.append("count(if(t.is_check_error=1,true,null)) as error_nums\n");
+        sql.append("from (\n");
+        sql.append("select t.teacher_id,t.is_mark,t11.is_check_error,ifnull(t11.end_time,t.create_time) as calculate_date,t.is_feedback,t.create_time,t11.end_time, \n");
+        sql.append("t12.name,t.subject,t12.course_name \n");
         sql.append("from scon_homework_picture t \n");
         sql.append("left join scon_homework_picture_correct t11 on t.id = t11.homework_picture_id \n");
         sql.append("left join tb_lib_manager t12 on t.teacher_id = t12.user_id\n");
-        sql.append("where t12.type = 30 and t11.type = 8 and to_days(t.create_time)<= to_days(?)\n");
+        sql.append("where t12.type = 30 and t11.type = 8 and (to_days(t.create_time)<= to_days(?) or to_days(t11.end_time)<= to_days(?))\n");
+        queryParams.add(dateTime);
         queryParams.add(dateTime);
-        sql.append("GROUP BY t.teacher_id,to_days(t.create_time)\n");
+        sql.append(") t \n");
+        sql.append("GROUP BY t.teacher_id,to_days(t.calculate_date)\n");
         sql.append(")a");
         return dao.findList(sql.toString(),queryParams.toArray(),ListVO.class);
     }
@@ -180,7 +185,7 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
         StringBuffer sql = new StringBuffer();
         List<Object> queryParams = new ArrayList<>();
         sql.append("SELECT a.correct_nums,a.teacher_id,a.overtime_nums,a.perk_nums,a.error_nums,a.work_date,\n");
-        sql.append("FLOOR(a.sum_perk/a.perk_nums) as perk_efficiency,Floor(100*(a.correct_nums-a.error_nums)/a.correct_nums) as accuracy,\n");
+        sql.append("FLOOR(a.sum_perk/a.perk_nums) as perk_efficiency,round(100*(a.correct_nums-a.error_nums)/a.correct_nums,2) as accuracy,\n");
         sql.append("case when a.perk_nums-a.perk_overtime_nums<134 and a.perk_nums-a.perk_overtime_nums>0  and floor(a.sum_perk/a.perk_nums)<120 then 20 \n");
         sql.append("     when a.perk_nums = a.perk_overtime_nums then (a.perk_overtime_nums-a.error_overtime_nums)*0.075 \n");
         sql.append(" else  (a.perk_nums-a.perk_overtime_nums-a.perk_error_nums+a.error_overtime_nums)*0.15+(a.perk_overtime_nums-a.error_overtime_nums)*0.075 end as perk_salary,\n");
@@ -265,7 +270,7 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
         sql.append("select t.work_date as workDate,t.correct_nums as  correctNums,  \n");
         sql.append("t.overtime_nums as overtimeNums,t.perk_nums as  perkNums,  \n");
         sql.append(" ifnull(replace(concat(SEC_TO_TIME(t.perk_efficiency),''),'.000000',''),'00:00:00') as perkEfficiency,t.error_nums as  errorNums,  \n");
-        sql.append(" t.accuracy,t.perk_salary as  perkSalary,  \n");
+        sql.append(" concat(ifnull(t.accuracy,'0.00'),'%') as accuracy,t.perk_salary as  perkSalary,  \n");
         sql.append(" t.other_salary as otherSalary,t.salary as  salary  \n");
         sql.append("from tb_teacher_salary t \n");
         sql.append("where t.teacher_id = ? and t.month=? and t.year=? order by t.work_date asc");