//按部门汇总
            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;
                            }

List IEnumerable的更多相关文章

  1. 先说IEnumerable,我们每天用的foreach你真的懂它吗?

    我们先思考几个问题: 为什么在foreach中不能修改item的值? 要实现foreach需要满足什么条件? 为什么Linq to Object中要返回IEnumerable? 接下来,先开始我们的正 ...

  2. 为IEnumerable<T>添加RemoveAll<IEnumerable<T>>扩展方法--高性能篇

    最近写代码,遇到一个问题,微软基于List<T>自带的方法是public bool Remove(T item);,可是有时候我们可能会用到诸如RemoveAll<IEnumerab ...

  3. C# 索引器,实现IEnumerable接口的GetEnumerator()方法

    当自定义类需要实现索引时,可以在类中实现索引器. 用Table作为例子,Table由多个Row组成,Row由多个Cell组成, 我们需要实现自定义的table[0],row[0] 索引器定义格式为 [ ...

  4. Entity Framework中使用IEnumerable<T>、IQueryable<T>及IList<T>的区别

    1. IEnumerable<T> IEnumerable<T> :对于在内存中集合上运行的方法,返回的可枚举对象将捕获传递到方法的参数.在枚举该对象时,将使用查询运算符的逻辑 ...

  5. 你可能不知道的陷阱, IEnumerable接口

    1.  IEnumerable 与  IEnumerator IEnumerable枚举器接口的重要性,说一万句话都不过分.几乎所有集合都实现了这个接口,Linq的核心也依赖于这个万能的接口.C语言的 ...

  6. 通过IEnumerable和IDisposable实现可暂停和取消的任务队列

    一般来说,软件中总会有一些长时间的操作,这类操作包括下载文件,转储数据库,或者处理复杂的运算. 一种处理做法是,在主界面上提示正在操作中,有进度条,其他部分不可用.这里带来很大的问题, 使用者不知道到 ...

  7. 判断IEnumerable<T>集合中是否包含有T对象

    比如,有角色集合中,只有用户创建有角色,才出现“分配”铵钮.反之,隐藏. IEnumerable有一个方法,叫Any:

  8. .NET面试题系列[11] - IEnumerable<T>的派生类

    “你每次都选择合适的数据结构了吗?” - Jeffery Zhao .NET面试题系列目录 ICollection<T>继承IEnumerable<T>.在其基础上,增加了Ad ...

  9. .NET面试题系列[10] - IEnumerable的派生类

    .NET面试题系列目录 IEnumerable分为两个版本:泛型的和非泛型的.IEnumerable只有一个方法GetEnumerator.如果你只需要数据而不打算修改它,不打算为集合插入或删除任何成 ...

  10. .NET面试题系列[9] - IEnumerable

    .NET面试题系列目录 什么是IEnumerable? IEnumerable及IEnumerable的泛型版本IEnumerable<T>是一个接口,它只含有一个方法GetEnumera ...

随机推荐

  1. Linux下Apache与Tomcat的完全分布式集群配置(负载均衡)

    最近公司要给客户提供一套集群方案,项目组采用了Apache和Tomcat的集群配置,用于实现负载均衡的实现. 由于以前没有接触过Apache,因此有些手生,另外在网上搜寻了很多有关这方面的集群文章,但 ...

  2. BMS 项目过程中遇到的问题

    环境搭建的问题 Git的ssh私人密钥问题, 路劲不正确的话使用ssh方式连接github进行远程push或clone会出现需要输入密码而怎么输入都不正确的情况,这个时候使用下面的办法: http方面 ...

  3. 存储过程系列之存储过程sql查询存储过程的使用

    1.查询某个表被哪些存储过程(以下简称 SP)使用到 : select distinct object_name(id) from syscomments where id in (select ob ...

  4. Linux 性能监测工具总结

    前言: Linux系统出现问题时,我们不仅需要查看系统日志信息,而且还要使用大量的性能监测工具来判断究竟是哪一部分(内存.CPU.硬盘……)出了问题.在Linux系统中,所有的运行参数保存在虚拟目录/ ...

  5. 【转】Android source build/envsetup.sh学习笔记

    原文网址:http://blog.csdn.net/mliubing2532/article/details/7567164 如果你只需要修改某一个模块的内容,但是却每次都要执行make, 最后等待很 ...

  6. ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  7. fcitx中文输入法

    Ubuntu自带的输入法不太尽如人意思,用起来也不方便,我在Ubuntu和FC中都是用Fcitx,很好用! 安装配置如下: 1. 安装 fcitx sudo apt-get install fcitx ...

  8. Unity3d Realtime Dynamic Volume Clouds Rendering

    Ray Marching体积渲染+perlin noise 动态效果: 博主近期渲染: 2016的渲染 2015后半段的渲染 ---- by wolf96

  9. flash挡住了下拉菜单

    遇到了flash挡住了菜单的疑难问题. 在网上查了资料,大部分都说是加一个 <param name="wmode" value="transparent" ...

  10. Miller-Rabin素性测试(POJ3641)

    一.概念引入 在以往判断一个数n是不是素数时,我们都是采用i从2到sqrt(n)能否整除n.如果能整除,则n是合数;否则是素数.但是该算法的时间复杂度为O(sqrt(n)),当n较大时,时间性能很差, ...