杜洪波
2024-08-19 1d1d34b48e6e80bea350d805d8ff2564ca226f25
src/main/java/com/product/administration/service/WorkAttendanceKanbanService.java
@@ -158,10 +158,10 @@
      sb.append(" ,',',if(d.punch_range_four is not null and d.punch_range_four>f.distance,'超出打卡范围',0)) dkfw, ");
      sb.append(" CASE  WHEN b.uuid is not null THEN c.dict_label ELSE  ");
      sb.append(" CASE  WHEN d.uuid is not null THEN   ");
      sb.append(" CONCAT(IF(d.punch_time_one IS TRUE, IF ( DATE_FORMAT(d.punch_time_one, '%H:%i:%S' )>=DATE_FORMAT(f.morning_work, '%H:%i:%S'), CONCAT('上午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_one),'分钟'), 0 ), '上午上班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_two IS TRUE, IF ( DATE_FORMAT(d.punch_time_two, '%H:%i:%S' )<=DATE_FORMAT(f.morning_work_off, '%H:%i:%S') and f.morning_work_off is not null, CONCAT('上午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_two,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '上午下班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_three IS TRUE, IF ( DATE_FORMAT(d.punch_time_three, '%H:%i:%S' )>=DATE_FORMAT(f.afternoon_work, '%H:%i:%S') and f.afternoon_work is not null, CONCAT('下午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_three),'分钟'), 0 ), '下午上班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_four IS TRUE, IF ( DATE_FORMAT(d.punch_time_four, '%H:%i:%S' )<=DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S'), CONCAT('下午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_four,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '下午下班未打卡' )) ");
      sb.append(" CONCAT(IF(d.punch_time_one IS TRUE, IF ( DATE_FORMAT(d.punch_time_one, '%H:%i:%S' )>DATE_FORMAT(f.morning_work, '%H:%i:%S'), CONCAT('上午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_one),'分钟'), 0 ), '上午上班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_two IS TRUE, IF ( DATE_FORMAT(d.punch_time_two, '%H:%i:%S' )<DATE_FORMAT(f.morning_work_off, '%H:%i:%S') and f.morning_work_off is not null, CONCAT('上午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_two,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '上午下班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_three IS TRUE, IF ( DATE_FORMAT(d.punch_time_three, '%H:%i:%S' )>DATE_FORMAT(f.afternoon_work, '%H:%i:%S') and f.afternoon_work is not null, CONCAT('下午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_three),'分钟'), 0 ), '下午上班未打卡' ) ");
      sb.append(" ,',',IF(d.punch_time_four IS TRUE, IF ( DATE_FORMAT(d.punch_time_four, '%H:%i:%S' )<DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S'), CONCAT('下午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_four,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '下午下班未打卡' )) ");
      sb.append(" ELSE '全天未打卡' END END reidis,CASE  WHEN b.uuid is not null THEN 1 ELSE CASE  WHEN d.uuid is not null THEN 0 ELSE 2 END END type ");
      sb.append(" FROM (SELECT CONCAT(DATE_FORMAT(?, '%Y-%m-'),IF(i<9,CONCAT('0',i + 1),i + 1)) punch_date  ");
      param.add(yearAndMonth+"-01");
@@ -407,13 +407,43 @@
            dataTableEntity1.getData().get(0).setValue("leaveEarly",Integer.parseInt(fieldSetEntity.getValue("leaveEarly").toString())+Integer.parseInt(fieldSetEntity1.getValue("leaveEarly").toString()));
            dataTableEntity1.getData().get(0).setValue("workDayOfMonth",Integer.parseInt(fieldSetEntity.getValue("workDayOfMonth").toString())+Integer.parseInt(fieldSetEntity1.getValue("workDayOfMonth").toString()));
            dataTableEntity1.getData().get(0).setValue("absenteeism",Integer.parseInt(fieldSetEntity1.getValue("absenteeism").toString())-Integer.parseInt(fieldSetEntity.getValue("workDayOfMonth").toString()));
         }
      }
      //处理补卡的情况
      List<Object>param2=new ArrayList<>();
      param2.add(currentUser);
      param2.add(fse.getString("yearAndMonth"));
      StringBuilder sbReplenish=new StringBuilder();
      sbReplenish.append(" SELECT DISTINCT replenish_date ");
      sbReplenish.append(" FROM product_oa_replenish_punch ");
      sbReplenish.append(" WHERE");
      sbReplenish.append(" created_by =? ");
      sbReplenish.append(" AND DATE_FORMAT( replenish_date, '%Y-%m' )=? ");
      sbReplenish.append(" and DATE_FORMAT( replenish_date, '%Y-%m-%d') ");
      sbReplenish.append(" not in (");
      sbReplenish.append(" SELECT DISTINCT record_data FROM ");
      sbReplenish.append(" ( ");
      sbReplenish.append(" select  DATE_FORMAT(punch_time_one, '%Y-%m-%d') as record_data  from  product_oa_punch_record ");
      sbReplenish.append(" union all select  DATE_FORMAT(punch_time_two, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
      sbReplenish.append(" union all select  DATE_FORMAT(punch_time_three, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
      sbReplenish.append(" union all select  DATE_FORMAT(punch_time_four, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
      sbReplenish.append(" )n )");
      DataTableEntity dataTableEntityReplenish = baseDao.listTable(sbReplenish.toString(), param2.toArray());
      if(dataTableEntityReplenish.getRows()!=0){
         dataTableEntity1.getData().get(0).setValue("workDayOfMonth",Integer.parseInt(dataTableEntity1.getData().get(0).getString("workDayOfMonth"))+dataTableEntityReplenish.getRows());
         dataTableEntity1.getData().get(0).setValue("dayOfWork",Integer.parseInt(dataTableEntity1.getData().get(0).getString("dayOfWork"))-dataTableEntityReplenish.getRows());
      }
      return  dataTableEntity1;
   }
}