浏览代码

计算工资 增加特殊日期-不用打卡日期信息

leiy 1 年之前
父节点
当前提交
f3ca56d5b6

+ 7 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -7055,6 +7055,7 @@ namespace OASystem.API.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
         {
             #region  参数验证
@@ -7088,6 +7089,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
         {
             #region  参数验证
@@ -7120,6 +7122,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
         {
 
@@ -7154,6 +7157,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
         {
             #region  参数验证
@@ -7194,6 +7198,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
         {
             #region  参数验证
@@ -7229,6 +7234,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
         {
             #region  参数验证
@@ -7262,6 +7268,7 @@ namespace OASystem.API.Controllers
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
         {
             #region  参数验证
@@ -7357,8 +7364,6 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, "操作成功!", Url));
         }
 
-
-
         #endregion
     }
 }

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

@@ -951,7 +951,6 @@ namespace OASystem.API.Controllers
         }
         #endregion
 
-
         #region 任务单
 
         /// <summary>

+ 50 - 7
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -15,6 +15,7 @@ using System.Collections.Generic;
 using System.Diagnostics.Eventing.Reader;
 using System.Drawing;
 using System.Linq.Expressions;
+using System.Text.Json.Nodes;
 using TencentCloud.Ocr.V20181119.Models;
 
 namespace OASystem.API.OAMethodLib
@@ -99,8 +100,36 @@ namespace OASystem.API.OAMethodLib
             //工作日日报
             workday_userRoots = workday_userRoots.OrderBy(it => it.base_info.date).ToList();
 
-            //获取 请假类型 Sp_Detail.template_id
-            string leave_template_id = "C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1";
+
+            //获取企业打卡规则
+            CorpCheckInRuleView corpCheckInRole = await _qiYeWeChatApiService.GetCheckIn_CorpCheckInOptionAsync();
+            if (corpCheckInRole.errcode != 0)
+            {
+                _result.Msg = "【企业微信】【打卡】【获取企业打卡规则】【Msg】" + corpCheckInRole.errmsg;
+                return _result;
+            }
+
+            int spe_offdays = 0;
+
+            GroupItem group = corpCheckInRole.group.Where(it => it.groupid == 4).FirstOrDefault();
+            if (group != null)
+            {
+                foreach (var item in group.spe_offdays)
+                {
+
+                    if (item.begtime_dt>= startDt && item.endtime_dt <= endDt)
+                    {
+                        TimeSpan ts = item.endtime_dt - item.begtime_dt;
+                        spe_offdays += ts.Days;
+                    }
+                }
+            }
+
+
+
+
+                //获取 请假类型 Sp_Detail.template_id
+                string leave_template_id = "C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1";
             List<VacationLeaveTypeView> vacationLeaveTypes = await GetVacationLeaveTypes(leave_template_id);
             if (vacationLeaveTypes.Count <= 0)
             {
@@ -1339,7 +1368,7 @@ namespace OASystem.API.OAMethodLib
                     }
 
                     #region 应发合计 实发合计 扣款合计(假勤扣款,其他扣款,社保扣款,公积金代扣,个税扣款)
-
+                    int workDays = dk_work_days + spe_offdays;
                     decimal mealTotal = meal_subsidy - meal_deduction;  //餐补
                     decimal salaryTotal = 0.00M;
                     if (dk_work_days >= work_days)
@@ -1355,7 +1384,9 @@ namespace OASystem.API.OAMethodLib
                         }
                         else
                         {
-                            salaryTotal = (dk_work_days * dailyWage) + mealTotal + pm_wsInfo.OtherHandle;    //应发合计
+                            
+
+                            salaryTotal = (workDays * dailyWage) + mealTotal + pm_wsInfo.OtherHandle;    //应发合计
                         }
                             
                     }
@@ -1373,7 +1404,7 @@ namespace OASystem.API.OAMethodLib
                     pm_wsInfo.StartDate = startDt.ToString("yyyy-MM-dd");
                     pm_wsInfo.EndDate = endDt.ToString("yyyy-MM-dd");
                     pm_wsInfo.WorkDays = work_days;        //当月应出勤天数
-                    pm_wsInfo.RegularDays = dk_work_days;  //当月正常出勤天数
+                    pm_wsInfo.RegularDays = workDays;  //当月正常出勤天数
 
                     pm_wsInfo.SickLeave = sickLeaveTotal;           //病假
                     pm_wsInfo.SomethingFalse = personalLeaveTotal;  //事假
@@ -1399,8 +1430,6 @@ namespace OASystem.API.OAMethodLib
                     #endregion
 
                 }
-
-                
             }
             catch (Exception ex)
             {
@@ -2260,5 +2289,19 @@ namespace OASystem.API.OAMethodLib
 
             return workdays;
         }
+
+        /// <summary>
+        /// 获取一个类指定的属性值
+        /// </summary>
+        /// <param name="info">object对象</param>
+        /// <param name="field">属性名称</param>
+        /// <returns></returns>
+        public static object GetPropertyValue(object info, string field)
+        {
+            if (info == null) return null;
+            System.Type t = info.GetType();
+            IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
+            return property.First().GetValue(info, null);
+        }
     }
 }

+ 6 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/IQiYeWeChatApiService.cs

@@ -33,6 +33,12 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         /// <returns></returns>
         Task<UserIdListView> GetUserIdListAsync();
 
+        /// <summary>
+        /// 获取企业所有打卡规则
+        /// </summary>
+        /// <returns></returns>
+        Task<CorpCheckInRuleView> GetCheckIn_CorpCheckInOptionAsync();
+
         /// <summary>
         /// 获取月打卡数据
         /// </summary>

+ 31 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -293,6 +293,37 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
 
         #region 打卡
 
+        /// <summary>
+        /// 获取企业所有打卡规则
+        /// </summary>
+        /// <returns></returns>
+        public async Task<CorpCheckInRuleView> GetCheckIn_CorpCheckInOptionAsync()
+        {
+            CorpCheckInRuleView corpCheckInRuleView = new CorpCheckInRuleView();
+
+            //获取打卡数据 token
+            Access_TokenView access_Token = await GetTokenAsync(2);
+            if (access_Token.errcode != 0)
+            {
+                corpCheckInRuleView.errcode = access_Token.errcode;
+                corpCheckInRuleView.errmsg = string.Format("【企业微信】【获取月打卡数据】【Token】【Msg】{0}", access_Token.errmsg);
+                return corpCheckInRuleView;
+            }
+
+            string url = string.Format("/cgi-bin/checkin/getcorpcheckinoption?access_token={0}", access_Token.access_token);
+
+            var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
+            var create_Req = await _httpClient.PostAsync(url, content);
+            var stringResponse = await create_Req.Content.ReadAsStringAsync();
+
+            corpCheckInRuleView = System.Text.Json.JsonSerializer.Deserialize<CorpCheckInRuleView>(stringResponse,
+                new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+
+
+            return corpCheckInRuleView;
+        }
+
+
         /// <summary>
         /// 获取月打卡记录数据
         /// </summary>

+ 86 - 0
OASystem/OASystem.Domain/ViewModels/QiYeWeChat/CheckInView.cs

@@ -6,6 +6,92 @@ using System.Threading.Tasks;
 
 namespace OASystem.Domain.ViewModels.QiYeWeChat
 {
+
+    #region 企业微信 API 获取企业打卡规则
+
+    /// <summary>
+    /// 企业微信 API 获取企业打卡规则
+    /// </summary>
+    public class CorpCheckInRuleView : ResponseBase
+    {
+        /// <summary>
+        /// 企业规则信息列表
+        /// </summary>
+        public List<GroupItem>? group { get; set; }
+    }
+
+    public class GroupItem
+    {
+        /// <summary>
+        /// 打卡规则类型,1:固定时间上下班;2:按班次上下班;3:自由上下班
+        /// </summary>
+        public int grouptype { get; set; }
+
+        /// <summary>
+        /// 打卡规则id
+        /// </summary>
+        public int groupid { get; set; }
+
+        /// <summary>
+        /// 打卡规则名称
+        /// </summary>
+        public string groupname { get; set; }
+
+        /// <summary>
+        /// 特殊日期-不用打卡日期时间戳
+        /// </summary>
+        public List<spe_offdaysItem> spe_offdays { get; set; }
+    }
+
+    /// <summary>
+    /// 特殊日期-不用打卡日期时间戳
+    /// </summary>
+    public class spe_offdaysItem
+    {
+        /// <summary>
+        /// 特殊日期备注
+        /// </summary>
+        public string notes { get; set; }
+
+        public long timestamp { get; set; }
+
+        public List<long> checkintime { get; set; }
+
+        public int type { get; set; }
+
+        /// <summary>
+        /// 开始时间戳
+        /// </summary>
+        public long begtime { get; set; }
+
+        /// <summary>
+        /// 开始时间
+        /// </summary>
+        public DateTime begtime_dt
+        {
+            get
+            {
+                return new DateTime(begtime * 10000000 + 621355968000000000L).ToLocalTime();
+            }
+        }
+
+        public long endtime { get; set; }
+
+        /// <summary>
+        /// 开始时间
+        /// </summary>
+        public DateTime endtime_dt
+        {
+            get
+            {
+                return new DateTime(endtime * 10000000 + 621355968000000000L).ToLocalTime();
+            }
+        }
+    }
+
+
+    #endregion
+
     /// <summary>
     /// 企业微信 API
     /// 打卡月数据