Browse Source

1.处理工资管理 外出打卡BUG(过滤已补卡的打卡记录)
2.修改迟到时间 》= 六十分钟 为旷工半天
3.修改早退时间 》= 六十分钟 为旷工半天
4.处理假期类型(丧假)为天数的假期

leiy 1 year ago
parent
commit
031c5b1a8c
1 changed files with 173 additions and 94 deletions
  1. 173 94
      OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

+ 173 - 94
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -278,7 +278,7 @@ namespace OASystem.API.OAMethodLib
                                         }
                                         beLate_deduction += day_deduction; //迟到扣款 总额
                                     }
-                                    else if (timelength >= 10 && timelength <= 60)
+                                    else if (timelength >= 10 && timelength < 60)
                                     {
                                         string thisStartDt = (TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))
                                                              .AddTicks((date + earliest_time) * 10000000))
@@ -290,12 +290,12 @@ namespace OASystem.API.OAMethodLib
                                         beLate_belate_ex.SubTypeId = 1;
                                         beLate_belate_ex.SubType = "迟到";
                                     }
-                                    else if (timelength > 60 && timelength <= 180)
+                                    else if (timelength >= 60 && timelength <= 180)
                                     {
                                         day_deduction = ConvertToDecimal(dailyWage / 2); //3小时 按半天计算
                                         meal_deduction += 10.00M;  //餐补扣款
                                         absenteeism_deduction += day_deduction; //矿工半日
-                                        beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为上午旷工(3小时)";
+                                        beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为旷工半天";
                                     }
                                     else
                                     {
@@ -330,7 +330,7 @@ namespace OASystem.API.OAMethodLib
                                         }
                                         early_deduction += day_deduction;  //早退扣款 总计
                                     }
-                                    else if (timelength >= 10 && timelength <= 60)
+                                    else if (timelength >= 10 && timelength < 60)
                                     {
                                         day_deduction = 50.00M;
                                         early_deduction += day_deduction;  //早退扣款 总计
@@ -341,7 +341,7 @@ namespace OASystem.API.OAMethodLib
                                                            .ToString("yyyy-MM-dd HH:mm:ss");
                                         beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisEndDt);
                                     }
-                                    else if (timelength > 60 && timelength <= 180)
+                                    else if (timelength >= 60 && timelength <= 180)
                                     {
                                         day_deduction = ConvertToDecimal(dailyWage / 2); //3小时 按半天计算
                                         meal_deduction += 10.00M;
@@ -375,7 +375,7 @@ namespace OASystem.API.OAMethodLib
 
                                                     beLate_belate_ex.Duration = 270;
                                                     absenteeism_deduction += day_deduction; //矿工半日
-                                                    beLate_belate_ex.Reason = thisDtStr + " 下午(18:00)缺卡/未打卡视为下午旷工(4.5小时)";
+                                                    beLate_belate_ex.Reason = thisDtStr + " 下午(18:00)缺卡/未打卡视为旷工半天";
 
                                                     beLate_belate_ex.Deduction = day_deduction;
                                                     ex_reissuecard_Items.Add(beLate_belate_ex);
@@ -386,7 +386,7 @@ namespace OASystem.API.OAMethodLib
                                                     meal_deduction += 10.00M;
                                                     absenteeism_deduction += day_deduction; //矿工半日
                                                     beLate_belate_ex.Duration = 180;
-                                                    beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为上午旷工(3小时)";
+                                                    beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为旷工半天";
 
                                                     beLate_belate_ex.Deduction = day_deduction;
                                                     ex_reissuecard_Items.Add(beLate_belate_ex);
@@ -402,8 +402,6 @@ namespace OASystem.API.OAMethodLib
                                                     beLate_belate_ex.Deduction = day_deduction;
                                                     ex_reissuecard_Items.Add(beLate_belate_ex);
                                                 }
-
-
                                             }
                                         }
                                         else
@@ -411,7 +409,7 @@ namespace OASystem.API.OAMethodLib
                                             day_deduction = dailyWage;
                                             meal_deduction += 10.00M;
                                             absenteeism_deduction += day_deduction;
-                                            beLate_belate_ex.Reason = "上午-下午 缺卡/未打卡为旷工 一天";
+                                            beLate_belate_ex.Reason = "上午-下午 缺卡/未打卡为旷工一天";
                                             beLate_belate_ex.Deduction = day_deduction;
                                             ex_reissuecard_Items.Add(beLate_belate_ex);
                                         }
@@ -458,24 +456,22 @@ namespace OASystem.API.OAMethodLib
                                                 beLate_belate_ex.Deduction = day_deduction;
                                                 ex_reissuecard_Items.Add(beLate_belate_ex);
                                             }
-
-
                                         }
                                     }
                                 }
                                 else if (exception == 4) //旷工
                                 {
-                                    if (timelength > 60 && timelength <= 180)
+                                    if (timelength >= 60 && timelength <= 180)
                                     {
                                         day_deduction = ConvertToDecimal(dailyWage / 2); //3小时
-                                        beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工上午(3小时)";
+                                        beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工半天";
                                         meal_deduction += 10.00M;
                                         absenteeism_deduction += day_deduction; //矿工半日
                                     }
                                     else if (timelength > 180 && timelength <= 270)
                                     {
                                         day_deduction = ConvertToDecimal(dailyWage / 2); //3小时
-                                        beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工下午午(4.5小时)";
+                                        beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工半天";
                                         meal_deduction += 10.00M;
                                         absenteeism_deduction += day_deduction; //矿工半日
                                     }
@@ -490,7 +486,6 @@ namespace OASystem.API.OAMethodLib
                                     beLate_belate_ex.Deduction = day_deduction;
                                     ex_reissuecard_Items.Add(beLate_belate_ex);
                                 }
-
                             }
                         }
 
@@ -747,10 +742,8 @@ namespace OASystem.API.OAMethodLib
                                         leave_item.IsDeduction = true;
                                     }
 
-
                                     #region 累计类型扣款
                                     //1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
-
                                     if (leaveType == 2) //事假
                                     {
                                         personalLeaveTotal += thisTypeDeduction;
@@ -797,6 +790,57 @@ namespace OASystem.API.OAMethodLib
                             List<Sp_Detail> sp_buka_details = new List<Sp_Detail>();
                             sp_buka_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 2); //时间段内所有 已同意的 请假 审批数据
 
+
+                            //外出审批 已通过的数据 且 外出未打卡
+                            List<Sp_Detail> sp_goout_details = new List<Sp_Detail>();
+                            sp_goout_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 4); //时间段内所有 已同意的 外出 审批数据
+                            //打卡记录-未打卡 处理日期范围内的数据
+                            List<CheckInDataInfo> filtratePrefix_checkInData = new List<CheckInDataInfo>();
+
+                            //打卡记录-未打卡 扣款
+                            if (sp_goout_details.Count > 0)
+                            {
+                                //找出外出的具体日期
+                                List<string> goOutDts = new List<string>();
+                                foreach (var goOutItem in sp_goout_details)
+                                {
+                                    Apply_data? apply_data = goOutItem.apply_data;
+                                    if (apply_data != null)
+                                    {
+                                        List<ContentsItem> contents = apply_data.contents;
+                                        ContentsItem content_Vacation = contents.Where(it => it.control == "Attendance").FirstOrDefault();  //请假类型 
+                                        ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault();    //多行文本 
+
+                                        if (content_Vacation != null)
+                                        {
+                                            var attendance = content_Vacation.value.attendance;
+
+                                            DateTime goOutDt = attendance.date_range.new_begin_dt;
+                                            DateTime goOutDtJudge = Convert.ToDateTime(goOutDt.ToString("yyyy-MM-dd"));
+                                            //筛选 不在工作日内的假勤申请
+                                            if (startDt >= goOutDtJudge || goOutDtJudge > endDt)
+                                            {
+                                                continue;
+                                            }
+                                            goOutDts.Add(goOutDt.ToString("yyyy-MM-dd"));
+                                        }
+                                    }
+                                }
+
+                                if (goOutDts.Count > 0)
+                                {
+                                    foreach (var goOutDtItem in goOutDts)
+                                    {
+                                        List<CheckInDataInfo> filtrate_checkInData = new List<CheckInDataInfo>();
+                                        filtrate_checkInData = checkInData2.Where(it => it.checkin_time_dt.ToString("yyyy-MM-dd").Equals(goOutDtItem)).ToList();
+                                        if (filtrate_checkInData.Count > 0)
+                                        {
+                                            filtratePrefix_checkInData.AddRange(filtrate_checkInData);
+                                        }
+                                    }
+                                }
+                            }
+
                             int bukaNum = 1;
                             foreach (var item in sp_buka_details)
                             {
@@ -819,7 +863,7 @@ namespace OASystem.API.OAMethodLib
                                             continue;
                                         }
                                         
-                                        decimal bukaPrice = 0.00M;
+                                       decimal bukaPrice = 0.00M;
 
                                         if (user_probationary_bk_decimal == 0) //计算试用员工补卡次数
                                         {
@@ -834,11 +878,51 @@ namespace OASystem.API.OAMethodLib
                                             else bukaPrice = 50.00M;
                                         }
 
-                                        
                                         var app_data = item.apply_data;
                                         var punch_correction1 = app_data.contents[0].value.punch_correction; //未打卡时间
                                         var punch_correction2 = app_data.contents[1].value;
 
+                                        #region 处理未打卡记录表数据 已补卡的数据
+
+                                        if (filtratePrefix_checkInData.Count > 0)
+                                        {
+                                            var filtratePrefix_checkInItems = filtratePrefix_checkInData.Where(it => it.sch_checkin_time_dt.ToString("yyyy-MM-dd")
+                                                                                                                       .Equals(punch_correction1.time_dt.ToString("yyyy-MM-dd"))).ToList();
+                                            if (filtratePrefix_checkInItems.Count > 0)
+                                            {
+                                                //按时间段移除 上午补卡时间段 09:00 - 12:00 下午补卡时间段 12:00 - 18:00
+                                                TimeSpan _strWorkingDayAM = DateTime.Parse("09:00").TimeOfDay;
+                                                TimeSpan _endWorkingDayAM = DateTime.Parse("12:00").TimeOfDay; 
+                                                TimeSpan _strWorkingDayPM = DateTime.Parse("13:30").TimeOfDay; 
+                                                TimeSpan _endWorkingDayPM = DateTime.Parse("18:00").TimeOfDay;
+                                                TimeSpan _dspNow = punch_correction1.time_dt.TimeOfDay;
+
+                                                //上午时间段 打卡记录数据
+                                                var filtratePrefix_checkInItemAMs = filtratePrefix_checkInItems.Where(it => it.sch_checkin_time_dt.TimeOfDay >= _strWorkingDayAM &&
+                                                                                                                           it.sch_checkin_time_dt.TimeOfDay <= _endWorkingDayAM ).ToList();
+                                                if (filtratePrefix_checkInItemAMs.Count > 0)
+                                                {
+                                                    foreach (var filtratePrefix_checkInItem1 in filtratePrefix_checkInItemAMs)
+                                                    {
+                                                        filtratePrefix_checkInData.Remove(filtratePrefix_checkInItem1);
+                                                    }
+                                                }
+
+                                                //下午时间段 打卡记录数据
+                                                var filtratePrefix_checkInItemPMs = filtratePrefix_checkInItems.Where(it => it.sch_checkin_time_dt.TimeOfDay >= _strWorkingDayPM &&
+                                                                                                                           it.sch_checkin_time_dt.TimeOfDay <= _endWorkingDayPM).ToList();
+                                                if (filtratePrefix_checkInItemPMs.Count > 0)
+                                                {
+                                                    foreach (var filtratePrefix_checkInItem1 in filtratePrefix_checkInItemPMs)
+                                                    {
+                                                        filtratePrefix_checkInData.Remove(filtratePrefix_checkInItem1);
+                                                    }
+                                                }
+                                            }
+                                        }
+
+                                        #endregion
+
                                         Ex_Item ex_reissueCard = new Ex_Item()
                                         {
                                             SubTypeId = 7,
@@ -855,85 +939,35 @@ namespace OASystem.API.OAMethodLib
                                 }
                             }
 
-                            //外出审批 已通过的数据 且 外出未打卡
-                            List<Sp_Detail> sp_goout_details = new List<Sp_Detail>();
-                            sp_goout_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 4); //时间段内所有 已同意的 外出 审批数据
-                            if (sp_goout_details.Count > 0)
+                            //打卡记录里抓取的未打卡数据 扣款
+                            foreach (var item in filtratePrefix_checkInData)
                             {
-                                //找出外出的具体日期
-                                List<string> goOutDts = new List<string>();
-                                foreach (var goOutItem in sp_goout_details)
-                                {
-                                    Apply_data? apply_data = goOutItem.apply_data;
-                                    if (apply_data != null)
-                                    {
-                                        List<ContentsItem> contents = apply_data.contents;
-                                        ContentsItem content_Vacation = contents.Where(it => it.control == "Attendance").FirstOrDefault();  //请假类型 
-                                        ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault();    //多行文本 
+                                decimal bukaPrice = 0.00M;
 
-                                        if (content_Vacation != null)
-                                        {
-                                            var attendance = content_Vacation.value.attendance;
-
-                                            DateTime goOutDt = attendance.date_range.new_begin_dt;
-                                            DateTime goOutDtJudge = Convert.ToDateTime(goOutDt.ToString("yyyy-MM-dd"));
-                                            //筛选 不在工作日内的假勤申请
-                                            if (startDt >= goOutDtJudge || goOutDtJudge > endDt)
-                                            {
-                                                continue;
-                                            }
-                                            goOutDts.Add(goOutDt.ToString("yyyy-MM-dd"));
-                                        }
-                                    }
+                                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;
                                 }
-
-                                //处理日期范围内的数据
-                                List<CheckInDataInfo> filtratePrefix_checkInData = new List<CheckInDataInfo>();
-                                if (goOutDts.Count > 0)
+                                else   //计算正式员工补卡次数
                                 {
-                                    foreach (var goOutDtItem in goOutDts)
-                                    {
-                                        List<CheckInDataInfo> filtrate_checkInData = new List<CheckInDataInfo>();
-                                        filtrate_checkInData = checkInData2.Where(it => it.checkin_time_dt.ToString("yyyy-MM-dd").Equals(goOutDtItem)).ToList();
-                                        if (filtrate_checkInData.Count > 0)
-                                        {
-                                            filtratePrefix_checkInData.AddRange(filtrate_checkInData);
-                                        }
-                                    }
+                                    if (bukaNum <= 2) bukaPrice = 10.00M;
+                                    else bukaPrice = 50.00M;
                                 }
 
-
-                                //打卡记录里抓取的未打卡数据
-                                foreach (var item in filtratePrefix_checkInData)
+                                Ex_Item ex_reissueCard = new Ex_Item()
                                 {
-                                    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++;
-                                }
+                                    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++;
                             }
                         }
 
@@ -1534,7 +1568,52 @@ namespace OASystem.API.OAMethodLib
                     CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
                     break;
                 case 9: //9丧假
-                    CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
+                    if (date_Range_type == "halfday")
+                    {
+                        if (duration >= 0.5M && duration <= 1M) //一天
+                        {
+                            var njItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd") &&
+                                                      it.EndDt.ToString("yyyy-MM-dd") == endTime.ToString("yyyy-MM-dd")).ToList();
+                            if (njItem.Count > 1)
+                            {
+                                if (njItem[0].StartDt == startTime)
+                                {
+                                    mealDeduction = 10; //餐补扣款
+                                }
+                            }
+                            else
+                            {
+                                mealDeduction = 10; //餐补扣款 
+                            }
+                        }
+                        else // 多天
+                        {
+                            var njManyDaysItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd")).ToList();
+                            if (njManyDaysItem.Count > 1)
+                            {
+                                var njManyDaysItem1 = njManyDaysItem.Where(it => it.StartDt != startTime).ToList();
+                                if (njManyDaysItem1.Count > 0)
+                                {
+                                    if (njManyDaysItem1[0].Unit.Equals("天"))
+                                    {
+                                        mealDeduction = 10 * Math.Floor(duration);
+                                    }
+                                    else if (njManyDaysItem1[0].Unit.Equals("小时") && njManyDaysItem1[0].New_Duration >= 3)
+                                    {
+                                        mealDeduction = 10 * Math.Floor(duration);
+                                    }
+                                    else
+                                    {
+                                        mealDeduction = 10 * Math.Ceiling(duration);
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                mealDeduction = 10 * Math.Ceiling(duration);
+                            }
+                        }
+                    }
                     break;
 
             }
@@ -1841,7 +1920,7 @@ namespace OASystem.API.OAMethodLib
 
             if (date_Range_type == "halfday")
             {
-                mealDeduction = 10; //餐补扣款 
+                mealDeduction = duration * 10; //餐补扣款 
             }
             else if (date_Range_type == "hour")
             {