Просмотр исходного кода

计算工资
删除 代码中的测试数据

leiy 1 год назад
Родитель
Сommit
31cfd0b289

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

@@ -5419,7 +5419,7 @@ namespace OASystem.API.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        public async Task<IActionResult> TourClientListByDiId(TourClientListByDiIdDto _dto)
+        public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
         {
             #region  参数验证
             if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
@@ -5445,6 +5445,40 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(viewData.Data));
         }
 
+
+        /// <summary>
+        /// 接团客户名单
+        /// 基础数据 Init
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
+        {
+
+            #region  参数验证
+            if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
+            if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+
+            #region 页面操作权限验证
+            pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
+            #endregion
+
+            #endregion
+
+            var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
+            if (viewData.Code != 0)
+            {
+                return Ok(JsonView(false, viewData.Msg));
+            }
+
+            return Ok(JsonView(viewData.Data));
+        }
+
         /// <summary>
         /// 接团客户名单
         /// 根据 Id查询 Details
@@ -5452,7 +5486,7 @@ namespace OASystem.API.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        public async Task<IActionResult> TourClientListDetails(TourClientListDetailsDto _dto)
+        public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
         {
 
             #region  参数验证
@@ -5479,6 +5513,46 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(viewData.Data));
         }
 
+        /// <summary>
+        /// 接团客户名单
+        /// 根据 Id查询 Details
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
+        {
+
+            #region  参数验证
+            if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
+            if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
+            if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+
+            #region 页面操作权限验证
+            pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            if (_dto.Id == 0) //添加
+            {
+                if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
+            }else if (_dto.Id >= 0) //修改
+            {
+                if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
+            }
+
+            #endregion
+
+            #endregion
+
+            var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
+            if (viewData.Code != 0)
+            {
+                return Ok(JsonView(false, viewData.Msg));
+            }
+
+            return Ok(JsonView(viewData.Data));
+        }
         #endregion
     }
 }

+ 53 - 22
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -108,7 +108,6 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GetWageSheetMonthWorkdaysAddOrEdit(WageSheetMonthWorkdaysAddOrEditDto dto)
         {
-
             //参数处理
             string yearFormat = "yyyy-MM";
             string dtFormat = "yyyy-MM-dd";
@@ -127,6 +126,11 @@ namespace OASystem.API.Controllers
             pm_WageIssueWorkingDay1 = _mapper.Map<Pm_WageIssueWorkingDay>(dto);
             List<Sys_Calendar> sys_Calendars = new List<Sys_Calendar>();
             sys_Calendars = _mapper.Map<List<Sys_Calendar>>(dto.CalendarInfos);
+            if (sys_Calendars.Count > 0)
+            {
+                sys_Calendars = sys_Calendars.OrderBy(it => it.Dt).ToList();
+            }
+
             pm_WageIssueWorkingDay1.Workdays = sys_Calendars.Where(it => it.IsWorkDay == true).ToList().Count();
             foreach (var item in sys_Calendars)
             {
@@ -142,13 +146,50 @@ namespace OASystem.API.Controllers
             
             try
             {
+                List<Sys_Calendar> sys_Calendars_add = new List<Sys_Calendar>();
+                List<Sys_Calendar> sys_Calendars_update = new List<Sys_Calendar>();
+                sys_Calendars_add = sys_Calendars.Where(it => it.Id == 0).OrderBy(it => it.Dt).ToList();
+                sys_Calendars_update = sys_Calendars.Where(it => it.Id != 0).OrderBy(it => it.Dt).ToList();
+
+                int add1 = 0;
+                int upd = 0;
+                if (sys_Calendars_add.Count > 0)
+                {
+                    var calendarsAdd = await _sqlSugar.Insertable(sys_Calendars_add).ExecuteReturnIdentityAsync();
+
+                    if (calendarsAdd < 0)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false, "工作日/节假日/休息日添加失败!"));
+                    }
+                }
+                if (sys_Calendars_update.Count > 0)
+                {
+                    var calendarsUpdate = await _sqlSugar.Updateable<Sys_Calendar>(sys_Calendars)
+                    .UpdateColumns(it => new { it.Dt, it.IsWorkDay, it.IsHoliDay, it.HoliName })
+                    .WhereColumns(it => it.Id)
+                    .ExecuteCommandAsync();
+                    if (calendarsUpdate < 0)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false, "工作日/节假日/休息日编辑失败!"));
+                    }
+                }
+
+                var calendarsDatas = await _sqlSugar.Queryable<Sys_Calendar>()
+                    .Where(it => Convert.ToDateTime(it.Dt) >= Convert.ToDateTime(dto.StartDate) && Convert.ToDateTime(it.Dt) <= Convert.ToDateTime(dto.EndDate)).ToListAsync();
+                if (calendarsDatas.Count < 0)
+                {
+                    _sqlSugar.RollbackTran();
+                    return Ok(JsonView(false, "日期包暂无工作日/节假日/休息日的信息!"));
+                }
                 //月份表是否存在
                 Pm_WageIssueWorkingDay pm_WageIssueWorkingDay = new Pm_WageIssueWorkingDay()
                 {
                     YearMonth = dto.YearMonth,
                     StartDate = dto.StartDate,
                     EndDate = dto.EndDate,
-                    Workdays = dto.CalendarInfos.Where(it => it.IsWorkDay == true).ToList().Count()
+                    Workdays = calendarsDatas.Where(it => it.IsWorkDay == true).ToList().Count()
                 };
 
                 string sql = string.Format("Select * From Pm_WageIssueWorkingDay Where Isdel = 0 And YearMonth='{0}'", dto.YearMonth);
@@ -159,8 +200,12 @@ namespace OASystem.API.Controllers
 
                 if (workdsys == null) //添加
                 {
-
                     int addId = await _sqlSugar.Insertable(pm_WageIssueWorkingDay).ExecuteReturnIdentityAsync();
+                    if (addId < 0)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false, "工作日设置添加失败!"));
+                    }
                 }
                 else //更新
                 {
@@ -168,25 +213,11 @@ namespace OASystem.API.Controllers
                         .IgnoreColumns(z => new { z.CreateUserId, z.CreateTime, z.DeleteUserId, z.DeleteTime, z.IsDel })
                         .WhereColumns(it => it.YearMonth)
                         .ExecuteCommandAsync();
-                }
-
-                List<Sys_Calendar> sys_Calendars_add = new List<Sys_Calendar>();
-                List<Sys_Calendar> sys_Calendars_update = new List<Sys_Calendar>();
-                sys_Calendars_add = sys_Calendars.Where(it => it.Id == 0).OrderBy(it => it.Dt).ToList();
-                sys_Calendars_update = sys_Calendars.Where(it => it.Id != 0).OrderBy(it => it.Dt).ToList();
-
-                int add1 = 0;
-                int upd = 0;
-                if (sys_Calendars_add.Count > 0)
-                {
-                    await _sqlSugar.Insertable(sys_Calendars_add).ExecuteReturnIdentityAsync();
-                }
-                if (sys_Calendars_update.Count > 0)
-                {
-                    await _sqlSugar.Updateable<Sys_Calendar>(sys_Calendars)
-                    .UpdateColumns(it => new { it.Dt, it.IsWorkDay, it.IsHoliDay, it.HoliName })
-                    .WhereColumns(it => it.Id)
-                    .ExecuteCommandAsync();
+                    if (updCount < 0)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false, "工作日设置编辑失败!"));
+                    }
                 }
 
                 _sqlSugar.CommitTran();

+ 20 - 20
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -608,26 +608,26 @@ namespace OASystem.API.OAMethodLib
                             }
 
                             #region 年假测试数据
-                            leaveDetails.Add(new LeaveDetails() { 
-                                TypeId = 1,
-                                TypeName = "年假",
-                                StartDt = Convert.ToDateTime("2023-11-21 09:00:00"),
-                                EndDt = Convert.ToDateTime("2023-11-21 12:00:00"),
-                                DtType = "halfday",
-                                Unit = "天",
-                                New_Duration = 0.50M
-                            });
-
-                            leaveDetails.Add(new LeaveDetails()
-                            {
-                                TypeId = 1,
-                                TypeName = "年假",
-                                StartDt = Convert.ToDateTime("2023-11-21 12:00:00"),
-                                EndDt = Convert.ToDateTime("2023-11-23 18:00:00"),
-                                DtType = "halfday",
-                                Unit = "天",
-                                New_Duration = 2.50M
-                            });
+                            //leaveDetails.Add(new LeaveDetails() { 
+                            //    TypeId = 1,
+                            //    TypeName = "年假",
+                            //    StartDt = Convert.ToDateTime("2023-11-21 09:00:00"),
+                            //    EndDt = Convert.ToDateTime("2023-11-21 12:00:00"),
+                            //    DtType = "halfday",
+                            //    Unit = "天",
+                            //    New_Duration = 0.50M
+                            //});
+
+                            //leaveDetails.Add(new LeaveDetails()
+                            //{
+                            //    TypeId = 1,
+                            //    TypeName = "年假",
+                            //    StartDt = Convert.ToDateTime("2023-11-21 12:00:00"),
+                            //    EndDt = Convert.ToDateTime("2023-11-23 18:00:00"),
+                            //    DtType = "halfday",
+                            //    Unit = "天",
+                            //    New_Duration = 2.50M
+                            //});
 
 
                             #endregion

+ 0 - 30
OASystem/OASystem.Domain/DateOnlyConverter.cs

@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Text.Json;
-using System.Threading.Tasks;
-
-namespace OASystem.Domain
-{
-    /// <summary>
-    /// datetime 返回日期 格式 yyyy-MM-dd
-    /// </summary>
-    public class DateOnlyConverter : JsonConverter<DateTime>
-    {
-        public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
-        {
-            throw new NotImplementedException();
-        }
-
-        public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
-        {
-            writer.WriteStringValue(value.ToString("yyyy-MM-dd"));
-        }
-    }
-
-
-
-}
-

+ 116 - 0
OASystem/OASystem.Domain/Dtos/Groups/TourClientListDto.cs

@@ -23,6 +23,12 @@ namespace OASystem.Domain.Dtos.Groups
         public int DiId { get; set; }
     }
 
+    /// <summary>
+    /// 接团客户名单
+    /// 基础数据 Dto
+    /// </summary>
+    public class TourClientListBasicDataInitDto : UserPageFuncDtoBase { }
+
     /// <summary>
     /// 接团客户名单
     /// 根据Id 查询 Details
@@ -31,4 +37,114 @@ namespace OASystem.Domain.Dtos.Groups
     {
         public int Id { get; set; }
     }
+
+    /// <summary>
+    /// 接团客户名单
+    /// Add Or Edit
+    /// </summary>
+    public class TourClientListAddOrEditDto : UserPageFuncDtoBase
+    {
+        /// <summary>
+        /// 数据Id
+        /// Id==0 Add Id>0 Update Id<0 无效
+        /// </summary>
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 姓
+        /// </summary>
+        public string? LastName { get; set; }
+
+        /// <summary>
+        /// 名
+        /// </summary>
+        public string? FirstName { get; set; }
+
+        /// <summary>
+        /// 姓名拼音
+        /// 姓/名 eg: LEI/YI
+        /// </summary>
+        public string? Pinyin { get; set; }
+
+        /// <summary>
+        /// 性别
+        /// 0 男1 女 其他值 未设置
+        /// </summary>
+        public int Sex { get; set; }
+
+        /// <summary>
+        /// 公司名全称
+        /// </summary>
+        public string? CompanyFullName { get; set; }
+
+        /// <summary>
+        /// 职位
+        /// </summary>
+        public string? Job { get; set; }
+
+        /// <summary>
+        /// 身份证No
+        /// </summary>
+        public string? IDCardNo { get; set; }
+
+        /// <summary>
+        /// 生日
+        /// </summary>
+        public string? BirthDay { get; set; }
+
+        /// <summary>
+        /// 护照类型Id(数据类型表Id)
+        /// </summary>
+        public int PassportType { get; set; }
+
+        /// <summary>
+        /// 护照No
+        /// </summary>
+        public string? PassportNo { get; set; }
+
+        /// <summary>
+        /// 签发国
+        /// </summary>
+        public string? Country { get; set; }
+
+        /// <summary>
+        /// 签发地区
+        /// </summary>
+        public string? Area { get; set; }
+
+        /// <summary>
+        /// 签发时间
+        /// </summary>
+        public string? IssueDt { get; set; }
+
+        /// <summary>
+        /// 有效期限
+        /// </summary>
+        public string? ExpiryDt { get; set; }
+
+        /// <summary>
+        /// 舱位类型(数据类型表Id)
+        /// </summary>
+        public int ShippingSpaceTypeId { get; set; }
+
+        /// <summary>
+        /// 舱位特殊需求
+        /// </summary>
+        public string? ShippingSpaceSpecialNeeds { get; set; }
+
+        /// <summary>
+        /// 酒店特殊需求
+        /// </summary>
+        public string? HotelSpecialNeeds { get; set; }
+
+        /// <summary>
+        /// 餐食特殊需求
+        /// </summary>
+        public string? MealSpecialNeeds { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? Remark { get; set; }
+    }
 }

+ 3 - 4
OASystem/OASystem.Domain/ViewModels/Groups/TourClientListView.cs

@@ -138,8 +138,7 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 生日
         /// </summary>
-        [JsonConverter(typeof(DateOnlyConverter))]
-        public DateTime BirthDay { get; set; }
+        public string? BirthDay { get; set; }
 
         /// <summary>
         /// 护照类型Id(数据类型表Id)
@@ -164,12 +163,12 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// 签发时间
         /// </summary>
-        public DateTime? IssueDt { get; set; }
+        public string? IssueDt { get; set; }
 
         /// <summary>
         /// 有效期限
         /// </summary>
-        public DateTime? ExpiryDt { get; set; }
+        public string? ExpiryDt { get; set; }
 
         /// <summary>
         /// 舱位类型(数据类型表Id)

+ 82 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -2,6 +2,7 @@
 using OASystem.Domain;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Infrastructure.Tools;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -56,6 +57,38 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return _result;
         }
 
+        /// <summary>
+        /// 基础数据 Init
+        /// </summary>
+        /// <param name="portId"></param>
+        /// <returns></returns>
+        public async Task<Result> _BasicDataInit(int portId)
+        {
+            if (portId == 1 || portId == 2 || portId == 3) // 1 web 2 Android 3 ios
+            {
+                
+                var setData = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0) .ToListAsync();
+
+                var shippingSpaceTypeData = setData.Where(it => it.STid == 44).ToList(); //舱位类型
+                List<SetDataInfoView> _ShippingSpaceTypeData = _mapper.Map<List<SetDataInfoView>>(shippingSpaceTypeData);
+
+                var passportTypeData = setData.Where(it => it.STid == 74).ToList(); //护照类型
+                List<SetDataInfoView> _PassportTypeData = _mapper.Map<List<SetDataInfoView>>(passportTypeData);
+
+                var _view = new {
+                    ShippingSpaceTypeData = _ShippingSpaceTypeData,
+                    PassportTypeData = _PassportTypeData
+                };
+                _result.Code = 0;
+                _result.Data = _view;
+            }
+            else
+            {
+                _result.Msg = "请传入有效的PortType参数,1 Web 2 Android 3 IOS!";
+            }
+            return _result;
+        }
+
         /// <summary>
         /// 根据Id查询Details
         /// </summary>
@@ -81,8 +114,55 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                              On temp.DcId =tcl.ClientId  
                                              Where tcl.IsDel = 0 And tcl.Id = {0}", id);
                 var data = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).FirstAsync();
-                _result.Code = 0;
-                _result.Data = data;
+                if (data != null) 
+                {
+                    data.BirthDay = data.BirthDay.DateFormat("yyyy-MM-dd");
+                    data.IssueDt = data.IssueDt.DateFormat("yyyy-MM-dd");
+                    data.ExpiryDt = data.ExpiryDt.DateFormat("yyyy-MM-dd");
+                    _result.Code = 0;
+                    _result.Data = data;
+                }
+            }
+            else
+            {
+                _result.Msg = "请传入有效的PortType参数,1 Web 2 Android 3 IOS!";
+            }
+            return _result;
+        }
+
+        /// <summary>
+        /// Add Or Edit
+        /// </summary>
+        /// <param name="portId"></param>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<Result> _AddOrEdit(int portId, int id)
+        {
+            if (portId == 1 || portId == 2 || portId == 3) // 1 web 2 Android 3 ios
+            {
+                string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
+                                             tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
+                                             From Grp_TourClientList tcl
+                                             Left Join 
+	                                             (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
+	                                                 cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
+	                                                 cc2.Area,cc2.IssueDt,cc2.ExpiryDt
+	                                                 From Crm_DeleClient dc
+	                                                 Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id  And ccom.IsDel = 0
+	                                                 Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
+	                                                 Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
+	                                                 Where dc.IsDel = 0) temp 
+                                             On temp.DcId =tcl.ClientId  
+                                             Where tcl.IsDel = 0 And tcl.Id = {0}", id);
+                var data = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).FirstAsync();
+                if (data != null)
+                {
+                    data.BirthDay = data.BirthDay.DateFormat("yyyy-MM-dd");
+                    data.IssueDt = data.IssueDt.DateFormat("yyyy-MM-dd");
+                    data.ExpiryDt = data.ExpiryDt.DateFormat("yyyy-MM-dd");
+                    _result.Code = 0;
+                    _result.Data = data;
+                }
             }
             else
             {

+ 31 - 0
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -1,5 +1,6 @@
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
+using System.Globalization;
 using System.Reflection.Metadata;
 
 namespace OASystem.Infrastructure.Tools;
@@ -378,4 +379,34 @@ public static class CommonFun
         return regex.IsMatch(idNumber);
     }
     #endregion
+
+    #region string格式日期格式化
+
+    /// <summary>
+    /// string格式日期格式化
+    /// </summary>
+    /// <param name="dateStr"></param>
+    /// <param name="format">
+    /// 格式化标准
+    /// yyyy-MM-dd  yyyy/MM/dd
+    /// </param>
+    /// <returns></returns>
+    public static string DateFormat(this string dateStr, string format)
+    {
+        if (!string.IsNullOrEmpty(dateStr))
+        {
+            if (!string.IsNullOrEmpty(format))
+            {
+                DateTime result;
+                if (DateTime.TryParse(dateStr, out result))
+                {
+                    return result.ToString(format);
+                }
+            }
+        }
+
+        return "";
+    }
+
+    #endregion
 }