/// <summary>
        /// 初次插入数据
        /// </summary>
        /// <param name="attendTimeMdl"></param>
        /// <param name="worker"></param>
        /// <param name="slodCardTime"></param>
        /// <returns></returns>
        private int InitAttendData(AttendFingerPrintDataInTimeModel attendTimeMdl, ArWorkerInfo worker, DateTime slodCardTime, out AttendSlodFingerDataCurrentMonthModel initMdl, DateTime middleTime)
        {
            initMdl = null;
            int record = 0;
            var mdl    = CreateAttendDataModel(attendTimeMdl, worker, slodCardTime);

            //首次赋值需要加中间判定时间
            if (slodCardTime > middleTime)
            {
                mdl.SlotCardTime2 = slodCardTime.ToString("yyyy-MM-dd HH:mm");
            }
            else
            {
                mdl.SlotCardTime1 = slodCardTime.ToString("yyyy-MM-dd HH:mm");
            }
            record = irep.Insert(mdl);
            if (record == 1)
            {
                initMdl               = CreateAttendDataModel(attendTimeMdl, worker, slodCardTime);
                initMdl.Id_Key        = mdl.Id_Key;
                initMdl.SlotCardTime1 = mdl.SlotCardTime1;
            }
            return(record);
        }
 private void DrawImageRight(Image imageFrom, Graphics g, Brush brush, Font font, int index, ArWorkerInfo cardData)
 {
     if (index >= 5)
     {
         index = index - 5;
     }
     if (index == 0)
     {
         DrawImage(imageFrom, g, brush, font, startX + decImageWidth + midSpliter, startY, cardData);
     }
     else
     {
         DrawImage(imageFrom, g, brush, font, startX + decImageWidth + midSpliter, startY + (decImageHeight + 3) * index, cardData);
     }
 }
 private void DrawImageLeft(Image imageFrom, Graphics g, Brush brush, Font font, int index, ArWorkerInfo cardData)
 {
     if (index == 0)
     {
         DrawImage(imageFrom, g, brush, font, startX, startY, cardData);
     }
     else
     {
         DrawImage(imageFrom, g, brush, font, startX, startY + (decImageHeight + 3) * index, cardData);
     }
 }
 private void DrawImage(Image imageFrom, Graphics g, Brush brush, Font font, int x, int y, ArWorkerInfo cardData)
 {
     g.DrawImage(imageFrom, new Rectangle(x, y, decImageWidth, decImageHeight), new Rectangle(0, 0, imageFrom.Width, imageFrom.Height), GraphicsUnit.Pixel);
     g.DrawString("姓名:", font, brush, new RectangleF(x + 140, y + 92, 497, 40));
     g.DrawString(cardData.Name, font, brush, new RectangleF(x + 190, y + 92, 497, 40));
     g.DrawString("部门:", font, brush, new RectangleF(x + 140, y + 118, 497, 40));
     g.DrawString(cardData.Department, font, brush, new RectangleF(x + 190, y + 118, 497, 40));
     g.DrawString("工号:", font, brush, new RectangleF(x + 140, y + 143, 497, 40));
     g.DrawString(cardData.WorkerId, font, brush, new RectangleF(x + 190, y + 143, 497, 40));
 }
 private void DrawImage(Image imageFrom, Graphics g, Brush brush, Font font, int index, ArWorkerInfo cardData)
 {
     if (index >= 5)
     {
         DrawImageRight(imageFrom, g, brush, font, index, cardData);
     }
     else
     {
         DrawImageLeft(imageFrom, g, brush, font, index, cardData);
     }
 }
        private AttendSlodFingerDataCurrentMonthModel CreateAttendDataModel(AttendFingerPrintDataInTimeModel attendTimeMdl, ArWorkerInfo worker, DateTime slodCardTime)
        {
            var mdl = new AttendSlodFingerDataCurrentMonthModel()
            {
                AttendanceDate            = attendTimeMdl.SlodCardDate,
                WorkerId                  = worker.WorkerId,
                CardID                    = attendTimeMdl.CardID,
                CardType                  = attendTimeMdl.CardType,
                ClassType                 = worker.ClassType,
                Department                = worker.Department,
                WorkerName                = worker.Name,
                WeekDay                   = attendTimeMdl.SlodCardDate.DayOfWeek.ToString().ToChineseWeekDay(),
                LeaveHours                = 0,
                LeaveMark                 = 0,
                YearMonth                 = slodCardTime.ToString("yyyyMM"),
                SlotCardTime              = slodCardTime.ToString("HH:mm"),
                HandleSlotExceptionStatus = 0,
                SlotExceptionMark         = 0,
                OpSign                    = "init",
                OpPerson                  = "system",
            };

            return(mdl);
        }
        /// <summary>
        /// 将实时考勤数据转移至本月数据表中
        /// </summary>
        /// <returns></returns>
        public OpResult TransimitAttendDatas(DateTime qryDate)
        {
            qryDate = qryDate.ToDate();
            //处理总记录数
            int totalRecord = 0, record = 0;
            var datasInTime = this.fingerPrintDataInTime.FingPrintDatas.FindAll(e => e.SlodCardDate == qryDate);

            if (datasInTime == null || datasInTime.Count == 0)
            {
                return(OpResult.SetErrorResult("没有考勤数据要进行汇总"));
            }
            AttendanceDbHelpHandler.BackupData(datasInTime);
            //一次载入该日期的所有考勤数据到内存中
            var dayAttendDatas = this.irep.Entities.Where(e => e.AttendanceDate == qryDate);
            //获取所有人员信息到内存中
            var workers     = AttendanceDbHelpHandler.GetWorkerInfos();
            var departments = AttendanceDbHelpHandler.GetDepartmentDatas();
            //中间时间
            DateTime middleTime = new DateTime(qryDate.Year, qryDate.Month, qryDate.Day, 13, 0, 0);
            //处理实时考勤数据
            ArWorkerInfo worker = null;
            //将考勤中数据中的人进行分组
            List <string>   attendWorkerIdList = datasInTime.Select(e => e.WorkerId).Distinct().ToList();
            ClassTypeModel  ctmdl = null;
            DepartmentModel depm  = null;

            attendWorkerIdList.ForEach(workerId =>
            {
                record = 0;
                //获取每个人的信息
                worker = workers.FirstOrDefault(w => w.WorkerId == workerId);
                if (worker == null)
                {
                    var m = ArchiveService.ArchivesManager.WorkerIdChangeManager.GetModel(workerId);
                    if (m != null)
                    {
                        worker = workers.FirstOrDefault(w => w.WorkerId == m.NewWorkerId);
                    }
                }
                //从实时考勤数据表中获取该员工的考勤数据
                var attendDataPerWorker = datasInTime.FindAll(f => f.WorkerId == workerId).OrderBy(o => o.SlodCardTime).ToList();
                var currentAttendData   = dayAttendDatas.FirstOrDefault(e => e.WorkerId == workerId);//从内存中进行查找
                if (worker != null)
                {
                    ctmdl             = AttendanceDbHelpHandler.GetClassType(workerId, qryDate);
                    depm              = departments.FirstOrDefault(d => d.DataNodeName == worker.Department);
                    worker.ClassType  = ctmdl == null ? "白班" : ctmdl.ClassType;
                    worker.Department = depm == null ? worker.Department : depm.DataNodeText;

                    int len = attendDataPerWorker.Count;
                    for (int i = 0; i < len; i++)
                    {
                        var attendance = attendDataPerWorker[i];

                        //如果考勤数据表没有该人员的考勤数据
                        if (currentAttendData == null)
                        {
                            //则初始化考勤数据
                            record += InitAttendData(attendance, worker, attendance.SlodCardTime, out currentAttendData, middleTime);
                        }
                        else
                        {
                            //反之则合并数据
                            record += MergeAttendTime(currentAttendData, attendance.SlodCardTime);
                        }
                    }
                    if (record == len)//如果处理记录与目标数量一致则进行备份数据
                    {
                        this.fingerPrintDataInTime.BackupData(attendDataPerWorker, record);
                        //从内存中移除数据,减少查询时间
                        //workers.Remove(worker);
                        //从内存中移除该人员的考勤数据,减少查询时间
                        attendDataPerWorker.ForEach(m => datasInTime.Remove(m));
                        totalRecord += record;
                    }
                }
                else
                {
                    this.fingerPrintDataInTime.StoreNoIdentityWorkerInfo(attendDataPerWorker[0]);
                }
            });
            return(OpResult.SetSuccessResult("处理考勤数据成功!", record > 0));
        }