コード例 #1
0
        /// <summary>
        /// 设置班别数据
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public OpResult SetClassType(List <AttendClassTypeModel> entities, string opPerson)
        {
            int record = 0;

            try
            {
                if (entities == null || entities.Count == 0)
                {
                    return(OpResult.SetSuccessResult("entities can't be null", false));
                }
                AttendClassTypeDetailModel mdl   = null;
                AttendClassTypeModel       ctMdl = null;
                entities.ForEach(dto =>
                {
                    dto.DateFrom    = dto.DateFrom.AddDays(1).ToDate();
                    dto.DateTo      = dto.DateTo.AddDays(1).ToDate();
                    dto.OpDate      = DateTime.Now;
                    dto.IsAlwaysDay = "否";
                    dto.OpPerson    = opPerson;
                    StoreClassTypeData(ref record, ctMdl, dto);
                    StoreClassTypeDetailData(ref record, mdl, dto);
                    //同步总表中的班别信息
                    ArchiveService.ArchivesManager.ChangeClassType(dto.WorkerId, dto.ClassType);
                });
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(OpResult.SetSuccessResult("设置班别成功!", record > 0));
        }
コード例 #2
0
        /// <summary>
        /// 初始化班别信息,存储到班次明细信息中
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int InitClassType(AttendClassTypeDetailModel entity)
        {
            int record = 0;

            if (this.irepDetail.IsExist(e => e.WorkerId == entity.WorkerId))
            {
                this.irepDetail.Delete(e => e.WorkerId == entity.WorkerId);
            }
            record = this.irepDetail.Insert(entity);
            return(record);
        }
コード例 #3
0
        private void StoreClassTypeDetailData(ref int record, AttendClassTypeDetailModel mdl, AttendClassTypeModel dto)
        {
            DateTime dateFrom = dto.DateFrom;
            DateTime dateTo   = dto.DateTo;

            while (dateFrom <= dateTo)
            {
                mdl = this.irepDetail.Entities.FirstOrDefault(e => e.WorkerId == dto.WorkerId && e.DateAt == dateFrom);
                if (mdl != null)
                {
                    mdl.ClassType = dto.ClassType;
                    //如果存在,则直接修改信息
                    record += this.irepDetail.Update(u => u.WorkerId == dto.WorkerId && u.DateAt == dateFrom, mdl);
                }
                else
                {
                    mdl = new AttendClassTypeDetailModel()
                    {
                        ClassType   = dto.ClassType,
                        DateAt      = dateFrom,
                        Department  = dto.Department,
                        IsAlwaysDay = dto.IsAlwaysDay,
                        OpPerson    = dto.OpPerson,
                        WorkerId    = dto.WorkerId,
                        WorkerName  = dto.WorkerName,
                        OpDate      = dto.DateFrom,
                        OpSign      = "add"
                    };
                    //不存在,则直接添加
                    record += this.irepDetail.Insert(mdl);
                }
                //同步汇总考勤中的数据信息,待写
                this.attendanceHandler.UpdateClassTypeInfo(dto.ClassType, dateFrom);
                dateFrom = dateFrom.AddDays(1);
            }
        }
コード例 #4
0
        /// <summary>
        /// 返回有异常的数据
        /// </summary>
        public List <AttendSlodFingerDataCurrentMonthModel> AutoHandleExceptionSlotData(string yearMonth)
        {
            List <AttendSlodFingerDataCurrentMonthModel> attendExceptionSlodDatas = new List <AttendSlodFingerDataCurrentMonthModel>();

            string[] dfields = yearMonth.Split('-');
            if (dfields.Length != 2)
            {
                return(attendExceptionSlodDatas);
            }
            int qurYear = dfields[0].Trim().ToInt(), qurMonth = dfields[1].Trim().ToInt();
            //考勤数据中没有处理过异常的数据集
            List <AttendSlodFingerDataCurrentMonthModel> attendSlotDatas = this.irep.Entities.Where(e => e.HandleSlotExceptionStatus == 0 && e.YearMonth == yearMonth).ToList();

            if (attendSlotDatas == null || attendSlotDatas.Count == 0)
            {
                return(attendExceptionSlodDatas);
            }
            //本月考勤中所有员工列表
            List <AttendSlodWorkerModel> attendSlodWorkers = this.GetAttendSlodWorkers(qurYear, qurMonth);
            AttendClassTypeSetter        classTypeSetter   = new AttendClassTypeSetter();
            //获取本月份的日期天数
            int daysInMonths = DateTime.DaysInMonth(qurYear, qurMonth);

            Dictionary <string, string> dicClassTypes = new Dictionary <string, string>();
            //一天的中间时间
            DateTime dayMiddleTime;
            DateTime currentDay;
            string   workerId;                                //工号
            string   classType;                               //班别
            string   slotExceptionType        = string.Empty; //刷卡异常类别
            AttendClassTypeDetailModel ctdMdl = null;
            //每个人考勤数据
            List <AttendSlodFingerDataCurrentMonthModel> attendSlotDatasOfWorker = null;
            AttendSlodFingerDataCurrentMonthModel        attendSd = null;

            attendSlodWorkers.ForEach(worker =>
            {
                attendSlotDatasOfWorker = attendSlotDatas.Where(m => m.WorkerId == worker.WorkerId).ToList();
                while (worker.AttendDateStart <= worker.AttendDateEnd)
                {
                    currentDay = worker.AttendDateStart;
                    //每天的考勤数据
                    attendSd = attendSlotDatasOfWorker.FirstOrDefault(d => d.AttendanceDate == currentDay);
                    if (attendSd == null)//如果不存在考勤数据
                    {
                        //初始化该日期的考勤数据
                        ctdMdl  = classTypeSetter.GetClassTypeDetailModel(attendSd.WorkerId, attendSd.AttendanceDate);
                        var mdl = new AttendSlodFingerDataCurrentMonthModel()
                        {
                            AttendanceDate            = currentDay,
                            WorkerId                  = worker.WorkerId,
                            CardID                    = "",
                            CardType                  = "",
                            ClassType                 = ctdMdl == null ? "白班" : ctdMdl.ClassType,
                            Department                = worker.Department,
                            WorkerName                = worker.WorkerName,
                            WeekDay                   = currentDay.DayOfWeek.ToString().ToChineseWeekDay(),
                            LeaveHours                = 0,
                            LeaveMark                 = 0,
                            YearMonth                 = currentDay.ToString("yyyyMM"),
                            SlotCardTime              = currentDay.ToString("HH:mm"),
                            HandleSlotExceptionStatus = 0,
                            SlotExceptionMark         = 0,
                            OpSign                    = "init",
                            OpPerson                  = "system",
                        };
                        this.irep.Insert(mdl);
                    }
                    else
                    {
                        //存在的话则进行检测处理
                        workerId = attendSd.WorkerId;
                        //刷卡异常类型
                        slotExceptionType = string.Empty;
                        classType         = attendSd.ClassType;
                        //时间点
                        int hour  = classType == "白班" ? 12 : 24;
                        int day   = attendSd.AttendanceDate.Day;
                        int year  = attendSd.AttendanceDate.Year;
                        int month = attendSd.AttendanceDate.Month;
                        //中间时间
                        dayMiddleTime       = new DateTime(year, month, day, hour, 0, 0);
                        string slotCardTime = attendSd.SlotCardTime;//刷卡时间
                        if (slotCardTime == null || slotCardTime.Length < 5)
                        {
                            if (attendSd.LeaveMark == 0)                             //如果有请假的话,则不做旷工标志处理
                            {
                                MergeSlotExceptionType(ref slotExceptionType, "旷工"); //标志异常考勤信息为旷工
                            }
                        }
                        else
                        {
                            if (attendSd.SlotCardTime1 == null || attendSd.SlotCardTime2 == null)//刷卡时间不完整的情况分析
                            {
                                if (attendSd.LeaveMark == 0)
                                {
                                    MergeSlotExceptionType(ref slotExceptionType, "漏刷卡");
                                }
                                else
                                {
                                    MergeSlotExceptionType(ref slotExceptionType, "请假漏刷");
                                }
                            } //继续分析刷卡时间都全面的情况
                            else
                            {
                                //在都完整的情况下,分析考勤异常情况
                                AnalogSlotCardTime(attendSd, ref slotExceptionType, classType, day, year, month, slotCardTime);
                            }
                        }
                        attendSd.SlotExceptionType         = slotExceptionType;
                        attendSd.SlotExceptionMark         = slotExceptionType != null && slotExceptionType.Length >= 2 ? 1 : 0;
                        attendSd.HandleSlotExceptionStatus = attendSd.SlotExceptionMark == 1 ? 1 : -1; //若有异常,则状态为1,没有异常则状态为-1代表已经检测过
                                                                                                       //同步到数据库中
                        this.irep.Update(f => f.WorkerId == attendSd.WorkerId && f.AttendanceDate == attendSd.AttendanceDate, u => new AttendSlodFingerDataCurrentMonthModel
                        {
                            HandleSlotExceptionStatus = attendSd.HandleSlotExceptionStatus,
                            SlotExceptionType         = slotExceptionType,
                            SlotExceptionMark         = attendSd.SlotExceptionMark
                        });
                    }
                    //日期递增
                    worker.AttendDateStart = worker.AttendDateStart.AddDays(1);
                }
            });
            attendExceptionSlodDatas = attendSlotDatas.Where(e => e.HandleSlotExceptionStatus == 1).OrderBy(o => o.AttendanceDate).ToList();
            return(attendExceptionSlodDatas);
        }