Browse Source

计算工资 5.7

leiy 1 year ago
parent
commit
ab27b1dbfa

+ 79 - 51
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -1,5 +1,6 @@
 using Google.Protobuf.WellKnownTypes;
 using NPOI.OpenXmlFormats.Spreadsheet;
+using NPOI.SS.Formula.Functions;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI;
 using OASystem.Domain;
 using OASystem.Domain.Entities.PersonnelModule;
@@ -7,6 +8,7 @@ using OASystem.Domain.ViewModels.PersonnelModule;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
 using System;
+using System.Diagnostics.Eventing.Reader;
 using System.Linq.Expressions;
 using TencentCloud.Ocr.V20181119.Models;
 
@@ -285,34 +287,41 @@ namespace OASystem.API.OAMethodLib
 
                     if (reissueCardNum > 0)
                     {
-                        if (reissueCardNum <= 3)
-                        {
-                            reissuecard_deduction += 10 * reissueCardNum;
-                        }
-                        else if (reissueCardNum > 3) //补卡超过三 每补卡一次 50 CNY
-                        {
-                            int for_reissueCardNum = reissueCardNum - 3;
+                       
+                        List<Sp_Detail> sp_buka_details = new List<Sp_Detail>();
+                        sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 2); //时间段内所有 已同意的 请假 审批数据
 
-                            for (int i = 0; i < for_reissueCardNum; i++)
+                        int bukaNum = 1;
+                        foreach (var item in sp_leave_details)
+                        {
+                            decimal bukaPrice = 0.00M;
+                            if (bukaNum <= 2)
                             {
-                                reissuecard_deduction += 50;
+                                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++;
                         }
-                        unprinted_deduction += reissuecard_deduction;  //补卡次数 放在未打卡里面
-                        Ex_Item ex_reissueCard = new Ex_Item()
-                        {
-                            SubTypeId = 7,
-                            SubType = "补卡次数",
-                            Duration = reissueCardNum,
-                            Deduction = reissuecard_deduction,
-                            Reason = "补卡:员工发现自己漏打卡时,需及时提起补卡申请,并说明情况。试用期员工每月有 2 次\r\n补卡机会,超过 2 次不足 5 次的部分,按 10 元/次处罚,5 次及以上的漏卡,按 50 元/次处罚;正式员工每月 3 次以内的补卡,按 10 元/次处罚,3 次及以上的漏卡,按 50 元/次处罚。\r\n补卡路径为:企微-工作台-审批-打卡补卡。",
-                            unit = string.Empty
-                        };
-
-                        ex_reissuecard_Items.Add(ex_reissueCard);
                     }
 
-
                     #endregion
 
                     List<Sp_Detail> sp_reissuecard_details = new List<Sp_Detail>();
@@ -398,7 +407,7 @@ namespace OASystem.API.OAMethodLib
                                     if (timelength == 9) timelength = 7.50M;
 
                                     int exception = exception_info.exception; //异常类型
-                                    decimal day_miner_unit = dailyWage / 15;  //以0.5小时为单位 
+                                    decimal day_miner_unit = ConvertToDecimal(dailyWage / 15);  //以0.5小时为单位 
 
                                     //1:一个自然月内,不足 10 分钟的迟到/早退,不超过 2 次的部分,不做处罚;3 次及以上,按50 元 / 次处罚;
                                     //2:超过 10 分钟(含 10 分钟),不足 60 分钟的迟到 / 早退,按 50 元 / 次处罚;
@@ -494,41 +503,60 @@ namespace OASystem.API.OAMethodLib
                                     }
                                     else if (exception == 3) //缺卡
                                     {
-                                        if (timelength < 10)
-                                        {
-                                            reissueCardNum++;
-                                            beLate_belate_ex.SubTypeId = 3;
-                                            beLate_belate_ex.SubType = "缺卡";
 
-                                            if (reissueCardNum >= 3)
-                                            {
-                                                day_deduction = 50.00M;
-                                                unprinted_deduction += day_deduction; //缺卡/未打卡 总额
-                                            }
-
-                                        }
-                                        else if (timelength >= 10 && timelength <= 60)
+                                        if (roots_ex.exception_infos.Count == 2)
                                         {
-                                            day_deduction = 50.00M;
-                                            unprinted_deduction += day_deduction; //缺卡/未打卡 总额
-                                            beLate_belate_ex.SubTypeId = 3;
-                                            beLate_belate_ex.SubType = "缺卡";
-                                        }
-                                        else if (timelength > 60 && timelength <= 180)
-                                        {
-                                            day_deduction = day_miner_unit * 6; //3小时
-                                            absenteeism_deduction += day_deduction; //矿工半日
+                                            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
+                                        else if (roots_ex.exception_infos.Count == 1)
                                         {
-                                            day_deduction = dailyWage;
-                                            meal_deduction += 10.00M;
-                                            absenteeism_deduction += day_deduction; //矿工一日
+                                            long date = roots_ex.base_info.date; //当日工作日期
+                                            long earliest_time = roots_ex.summary_info.earliest_time; //最早打卡时间
+                                            long lastest_time = roots_ex.summary_info.lastest_time; //最晚打卡时间
+
+                                            if (earliest_time == lastest_time)
+                                            {
+                                                long this_date = date + earliest_time;
+                                                DateTime thisDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks(this_date * 10000000);
+                                                DateTime thisDt1 = Convert.ToDateTime(thisDt.ToString("yyyy-MM-dd") + " 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 = thisDt.ToString("yyyy-MM-dd") + "下午缺卡/未打卡为旷工 4.5小时";
+                                                }
+                                                else if (thisDt >= thisDt1) //旷工下午
+                                                {
+                                                    day_deduction = day_miner_unit * 6; //3小时
+                                                    absenteeism_deduction += day_deduction; //矿工半日
+                                                    beLate_belate_ex.Reason = thisDt.ToString("yyyy-MM-dd") + "上午缺卡/未打卡为旷工 3小时";
+                                                }
+                                                else //矿工一日
+                                                {
+
+                                                    day_deduction = dailyWage;
+                                                    meal_deduction += 10.00M;
+                                                    absenteeism_deduction += day_deduction;
+                                                    beLate_belate_ex.Reason = thisDt.ToString("yyyy-MM-dd") + "上午-下午 缺卡/未打卡为旷工 一天";
+                                                }
+
+
+                                                beLate_belate_ex.Deduction = day_deduction;
+                                                ex_reissuecard_Items.Add(beLate_belate_ex);
+
+                                            }
                                         }
 
-                                        beLate_belate_ex.Deduction = day_deduction;
-                                        ex_reissuecard_Items.Add(beLate_belate_ex);
+                                        
+
                                     }
                                     else if (exception == 4) //旷工
                                     {

+ 3 - 0
OASystem/OASystem.Domain/ViewModels/QiYeWeChat/ApprovalDataView.cs

@@ -316,6 +316,8 @@ namespace OASystem.Domain.ViewModels.QiYeWeChat
     /// </summary>
     public class Value
     {
+        public string? text { get; set; }
+
         /// <summary>
         /// 此控件不显示在审批详情中,故value为空
         /// </summary>
@@ -358,6 +360,7 @@ namespace OASystem.Domain.ViewModels.QiYeWeChat
         /// 关联审批单的模板
         /// </summary>
         public List<Related_Approval> related_approval { get; set; }
+
         ///// <summary>
         ///// 
         ///// </summary>