Browse Source

计算工资

leiy 1 year ago
parent
commit
ffec0374d1

+ 314 - 30
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -49,6 +49,30 @@ namespace OASystem.API.Controllers
 
         #region 工资表单
 
+        /// <summary>
+        /// 工资表单 基础数据源
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetWageSheetBasicsDataSource()
+        {
+
+            //获取OA系统内所有用户
+            var nameData = await _usersRep.GetUserNameList(1);
+            if (nameData.Code != 0)
+            {
+                return Ok(JsonView(false, nameData.Msg));
+            }
+
+            var data = new {
+                userNames = nameData.Data
+        };
+
+
+            return Ok(JsonView(true, "查询成功!", data));
+        }
+
         /// <summary>
         /// 获取工资表单
         /// </summary>
@@ -58,7 +82,6 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GetWageSheetList(WageSheetListDto dto)
         {
-
             //参数处理
             string ymFormat = "yyyy-MM";
             DateTime yearMonthDt;
@@ -74,7 +97,7 @@ namespace OASystem.API.Controllers
             string startDt = yearMonthDt.AddDays(-1).ToString("yyyy-MM") + "-28",
                    endDt = yearMonth + "-27";
 
-            //应发合计 = 基本工资 +绩效工资 + 岗位津贴 + 员工的岗位津贴 + 服装洗理补贴 + 通讯补贴 + 交通补贴 + 保密费 + 操作奖金+ 其他补贴 + 部门集体团建费 + 代扣保险 + 代扣公积金 + 餐补 - 个税
+            //应发合计 = 基本工资 +绩效工资 + 岗位津贴 + 员工的岗位津贴 + 服装洗理补贴 + 通讯补贴 + 交通补贴 + 保密费 + 操作奖金+ 其他补贴 + 部门集体团建费 + 代扣保险 + 代扣公积金 + 餐补 
 
             //事假  病假 合计
 
@@ -132,6 +155,34 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, _result.Msg, _result.Data));
         }
 
+
+        /// <summary>
+        /// 人事模块 工资表单 删除
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostWageSheetDel(WageDelDto dto)
+        {
+            try
+            {
+                _result = await _wageSheetRep.Post_WageSheet_DelAsync(dto);
+                if (_result.Code != 0)
+                {
+                    return Ok(JsonView(false, _result.Msg));
+
+                }
+            }
+            catch (Exception ex)
+            {
+
+                return Ok(JsonView(false, ex.Message));
+            }
+
+            return Ok(JsonView(true, _result.Msg, _result.Data));
+        }
+
         /// <summary>
         /// 人事模块 工资表单 添加 Or 修改
         /// </summary>
@@ -205,7 +256,7 @@ namespace OASystem.API.Controllers
 
             //获取OA系统内所有用户
             var nameData = await _usersRep.GetUserNameList(1);
-            List<UserNameView> userNames = nameData.Data;
+            List<UserNameView>? userNames = nameData.Data;
 
             //获取所有打卡数据
             CheckInView checkIn = await _qiYeWeChatApiService.GetCheckin_MonthDataAsync(startDt, endDt); //时间段内所有 打卡数据
@@ -221,7 +272,6 @@ namespace OASystem.API.Controllers
             DateTime sp_centerDt = sp_startDt.AddDays(30);
             DateTime sp_endDt = endDt.AddDays(10);
 
-
             List<Sp_Info> sp_Infos = new List<Sp_Info>();
             string redisName = "ApprovalData_" + sp_startDt.Year + "_" + sp_startDt.Month;
             string sp_InfosString = await RedisRepository.RedisFactory
@@ -267,7 +317,6 @@ namespace OASystem.API.Controllers
                 Pm_WageSheet pm_wsInfo = new Pm_WageSheet();
                 pm_wsInfo = _mapper.Map<Pm_WageSheet>(item);
 
-
                 //补贴 金额
                 decimal meal_subsidy = 0.00M;  // 午餐(午餐10元/天)  补贴 * 计算方式:单日上午请假时长(小时)大于或者等于三小时 没有餐补
 
@@ -292,14 +341,11 @@ namespace OASystem.API.Controllers
                 decimal meal_deduction = 0.00M;           // 餐补 扣款金额
                 decimal reissuecard_deduction = 0.00M;    // 补卡 扣款金额
 
-
-
                 //打卡数据
                 Data? checkInData = checkInDatas.Where(it => it.base_info.name == item.Name).FirstOrDefault();
                 if (checkInData == null) { continue; }
                 string acctid = checkInData.base_info.acctid; //用户Id
                
-
                 //当月总计数据
                 Summary_Info? summary_Info = checkInData.summary_info;
                 if (summary_Info == null ) { continue; }
@@ -365,29 +411,44 @@ namespace OASystem.API.Controllers
 
                 List<Sp_Info> sp_leave_item_infosData = sp_leave_InfosData.Where(it => it.spname == "请假" && it.apply_name == item.Name).ToList();
 
+                List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
+                Ex_Items ex_Items_jq = new Ex_Items() { Type = "假勤" };   //假勤
+                List<Ex_Item> ex_ItemInfos = new List<Ex_Item>();
+
                 foreach (Sp_Info sp_item in sp_leave_item_infosData)
                 {
                     Leave? sp_leave = sp_item.leave;
                     if (sp_leave != null)
                     {
-                        //leave_type 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他
 
+                        //请假时长
+                        double leaveLength = (sp_leave.end_time_dt - sp_leave.start_time_dt).TotalHours;
+
+                        string typeName = string.Empty;
+                        //leave_type 1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他
                         switch (sp_leave.leave_type)
                         {
                             case 1:    //年假
+                                typeName = "年假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3)
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
                                     }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
+                                    }
                                 }
                                 break;
                             case 2:    //事假 需调整
+                                typeName = "事假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
@@ -395,14 +456,19 @@ namespace OASystem.API.Controllers
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3)
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
-                                        personalLeaveTotal += dailyWage;
+                                    }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
                                     }
                                 }
                                 break;
                             case 3:    //病假 需调整
+                                typeName = "病假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
@@ -410,75 +476,123 @@ namespace OASystem.API.Controllers
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3) //7.5小时 一天
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
-                                        sickLeaveTotal += sickLeave_deduction;
+                                    }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
                                     }
                                 }
                                 break;
                             case 4:    //调休假
+                                typeName = "调休假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3) //7.5小时 一天
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
+                                    } 
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
                                     }
                                 }
                                 break;
                             case 5:    //婚假
+                                typeName = "婚假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3) //7.5小时 一天
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
                                     }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
+                                    }
                                 }
                                 break;
                             case 6:    //产假
+                                typeName = "产假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3) //7.5小时 一天
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
                                     }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
+                                    }
                                 }
                                 break;
                             case 7:    //陪产假
+                                typeName = "陪产假";
                                 if (sp_leave.timeunit == 0) //半天
                                 {
                                     meal_deduction += 10;
                                 }
                                 else if (sp_leave.timeunit == 1) //小时
                                 {
-                                    if (sp_leave.duration >= 3) //7.5小时 一天
+                                    if (sp_leave.duration >= 3 && sp_leave.duration <= 7.5) //7.5小时 一天
                                     {
                                         meal_deduction += 10;
                                     }
+                                    else if (sp_leave.duration > 7.5)
+                                    {
+                                        decimal daysPrice = Convert.ToDecimal(sp_leave.duration / 7.5 * 10);
+                                        meal_deduction += daysPrice;
+                                    }
                                 }
                                 break;
                             default:
                                 break;
                         }
+
+                        Ex_Item ex_Item = new Ex_Item() {
+                            SubTypeId = sp_leave.leave_type,
+                            SubType = typeName,
+                            Start_time_dt = sp_leave.start_time_dt,
+                            End_time_dt = sp_leave.end_time_dt,
+                            Duration = sp_leave.duration,
+                            Reason = sp_leave.reason,
+                            Apply_time_dt = sp_item.apply_time_dt,
+                            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.Start_time_dt).ToList();
+                    ex_Items.Add(ex_Items_jq);
+                }
+
+                #endregion
+
                 #endregion
 
 
-                #region 补卡 处理
+                #region 打卡补卡 处理
 
                 if (reissueCardNum == 3)
                 {
@@ -491,10 +605,13 @@ namespace OASystem.API.Controllers
 
                 #endregion
 
+                Ex_Items ex_Items_dk = new Ex_Items() { Type = "打卡" };    //打卡
+                //List<Ex_Item> ex_reissuecard_Items = new List<Ex_Item>();
+                List<dynamic> ex_reissuecard_Items = new List<dynamic>();
+                List<Sp_Info> sp_reissuecard_item_InfosData = sp_reissuecard_InfosData.Where(it => it.apply_name == item.Name).ToList();
 
-                #endregion
+                #region 打卡异常处理 统计 1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常;
 
-                //打卡异常处理 统计 1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常;
                 int beLateNum = 0,           // 1-迟到;
                     leaveEarlyNum = 0,       // 2-早退;
                     dummyDeckNum = 0,        // 3-缺卡;
@@ -516,6 +633,146 @@ namespace OASystem.API.Controllers
                     }
                 }
 
+                foreach (Sp_Info sp_reissuecard_item in sp_reissuecard_item_InfosData)
+                {
+                    DateTime apply_time_dt = sp_reissuecard_item.apply_time_dt; //申请时间
+                    List<string>? approval_name = sp_reissuecard_item.approval_name; //审核人
+
+                    Comm sp_comm = sp_reissuecard_item.comm;
+                    if (sp_comm != null)
+                    {
+                        if (sp_comm.applydata != null )
+                        {
+                            List<ApplyInfo>  applyInfos = sp_comm.applydata;
+                            if (applyInfos.Count > 0)
+                            {
+                                //Ex_Item ex_reissuecard_Item = new Ex_Item();
+                                dynamic ex_reissuecard_Item = null;
+                                string text = applyInfos.Where(it => it.type == "text").FirstOrDefault().value.ToString(); //异常状态
+                                DateTime? datehour = applyInfos.Where(it => it.type == "datehour").FirstOrDefault().valueDt;//补卡时间
+                                string textarea = applyInfos.Where(it => it.type == "textarea").FirstOrDefault().value.ToString();//补卡事由
+                                if (text.Contains("未打卡"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 0,
+                                        SubType = "未打卡",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("迟到"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 1,
+                                        SubType = "迟到",
+                                        title = text,
+                                        datehour = datehour == null? "": Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("早退"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 2,
+                                        SubType = "早退",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("缺卡"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 3,
+                                        SubType = "缺卡",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("旷工"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 4,
+                                        SubType = "旷工",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("地点异常"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 5,
+                                        SubType = "地点异常",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                else if (text.Contains("设备异常"))
+                                {
+                                    ex_reissuecard_Item = new
+                                    {
+                                        SubTypeId = 6,
+                                        SubType = "设备异常",
+                                        title = text,
+                                        datehour = datehour == null ? "" : Convert.ToDateTime(datehour).ToString("yyyy-MM-dd HH:mm:ss"),
+                                        textarea = textarea,
+                                        apply_time_dt = apply_time_dt,
+                                        approval_name = approval_name
+                                    };
+                                }
+                                if (ex_reissuecard_Item != null)
+                                {
+                                    ex_reissuecard_Items.Add(ex_reissuecard_Item);
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (ex_reissuecard_Items.Count>0)
+                {
+                    ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.datehour).ToList();
+                    ex_Items.Add(ex_Items_dk);
+                }
+
+                #endregion
+
+
+                #region 应发合计 实发合计 扣款合计(假勤扣款,其他扣款,社保扣款,公积金代扣,个税扣款)
+
+                decimal mealTotal = meal_subsidy - meal_deduction;  //餐补
+                decimal salaryTotal = amountPayable + mealTotal;    //应发合计
+
+                //扣款合计 不含个税
+                decimal eductionTotal = sickLeaveTotal + personalLeaveTotal + beLate_deduction + early_deduction + absenteeism_deduction + unprinted_deduction + other_deduction +
+                    pm_wsInfo.WithholdingInsurance + pm_wsInfo.ReservedFunds;
+                decimal actualReleaseTotal = salaryTotal - eductionTotal; //实发合计 * 不含个税
+
+
+                #endregion
+
                 #region 处理当月工资数据
                 pm_wsInfo.YearMonth = thisYearMonth;
                 pm_wsInfo.StartDate = startDt.ToString("yyyy-MM-dd");
@@ -528,13 +785,13 @@ namespace OASystem.API.Controllers
                 pm_wsInfo.Absenteeism = absenteeism_deduction;  //旷工
                 pm_wsInfo.NotPunch = unprinted_deduction;       //未打卡
                 pm_wsInfo.OtherDeductions = other_deduction;    //其他
+                pm_wsInfo.Ex_ItemsRemark = JsonConvert.SerializeObject(ex_Items);  //
+                pm_wsInfo.Mealsupplement = mealTotal;          //餐补
 
-                pm_wsInfo.Mealsupplement = meal_subsidy - meal_deduction;  //餐补
-
-                
-                decimal salaryTotal = amountPayable; //应发合计
-                //decimal eductionTotal =  ;
-                decimal actualReleaseTotal = 0.00M; //实发合计
+                pm_wsInfo.Should = salaryTotal;            //应发合计
+                pm_wsInfo.TotalDeductions = eductionTotal; //扣款合计
+                pm_wsInfo.TotalRealHair = actualReleaseTotal; //实发合计
+                pm_wsInfo.AfterTax = actualReleaseTotal - pm_wsInfo.WithholdingTax; //税后工资
 
                 pm_wsInfo.LastUpdateUserId = dto.UserId;
                 pm_wsInfo.LastUpdateDt = DateTime.Now;
@@ -546,11 +803,38 @@ namespace OASystem.API.Controllers
 
                 wageSheets.Add(pm_wsInfo);
             }
-           
 
-            
+            #region 批量添加
+            var add = await _wageSheetRep._sqlSugar.Insertable(wageSheets).ExecuteCommandAsync();
+            if (add <= 0)
+            {
+                return Ok(JsonView(false, "操作失败!"));
+            }
+
+            #endregion
+
+            #region 处理返回数据
+
+            List <WageSheetItemInfoView> wageSheetItems = new List<WageSheetItemInfoView>();
+            wageSheetItems = _mapper.Map<List<WageSheetItemInfoView>>(wageSheets);
+            wageSheetItems = wageSheetItems.Select(it => 
+                    {
+                        UserNameView? uName1 = new UserNameView();
+                        UserNameView? uName2 = new UserNameView();
+                        uName1 = userNames.Where(it1 => it.UserId == it1.Id).FirstOrDefault();
+                        if (uName1 != null)  it.Name = uName1.CnName;
+
+                        uName2 = userNames.Where(it1 => it.LastUpdateUserId == it1.Id).FirstOrDefault();
+                        if (uName2 != null) it.LastUpdateUserName = uName2.CnName;
+
+                        return it; }
+                    ).ToList();
+            #endregion
+
+
+
 
-            return Ok(JsonView(true,"操作成功!", wageSheets));
+            return Ok(JsonView(true,"操作成功!", wageSheetItems));
         }
 
         /// <summary>

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

@@ -182,6 +182,11 @@ namespace OASystem.Domain.Dtos.PersonnelModule
         /// </summary>
         public decimal OtherDeductions { get; set; }
 
+        /// <summary>
+        /// 假勤 / 打卡补卡 明细
+        /// </summary>
+        public string? Ex_ItemsRemark { get; set; }
+
         /// <summary>
         /// 应发合计
         /// </summary>
@@ -210,6 +215,22 @@ namespace OASystem.Domain.Dtos.PersonnelModule
 
     }
 
+    /// <summary>
+    /// 删除
+    /// </summary>
+    public class WageDelDto
+    {
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public int UserId { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Id { get; set; }
+    }
+
     /// <summary>
     /// 计算工资 Dto
     /// </summary>

+ 6 - 3
OASystem/OASystem.Domain/Entities/PersonnelModule/Pm_WageSheet.cs

@@ -135,21 +135,18 @@ namespace OASystem.Domain.Entities.PersonnelModule
 
         /// <summary>
         /// 迟到 
-        /// 计算次数
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(8,2)")]
         public decimal LateTo { get; set; }
 
         /// <summary>
         /// 早退 
-        /// 计算次数
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(8,2)")]
         public decimal LeaveEarly { get; set; }
 
         /// <summary>
         /// 旷工 
-        /// 小时计算 7.5小时一天
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(8,2)")]
         public decimal Absenteeism { get; set; }
@@ -166,6 +163,12 @@ namespace OASystem.Domain.Entities.PersonnelModule
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(8,2)")]
         public decimal OtherDeductions { get; set; }
 
+        /// <summary>
+        /// 扣款项 明细
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string? Ex_ItemsRemark { get; set; }
+
         /// <summary>
         /// 应发合计
         /// </summary>

+ 97 - 6
OASystem/OASystem.Domain/ViewModels/PersonnelModule/WageSheetView.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.Entities.PersonnelModule;
+using Newtonsoft.Json;
+using OASystem.Domain.Entities.PersonnelModule;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -10,15 +11,15 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
     /// <summary>
     /// 工资表详情
     /// </summary>
-    public class WageSheetView:Pm_WageSheet 
+    public class WageSheetView : Pm_WageSheet
     {
-      
+
     }
 
     /// <summary>
     /// 工资表单详情
     /// </summary>
-    public class WageSheetInfoView 
+    public class WageSheetInfoView
     {
         public int Id { get; set; }
 
@@ -249,6 +250,37 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         /// </summary>
         public decimal TotalDeductions { get; set; }
 
+        /// <summary>
+        /// 假勤  / 打卡补卡 明细 string
+        /// </summary>
+        public string? Ex_ItemsRemark { get; set; }
+
+        ///// <summary>
+        ///// 假勤  / 打卡补卡 明细 对象
+        ///// </summary>
+        //public List<Ex_Items>? Ex_Items
+        //{
+        //    get;set;
+        //}
+
+        ///// <summary>
+        ///// 假勤  / 打卡补卡 明细 对象
+        ///// </summary>
+        //public List<Ex_Items>? Ex_Items
+        //{
+        //    get
+        //    {
+        //        List<Ex_Items>? data = new List<Ex_Items>();
+
+        //        if (!string.IsNullOrEmpty(Ex_ItemsRemark))
+        //        {
+        //            data = JsonConvert.DeserializeObject<List<Ex_Items>>(Ex_ItemsRemark);
+        //        }
+
+        //        return data;
+        //    }
+        //}
+
         /// <summary>
         /// 实发合计
         /// </summary>
@@ -277,15 +309,74 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         /// <summary>
         /// 最后操作时间
         /// </summary>
-        public string? LastUpdateDt { get; set; }
+        public DateTime? LastUpdateDt { get; set; }
     }
 
 
     /// <summary>
     /// 工资列表信息
     /// </summary>
-    public class WageSheetInfos:Pm_WageSheet
+    public class WageSheetInfos : Pm_WageSheet
     {
         public string Name { get; set; }
     }
+
+    #region 假勤 和 打卡 统计
+
+    public class Ex_Items
+    {
+        /// <summary>
+        /// 类型
+        /// 假勤 打卡
+        /// </summary>
+        public string? Type { get; set; }
+
+        public Object? Ex_ItemInfo { get; set; }
+    }
+
+
+    public class Ex_Item
+    {
+        /// <summary>
+        /// 子类型Id
+        /// </summary>
+        public int SubTypeId { get; set; }
+
+        /// <summary>
+        /// 子类型
+        /// </summary>
+        public string? SubType { get; set; }
+
+        /// <summary>
+        /// 请假开始时间,datetime时间
+        /// </summary>
+        public DateTime? Start_time_dt { get; set; }
+
+        /// <summary>
+        /// 请假开始时间,datetime时间
+        /// </summary>
+        public DateTime? End_time_dt { get; set; }
+
+        /// <summary>
+        /// 请假时长,单位小时
+        /// </summary>
+        public int Duration { get; set; }
+
+        /// <summary>
+        /// 请假事由
+        /// </summary>
+        public string? Reason { get; set; }
+
+        /// <summary>
+        /// 申请时间
+        /// </summary>
+        public DateTime Apply_time_dt { get; set; }
+
+        /// <summary>
+        /// 审核人
+        /// </summary>
+        public List<string>? Approval_name { get; set; }
+    }
+
+    #endregion
 }

+ 2 - 5
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -159,7 +159,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
-            if (dto.PortType == 1 || dto.PortType == 2) //web
+            if (dto.PortType == 1 || dto.PortType == 2) //Web Or Android
             {
                 string sql = string.Format(@"Select Id,SalesQuoteNo,TourCode,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
 	                                                ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
@@ -174,10 +174,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     result.Msg = "成功!";
                     result.Data = _DelegationInfo;
                 }
-                else
-                {
-                    result.Msg = "暂无该团组信息";
-                }
+                else result.Msg = "暂无该团组信息"; 
             }
 
             return result;

+ 60 - 7
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/WageSheetRepository.cs

@@ -9,6 +9,7 @@ using System.Text;
 using System.Threading.Tasks;
 using SqlSugar;
 using Result = OASystem.Domain.Result;
+using Newtonsoft.Json;
 
 namespace OASystem.Infrastructure.Repositories.PersonnelModule
 {
@@ -39,9 +40,9 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 return _result;
             }
 
-            string sql = string.Format(@"Select sys_u1.CnName Name,sys_u2.CnName LastUpdateUserName,pm_ws.Id, 
+            string sql = string.Format(@"Select sys_u1.CnName Name,sys_u2.CnName LastUpdateUserName,pm_ws.LastUpdateDt, pm_ws.Id, 
                                          pm_ws.YearMonth,pm_ws.StartDate,pm_ws.EndDate,pm_ws.UserId,pm_ws.Should,
-                                         pm_ws.TotalDeductions,pm_ws.TotalRealHair,pm_ws.WithholdingTax,pm_ws.AfterTax
+                                         pm_ws.TotalDeductions,pm_ws.Ex_ItemsRemark,TotalRealHair,pm_ws.WithholdingTax,pm_ws.AfterTax
                                          From Pm_WageSheet pm_ws
                                          Left Join Sys_Users sys_u1 On pm_ws.UserId = sys_u1.Id
                                          Left Join Sys_Users sys_u2 On pm_ws.LastUpdateUserId = sys_u2.Id
@@ -53,7 +54,18 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 _result.Msg = "暂无数据!";
                 return _result;
             }
+            //wageSheetList = wageSheetList.Select(it => {
 
+            //    if (!string.IsNullOrEmpty(it.Ex_ItemsRemark))
+            //    {
+            //        List<Ex_Items>? data = new List<Ex_Items>();
+            //        data = JsonConvert.DeserializeObject<List<Ex_Items>>(it.Ex_ItemsRemark);
+            //        it.Ex_Items = data;
+            //    }
+
+            //    return it;
+                
+            //}).ToList();   
             _result.Code = 0;
             _result.Msg = "查询成功!";
             _result.Data = wageSheetList;
@@ -71,12 +83,15 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                          Left Join Sys_Users sys_u1 On pm_ws.UserId = sys_u1.Id
                                          Left Join Sys_Users sys_u2 On pm_ws.LastUpdateUserId = sys_u2.Id
                                          Where pm_ws.IsDel = 0 And pm_ws.Id = {0}", id);
-            var wageSheetInfo = await _sqlSugar.SqlQueryable<WageSheetInfoView>(sql).ToListAsync();
-
-            _result.Code = 0;
-            _result.Msg = "查询成功!";
-            _result.Data = wageSheetInfo;
+            var wageSheetInfo = await _sqlSugar.SqlQueryable<WageSheetInfoView>(sql).FirstAsync();
 
+            if (wageSheetInfo != null)
+            {
+                _result.Code = 0;
+                _result.Msg = "查询成功!";
+                _result.Data = wageSheetInfo;
+            }
+            
             return _result;
         }
 
@@ -92,6 +107,15 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
 
             if (dto.Status == 1) //添加
             {
+                var select = await _sqlSugar.Queryable<Pm_WageSheet>().
+                    Where(it => it.IsDel == 0 && it.UserId == pm_WageSheet.UserId && it.YearMonth == pm_WageSheet.YearMonth).
+                    FirstAsync();
+                if (select != null) 
+                {
+                    _result.Msg = "该用户 "+ pm_WageSheet.YearMonth + " 工资信息已存在,请前往修改!";
+                    return _result;
+                }
+
                 int add = await _sqlSugar.Insertable(pm_WageSheet).ExecuteReturnIdentityAsync();
                 if (add <= 0)
                 {
@@ -121,5 +145,34 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             return _result;
         }
 
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <returns></returns>
+        public async Task<Result> Post_WageSheet_DelAsync(WageDelDto dto)
+        {
+            Pm_WageSheet pm_WageSheet = new Pm_WageSheet()
+            {
+                Id = dto.Id,
+                DeleteUserId = dto.UserId,
+                DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                LastUpdateUserId = dto.UserId,
+                IsDel = 1
+            };
+            int update = await _sqlSugar.Updateable(pm_WageSheet)
+                                             .UpdateColumns(it => new { it.DeleteUserId, it.DeleteTime, it.IsDel, it.LastUpdateUserId, it.LastUpdateDt })
+                                             .WhereColumns(it => new { it.Id })
+                                             .ExecuteCommandAsync();
+            if (update <= 0)
+            {
+                _result.Msg = "操作失败!";
+                return _result;
+            }
+
+            _result.Code = 0;
+            _result.Msg = "操作成功!";
+
+            return _result;
+        }
     }
 }