Browse Source

计算工资 获取外出打卡未打卡的数据
范围控制在 外出申请审批已通过的数据

leiy 1 year ago
parent
commit
808195a4d0

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

@@ -127,13 +127,9 @@ namespace OASystem.API.Controllers
 
             var _sqlSugar = _wageSheetRep._sqlSugar;
             _sqlSugar.BeginTran();
-
-
+            
             try
             {
-
-
-
                 //月份表是否存在
                 Pm_WageIssueWorkingDay pm_WageIssueWorkingDay = new Pm_WageIssueWorkingDay()
                 {

+ 82 - 140
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -439,120 +439,6 @@ namespace OASystem.API.OAMethodLib
                             }
                         }
 
-                        //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
 
                         #region 假勤/补卡次数 审批
@@ -629,8 +515,18 @@ namespace OASystem.API.OAMethodLib
                                             unit = "天";
                                             startTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd") + " 09:00";
                                             endTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd") + " 18:00";
-                                            startTime1 = "09:00:00";
-                                            endTime1 = "18:00:00";
+                                            if (new_duration == 1)
+                                            {
+                                                startTime1 = "09:00:00";
+                                                endTime1 = "18:00:00";
+                                            }
+                                            else
+                                            {
+                                                startTime1 = date_Range.new_begin_dt.ToString("HH:mm:ss");
+                                                endTime1 = date_Range.new_end_dt.ToString("HH:mm:ss");
+                                            }
+
+                                            
                                         }
                                         else if (date_Range.type == "hour")
                                         {
@@ -779,40 +675,86 @@ namespace OASystem.API.OAMethodLib
                                 }
                             }
 
-                            //打卡记录里抓取的未打卡数据
-                            foreach (var item in checkInData2)
+                            //外出审批 已通过的数据 且 外出未打卡
+                            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)
                             {
-                                decimal bukaPrice = 0.00M;
-
-                                if (user_probationary_bk_decimal == 0) //计算试用员工补卡次数
+                                //找出外出的具体日期
+                                List<string> goOutDts = new List<string>();
+                                foreach (var goOutItem in sp_goout_details)
                                 {
-                                    if (bukaNum <= 2) bukaPrice = 0.00M;
-                                    else if (bukaNum <= 4 && bukaNum > 2) bukaPrice = 10.00M;
-                                    else bukaPrice = 50.00M;
+                                    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"));
+                                        }
+                                    }
                                 }
-                                else   //计算正式员工补卡次数
+
+                                //处理日期范围内的数据
+                                List<CheckInDataInfo> filtratePrefix_checkInData = new List<CheckInDataInfo>();
+                                if (goOutDts.Count > 0)
                                 {
-                                    if (bukaNum <= 2) bukaPrice = 10.00M;
-                                    else bukaPrice = 50.00M;
+                                    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);
+                                        }
+                                    }
                                 }
 
 
-
-                                Ex_Item ex_reissueCard = new Ex_Item()
+                                //打卡记录里抓取的未打卡数据
+                                foreach (var item in filtratePrefix_checkInData)
                                 {
-                                    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++;
-                            }
+                                    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)