Browse Source

计算工资 更改接口

leiy 1 year ago
parent
commit
82e14750fe

+ 4 - 1
OASystem/EntitySync/Program.cs

@@ -94,7 +94,7 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Fin_DailyFeePayment),       // 财务 - 日付申请
     //typeof(Fin_DailyFeePaymentContent),// 财务 - 日付申请详细类
     //typeof(Grp_GroupsTaskAssignment),
-    typeof(Grp_AirTicketReservations),
+    //typeof(Grp_AirTicketReservations),
     //typeof(Grp_GroupCostParameter),
     //typeof(Grp_TeamRate),              // 团组汇率
     //typeof(Fin_ForeignReceivables),    // 对外收款账单
@@ -110,5 +110,8 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Pm_WageSheet)       //人事模块 工资表单
     //typeof(Grp_VisaProgressCustomer),
     //typeof(Grp_VisaProgressCustomerPicture)
+    
+    //typeof(Sys_Calendar), //日历表
+    typeof(Pm_WageIssueWorkingDay), //日历表Pm_WageIssueWorkingDay
 });
 Console.WriteLine("数据库结构同步完成!");

+ 21 - 2
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -90,6 +90,25 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, "查询成功!", data));
         }
 
+        /// <summary>
+        /// 获取工资发放月份
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetWageYaerMonths(WageYearDto dto)
+        {
+            string sql = string.Format(@"Select * From  Pm_WageIssueWorkingDay 
+                                         Where Isdel = 0 And YearMonth Like '%{0}%'
+                                         Order By YearMonth Asc", dto.Year);
+
+            var data  = await _wageSheetRep._sqlSugar.SqlQueryable<WageYearMonthView>(sql).ToListAsync();
+            
+           
+            return Ok(JsonView(true,"操作成功!", data));
+        }
+
         /// <summary>
         /// 获取工资表单
         /// </summary>
@@ -288,7 +307,7 @@ namespace OASystem.API.Controllers
 
             //计算本月工资起止时间 比如是2月的1号-28号,那就是2月1号的零点到3月1号的零点 
             DateTime thisStartDt = startDt;
-            DateTime thisEndDt = endDt.AddDays(1); //
+            DateTime thisEndDt = endDt; //
 
             //本月工资是否有数据 有数据则不计算
             result = await _wageSheetRep.Get_WageSheet_ListByYearMonthAsync(thisYearMonth);
@@ -392,7 +411,7 @@ namespace OASystem.API.Controllers
             var nameData = await _usersRep.GetUserNameList(1);
             List<UserNameView>? userNames = nameData.Data;
 
-            _result = await PayrollComputation.SalaryCalculatorAsync(wageSheets, userNames, dto.UserId, dto.YearMonth, startDt, endDt.AddDays(1));
+            _result = await PayrollComputation.SalaryCalculatorAsync(wageSheets, userNames, dto.UserId, dto.YearMonth, startDt, endDt);
 
             if (_result.Code != 0)
             {

+ 445 - 80
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -34,7 +34,7 @@ namespace OASystem.API.OAMethodLib
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
         /// <returns></returns>
-        public static async Task<Result> SalaryCalculatorAsync(
+        public static async Task<Result> SalaryCalculatorAsync1(
             List<Pm_WageSheet> pm_WageSheetDattaSources, List<UserNameView> userNames, int userId, string thisYearMonth, DateTime startDt, DateTime endDt)
         {
             if (pm_WageSheetDattaSources.Count <= 0)
@@ -51,7 +51,7 @@ namespace OASystem.API.OAMethodLib
 
             //计算时间段内工作日
 
-            int work_days = GetWorkDays(startDt, endDt);
+            int work_days = await GetWorkDays(thisYearMonth);
 
             //获取所有打卡数据
             CheckInView checkIn = await _qiYeWeChatApiService.GetCheckin_MonthDataAsync(startDt, endDt); //时间段内所有 打卡数据
@@ -296,6 +296,7 @@ namespace OASystem.API.OAMethodLib
                         #endregion
 
                         Ex_Items ex_Items_dk = new Ex_Items() { Type = "打卡" };    //打卡
+
                         List<Ex_Item> ex_reissuecard_Items = new List<Ex_Item>();
                         #region 打卡补卡 补卡次数 处理
 
@@ -737,7 +738,7 @@ namespace OASystem.API.OAMethodLib
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
         /// <returns></returns>
-        public static async Task<Result> SalaryCalculatorAsync1(
+        public static async Task<Result> SalaryCalculatorAsync(
             List<Pm_WageSheet> pm_WageSheetDattaSources, List<UserNameView> userNames, int userId, string thisYearMonth, DateTime startDt, DateTime endDt)
         {
             if (pm_WageSheetDattaSources.Count <= 0)
@@ -753,7 +754,12 @@ namespace OASystem.API.OAMethodLib
             }
 
             //计算时间段内工作日
-            int work_days = GetWorkDays(startDt, endDt);
+            int work_days = await GetWorkDays(thisYearMonth);
+            if (work_days <=0)
+            {
+                _result.Msg = thisYearMonth+" 工作日未设置,请前往《工作日管理页面》设置!";
+                return _result;
+            }
 
             UserIdListView userIdListView = await _qiYeWeChatApiService.GetUserIdListAsync();
             if (userIdListView.errcode != 0)
@@ -770,7 +776,8 @@ namespace OASystem.API.OAMethodLib
                 return _result;
             }
             //筛选出工作日日报
-            List<Root> workday_userRoots = checkInDayDataView.datas.Where(it => it.base_info.day_type == 0).ToList(); //工作日日报
+            List<Root> workday_userRoots = checkInDayDataView.datas.Where(it => it.base_info.day_type == 0 && it.base_info.record_type == 1).ToList(); //工作日日报
+            workday_userRoots = workday_userRoots.OrderBy(it => it.base_info.date).ToList();
 
             //获取 请假类型 Sp_Detail.template_id
             string leave_template_id = "C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1";
@@ -825,42 +832,449 @@ namespace OASystem.API.OAMethodLib
                     sickLeave_deduction = dailyWage - sickLeave_dailywage;
 
                     List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
-
+                    Ex_Items ex_Items_dk = new Ex_Items() { Type = "打卡" };    //打卡
+                    Ex_Items ex_Items_jq = new Ex_Items() { Type = "假勤" };   //假勤
                     #endregion
 
-                    List<Root> userRoots = workday_userRoots.Where(it => it.base_info.name == itemName && it.base_info.day_type == 0).ToList(); //工作日日报
+                    List<Root> userRoots = workday_userRoots.Where(it => it.base_info.name == itemName).ToList(); //工作日日报 1-固定上下班;
+                    userRoots = userRoots.Distinct().ToList();
 
                     int dk_work_days = userRoots.Count;   //应出勤天数 
 
+                    if (dk_work_days > work_days)
+                    {
+                        dk_work_days = work_days;
+                    }
                     meal_subsidy = dk_work_days * 10; //应发放餐补
 
 
                     if (!itemName.Equals("张海麟"))
                     {
+                        string acctid = userRoots[0].base_info.acctid;
+                        List<Ex_Item> ex_reissuecard_Items = new List<Ex_Item>(); //打卡类型 数据
+                        List<Sp_items> acc_sp_items = new List<Sp_items>(); //审批数据
+
+                        #region 迟到 早退 矿工
+
+                        int user_cd_zt_num = 0; //早退/迟到 次数 10分钟内 2次以内不记处罚 三次及以上50一次
                         foreach (var root in userRoots)
                         {
                             List<Holiday_infos> holiday_Infos = root.holiday_infos; //当天假勤信息
                             List<Exception_infos> exception_infos = root.exception_infos; //当天校准状态信息
                             List<Sp_items> sp_Items = root.sp_items;//当天假勤统计信息
-                            #region 假勤处理
                             if (sp_Items.Count > 0)
                             {
+                                sp_Items = sp_Items.Where(it => it.count > 0).ToList();
+                                acc_sp_items.AddRange(sp_Items);
+                            }
+
+                            foreach (var exception_info in exception_infos)
+                            {
+                                decimal timelength = ConvertToDecimal((Convert.ToDecimal(exception_info.duration) / 3600.00M) * 60.00M);  //时长 分钟
+
+                                if (timelength == 9) timelength = 7.50M;
+
+                                int exception = exception_info.exception; //异常类型
+                                decimal day_miner_unit = ConvertToDecimal(dailyWage / 15);  //以0.5小时为单位 
+
+                                //1:一个自然月内,不足 10 分钟的迟到/早退,不超过 2 次的部分,不做处罚;3 次及以上,按50 元 / 次处罚;
+                                //2:超过 10 分钟(含 10 分钟),不足 60 分钟的迟到 / 早退,按 50 元 / 次处罚;
+                                //3:超过 60 分钟(含 60 分钟),不足 3 小时的迟到 / 早退,且无请假者,按旷工半日处理;超过 3 小时的迟到 / 早退,且无请假者,按旷工一日处理。
+
+                                long date = root.base_info.date; //当日工作日期
+                                long earliest_time = root.summary_info.earliest_time; //最早打卡时间
+                                long lastest_time = root.summary_info.lastest_time; //最晚打卡时间
+                                long this_date = date + earliest_time;
+                                DateTime thisDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks(this_date * 10000000);
+
+                                string thisDtStr = thisDt.ToString("yyyy-MM-dd");
+
+                                Ex_Item beLate_belate_ex = new Ex_Item()
+                                {
+                                    SubTypeId = 4,
+                                    SubType = "旷工",
+                                    Duration = timelength,
+                                    StartTimeDt = Convert.ToDateTime(root.base_info.dateDt.ToString("yyyy-MM-dd HH:mm:ss")),
+                                    Unit = "分钟",
+                                };
+
+                                decimal day_deduction = 0.00M;
+                                //1 - 迟到;2 - 早退;3 - 缺卡;4 - 旷工;5 - 地点异常;6 - 设备异常
+                                if (exception == 1)   //迟到
+                                {
+                                    if (timelength < 10)
+                                    {
+                                        user_cd_zt_num++;
+                                        beLate_belate_ex.SubTypeId = 1;
+                                        beLate_belate_ex.SubType = "迟到";
+
+                                        string thisStartDt = (TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks((date + earliest_time) * 10000000))
+                                                              .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_deduction += day_deduction; //迟到扣款 总额
+                                    }
+                                    else if (timelength >= 10 && timelength <= 60)
+                                    {
+                                        string thisStartDt = (TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks((date + earliest_time) * 10000000))
+                                                              .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.SubType = "迟到";
+                                    }
+                                    else if (timelength > 60 && timelength <= 180)
+                                    {
+                                        day_deduction = day_miner_unit * 6; //3小时
+                                        meal_deduction += 10.00M;  //餐补扣款
+                                        absenteeism_deduction += day_deduction; //矿工半日
+                                    }
+                                    else
+                                    {
+                                        day_deduction = dailyWage;
+                                        absenteeism_deduction += day_deduction; //矿工一日
+                                        meal_deduction += 10.00M;
+                                    }
+
+                                    beLate_belate_ex.Deduction = day_deduction;
+                                    ex_reissuecard_Items.Add(beLate_belate_ex);
+                                }
+                                else if (exception == 2)  //早退
+                                {
+                                    if (timelength < 10)
+                                    {
+                                        user_cd_zt_num++;
+                                        beLate_belate_ex.SubTypeId = 2;
+                                        beLate_belate_ex.SubType = "早退";
+                                        string thisEndDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks((date + lastest_time) * 10000000)
+                                                           .ToString("yyyy-MM-dd HH:mm:ss");
+                                        beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisEndDt);
+
+
+                                        if (user_cd_zt_num >= 3)
+                                        {
+                                            day_deduction = 50.00M;
+                                        }
+                                        else
+                                        {
+                                            day_deduction = 0.00M;
+                                        }
+                                        early_deduction += day_deduction;  //早退扣款 总计
+                                    }
+                                    else if (timelength >= 10 && timelength <= 60)
+                                    {
+                                        day_deduction = 50.00M;
+                                        early_deduction += day_deduction;  //早退扣款 总计
+                                        beLate_belate_ex.SubTypeId = 2;
+                                        beLate_belate_ex.SubType = "早退";
+                                        string thisEndDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks((date + lastest_time) * 10000000)
+                                                           .ToString("yyyy-MM-dd HH:mm:ss");
+                                        beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisEndDt);
+                                    }
+                                    else if (timelength > 60 && timelength <= 180)
+                                    {
+                                        day_deduction = day_miner_unit * 6; //3小时
+                                        absenteeism_deduction += day_deduction; //矿工半日
+
+                                    }
+                                    else
+                                    {
+                                        day_deduction = dailyWage;
+                                        meal_deduction += 10.00M;
+                                        absenteeism_deduction += day_deduction; //矿工一日
+                                    }
+
+                                    beLate_belate_ex.Deduction = day_deduction;
+                                    ex_reissuecard_Items.Add(beLate_belate_ex);
+                                }
+                                else if (exception == 3) //缺卡
+                                {
+
+                                    if (root.exception_infos.Count == 2)
+                                    {
+                                        day_deduction = dailyWage;
+                                        meal_deduction += 10.00M;
+                                        absenteeism_deduction += day_deduction;
+                                        beLate_belate_ex.Reason = "上午-下午 缺卡/未打卡为旷工 一天";
+                                        beLate_belate_ex.Deduction = day_deduction;
+                                        ex_reissuecard_Items.Add(beLate_belate_ex);
+
+                                    }
+                                    else if (root.exception_infos.Count == 1)
+                                    {
+
+                                        if (earliest_time == lastest_time)
+                                        {
+                                            DateTime thisDt1 = Convert.ToDateTime(thisDtStr + " 12:00");
+
+
+                                            if (thisDt <= thisDt1)  //旷工 下午
+                                            {
+                                                day_deduction = day_miner_unit * 9; //4.5小时
+                                                meal_deduction += 10.00M;
+                                                absenteeism_deduction += day_deduction; //矿工半日
+                                                beLate_belate_ex.Reason = thisDtStr + " 下午(18:00)缺卡/未打卡视为下午旷工(4.5小时)";
+
+                                                beLate_belate_ex.Deduction = day_deduction;
+                                                ex_reissuecard_Items.Add(beLate_belate_ex);
+                                            }
+                                            else if (thisDt >= thisDt1) //旷工下午
+                                            {
+                                                day_deduction = day_miner_unit * 6; //3小时
+                                                absenteeism_deduction += day_deduction; //矿工半日
+                                                beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为上午旷工(3小时)";
+
+                                                beLate_belate_ex.Deduction = day_deduction;
+                                                ex_reissuecard_Items.Add(beLate_belate_ex);
+                                            }
+                                            else //矿工一日
+                                            {
+
+                                                day_deduction = dailyWage;
+                                                meal_deduction += 10.00M;
+                                                absenteeism_deduction += day_deduction;
+                                                beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
+
+                                                beLate_belate_ex.Deduction = day_deduction;
+                                                ex_reissuecard_Items.Add(beLate_belate_ex);
+                                            }
+
+
+                                        }
+                                    }
+                                }
+                                else if (exception == 4) //旷工
+                                {
+                                    if (timelength > 60 && timelength <= 180)
+                                    {
+                                        day_deduction = day_miner_unit * 6; //3小时
+                                        beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工上午(3小时)";
+                                        meal_deduction += 10.00M;
+                                        absenteeism_deduction += day_deduction; //矿工半日
+
+                                    }
+                                    else
+                                    {
+                                        day_deduction = dailyWage;
+                                        beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
+                                        meal_deduction += 10.00M;
+                                        absenteeism_deduction += day_deduction; //矿工一日
+                                    }
+
+                                    beLate_belate_ex.Deduction = day_deduction;
+                                    ex_reissuecard_Items.Add(beLate_belate_ex);
+                                }
+
+                            }
+                        }
+
+                        
+                        #endregion
+
+                        #region 假勤/补卡次数 审批
+
+                        int leaveNum = 0; //请假次数
+                        int reissuecardNum = 0; //补卡次数\
+                        //类型:1 - 请假;2 - 补卡;3 - 出差;4 - 外出;100 - 外勤
+                        leaveNum = acc_sp_items.Where(it => it.type == 1).ToList().Count();
+                        reissuecardNum = acc_sp_items.Where(it => it.type == 2).ToList().Count();
+
+                        //请假审批
+                        if (leaveNum > 0)
+                        {
+                            List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
+                            sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 1); //时间段内所有 已同意的 请假 审批数据
+                            if (sp_leave_details.Count <= 0)
+                            {
+                                _result.Msg += startDt + " - " + endDt + "  " + itemName + "  请假 审批数据获取未获取到!\r\n";
+                                //continue;
+                            }
+                            List<Ex_Item> ex_ItemInfos = new List<Ex_Item>();
+
+                            foreach (Sp_Detail sp_item in sp_leave_details)
+                            {
+                                Apply_data? apply_data = sp_item.apply_data;
+                                if (apply_data != null)
+                                {
+                                    List<ContentsItem> contents = apply_data.contents;
+                                    ContentsItem content_Vacation = contents.Where(it => it.control == "Vacation").FirstOrDefault();  //请假类型 
+                                    ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault(); //多行文本 
+
+                                    if (content_Vacation != null)
+                                    {
+                                        Vacation vacation = content_Vacation.value.vacation;
+                                        Attendance attendance = vacation.attendance; //假勤组件
+                                        Selector selector = vacation.selector;       //请假类型
+
+                                        List<OptionsItem> optionsItems = selector.options; //key 请假类型 id
+                                        List<TitleItem> value = optionsItems[0].value; // value 文本描述值
+
+                                        int leaveType = int.Parse(optionsItems[0].key);  //key 请假子类型 id
+                                        Date_range date_Range = attendance.date_range;
+
+                                        //筛选 不在工作日内的假勤申请
+                                        if (startDt >= date_Range.new_begin_dt || date_Range.new_end_dt > endDt)
+                                        {
+                                            continue;
+                                        }
+                                       
+
+                                        decimal thisTypeDeduction = 0.00M;//当前类型扣款
+                                        string leave_starttime = date_Range.new_begin_dt.ToString("HH:mm");
+                                        string leave_endtime = date_Range.new_end_dt.ToString("HH:mm");
+
+                                        string typeName = string.Empty;
+                                        string unit = string.Empty;
+                                        int leaveTypeId = leaveType;
+                                        var leaveTypeData = vacationLeaveTypes.Where(it => it.id == leaveTypeId).FirstOrDefault();
 
+                                        if (leaveTypeData != null) { typeName = leaveTypeData.name; }
+
+                                        string startTime = string.Empty;
+                                        string endTime = string.Empty;
+                                        //计算请假类型扣款金额
+                                        decimal new_duration = 0.00M;
+                                        if (date_Range.type == "halfday")
+                                        {
+                                            new_duration = Convert.ToDecimal(date_Range.new_duration) / 86400M;
+                                            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";
+                                        }
+                                        else if (date_Range.type == "hour")
+                                        {
+                                            new_duration = Convert.ToDecimal(date_Range.new_duration) / 3600M;
+                                            unit = "小时";
+                                            startTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd HH:mm:ss");
+                                            endTime = date_Range.new_end_dt.ToString("yyyy-MM-dd HH:mm:ss");
+                                        }
+                                        decimal leave_meals = 0.00M;
+
+                                        //计算餐补 假勤类型扣款
+                                        CalculateTypeFee(leaveType, date_Range.type, leave_starttime, leave_endtime, amountPayable, work_days, new_duration,
+                                            out leave_meals, out thisTypeDeduction);
+
+                                        #region 累计类型扣款
+                                        //1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
+
+                                        if (leaveType == 2) //事假
+                                        {
+                                            personalLeaveTotal += thisTypeDeduction;
+                                        }
+                                        else if (leaveType == 3) //病假
+                                        {
+                                            sickLeaveTotal = thisTypeDeduction;
+                                        }
+
+                                        #endregion
+
+                                        meal_deduction += leave_meals;
+
+
+                                        Ex_Item ex_Item = new Ex_Item()
+                                        {
+                                            SubTypeId = leaveType,
+                                            SubType = typeName,
+                                            StartTimeDt = Convert.ToDateTime(startTime),
+                                            EndTimeDt = Convert.ToDateTime(endTime),
+                                            Duration = new_duration,
+                                            Unit = unit,
+                                            Deduction = thisTypeDeduction,
+                                            //Reason = apply_data.reason,
+                                            Apply_time_dt = Convert.ToDateTime(sp_item.apply_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
+                                            //Approval_name = sp_item.approval_name,
+                                        };
+                                        ex_ItemInfos.Add(ex_Item);
+                                    }
+                                }
                             }
 
+                            if (ex_ItemInfos.Count > 0)
+                            {
+                                ex_Items_jq.Ex_ItemInfo = ex_ItemInfos.OrderBy(it => it.SubTypeId).ThenBy(it => it.Apply_time_dt).ToList();
+                                ex_Items.Add(ex_Items_jq);
+                            }
 
-                            #endregion
+                        }
 
-                            #region 打卡补卡
+                        //打卡补卡
+                        if (reissuecardNum > 0)
+                        {
+                            List<Sp_Detail> sp_buka_details = new List<Sp_Detail>();
+                            sp_buka_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 2); //时间段内所有 已同意的 请假 审批数据
 
-                            #endregion
+                            int bukaNum = 1;
+                            foreach (var item in sp_buka_details)
+                            {
+                                Apply_data? apply_data = item.apply_data;
+                                if (apply_data != null)
+                                {
+                                    List<ContentsItem> contents = apply_data.contents;
+                                    ContentsItem content_Vacation = contents.Where(it => it.control == "PunchCorrection").FirstOrDefault();  //请假类型 
+                                    ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault(); //多行文本 
+
+                                    if (content_Vacation != null)
+                                    {
+                                        var punch_correction = content_Vacation.value.punch_correction;
 
-                            #region 迟到 早退 矿工
+                                        DateTime bukaDt = punch_correction.time_dt;
+
+                                        //筛选 不在工作日内的假勤申请
+                                        if (startDt >= bukaDt || bukaDt > endDt)
+                                        {
+                                            continue;
+                                        }
 
+                                        decimal bukaPrice = 0.00M;
+                                        if (bukaNum <= 2)
+                                        {
+                                            bukaPrice = 10.00M;
+                                        }
+                                        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;
+
+                                        Ex_Item ex_reissueCard = new Ex_Item()
+                                        {
+                                            SubTypeId = 7,
+                                            SubType = "打卡补卡",
+                                            StartTimeDt = Convert.ToDateTime(punch_correction1.time_dt.ToString("yyyy-MM-dd HH:mm:ss")),  //未打卡时间
+                                            Deduction = bukaPrice,
+                                            Reason = punch_correction2.text,
+                                            Unit = string.Empty
+                                        };
+                                        unprinted_deduction += bukaPrice;
+                                        ex_reissuecard_Items.Add(ex_reissueCard);
+                                        bukaNum++;
+                                    }
+                                }
+                            }
+                        }
 
-                            #endregion
+                        if (ex_reissuecard_Items.Count > 0)
+                        {
+                            ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items;
+                            ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.StartTimeDt).ToList();
+                            ex_Items.Add(ex_Items_dk);
                         }
 
+                        #endregion
+
+
                     }
                     else
                     {
@@ -878,7 +1292,15 @@ namespace OASystem.API.OAMethodLib
                     }
                     else
                     {
-                        salaryTotal = (dk_work_days * dailyWage) + mealTotal;    //应发合计
+                        if (itemName.Equals("张海麟"))
+                        {
+                            salaryTotal = amountPayable + mealTotal;    //应发合计
+                        }
+                        else
+                        {
+                            salaryTotal = (dk_work_days * dailyWage) + mealTotal;    //应发合计
+                        }
+                            
                     }
 
 
@@ -892,7 +1314,7 @@ namespace OASystem.API.OAMethodLib
                     #region 处理当月工资数据
                     pm_wsInfo.YearMonth = thisYearMonth;
                     pm_wsInfo.StartDate = startDt.ToString("yyyy-MM-dd");
-                    pm_wsInfo.EndDate = endDt.AddDays(-1).ToString("yyyy-MM-dd");
+                    pm_wsInfo.EndDate = endDt.ToString("yyyy-MM-dd");
                     pm_wsInfo.WorkDays = work_days;        //当月应出勤天数
                     pm_wsInfo.RegularDays = dk_work_days;  //当月正常出勤天数
 
@@ -1291,77 +1713,20 @@ namespace OASystem.API.OAMethodLib
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
         /// <returns></returns>
-        public static int GetWorkDays(DateTime startDt,DateTime endDt) 
+        public static async Task<int> GetWorkDays(string yearMonth) 
         {
-            string startYear = startDt.ToString("yyyy");
-            string endYear = endDt.ToString("yyyy");
-
-            var holidays = AppSettingsHelper.Get<HoliDaysDataSourceView>("HoliDayDataSource");
-            List<HoliDaysDataSourceView> holiDatas = new List<HoliDaysDataSourceView>();
-            if (startYear.Equals(endYear))
-            {
-                holiDatas.Add(holidays.Where(it => it.Year == startYear).FirstOrDefault());
-            }
-            else
-            {
-                holiDatas.Add(holidays.Where(it => it.Year == startYear).FirstOrDefault());
-                holiDatas.Add(holidays.Where(it => it.Year == endYear).FirstOrDefault());
-            }
+            int workdays = 0;
+            string sql = string.Format(@"Select * From  Pm_WageIssueWorkingDay 
+                                         Where Isdel = 0 And YearMonth = '{0}' ", yearMonth);
 
-            int _totalDays = (int)(endDt - startDt).TotalDays;
-            List<HolidaysInfo> _holidays = new List<HolidaysInfo>();
-            List<HolidaysInfo> _weekdys = new List<HolidaysInfo>();
-            List<HolidaysInfo> _workdays = new List<HolidaysInfo>();
-            string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
+            var data = await _usersRep._sqlSugar.SqlQueryable<WageYearMonthView>(sql).FirstAsync();
 
-            for (int i = 0; i <= _totalDays; i++)
+            if (data != null)
             {
-                string thisYear = startDt.ToString("yyyy");
-                string thisDt = startDt.ToString("MM-dd");
-                string thisYMD = startDt.ToString("yyyy-MM-dd");
-                string thisWeek = Day[Convert.ToInt32(startDt.DayOfWeek.ToString("d"))].ToString();
-
-
-                HoliDaysDataSourceView holiDaysData = new HoliDaysDataSourceView();
-                holiDaysData = holiDatas.Where(it => it.Year == thisYear).FirstOrDefault();
-                //周末
-                if (thisWeek.Equals("星期六") || thisWeek.Equals("星期日"))
-                {
-                    HolidaysInfo holidaysInfo = new HolidaysInfo();
-                    holidaysInfo = holiDaysData.Holidays.Where(it => it.HoliDate == thisDt).FirstOrDefault();
-                    if (holidaysInfo != null)
-                    {
-                        if (holidaysInfo.HoliName.Equals("工作日"))
-                        {
-                            _workdays.Add(new HolidaysInfo { HoliDate = thisYMD, HoliName = Day[Convert.ToInt32(startDt.DayOfWeek.ToString("d"))].ToString() });
-                            startDt = startDt.AddDays(1);
-                            continue;
-                        }
-                    }
-                    _weekdys.Add(new HolidaysInfo { HoliDate = thisYMD, HoliName = thisWeek });
-                    startDt = startDt.AddDays(1);
-                    continue;
-                }
-                
-                //节假日
-                if (holiDaysData != null)
-                {
-                    HolidaysInfo holidaysInfo = new HolidaysInfo();
-                    holidaysInfo = holiDaysData.Holidays.Where(it => it.HoliDate == thisDt).FirstOrDefault();
-                    if (holidaysInfo != null)
-                    {
-                        _holidays.Add(new HolidaysInfo { HoliDate = thisYMD, HoliName = holidaysInfo.HoliName });
-                        startDt = startDt.AddDays(1);
-                        continue;
-                    }
-                }
-                //工作日
-                _workdays.Add(new HolidaysInfo { HoliDate = thisYMD, HoliName = Day[Convert.ToInt32(startDt.DayOfWeek.ToString("d"))].ToString() });
-
-                startDt = startDt.AddDays(1);
+                workdays = data.Workdays;
             }
 
-            return _workdays.Count();
+            return workdays;
         }
     }
 }

+ 323 - 26
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.Dtos.QiYeWeChat;
+using Microsoft.AspNetCore.Identity;
+using OASystem.Domain.Dtos.QiYeWeChat;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using Org.BouncyCastle.Ocsp;
@@ -298,7 +299,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
         /// <returns></returns>
-        public async Task<CheckInView> GetCheckin_MonthDataAsync(DateTime startDt,DateTime endDt)
+        public async Task<CheckInView> GetCheckin_MonthDataAsync1(DateTime startDt,DateTime endDt)
         {
             CheckInView checkInView = new CheckInView();
 
@@ -347,6 +348,152 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             return checkInView;
         }
 
+        /// <summary>
+        /// 获取月打卡记录数据
+        /// </summary>
+        /// <param name="startDt"></param>
+        /// <param name="endDt"></param>
+        /// <returns></returns>
+        public async Task<CheckInView> GetCheckin_MonthDataAsync(DateTime startDt, DateTime endDt)
+        {
+            CheckInView checkInView = new CheckInView();
+
+            //获取员工Id
+            UserIdListView userIdListView = await GetUserIdListAsync();
+            if (userIdListView.errcode != 0)
+            {
+                checkInView.errcode = userIdListView.errcode;
+                checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】{0}", userIdListView.errmsg);
+                return checkInView;
+            }
+
+            if (userIdListView.dept_user == null || userIdListView.dept_user.Count <= 0)
+            {
+                checkInView.errmsg = string.Format("【企业微信】【获取员工IdList】【Msg】未查出员工Id");
+                return checkInView;
+            }
+
+            //获取打卡数据 token
+            Access_TokenView access_Token = await GetTokenAsync(2);
+            if (access_Token.errcode != 0)
+            {
+                checkInView.errcode = access_Token.errcode;
+                checkInView.errmsg = string.Format("【企业微信】【获取月打卡数据】【Token】【Msg】{0}", access_Token.errmsg);
+                return checkInView;
+            }
+
+
+            #region 处理超31天的月报表数据
+
+            string url = string.Format("/cgi-bin/checkin/getcheckin_monthdata?access_token={0}", access_Token.access_token);
+
+            Checkin_MonthData_Request checkInReq = new Checkin_MonthData_Request();
+            checkInReq.access_token = access_Token.access_token;
+            checkInReq.useridlist = userIdListView.dept_user.Select(it => it.userid).ToList();
+
+            uint starttimeOne, endtimeOne, starttimeTwo, endtimeTwo;
+            int days = (int)(endDt - startDt).TotalDays;
+
+            if (days > 32) 
+            {
+                starttimeOne = (uint)((startDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+                endtimeOne = (uint)((startDt.AddDays(31).ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+                starttimeTwo = (uint)((startDt.AddDays(32).ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+                endtimeTwo = (uint)((endDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+
+                checkInReq.starttime = starttimeOne;
+                checkInReq.endtime = endtimeOne;
+                CheckInView checkInViewOne = new CheckInView();
+
+                var jsonOne = System.Text.Json.JsonSerializer.Serialize(checkInReq);
+                var contentOne = new StringContent(jsonOne, Encoding.UTF8, "application/json");
+                var create_ReqOne = await _httpClient.PostAsync(url, contentOne);
+                var stringResponseOne = await create_ReqOne.Content.ReadAsStringAsync();
+
+                checkInViewOne = System.Text.Json.JsonSerializer.Deserialize<CheckInView>(stringResponseOne,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+
+                if (checkInViewOne.errcode != 0)
+                {
+                    return checkInViewOne;
+                }
+
+                checkInReq.starttime = starttimeTwo;
+                checkInReq.endtime = endtimeTwo;
+                CheckInView checkInViewTwo = new CheckInView();
+
+
+
+                var jsonTwo = System.Text.Json.JsonSerializer.Serialize(checkInReq);
+                var contentTwo = new StringContent(jsonTwo, Encoding.UTF8, "application/json");
+                var create_ReqTwo = await _httpClient.PostAsync(url, contentTwo);
+                var stringResponseTwo = await create_ReqTwo.Content.ReadAsStringAsync();
+
+                checkInViewTwo = System.Text.Json.JsonSerializer.Deserialize<CheckInView>(stringResponseTwo,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+
+                if (checkInViewTwo.errcode != 0)
+                {
+                    return checkInViewTwo;
+                }
+
+                #region 整合月报表数据 
+
+                foreach (var item_one in checkInViewOne.datas)
+                {
+                    foreach (var item_two in checkInViewTwo.datas)
+                    {
+                        if (item_one.base_info.acctid.Equals(item_two.base_info.acctid))
+                        {
+                            #region summary_info 汇总信息整合
+                            item_one.summary_info.work_days += item_two.summary_info.work_days; //应打卡天数
+                            item_one.summary_info.regular_days += item_two.summary_info.regular_days;  //正常天数
+                            item_one.summary_info.except_days += item_two.summary_info.except_days;   //异常天数
+                            item_one.summary_info.regular_work_sec += item_two.summary_info.regular_work_sec;  //实际工作时长,为统计周期每日实际工作时长之和
+                            item_one.summary_info.standard_work_sec += item_two.summary_info.standard_work_sec; //标准工作时长,为统计周期每日标准工作时长之和
+                            #endregion
+
+                            #region exception_infos 异常状态统计信息 整合
+                            item_one.exception_infos.AddRange(item_two.exception_infos);
+                            #endregion
+
+                            #region sp_items 	假勤统计信息整合
+                            item_one.sp_items.AddRange(item_two.sp_items);
+                            #endregion
+
+                            #region overwork_info 加班情况 整合
+                            item_one.overwork_info.workday_over_sec += item_two.overwork_info.workday_over_sec;   //工作日加班时长
+                            item_one.overwork_info.holidays_over_sec += item_two.overwork_info.holidays_over_sec;   //节假日加班时长
+                            item_one.overwork_info.restdays_over_sec += item_two.overwork_info.restdays_over_sec;   //休息日加班时长
+                            #endregion
+                            break;
+                        }
+                    }
+                }
+                #endregion
+                checkInView = checkInViewOne;
+            }
+            else
+            {
+                checkInReq.starttime = (uint)((startDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+                checkInReq.endtime = (uint)((endDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
+
+                var json = System.Text.Json.JsonSerializer.Serialize(checkInReq);
+                var content = new StringContent(json, Encoding.UTF8, "application/json");
+                var create_Req = await _httpClient.PostAsync(url, content);
+                var stringResponse = await create_Req.Content.ReadAsStringAsync();
+
+                checkInView = System.Text.Json.JsonSerializer.Deserialize<CheckInView>(stringResponse,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+            }
+
+
+            #endregion
+
+            return checkInView;
+        }
+
+
         /// <summary>
         /// 获取月打卡数据(redis缓存)
         /// </summary>
@@ -510,7 +657,6 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             return checkInDataView;
         }
 
-
         /// <summary>
         /// 获取打卡日报数据
         /// </summary>
@@ -518,7 +664,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// <param name="startDt"></param>
         /// <param name="endDt"></param>
         /// <returns></returns>
-        public async Task<CheckInDayDataView> GetCheckInDayDataAsync(List<string> useridlist, DateTime startDt, DateTime endDt)
+        public async Task<CheckInDayDataView> GetCheckInDayDataAsync1(List<string> useridlist, DateTime startDt, DateTime endDt)
         {
             CheckInDayDataView checkInDayDataView = new CheckInDayDataView();
 
@@ -562,6 +708,115 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
 
             return checkInDayDataView;
         }
+
+
+        /// <summary>
+        /// 获取打卡日报数据
+        /// </summary>
+        /// <param name="useridlist"></param>
+        /// <param name="startDt"></param>
+        /// <param name="endDt"></param>
+        /// <returns></returns>
+        public async Task<CheckInDayDataView> GetCheckInDayDataAsync(List<string> useridlist, DateTime startDt, DateTime endDt)
+        {
+            CheckInDayDataView checkInDayDataView = new CheckInDayDataView();
+
+            //参数处理
+            if (useridlist.Count <= 0)
+            {
+                checkInDayDataView.errmsg = "请填写企业微信用户id,可为多个!";
+                return checkInDayDataView;
+            }
+
+
+            //获取打卡数据 token
+            Access_TokenView access_Token = await GetTokenAsync(2);
+            if (access_Token.errcode != 0)
+            {
+                checkInDayDataView.errcode = access_Token.errcode;
+                checkInDayDataView.errmsg = string.Format("【企业微信】【获取打卡日报数据】【Token】【Msg】{0}", access_Token.errmsg);
+                return checkInDayDataView;
+            }
+
+            string url = string.Format("/cgi-bin/checkin/getcheckin_daydata?access_token={0}&debug=1", access_Token.access_token);
+
+            int days = (int)(endDt - startDt).TotalDays;
+            if (days > 31)
+            {
+                long startTs_One = (startDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+                long endTs_One = (startDt.AddDays(31).ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+                long startTs_Two = (startDt.AddDays(31).ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+                long endTs_Two = (endDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+
+                var checkInData_ReqOne = new
+                {
+                    access_token = access_Token.access_token,
+                    useridlist = useridlist,
+                    starttime = startTs_One,
+                    endtime = endTs_One
+                };
+
+                var jsonOne = System.Text.Json.JsonSerializer.Serialize(checkInData_ReqOne);
+                var contentOne = new StringContent(jsonOne, Encoding.UTF8, "application/json");
+                var create_ReqOne = await _httpClient.PostAsync(url, contentOne);
+                var stringResponseOne = await create_ReqOne.Content.ReadAsStringAsync();
+
+                CheckInDayDataView checkInDayDataViewOne = System.Text.Json.JsonSerializer.Deserialize<CheckInDayDataView>(stringResponseOne,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+
+                if (checkInDayDataViewOne.errcode != 0)
+                {
+                    return checkInDayDataViewOne;
+                }
+
+                var checkInData_ReqTwo = new
+                {
+                    access_token = access_Token.access_token,
+                    useridlist = useridlist,
+                    starttime = startTs_Two,
+                    endtime = endTs_Two
+                };
+
+                var jsonTwo = System.Text.Json.JsonSerializer.Serialize(checkInData_ReqTwo);
+                var contentTwo = new StringContent(jsonTwo, Encoding.UTF8, "application/json");
+                var create_ReqTwo = await _httpClient.PostAsync(url, contentTwo);
+                var stringResponseTwo = await create_ReqTwo.Content.ReadAsStringAsync();
+
+                CheckInDayDataView checkInDayDataViewTwo = System.Text.Json.JsonSerializer.Deserialize<CheckInDayDataView>(stringResponseTwo,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+                if (checkInDayDataViewTwo.errcode != 0)
+                {
+                    return checkInDayDataViewTwo;
+                }
+                checkInDayDataViewOne.datas.AddRange(checkInDayDataViewTwo.datas);
+                return checkInDayDataViewOne;
+            }
+            else
+            {
+                long startTs = (startDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+                long endTs = (endDt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+
+                var checkInData_Req = new
+                {
+                    access_token = access_Token.access_token,
+                    useridlist = useridlist,
+                    starttime = startTs,
+                    endtime = endTs
+                };
+
+                var json = System.Text.Json.JsonSerializer.Serialize(checkInData_Req);
+                var content = new StringContent(json, Encoding.UTF8, "application/json");
+                var create_Req = await _httpClient.PostAsync(url, content);
+                var stringResponse = await create_Req.Content.ReadAsStringAsync();
+
+                checkInDayDataView = System.Text.Json.JsonSerializer.Deserialize<CheckInDayDataView>(stringResponse,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+            }
+            
+
+            return checkInDayDataView;
+        }
+
         #endregion
 
         #region 审批
@@ -759,8 +1014,18 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
 
             //获取所有打卡补卡,审批 数据 前后范围增加10天
             DateTime sp_startDt = startDt.AddDays(-10);
-            DateTime sp_centerDt = sp_startDt.AddDays(30);
+            DateTime sp_centerDt = sp_startDt.AddDays(31);
             DateTime sp_endDt = endDt.AddDays(10);
+            DateTime thisDt = Convert.ToDateTime( DateTime.Now.ToString("yyyy-MM-dd"));
+            if (sp_endDt > thisDt)
+            {
+                sp_endDt = thisDt;
+            }
+            int days = (int)(sp_endDt - sp_startDt).TotalDays;
+            if (days > 31)
+            {
+                sp_centerDt = sp_startDt.AddDays(31);
+            }
 
             //获取审批数据 token
             Access_TokenView access_Token = await GetTokenAsync(5);
@@ -786,8 +1051,8 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             ApprovalInfo_Request approvalInfoReq = new ApprovalInfo_Request()
             {
                 access_token = access_Token.access_token,
-                starttime = (uint)(startDt - _1970).TotalSeconds,
-                endtime = (uint)(endDt - _1970).TotalSeconds,
+                starttime = (uint)ConvertToTimeSpan(sp_startDt),
+                endtime = (uint)ConvertToTimeSpan(sp_centerDt),
                 filters = filters.ToList(),
             };
             var json = System.Text.Json.JsonSerializer.Serialize(approvalInfoReq);
@@ -795,36 +1060,63 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             var create_Req = await _httpClient.PostAsync(url, content);
             var stringResponse = await create_Req.Content.ReadAsStringAsync();
 
-            approvalInfoView = System.Text.Json.JsonSerializer.Deserialize<ApprovalInfoView>(stringResponse,
+            ApprovalInfoView approvalInfoView1 = System.Text.Json.JsonSerializer.Deserialize<ApprovalInfoView>(stringResponse,
                 new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
 
-            List<string> sp_datas = new List<string>();
-            sp_datas.AddRange(approvalInfoView.sp_no_list);
+            if (approvalInfoView1.errcode != 0)
+            {
+                return approvalInfoView1;
+            }
 
+            ApprovalInfo_Request approvalInfoReq1 = new ApprovalInfo_Request()
+            {
+                access_token = access_Token.access_token,
+                starttime = (uint)ConvertToTimeSpan(sp_centerDt),
+                endtime = (uint)ConvertToTimeSpan(sp_endDt),
+                filters = filters.ToList(),
+            };
+            var json1 = System.Text.Json.JsonSerializer.Serialize(approvalInfoReq1);
+            var content1 = new StringContent(json1, Encoding.UTF8, "application/json");
+            var create_Req1 = await _httpClient.PostAsync(url, content1);
+            var stringResponse1 = await create_Req1.Content.ReadAsStringAsync();
 
-            int index = 0;
-            while (true)
+            ApprovalInfoView approvalInfoView2 = System.Text.Json.JsonSerializer.Deserialize<ApprovalInfoView>(stringResponse1,
+                new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+            if (approvalInfoView2.errcode != 0)
             {
-                if (string.IsNullOrEmpty(approvalInfoView.new_next_cursor)) break;
-                string new_cursor = approvalInfoView.new_next_cursor;
-                approvalInfoReq.new_cursor = new_cursor;
-                var while_json = System.Text.Json.JsonSerializer.Serialize(approvalInfoReq);
-                var while_content = new StringContent(while_json, Encoding.UTF8, "application/json");
-                var while_create_Req = await _httpClient.PostAsync(url, while_content);
-                var while_stringResponse = await while_create_Req.Content.ReadAsStringAsync();
+                return approvalInfoView1;
+            }
 
-                approvalInfoView = System.Text.Json.JsonSerializer.Deserialize<ApprovalInfoView>(while_stringResponse,
-                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+            approvalInfoView1.sp_no_list.AddRange(approvalInfoView2.sp_no_list);
+
+            //List<string> sp_datas = new List<string>();
+            //sp_datas.AddRange(approvalInfoView1.sp_no_list);
+            //sp_datas.AddRange(approvalInfoView2.sp_no_list);
 
-                sp_datas.AddRange(approvalInfoView.sp_no_list); //追加数据
-                index++;
-            }
 
-            approvalInfoView.sp_no_list = sp_datas;
+            //int index = 0;
+            //while (true)
+            //{
+            //    if (string.IsNullOrEmpty(approvalInfoView.new_next_cursor)) break;
+            //    string new_cursor = approvalInfoView.new_next_cursor;
+            //    approvalInfoReq.new_cursor = new_cursor;
+            //    var while_json = System.Text.Json.JsonSerializer.Serialize(approvalInfoReq);
+            //    var while_content = new StringContent(while_json, Encoding.UTF8, "application/json");
+            //    var while_create_Req = await _httpClient.PostAsync(url, while_content);
+            //    var while_stringResponse = await while_create_Req.Content.ReadAsStringAsync();
+
+            //    approvalInfoView = System.Text.Json.JsonSerializer.Deserialize<ApprovalInfoView>(while_stringResponse,
+            //        new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+
+            //    sp_datas.AddRange(approvalInfoView.sp_no_list); //追加数据
+            //    index++;
+            //}
+
+            //approvalInfoView.sp_no_list = sp_datas;
 
             sw.Stop();
             approvalInfoView.errmsg = approvalInfoView.errmsg + " 耗时:" + sw.Elapsed.TotalMilliseconds + "ms";
-            return approvalInfoView;
+            return approvalInfoView1;
         }
 
         /// <summary>
@@ -960,5 +1252,10 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
             return templateDetailView;
         }
         #endregion
+
+        public long ConvertToTimeSpan(DateTime dt)
+        { 
+            return (dt.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+        }
     }
 }

+ 8 - 0
OASystem/OASystem.Domain/Dtos/PersonnelModule/WageSheetDto.cs

@@ -14,6 +14,14 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     {
     }
 
+    public class WageYearDto
+    {
+        /// <summary>
+        /// 年
+        /// </summary>
+        public int Year { get; set; }
+    }
+
     /// <summary>
     /// 工资表单List Dto
     /// </summary>

+ 41 - 0
OASystem/OASystem.Domain/Entities/PersonnelModule/Pm_WageIssueWorkingDay.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.PersonnelModule
+{
+    /// <summary>
+    /// 人事 工资
+    /// 月份设置工作日
+    /// </summary>
+    [SugarTable("Pm_WageIssueWorkingDay")]
+    public class Pm_WageIssueWorkingDay: EntityBase
+    {
+        /// <summary>
+        /// 年月
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string? YearMonth { get; set; }
+
+        /// <summary>
+        /// 工资日期 起
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string? StartDate { get; set; }
+
+        /// <summary>
+        /// 工资日期 止
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string? EndDate { get; set; }
+
+        /// <summary>
+        /// 工作日
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int Workdays { get; set; }
+
+    }
+}

+ 39 - 0
OASystem/OASystem.Domain/Entities/System/Sys_Calendar.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.System
+{
+    /// <summary>
+    /// 日历表
+    /// </summary>
+    [SugarTable("Sys_Calendar")]
+    public class Sys_Calendar : EntityBase
+    {
+        /// <summary>
+        /// 年月日
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string Dt { get; set; }
+        /// <summary>
+        /// 是否是工作日
+        ///  0 true 1 false
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "bit")]
+        public bool IsWorkDays { get; set; }
+
+        /// <summary>
+        /// 是否是节假日
+        /// 0 true 1 false
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "bit)")]
+        public bool IsHoliDay { get; set; }
+        /// <summary>
+        /// 节假日名称
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        public string HoliDayName { get; set; }
+    }
+}

+ 11 - 0
OASystem/OASystem.Domain/ViewModels/PersonnelModule/WageSheetView.cs

@@ -16,6 +16,17 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
 
     }
 
+    /// <summary>
+    /// 工资年月 View
+    /// </summary>
+    public class WageYearMonthView 
+    {
+        public string YearMonth { get; set; }
+        public string StartDate { get; set; }
+        public string EndDate { get; set; }
+        public int Workdays { get; set; }
+    }
+
     /// <summary>
     /// 工资表单详情
     /// </summary>