许鹏程
2024-08-15 bce99b5506a632dfc93228b8410913084ed51c00
Merge remote-tracking branch 'origin/master'
已修改4个文件
472 ■■■■ 文件已修改
src/main/java/com/product/administration/controller/LeaveRequestController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/LeaveRequestService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/PunchRecordService.java 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/WorkAttendanceKanbanService.java 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/LeaveRequestController.java
@@ -140,6 +140,9 @@
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            String uuid = leaveRequestService.saveLeaveRequest(fse);
            if (uuid.equals("1")){
                return error("该时间段已经有请假记录无法保存");
            }
            if (!StringUtils.isEmpty(uuid)) {
                return OK_Add(uuid);
            }
src/main/java/com/product/administration/service/LeaveRequestService.java
@@ -61,17 +61,24 @@
     * 请假申请保存
     */
    public String saveLeaveRequest(FieldSetEntity fs) throws BaseException {
//        fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());//公司
//        fs.setValue("fill_in_time", new Date());//填单时间
//        fs.setValue("department_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());//部门
        fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());//姓名
        fs.setValue("flow_flag", 0);
        DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_ASK_FOR_LEAVE, " uuid  not in (?) and user_id=? and ((start_time<=? and end_time>=?) or(start_time<=? and end_time>=?))"
                , new String[]{StringUtils.isEmpty(fs.getUUID())?"":fs.getUUID(), fs.getString("user_id"), fs.getString("start_time"), fs.getString("start_time"), fs.getString("end_time"), fs.getString("end_time")});
        if (dataTableEntity.getRows()>0){
            return "1";
        }else {
        if(StringUtils.isEmpty(fs.getString(CmnConst.UUID))){
                fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("created_utc_datetime", new Date());
                fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
            return baseDao.add(fs);
        }else {
                fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("updated_utc_datetime", new Date());
            baseDao.update(fs);
            return fs.getString(CmnConst.UUID);
        }
        }
    }
    /**
     * @Date: 2020-03-30 16:43
src/main/java/com/product/administration/service/PunchRecordService.java
@@ -1,11 +1,23 @@
package com.product.administration.service;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -40,10 +52,245 @@
     * @param fse
     * @return
     */
    public DataTableEntity listRecordInfo(FieldSetEntity fse) {
    public DataTableEntity listRecordInfo(FieldSetEntity fse) throws ParseException {
        DataTableEntity dt=baseDao.listTable(CmnConst.PRODUCT_OA_PUNCH_RECORD, "created_by=?", new Object[] {SpringMVCContextHolder.getCurrentUser().getUser_id()}, null, CmnConst.CREATED_UTC_DATETIME+" DESC", fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE));
        dt.setFieldFormat("punch_time_one", "yyyy-MM-dd HH:mm:ss");
        dt.setFieldFormat("punch_time_three", "yyyy-MM-dd HH:mm:ss");
        for (int i=0;i<dt.getRows();i++){
            FieldSetEntity fieldSetEntity = dt.getData().get(i);
            String punch_time_one = fieldSetEntity.getValue("punch_time_one").toString();
            Date date1=new Date(punch_time_one);
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String sign_date = dateFormat.format(date1);
            fieldSetEntity.setValue("sign_date",sign_date);
            DateFormat dateFormatGet = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            //获取早退迟到的分钟数
            List<Object>param1=new ArrayList<>();
            param1.add(fieldSetEntity.getValue("created_by").toString());
            param1.add(fieldSetEntity.getValue("punch_congfig_uuid").toString());
            param1.add(fieldSetEntity.getValue("created_by").toString()+",");
            //获取使用到的设置规则
            StringBuilder sbPunchTime=new StringBuilder();
            sbPunchTime.append(" SELECT c.* ");
            sbPunchTime.append(" FROM ( ");
            sbPunchTime.append(" SELECT d.* ");
            sbPunchTime.append(" FROM product_oa_punch_time d ");
            sbPunchTime.append(" left JOIN product_oa_punch_record b ");
            sbPunchTime.append(" on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? where d.punch_site_uuid= ? ");
            sbPunchTime.append(" ) c ");
            sbPunchTime.append(" where  c.uuid in ( ");
            sbPunchTime.append(" SELECT DISTINCT uuid ");
            sbPunchTime.append(" FROM product_oa_punch_time ");
            sbPunchTime.append(" where LOCATE(?, concat(attendance_object,','))>0 ");
            sbPunchTime.append(" ) ");
            DataTableEntity dataTableEntity = baseDao.listTable(sbPunchTime.toString(), param1.toArray());
            //处理补卡的情况
            List<Object>param2=new ArrayList<>();
            param2.add(fieldSetEntity.getValue("created_by").toString());
            param2.add(sign_date);
            StringBuilder sbReplenish=new StringBuilder();
            sbReplenish.append(" SELECT T1.id,T1.uuid,T1.created_by,T1.applicant,T1.replenish_date,T1.reason,");
            sbReplenish.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.replacement_card_type, ',', T2.digit + 1 ), ',',- 1 ) AS type ");
            sbReplenish.append(" FROM product_oa_replenish_punch T1 ");
            sbReplenish.append(" JOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 ) T2");
            sbReplenish.append(" ON T2.digit < ( length( T1.replacement_card_type )- length( REPLACE ( T1.replacement_card_type, ',', '' ))+ 1 )");
            sbReplenish.append(" where t1.created_by=? ");
            sbReplenish.append(" and DATE_FORMAT( t1.replenish_date, '%Y-%m-%d' )=? ");
            DataTableEntity dataTableEntity1 = baseDao.listTable(sbReplenish.toString(), param2.toArray());
            if(dataTableEntity1.getRows()!=0){
                for(int j=0;j<dataTableEntity1.getRows();j++){
                    String type = dataTableEntity1.getData().get(j).getValue("type").toString();
                    if(type.equals("1")){
                        String morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                        Date parse = dateFormatGet.parse(morning_work);
                        fieldSetEntity.setValue("punch_time_one", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("2")){
                        String morning_work_off = dataTableEntity.getData().get(0).getValue("morning_work_off").toString();
                        Date parse = dateFormatGet.parse(morning_work_off);
                        fieldSetEntity.setValue("punch_time_two", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("3")){
                        String afternoon_work = dataTableEntity.getData().get(0).getValue("afternoon_work").toString();
                        Date parse = dateFormatGet.parse(afternoon_work);
                        fieldSetEntity.setValue("punch_time_three", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("4")){
                        String afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                        Date parse = dateFormatGet.parse(afternoon_work_off);
                        fieldSetEntity.setValue("punch_time_four", new Timestamp(parse.getTime()));
                    }
                }
            }
            long beLate1 = 0;
            long beLate2 = 0;
            long beEarily1 = 0;
            long beEarily2 = 0;
            if(dataTableEntity.getRows()!=0){
                String morning_work="";
                String morning_work_off="";
                String afternoon_work="";
                String afternoon_work_off="";
                Date  morning_work_date;
                Date  morning_work_off_date;
                Date  afternoon_work_date;
                Date  afternoon_work_off_date;
                DateTime punch_time_one_date;
                DateTime punch_time_two_date;
                DateTime punch_time_three_date;
                DateTime punch_time_four_date;
                SimpleDateFormat dateFormatHHmmss = new SimpleDateFormat("HH:mm:ss");
                StringBuilder  lateSb=new StringBuilder();
                StringBuilder   earilySb=new StringBuilder();
                StringBuilder supereffective_distance=new StringBuilder();
                if(!ObjectUtil.isNotEmpty(dataTableEntity.getData().get(0).getValue("morning_work_off")) && !ObjectUtil.isNotEmpty(dataTableEntity.getData().get(0).getValue("afternoon_work"))){
                    morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                    afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                    morning_work_date= DateUtil.parse(morning_work.split(" ")[1]);
                    afternoon_work_off_date= DateUtil.parse(afternoon_work_off.split(" ")[1]);
                    int distance = Integer.parseInt(dataTableEntity.getData().get(0).getValue("distance").toString());
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_one"))){
                        String punch_time_one1 = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_one"));
                        punch_time_one_date = DateUtil.parse(punch_time_one1);
                        if(punch_time_one_date.after(morning_work_date)){
                            beLate1 = DateUtil.between(punch_time_one_date, morning_work_date, DateUnit.MINUTE);
                            lateSb.append("迟到:"+beLate1+"分钟");
                            //计算超出的有效距离
                            int punch_range_one = Integer.parseInt(fieldSetEntity.getValue("punch_range_one").toString());
                            if(punch_range_one>distance){
                                int distanceMorning = punch_range_one- distance;
                                fieldSetEntity.setValue("supereffective_distance","上班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        lateSb.append("上班未打卡");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_four"))){
                        String punch_time_four = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_four"));
                        punch_time_four_date = DateUtil.parse(punch_time_four);
                        if(punch_time_four_date.before(afternoon_work_off_date)){
                            beEarily2 = DateUtil.between(punch_time_four_date, afternoon_work_off_date, DateUnit.MINUTE);
                            earilySb.append("早退:"+beEarily2+"分钟");
                            int punch_range_four = Integer.parseInt(fieldSetEntity.getValue("punch_range_four").toString());
                            if(punch_range_four>distance){
                                int distanceMorning = punch_range_four- distance;
                                fieldSetEntity.setValue("supereffective_distance","下班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        earilySb.append("下班未打卡");
                    }
                }else {
                    morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                    morning_work_date= DateUtil.parse(morning_work.split(" ")[1]);
                    morning_work_off = dataTableEntity.getData().get(0).getValue("morning_work_off").toString();
                    morning_work_off_date= DateUtil.parse(morning_work_off.split(" ")[1]);
                    afternoon_work =dataTableEntity.getData().get(0).getValue("afternoon_work").toString();
                    afternoon_work_date= DateUtil.parse(afternoon_work.split(" ")[1]);
                    afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                    afternoon_work_off_date= DateUtil.parse(afternoon_work_off.split(" ")[1]);
                    int distance = Integer.parseInt(dataTableEntity.getData().get(0).getValue("distance").toString());
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_one"))){
                        String punch_time_one1 = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_one"));
                        punch_time_one_date = DateUtil.parse(punch_time_one1);
                        if(punch_time_one_date.after(morning_work_date)){
                            beLate1 = DateUtil.between(punch_time_one_date, morning_work_date, DateUnit.MINUTE);
                            lateSb.append("早上班迟到:"+beLate1+" ");
                            int punch_range_one = Integer.parseInt(fieldSetEntity.getValue("punch_range_one").toString());
                            if(punch_range_one>distance){
                                int distanceMorning = punch_range_one- distance;
                                supereffective_distance.append("早上班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        lateSb.append("早上班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_two"))){
                        String punch_time_two= dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_two"));
                        punch_time_two_date = DateUtil.parse(punch_time_two);
                        if(punch_time_two_date.before(morning_work_off_date)){
                            beEarily1 = DateUtil.between(punch_time_two_date, morning_work_off_date, DateUnit.MINUTE);
                            earilySb.append("早下班早退:"+beEarily1+" ");
                            int punch_range_two = Integer.parseInt(fieldSetEntity.getValue("punch_range_two").toString());
                            if(punch_range_two>distance){
                                int distanceMorningoff = punch_range_two- distance;
                                supereffective_distance.append("早下班超有效距离:"+distanceMorningoff);
                            }
                        }
                    }else {
                        earilySb.append("早下班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_three"))){
                        String punch_time_three = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_three"));
                        punch_time_three_date = DateUtil.parse(punch_time_three);
                        if(punch_time_three_date.after(afternoon_work_date)){
                            beLate2 = DateUtil.between(punch_time_three_date, afternoon_work_date, DateUnit.MINUTE);
                            lateSb.append("下午上班迟到:"+beLate2+" ");
                            int punch_range_three = Integer.parseInt(fieldSetEntity.getValue("punch_range_three").toString());
                            if(punch_range_three>distance){
                                int distanceAfternoon = punch_range_three- distance;
                                supereffective_distance.append("下午上班超有效距离:"+distanceAfternoon);
                            }
                        }
                    }else {
                        lateSb.append("早上班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_four"))){
                        String punch_time_four = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_four"));
                        punch_time_four_date = DateUtil.parse(punch_time_four);
                        if(punch_time_four_date.before(afternoon_work_off_date)){
                            beEarily2 = DateUtil.between(punch_time_four_date, afternoon_work_off_date, DateUnit.MINUTE);
                            earilySb.append("下午下班早退:"+beEarily2+" ");
                            int punch_range_four = Integer.parseInt(fieldSetEntity.getValue("punch_range_four").toString());
                            if(punch_range_four>distance){
                                int distanceAfternoonoff = punch_range_four- distance;
                                supereffective_distance.append("下午下班超有效距离:"+distanceAfternoonoff);
                            }
                        }
                    }else {
                        earilySb.append("下午下班未打卡"+" ");
                    }
                }
                fieldSetEntity.setValue("be_late",lateSb);
                fieldSetEntity.setValue("ealy_leave",earilySb);
                fieldSetEntity.setValue("supereffective_distance",supereffective_distance.toString());
            }
        }
        dt.setFieldFormat("punch_time_one", " HH:mm");
        dt.setFieldFormat("punch_time_two", " HH:mm");
        dt.setFieldFormat("punch_time_three", " HH:mm");
        dt.setFieldFormat("punch_time_four", " HH:mm");
        baseDao.loadPromptData(dt);
        return dt;
    }
src/main/java/com/product/administration/service/WorkAttendanceKanbanService.java
@@ -5,6 +5,7 @@
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -157,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");
@@ -258,14 +259,31 @@
        
        //获取当前人信息
        SystemUser currentUser=SpringMVCContextHolder.getCurrentUser();
        String org_level_uuid=currentUser.getOrg_level_uuid();
        List<Object>param1=new ArrayList<>();
        param1.add(currentUser.getUser_id());
        param1.add(currentUser.getUser_id()+",");
       //获取使用到的设置规则
        StringBuilder sbPunchTime=new StringBuilder();
        sbPunchTime.append(" SELECT DISTINCT c.* ");
        sbPunchTime.append(" FROM ( ");
        sbPunchTime.append(" SELECT d.* ");
        sbPunchTime.append(" FROM product_oa_punch_time d ");
        sbPunchTime.append(" left JOIN product_oa_punch_record b ");
        sbPunchTime.append(" on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? ");
        sbPunchTime.append(" ) c ");
        sbPunchTime.append(" where  c.uuid in ( ");
        sbPunchTime.append(" SELECT DISTINCT uuid ");
        sbPunchTime.append(" FROM product_oa_punch_time ");
        sbPunchTime.append(" where LOCATE(?, concat(attendance_object,','))>0 ");
        sbPunchTime.append(" ) ");
        DataTableEntity dataTableEntity = baseDao.listTable(sbPunchTime.toString(), param1.toArray());
        List<DataTableEntity> dataTableEntityLits=new ArrayList<>();
        for(int i=0;i<dataTableEntity.getRows();i++){
        //获取公司工作时间配置信息
        FieldSetEntity fseCompanyPunch=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_OA_PUNCH_TIME, "", new Object[] {}, false);
            FieldSetEntity fseCompanyPunch = dataTableEntity.getData().get(i);
        if (fseCompanyPunch==null) {
            throw new BaseException(SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getValue(), SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getText(), this.getClass(), "listMonthReport");
        }
        //获取查询月份
        String yearAndMonth=fse.getString("yearAndMonth");
        if (StringUtils.isEmpty(yearAndMonth)) {
@@ -284,19 +302,24 @@
            dayOfWork=dayOfMonth-dtHoliday.getRows();
        }
        
        //workTimeMethod 0:上午上班,下午下班  1:一卡 2:四卡  3:上午上班,下午上班
        int workTimeMethod=0;
         if (StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_three")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
             workTimeMethod=1;
        } else if (!StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && !StringUtils.isEmpty(fseCompanyPunch.getString("work_time_three")) && !StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
            workTimeMethod=2;
        } else if (StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
            workTimeMethod=3;
        }
        
        StringBuilder sb=new StringBuilder();
        List<Object>param=new ArrayList<>();
            String morinng_work = fseCompanyPunch.getValue("morning_work").toString().split(" ")[1];
            param.add(morinng_work);
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                String morinng_work_off = fseCompanyPunch.getValue("morning_work_off").toString().split(" ")[1];
                String afternoon_work = fseCompanyPunch.getValue("afternoon_work").toString().split(" ")[1];
                param.add(afternoon_work);
                param.add(morinng_work_off);
            }
            String afternoon_work_off = fseCompanyPunch.getValue("afternoon_work_off").toString().split(" ")[1];
            String uuid = fseCompanyPunch.getValue("uuid").toString();
            param.add(afternoon_work_off);
        param.add(yearAndMonth);
            param.add(uuid);
        param.add(yearAndMonth);
        param.add(yearAndMonth);
        sb.append(" SELECT ");
@@ -304,60 +327,57 @@
        sb.append(" (SELECT org_level_name FROM product_sys_org_levels WHERE uuid=dept_uuid)dept_uuid, ");
        sb.append(" dayOfWork,workDayOfMonth,lateCome,leaveEarly,total_hours,casual_leave,medical_leave,marriage_leave,paid_leave,other_leave,(dayOfWork-workDayOfMonth)absenteeism ");
        sb.append(" FROM ( ");
        sb.append(" SELECT ");
        sb.append(" a.created_by,"+dayOfWork+" dayOfWork,COUNT(day_of_month)workDayOfMonth,a.dept_uuid, ");
        if (workTimeMethod==0) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        }else if (workTimeMethod==1) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" 0 leaveEarly ");
        }else if (workTimeMethod==2) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result2='早退',TRUE,NULL))+COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        }else if (workTimeMethod==3) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" 0 leaveEarly ");
        }
        /*
        if (workTimeMethod==1) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result2='早退',TRUE,NULL))+COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        } else if (workTimeMethod==2) {
            sb.append("");
        } else if (workTimeMethod==3) {
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" SELECT b.created_by,b.dayOfWork,b.workDayOfMonth,b.dept_uuid,b.lateCome1+b.lateCome2 lateCome,b.leaveEarly1+b.leaveEarly2 leaveEarly");
        } else {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
                sb.append(" SELECT b.created_by,b.dayOfWork,b.workDayOfMonth,b.dept_uuid,b.lateCome1 lateCome,b.leaveEarly2 leaveEarly");
        }
        */
        sb.append(" FROM ( ");
        sb.append(" SELECT ");
        sb.append(" created_by,dept_uuid, ");
        sb.append(" DATE_FORMAT(created_utc_datetime,'%Y-%m-%d') day_of_month, ");
        sb.append(" punch_time_one,IF(punch_time_one IS TRUE,IF(DATE_FORMAT(punch_time_one,'%H:%i:%S')>'09:00:00','迟到','正常'),'未打卡') result1 ");
            sb.append(" a.created_by,"+dayOfWork+" dayOfWork,COUNT(day_of_month)workDayOfMonth,a.dept_uuid, ");
            sb.append(" COUNT(");
            sb.append(" IF ");
            sb.append(" ( result1 = '迟到', TRUE, NULL )) lateCome1,");
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" COUNT(");
                sb.append(" IF ");
                sb.append(" ( result2 = '迟到', TRUE, NULL )) lateCome2,");
                sb.append(" COUNT(");
                sb.append(" IF ");
                sb.append(" ( result3 = '早退', TRUE, NULL )) leaveEarly1,");
        
//        sb.append(" punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<'12:00:00','早退','正常'),'未打卡') result2, ");
//        sb.append(" punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3, ");
//        sb.append(" punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        if (workTimeMethod==0) {
            sb.append(", punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        }else if (workTimeMethod==2) {
            sb.append(", punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<'12:00:00','早退','正常'),'未打卡') result2 ");
            sb.append(", punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3 ");
            sb.append(", punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        }else if (workTimeMethod==3) {
            sb.append(", punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3 ");
            }
            sb.append(" COUNT(");
            sb.append(" IF ");
            sb.append(" ( result4 = '早退', TRUE, NULL )) leaveEarly2 ");
            sb.append(" FROM ( ");
            sb.append(" SELECT d.created_by,d.dept_uuid,DATE_FORMAT( d.created_utc_datetime, '%Y-%m-%d' ) day_of_month,punch_time_one, ");
            sb.append(" IF ");
            sb.append(" ( punch_time_one IS TRUE, IF ( DATE_FORMAT( punch_time_one, '%H:%i:%S' )> ?, '迟到', '正常' ), '未打卡' ) ");
            sb.append(" result1 ,");
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" IF ");
                sb.append(" ( punch_time_three IS TRUE, IF ( DATE_FORMAT( punch_time_three, '%H:%i:%S' )> ?, '迟到', '正常' ), '未打卡' ) ");
                sb.append(" result2 ,");
                sb.append(" IF ");
                sb.append(" ( punch_time_two IS TRUE, IF ( DATE_FORMAT( punch_time_two, '%H:%i:%S' )< ?, '早退', '正常' ), '未打卡' ) ");
                sb.append(" result3 ,");
        }
        
        sb.append(" FROM product_oa_punch_record ");
        sb.append(" WHERE DATE_FORMAT(created_utc_datetime,'%Y-%m')=? AND DATE_FORMAT(punch_time_one,'%Y-%m-%d') NOT IN(SELECT date_holiday FROM product_sys_company_holiday) ");
            sb.append(" IF ");
            sb.append(" ( punch_time_four IS TRUE, IF ( DATE_FORMAT( punch_time_four, '%H:%i:%S' ) < ?, '早退', '正常' ), '未打卡' ) ");
            sb.append(" result4 ");
            sb.append(" FROM product_oa_punch_record d ");
            sb.append(" left JOIN   product_oa_punch_time e ");
            sb.append(" on d.punch_congfig_uuid=e.punch_site_uuid ");
            sb.append(" and DATE_FORMAT( d.created_utc_datetime,'%Y-%m')=? AND DATE_FORMAT(punch_time_one,'%Y-%m-%d') NOT IN(SELECT date_holiday FROM product_sys_company_holiday) ");
            sb.append(" where e.uuid=? ");
        sb.append(" )a  ");
        sb.append(" GROUP BY a.created_by,a.dept_uuid ");
            sb.append(" )b");
        sb.append(" )a ");
        sb.append(" LEFT JOIN (SELECT user_id,sum(total_hours)total_hours FROM product_oa_work_overtime WHERE flow_flag=2 AND DATE_FORMAT(start_time,'%Y-%m')=? GROUP BY user_id)b  ");
            sb.append(" LEFT JOIN (SELECT user_id, sum( duration ) total_hours FROM product_oa_work_overtime o left join product_oa_work_overtime_sub b on o.uuid=b.main_uuid and   DATE_FORMAT( b.start_time, '%Y-%m' )=? GROUP BY o.user_id)b  ");
        sb.append(" ON a.created_by=b.user_id ");
        sb.append(" LEFT JOIN ( ");
        sb.append(" SELECT ");
@@ -370,7 +390,60 @@
        sb.append(" )c ");
        sb.append(" ON a.created_by=c.created_by ");
        sb.append(" ORDER BY dept_uuid,a.created_by ");
        return baseDao.listTable(sb.toString(), param.toArray());
            DataTableEntity dataTableEntityReport = baseDao.listTable(sb.toString(), param.toArray());
            if(dataTableEntityReport.getRows()!=0){
                dataTableEntityLits.add(baseDao.listTable(sb.toString(), param.toArray()));
    }
        }
        DataTableEntity dataTableEntity1=new DataTableEntity();
        if(ObjectUtil.isNotEmpty(dataTableEntityLits)){
            dataTableEntity1=dataTableEntityLits.get(0);
            //本月内迟到早退数的累加
            for (int i = 1; i < dataTableEntityLits.size(); i++) {
                FieldSetEntity fieldSetEntity = dataTableEntityLits.get(i).getData().get(0);
                FieldSetEntity fieldSetEntity1 = dataTableEntity1.getData().get(0);
                dataTableEntity1.getData().get(0).setValue("lateCome",Integer.parseInt(fieldSetEntity.getValue("lateCome").toString())+Integer.parseInt(fieldSetEntity1.getValue("lateCome").toString()));
                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;
    }
}