• List IEnumerable


        //按部门汇总
        IEnumerable<WeekReportWithDepartmentInfo> report = summary
        .GroupBy(x => new
        {
            x.DeptID,
            x.DeptName
        }).Select(g => new WeekReportWithDepartmentInfo
        {
            DeptID = g.Key.DeptID,
            DeptName = g.Key.DeptName,
            TotalNumber = g.Count(),
            WorkOvertime = g.Sum(a => a.WorkOverHours),
            WorkLeave = g.Where(a => a.IsNeedAttendance == true).Sum(a => a.WorkHours),
            PersonalLeave = g.Where(a => a.IsNeedAttendance == true).Sum(a => a.PersonalLeave),
            PaidLeave = g.Where(a => a.IsNeedAttendance == true).Sum(a => a.PaidLeave),
            LateAndLeavingEarly = g.Where(a => a.IsNeedAttendance == true).Sum(a => a.LateAndLeavingEarly)
        }).Skip(PageSize * (CurrentPage - 1)).Take(PageSize);
    
        //总行数
        int rows = summary
        .GroupBy(x => new
        {
            x.DeptID,
            x.DeptName
        }).Count();
    
        List<WeekReportWithDepartmentInfo> reportlist = new List<WeekReportWithDepartmentInfo>();
        IEnumerable<string> tempEmail;
        foreach (WeekReportWithDepartmentInfo item in report)
        {
            //找到当前部门的所有人
            tempEmail = employees.Where(e => e.DeptID == item.DeptID).Select(s => s.Email);
            item.TotalNumber = summary.Where(e => e.DeptID == item.DeptID).GroupBy(x => new {x.EmpID}).Count();
            ////汇总所有人的事假
            //item.PersonalLeave = personalLeave.Where(p => tempEmail.Contains(p.Key)).Sum(s => s.Value);
    
            ////汇总所有人的带薪假总工时
            //item.PaidLeave = paidLeave.Where(p => tempEmail.Contains(p.Key)).Sum(s => s.Value);
    
            //double jialeave=JiaLeave.Where(p => tempEmail.Contains(p.Key)).Sum(s => s.Value);
            ////迟到早退工时
            //item.LateAndLeavingEarly = item.LateAndLeavingEarly - jialeave;
            //item.LateAndLeavingEarly = item.LateAndLeavingEarly < 0 ? 0 : item.LateAndLeavingEarly;
    
            //汇总所有人的加班总工时
            //item.WorkOvertime = workOvertime.Where(p => tempEmail.Contains(p.Key)).Sum(s => s.Value);
    
            //全勤人数
            item.QqingNumber = item.TotalNumber - summary.Where(s => s.IsNeedAttendance && s.DeptID == item.DeptID && s.AttendanceState != 9).Select(s => s.EmpID).Distinct().Count();//去重复
            //正常考勤时 item.WorkLeave
    
            //缺勤率
            item.BsenteeismRatio = (item.LateAndLeavingEarly + item.PersonalLeave + item.PaidLeave) / item.WorkLeave * 100;
            //加班率
            item.OvertimeRatio = item.WorkOvertime / item.WorkLeave * 100;
    
            reportlist.Add(item);
        }
    
    
    
        //IEnumerable<KeyValue<string, double>> JiaLeave = leaveWithWeek.Where(l => l.TypeName != LeaveType.加班
        //                                                               && l.TypeName != LeaveType.补打卡)
        //                                                    .GroupBy(x => new { x.Email })
        //                                                    .Select(g => new KeyValue<string, double>
        //                                                    {
        //                                                        Key = g.Key.Email,
        //                                                        Value = g.Sum(a => (a.AskLeaveHour))
        //                                                    });
    
    
        //签到(9:00-12:00)
        tempAtdRec = attendances.Where(a => a.EmpID == emp.EmpID && a.RecDateTime > workDay.GetInTime().AddHours(-4) && a.RecDateTime < workDay.GetOutTime()).OrderBy(a => a.RecDateTime);
        if (tempAtdRec.Count() > 0)
        {
            info.SigninTime = tempAtdRec.First().RecTime;
            info.SigninDateTime = tempAtdRec.First().RecDateTime;
        }
        //签退(13:30-18:00)
        tempAtdRec = attendances.Where(a => a.EmpID == emp.EmpID && a.RecDateTime > workDay.GetInTime() && a.RecDateTime < workDay.GetInTime().AddDays(1).AddHours(-4)).OrderByDescending(a => a.RecDateTime);
        if (tempAtdRec.Count() > 0)
        {
            info.SignoutTime = tempAtdRec.First().RecTime;
            info.SignoutDateTime = tempAtdRec.First().RecDateTime;
        }
    
                             
  • 相关阅读:
    mysql 异常处理实例
    Fix java version mismatch in windows---stackoverflow
    Building Tomcat7 source step by step---官方文档
    三个大数据处理框架:Storm,Spark和Samza 介绍比较
    Apache Samza流处理框架介绍——kafka+LevelDB的Key/Value数据库来存储历史消息+?
    mongodb停止遇到shutdownServer failed: unauthorized: this command must run from localhost when running db without auth解决方法
    mongodb集群——配置服务器放分片meta信息,说明meta里包含了哪些数据信息
    MongoDB 3.0 WiredTiger Compression and Performance
    mongodb 压缩——3.0+支持zlib和snappy
    wukong搜索引擎源码解读
  • 原文地址:https://www.cnblogs.com/chxl800/p/5694766.html
Copyright © 2020-2023  润新知