Bladeren bron

计算工资 抓取外出打卡没打卡的时间段

leiy 1 jaar geleden
bovenliggende
commit
75c149f2e0

+ 1 - 0
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -157,6 +157,7 @@ namespace OASystem.API.Controllers
                 if (upd1 > 0) res = 0;
                 int upd2 = await _sqlSugar.Updateable<Sys_Calendar>(sys_Calendars)
                     .UpdateColumns(it => new { it.Dt, it.IsWorkDay, it.IsHoliDay, it.HoliDayName })
+                    .WhereColumns(it => it.Id)
                     .ExecuteCommandAsync();
                 if (upd2 > 0) res = 0;
 

+ 154 - 104
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -80,7 +80,7 @@ namespace OASystem.API.OAMethodLib
 
             //获取所有打卡记录 外出
             CheckInDataView checkInDataView = new CheckInDataView();
-            checkInDataView = await _qiYeWeChatApiService.GetCheckinDataAsync(qyWhchatIdList, 2,startDt, endDt);
+            checkInDataView = await _qiYeWeChatApiService.GetCheckinDataAsync(qyWhchatIdList, 3,startDt, endDt);
             if (checkInDataView.errcode != 0)
             {
                 _result.Msg = "【企业微信】【打卡】【获取时间段内所有日打卡记录】【Msg】" + checkInDataView.errmsg;
@@ -203,6 +203,11 @@ namespace OASystem.API.OAMethodLib
                         checkInData1 = checkInDataView.checkindata;
                         List<CheckInDataInfo> checkInDatas = new List<CheckInDataInfo>();
                         checkInDatas = checkInData1.Where(it => it.userid == acctid).ToList();
+                        //找出外出的打卡记录
+                        List<CheckInDataInfo> checkInData2 = new List<CheckInDataInfo>();
+                        checkInData2 = checkInDatas.Where(it => it.exception_type.Equals("未打卡")).ToList();
+                        
+
 
                         #region 迟到 早退 旷工
 
@@ -434,109 +439,119 @@ namespace OASystem.API.OAMethodLib
                             }
                         }
 
-                        //外出打卡 计算旷工迟到
-                        foreach (var checkInData in checkInDatas)
-                        {
-                            //当前时间是上午还是下午
-                            decimal timelength = 0.00M;
-                            string thisTime = string.Format(@"12:00:00");
-                            string wcdkTime = checkInData.checkin_time_dt.ToString("HH:mm:ss");
-                            DateTime wcdkDt = Convert.ToDateTime(wcdkTime);
-
-                            if (Convert.ToDateTime(thisTime) > wcdkDt) //上午
-                            {
-                                DateTime amDt = Convert.ToDateTime("09:00:00");
-                                timelength = (decimal)(wcdkDt - amDt).TotalMinutes;
-                                if (wcdkDt <=  amDt)
-                                {
-                                    continue;
-                                }
-                            }
-                            else //下午
-                            {
-                                DateTime pmDt = Convert.ToDateTime("18:00:00");
-                                DateTime pmDt1 = Convert.ToDateTime("13:30:00");
-                                timelength = (decimal)(pmDt1 - wcdkDt).TotalMinutes;
-                                if (wcdkDt >= pmDt)
-                                {
-                                    continue;
-                                }
-                            }
-
-                            if (timelength < 1)
-                            {
-                                continue;
-                            }
-
-                            timelength = ConvertToDecimal(timelength);
-                            decimal day_deduction = 0.00M;
-
-                            Ex_Item beLate_belate_ex = new Ex_Item()
-                            {
-                                SubTypeId = 4,
-                                SubType = "旷工",
-                                Duration = timelength,
-                                StartTimeDt = checkInData.checkin_time_dt,
-                                Unit = "分钟",
-                                Reason = "[外出打卡]"
-                            };
-
-                            if (timelength >= 1 && timelength < 10)
-                            {
-                                user_cd_zt_num++;
-                                beLate_belate_ex.SubTypeId = 1;
-                                beLate_belate_ex.SubType = "迟到";
-                                string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
-                                beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
-
-                                if (user_cd_zt_num >= 3)
-                                {
-                                    day_deduction = 50.00M;
-                                }
-                                else
-                                {
-                                    day_deduction = 0.00M;
-                                }
-                                beLate_belate_ex.Reason += "迟到/早退";
-                                beLate_deduction += day_deduction; //迟到扣款 总额
-                            }
-                            else if (timelength >= 10 && timelength <= 60)
-                            {
-                                beLate_belate_ex.SubType = "迟到";
-                                string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
-                                beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
-
-                                day_deduction = 50.00M;
-                                beLate_deduction += day_deduction; //迟到扣款 总额
-                                beLate_belate_ex.SubTypeId = 1;
-                                beLate_belate_ex.Reason += "迟到/早退";
-                            }
-                            else if (timelength > 60 && timelength <= 180)
-                            {
-                                day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 3.00M)); //3小时
-                                meal_deduction += 10.00M;  //餐补扣款
-                                absenteeism_deduction += day_deduction; //矿工半日
-                                beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工上午(3小时)";
-                            }
-                            else if (timelength > 180 && timelength <= 270)
-                            {
-                                day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 4.50M)); //4小时
-                                meal_deduction += 10.00M;  //餐补扣款
-                                absenteeism_deduction += day_deduction; //矿工半日
-                                beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工下午(4.5小时)";
-                            }
-                            else if(timelength > 270)
-                            {
-                                day_deduction = ConvertToDecimal(dailyWage);
-                                absenteeism_deduction += day_deduction; //矿工一日
-                                meal_deduction += 10.00M;
-                                beLate_belate_ex.Reason += " 迟到/早退 视为旷工一天(7.5小时)";
-                            }
-
-                            beLate_belate_ex.Deduction = day_deduction;
-                            ex_reissuecard_Items.Add(beLate_belate_ex);
-
-                        }  
+                        //List<CheckInDataInfo> checkInDatas1 = new List<CheckInDataInfo>();
+                        //checkInDatas1 = checkInDatas.Where((x, i) => checkInDatas.FindLastIndex(z => z.checkin_time_dt.ToString("yyyy-MM-dd")
+                        //== x.checkin_time_dt.ToString("yyyy-MM-dd")) == i).ToList();
+
+                        //foreach (var checkInData in checkInDatas1)
+                        //{
+                        //    ex_reissuecard_Items.Add(new Ex_Item()
+                        //    {
+                        //        SubTypeId = 11,
+                        //        SubType = "外出打卡",
+                        //        StartTimeDt = Convert.ToDateTime(checkInData.checkin_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
+                        //        Reason = checkInData.location_title + "(" + checkInData.location_detail + ")"
+                        //    });
+                        //}
+
+                        #region 外出打卡 计算旷工迟到
+                        ////外出打卡 计算旷工迟到
+                        //foreach (var checkInData in checkInDatas1)
+                        //{
+                        //    //当前时间是上午还是下午
+                        //    decimal timelength = 0.00M;
+                        //    string thisTime = string.Format(@"12:00:00");
+                        //    string wcdkTime = checkInData.checkin_time_dt.ToString("HH:mm:ss");
+                        //    DateTime wcdkDt = Convert.ToDateTime(wcdkTime);
+                        //    if (Convert.ToDateTime(thisTime) > wcdkDt) //上午
+                        //    {
+                        //        DateTime amDt = Convert.ToDateTime("09:00:00");
+                        //        timelength = (decimal)(wcdkDt - amDt).TotalMinutes;
+                        //        if (wcdkDt <=  amDt)
+                        //        {
+                        //            continue;
+                        //        }
+                        //    }
+                        //    else //下午
+                        //    {
+                        //        DateTime pmDt = Convert.ToDateTime("18:00:00");
+                        //        DateTime pmDt1 = Convert.ToDateTime("13:30:00");
+                        //        timelength = (decimal)(pmDt1 - wcdkDt).TotalMinutes;
+                        //        if (wcdkDt >= pmDt)
+                        //        {
+                        //            continue;
+                        //        }
+                        //    }
+                        //    if (timelength < 1)
+                        //    {
+                        //        continue;
+                        //    }
+                        //    timelength = ConvertToDecimal(timelength);
+                        //    decimal day_deduction = 0.00M;
+                        //    Ex_Item beLate_belate_ex = new Ex_Item()
+                        //    {
+                        //        SubTypeId = 4,
+                        //        SubType = "旷工",
+                        //        Duration = timelength,
+                        //        StartTimeDt = Convert.ToDateTime(checkInData.checkin_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
+                        //        Unit = "分钟",
+                        //        Reason = "[外出打卡]"
+                        //    };
+                        //    if (timelength >= 1 && timelength < 10)
+                        //    {
+                        //        user_cd_zt_num++;
+                        //        beLate_belate_ex.SubTypeId = 1;
+                        //        beLate_belate_ex.SubType = "迟到";
+                        //        string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
+                        //        beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
+                        //        if (user_cd_zt_num >= 3)
+                        //        {
+                        //            day_deduction = 50.00M;
+                        //        }
+                        //        else
+                        //        {
+                        //            day_deduction = 0.00M;
+                        //        }
+                        //        beLate_belate_ex.Reason += "迟到/早退";
+                        //        beLate_deduction += day_deduction; //迟到扣款 总额
+                        //    }
+                        //    else if (timelength >= 10 && timelength <= 60)
+                        //    {
+                        //        beLate_belate_ex.SubType = "迟到";
+                        //        string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
+                        //        beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
+                        //        day_deduction = 50.00M;
+                        //        beLate_deduction += day_deduction; //迟到扣款 总额
+                        //        beLate_belate_ex.SubTypeId = 1;
+                        //        beLate_belate_ex.Reason += "迟到/早退";
+                        //    }
+                        //    else if (timelength > 60 && timelength <= 180)
+                        //    {
+                        //        day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 3.00M)); //3小时
+                        //        meal_deduction += 10.00M;  //餐补扣款
+                        //        absenteeism_deduction += day_deduction; //矿工半日
+                        //        beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工上午(3小时)";
+                        //    }
+                        //    else if (timelength > 180 && timelength <= 270)
+                        //    {
+                        //        day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 4.50M)); //4小时
+                        //        meal_deduction += 10.00M;  //餐补扣款
+                        //        absenteeism_deduction += day_deduction; //矿工半日
+                        //        beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工下午(4.5小时)";
+                        //    }
+                        //    else if(timelength > 270)
+                        //    {
+                        //        day_deduction = ConvertToDecimal(dailyWage);
+                        //        absenteeism_deduction += day_deduction; //矿工一日
+                        //        meal_deduction += 10.00M;
+                        //        beLate_belate_ex.Reason += " 迟到/早退 视为旷工一天(7.5小时)";
+                        //    }
+
+                        //    beLate_belate_ex.Deduction = day_deduction;
+                        //    ex_reissuecard_Items.Add(beLate_belate_ex);
+
+                        //}  
+                        #endregion
 
                         #endregion
 
@@ -763,6 +778,41 @@ namespace OASystem.API.OAMethodLib
                                     }
                                 }
                             }
+
+                            //打卡记录里抓取的未打卡数据
+                            foreach (var item in checkInData2)
+                            {
+                                decimal bukaPrice = 0.00M;
+
+                                if (user_probationary_bk_decimal == 0) //计算试用员工补卡次数
+                                {
+                                    if (bukaNum <= 2) bukaPrice = 0.00M;
+                                    else if (bukaNum <= 4 && bukaNum > 2) bukaPrice = 10.00M;
+                                    else bukaPrice = 50.00M;
+
+                                }
+                                else   //计算正式员工补卡次数
+                                {
+                                    if (bukaNum <= 2) bukaPrice = 10.00M;
+                                    else bukaPrice = 50.00M;
+                                }
+
+
+
+                                Ex_Item ex_reissueCard = new Ex_Item()
+                                {
+                                    SubTypeId = 7,
+                                    SubType = "打卡补卡",
+                                    StartTimeDt = Convert.ToDateTime(item.checkin_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),  //未打卡时间
+                                    Deduction = bukaPrice,
+                                    Reason = "[打卡记录]抓取到的未打卡数据!",
+                                    Unit = string.Empty
+                                };
+                                unprinted_deduction += bukaPrice;
+                                ex_reissuecard_Items.Add(ex_reissueCard);
+                                bukaNum++;
+                            }
+
                         }
 
                         if (ex_reissuecard_Items.Count > 0)

+ 2 - 0
OASystem/OASystem.Domain/ViewModels/PersonnelModule/WageSheetMonthView.cs

@@ -37,6 +37,8 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     /// </summary>
     public class CalendarInfoView
     {
+        public int Id { get; set; }
+
         /// <summary>
         /// 日期 
         /// Eg:yyyy-MM-dd