Sfoglia il codice sorgente

数据统计计算模糊图片和数据不全的
薪酬统计计算在线时长

shenhao 3 anni fa
parent
commit
e00b776cb0

+ 1 - 1
src/main/java/com/ssj/dao/sys/homework/dao/impl/HomeworkPictureQueryDaoImpl.java

@@ -200,7 +200,7 @@ public class HomeworkPictureQueryDaoImpl  implements  HomeworkPictureQueryDao {
 				.append(" hp.teacher_id, hp.allot_time,  hp.create_time, hp.corrected_picture_url, hpc.check_date, hpc.checker, hpc.is_check_error," )
 				.append(" hpc.error_reason, hp.is_checker_correct is_correct")
 				.append(" FROM scon_homework_picture hp left join scon_homework_picture_correct hpc on hp.id=hpc.homework_picture_id ")
-				.append(" where hp.homework_id=? and hpc.type = ? and hpc.is_checker_correct = 1 order by hp.create_time");
+				.append(" where hp.homework_id=? and hpc.type = ? and hpc.is_check_error = 1 order by hp.create_time");
 		param.add(homeworkId);
 		param.add(type);
 		return dao.findList(sb.toString(), param.toArray(), HomeworkPictureDto.class);

+ 4 - 4
src/main/java/com/ssj/dao/sys/homework/dao/impl/HomeworkQueryDaoImpl.java

@@ -336,21 +336,21 @@ public class HomeworkQueryDaoImpl implements HomeworkQueryDao {
         selSQL.append("a.next_1\n");
         selSQL.append("from (\n");
         selSQL.append("select t.homework_id,t12.child_name as student_name, t14.`subject`,t14.grade,\n");
-        selSQL.append("count(if(t.is_feedback = 1,true,null)) as correctNums,\n");
+        selSQL.append("count(if(t.is_feedback = 1 or t.is_mark in (1,3),true,null)) as correctNums,\n");
         selSQL.append("count(1) as totalNums,\n");
         selSQL.append("min(t.allot_time) as allot_time,\n");
         selSQL.append("min(t11.start_time) as start_time,\n");
         selSQL.append("max(t11.end_time) as end_time,\n");
         selSQL.append("min(t.create_time) as create_time,\n");
         selSQL.append("sum(t11.correction_time) as correction_time,\n");
-        selSQL.append("floor(sum(t11.correction_time)/ count(if(t.is_feedback = 1,true,null))) as next_1,\n");
+        selSQL.append("floor(sum(t11.correction_time)/ count(if(t.is_feedback = 1 or t.is_mark in (1,3),true,null))) as next_1,\n");
         selSQL.append("min(t.is_feedback) as is_feedback\n");
         selSQL.append("from scon_homework_picture t\n");
         selSQL.append("left join scon_homework t14 on t.homework_id = t14.id\n");
         selSQL.append("left join scon_homework_picture_correct t11 on t.id = t11.homework_picture_id and t11.type=8\n");
         selSQL.append("left join tb_lib_vip t12 on t.vip_id = t12.id\n");
-        selSQL.append(" where t.teacher_id=? and ((t11.end_time > ? and t.is_feedback=1) or t.is_feedback=0)\n");
-        selSQL.append("and t.is_mark in (0,2)\n");
+        selSQL.append(" where t.teacher_id=? and ((t11.end_time > ? and (t.is_feedback=1 or t.is_mark in (0,2)) ) or t.is_feedback=0)\n");
+        //selSQL.append("and t.is_mark in (0,2)\n");
         selSQL.append("group by t.homework_id");
         selSQL.append(") a \n");
         selSQL.append( ") b order by b.state asc ");

+ 2 - 3
src/main/java/com/ssj/dao/weixin/library/dao/impl/LibJoinQueryDaoImpl.java

@@ -1315,9 +1315,8 @@ public class LibJoinQueryDaoImpl implements ILibJoinQueryDao{
 		queryParams.add(params.get("beginTime"));
 		selSQL.append("(SELECT ifnull(concat(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,min(a.allot_time),NOW())),''),'00:00:00')   from scon_homework_picture a where a.teacher_id = t.user_id and a.is_mark in (0,2) and a.is_feedback = 0 and  not exists (select 1 from scon_homework_picture_correct x where x.type=8 and x.start_time is not null and a.homework_id = x.homework_id ) ) as wait_max_time, \n");
 		selSQL.append("t.user_id as teacher_id,t.name as teacher_name, \n");
-		selSQL.append("(select ifnull(concat(SEC_TO_TIME(sum(b.correction_time)),''),'00:00:00') from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id where a.teacher_id = t.user_id and a.is_mark in (0,2) and a.is_feedback=1 and to_days(b.end_time) =to_days(now())) as today_correct_time, \n");
-		selSQL.append("(select ifnull(concat(SEC_TO_TIME(floor(sum(TIMESTAMPDIFF(SECOND,a.allot_time,b.start_time))/count(1))),''),0) from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id and b.type=8 where a.teacher_id = t.user_id and a.is_mark in (0,2) and b.start_time is not null and ((a.is_feedback=1 and b.end_time > ?) or a.is_feedback=0)) as efficiency, \n");
-		queryParams.add(params.get("beginTime"));
+		selSQL.append("(select ifnull(concat(SEC_TO_TIME(sum(b.correction_time)),''),'00:00:00') from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id where a.teacher_id = t.user_id and ((a.is_mark in (0,2) and a.is_feedback=1) or a.is_mark in (1,3)) and to_days(b.end_time) =to_days(now())) as today_correct_time, \n");
+		selSQL.append("(select ifnull(concat(SEC_TO_TIME(floor(sum(TIMESTAMPDIFF(SECOND,a.allot_time,b.start_time))/count(1))),''),0) from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id and b.type=8 where a.teacher_id = t.user_id and b.start_time is not null and (((a.is_feedback=1 or is_mark in (1,3)) and to_days(b.end_time) = to_days(now())) or (a.is_feedback=0 and a.is_mark in (0,2) and to_days(b.start_time) = to_days(now())))) as efficiency, \n");
 		selSQL.append("t.is_online as state  \n");
 		selSQL.append("from tb_lib_manager t  \n");
 		selSQL.append("where t.type=30 and t.state=1 \n");

+ 8 - 1
src/main/java/com/ssj/statistics/dao/IStatisticsQueryDao.java

@@ -31,9 +31,16 @@ public interface IStatisticsQueryDao {
     List<ListVO> statisticsDataList(String dataDate);
 
     /**
-     *
+     *查询批注老师上月批改薪酬
      * @param month
      * @return
      */
     List<TeacherSalarysVO> addTeacherSalarysData(String month);
+
+    /**
+     * 查询高峰时段一直在线,且高峰时段未分配到作业的老师
+     * @param month
+     * @return
+     */
+    List<TeacherSalarysVO> findOnlineList(String month);
 }

+ 45 - 23
src/main/java/com/ssj/statistics/dao/impl/StatisticsQueryImpl.java

@@ -115,7 +115,7 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
         queryParams.add(teacherId);
         sql.append(" and  to_days(t11.create_time) =to_days(?)  ");
         queryParams.add(date);
-        sql.append("t11.homework_id");
+        sql.append("group by t11.homework_id");
         return dao.findMap(sql.toString(),queryParams.toArray());
     }
 
@@ -156,8 +156,8 @@ 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,true,NULL)) as correct_nums, \n");
-        sql.append("count(if(t.is_feedback=1 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" +
+        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("count(1) as total,\n");
         sql.append("DATE_FORMAT(t.create_time,'%Y-%m-%d') as calculate_date,\n");
@@ -179,34 +179,56 @@ public class StatisticsQueryImpl implements IStatisticsQueryDao {
     public List<TeacherSalarysVO> addTeacherSalarysData(String month) {
         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,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(" case when a.perk_nums<134 and a.sum_perk<120 then 20 else (a.perk_nums-a.error_nums)*0.15 end as perk_salary\n" );
-        sql.append(",(a.correct_nums-a.perk_nums-a.error_nums)*0.15 as other_salary\n" );
-        sql.append("from (\n" );
-        sql.append("SELECT\n" );
-        sql.append("count(1) as correct_nums,\n" );
+        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("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("sql.append(sql.append( else (a.perk_nums-a.perk_overtime_nums-a.error_overtime_nums)*0.15+(a.perk_overtime_nums-a.error_overtime_nums)*0.075 end as perk_salary,\n");
+        sql.append("case when a.correct_nums-a.perk_nums-a.overtime_nums+a.perk_overtime_nums=0 then (a.correct_nums-a.perk_nums)*0.075 \n");
+        sql.append("     else (a.correct_nums-a.perk_nums-a.overtime_nums+a.perk_overtime_nums)*0.15+(a.overtime_nums-a.perk_overtime_nums)*0.075 end as other_salary\n");
+        sql.append("from (\n");
+        sql.append("SELECT\n");
+        sql.append("count(1) as correct_nums,\n");
         sql.append("count(if((DATE_FORMAT(t11.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t11.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n");
         sql.append(" or (DATE_FORMAT(t11.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t11.create_time,'%Y-%m-%d'),' 23:59:59')),true,null)) as overtime_nums,\n");
-        sql.append("count(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00',TRUE,null)) as perk_nums,\n" );
-        sql.append("count(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00' and (DATE_FORMAT(t11.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t11.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n");
-        sql.append(" or (DATE_FORMAT(t11.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t11.create_time,'%Y-%m-%d'),' 23:59:59')),TRUE,null)) as perk_overtime_nums,\n" );
-        sql.append("count(IF(t.is_check_error=1,TRUE,null)) as error_nums,\n" );
-        sql.append("DATE_FORMAT(t.end_time,'%Y-%m-%d') as work_date,\n" );
-        sql.append("sum(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00',t.correction_time,0)) as sum_perk,\n" );
-        sql.append("t11.teacher_id,\n" );
-        sql.append("t.end_time,\n" );
-        sql.append("t.start_time \n" );
-        sql.append("from scon_homework_picture_correct t \n" );
-        sql.append("join scon_homework_picture t11 on t.homework_picture_id = t11.id\n" );
-        sql.append("where t.type=8 and t11.is_mark in(0,2) and t11.is_feedback=1 \n" );
-        sql.append("and t.end_time like concat('%',?,'%')\n" );
+        sql.append("count(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00',TRUE,null)) as perk_nums,\n");
+        sql.append("count(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00' and ((DATE_FORMAT(t11.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t11.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n");
+        sql.append(" or (DATE_FORMAT(t11.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t11.create_time,'%Y-%m-%d'),' 23:59:59'))),TRUE,null)) as perk_overtime_nums,\n");
+        sql.append("count(IF(t.is_check_error=1,TRUE,null)) as error_nums,\n");
+        sql.append("count(IF(t.is_check_error=1 and ((DATE_FORMAT(t11.create_time,'%H:%i')>='20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(DATE_ADD(t11.create_time,interval 1 day),'%Y-%m-%d'),' 12:00:00'))\n");
+        sql.append(" or (DATE_FORMAT(t11.create_time,'%H:%i')<'20:30' and DATE_FORMAT(t.end_time,'%Y-%m-%d %H:%i:%s')>concat(DATE_FORMAT(t11.create_time,'%Y-%m-%d'),' 23:59:59'))),TRUE,null)) as error_overtime_nums,\n");
+        sql.append("DATE_FORMAT(t.end_time,'%Y-%m-%d') as work_date,\n");
+        sql.append("sum(IF(DATE_FORMAT(t.end_time,'%H:%i')>='18:00' and DATE_FORMAT(t.end_time,'%H:%i')<='20:00',t.correction_time,0)) as sum_perk,\n");
+        sql.append("t11.teacher_id\n");
+        sql.append("from scon_homework_picture_correct t \n");
+        sql.append("join scon_homework_picture t11 on t.homework_picture_id = t11.id\n");
+        sql.append("where t.type=8 and t11.is_mark in(0,2) and t11.is_feedback=1 \n");
+        sql.append("and t.end_time like concat(?,'%') \n");
         queryParams.add(month);
-        sql.append("GROUP BY t11.teacher_id\n" );
+        sql.append("GROUP BY t11.teacher_id\n");
         sql.append(") a");
         return dao.findList(sql.toString(),queryParams.toArray(),TeacherSalarysVO.class);
     }
 
     @Override
+    public List<TeacherSalarysVO> findOnlineList(String month) {
+        StringBuffer sql = new StringBuffer();
+        List<Object> queryParams = new ArrayList<>();
+        sql.append("select a.work_date,a.user_id as teacher_id from (\n");
+        sql.append("SELECT DATE_FORMAT(t.login_datetime,'%Y-%m-%d') as work_date,t.user_id \n");
+        sql.append(" from tb_user_login t\n");
+        sql.append(" where DATE_FORMAT(t.login_datetime,'%H:%i')<='18:00' \n");
+        sql.append("  and (concat(DATE_FORMAT(t.login_datetime,'%Y-%m-%d'),' 20:00:00') <DATE_FORMAT(t.logout_datetime,'%Y-%m-%d %H:%i:%s') or logout_time=0)\n");
+        sql.append(" and t.login_datetime like concat(?,'%')");
+        queryParams.add(month);
+        sql.append("sql.append(GROUP BY t.user_id,to_days(t.login_datetime)\n");
+        sql.append(") a \n");
+        sql.append("sql.append(left join scon_homework_picture b on a.user_id = b.teacher_id and a.work_date = DATE_FORMAT(b.allot_time,'%Y-%m-%d') and DATE_FORMAT(b.allot_time,'%H:%i')>='18:00' and DATE_FORMAT(b.allot_time,'%H:%i')<='20:00'\n");
+        sql.append("sql.append(where b.id is null");
+        return dao.findList(sql.toString(),queryParams.toArray(),TeacherSalarysVO.class);
+    }
+
+    @Override
     public List<CheckDetailVO> checkDetailList(String homeworkId) {
         StringBuffer sql = new StringBuffer();
         List<Object> queryParams = new ArrayList<>();

+ 32 - 4
src/main/java/com/ssj/statistics/service/impl/StatisticsServiceImpl.java

@@ -108,10 +108,11 @@ public class StatisticsServiceImpl  extends BaseServiceImpl<PlatTeacherStatistic
             month = DateFormatUtils.format(DateUtil.addMonth(-1), "yyyy-MM");
         }
         List<TeacherSalarysVO> list = queryDao.addTeacherSalarysData(month);
+        String monthTemp = month.split("-")[1];
+        int month2 = monthTemp.startsWith("0")?Integer.parseInt(monthTemp.substring(1)):Integer.parseInt(monthTemp);
+        int year =Integer.parseInt(month.split("-")[0]) ;
+        List<TeacherPay> payList = new ArrayList<>();
         if(Objects.nonNull(list) && list.size()>0){
-            String monthTemp = month.split("-")[1];
-            int month2 = monthTemp.startsWith("0")?Integer.parseInt(monthTemp.substring(1)):Integer.parseInt(monthTemp);
-            int year =Integer.parseInt(month.split("-")[0]) ;
             for(TeacherSalarysVO vo:list){
                 TeacherPay pay = new TeacherPay();
                 BeanUtils.copyProperties(vo,pay);
@@ -119,8 +120,35 @@ public class StatisticsServiceImpl  extends BaseServiceImpl<PlatTeacherStatistic
                 pay.setYear(year);
                 pay.setCreateTime(new Date());
                 pay.setSalary(new BigDecimal(pay.getPerkSalary()).add(new BigDecimal(pay.getOtherSalary())));
-                payService.save(pay);
+                payList.add(pay);
             }
         }
+
+        //查询上月高峰期在线2小时且高峰期未分配到作业的老师
+        List<TeacherSalarysVO> onlineList = queryDao.findOnlineList(month);
+        if(Objects.nonNull(onlineList) && onlineList.size()>0){
+            for(TeacherSalarysVO vo:onlineList){
+                boolean add = true;
+                if(payList.size()>0){
+                    for(TeacherPay pay :payList){
+                        if(pay.getTeacherId().equals(vo.getTeacherId()) && pay.getWorkDate().equals(vo.getWorkDate())){
+                            pay.setPerkSalary("20");
+                            add = false;
+                            break;
+                        }
+                    }
+                }
+                if(add){
+                    TeacherPay pay = new TeacherPay();
+                    BeanUtils.copyProperties(vo, pay);
+                    pay.setMonth(month2);
+                    pay.setYear(year);
+                    pay.setCreateTime(new Date());
+                    pay.setPerkSalary("20");
+                    payList.add(pay);
+                }
+            }
+        }
+        payService.save(payList);
     }
 }