소스 검색

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 년 전
부모
커밋
c53f82db38

+ 230 - 24
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -65,6 +65,8 @@ using static NPOI.POIFS.Crypt.CryptoFunctions;
 using Aspose.Words.Lists;
 using OASystem.API.OAMethodLib.YouDaoAPI;
 using NPOI.XSSF.Streaming.Values;
+using OASystem.API.OAMethodLib.Quartz.Business;
+using System.Linq;
 
 namespace OASystem.API.Controllers
 {
@@ -1346,6 +1348,14 @@ namespace OASystem.API.Controllers
 
                 var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
 
+
+                /*
+                 * 车/导游地接 费用类型
+                 */
+                var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
+
+                var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
+
                 /*
                  * 用户信息
                  */
@@ -1475,7 +1485,33 @@ namespace OASystem.API.Controllers
                                 }
 
 
-                                _detail.PriceNameContent = touristGuideGroundReservations.Area;
+                                bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
+
+                                if (isInt)
+                                {
+                                    var cityInfo = cityData.Find(it => it.Id == cityId);
+                                    if (cityInfo != null)
+                                    {
+                                        string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
+
+                                        var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
+                                        if (carFeeItem != null )
+                                        {
+                                            nameContent += $@"({carFeeItem.Name})";
+                                        }
+                                        _detail.PriceNameContent = nameContent;
+
+                                    }
+                                }
+                                else
+                                {
+                                    _detail.PriceNameContent = touristGuideGroundReservations.Area;
+                                }
+
+                                
+
+
+                                
 
                                 List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
                                     .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
@@ -4232,18 +4268,20 @@ namespace OASystem.API.Controllers
 
                         //总计
                         decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
-                        
+
                         //国际旅费
 
                         string outsideJJ = "";
                         string allPriceJJ = "";
-                        if (_EnterExitCosts.SumJJC == 1) {
+                        if (_EnterExitCosts.SumJJC == 1)
+                        {
                             outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
                             allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
                         }
                         string outsideGW = "";
                         string allPriceGW = "";
-                        if (_EnterExitCosts.SumGWC == 1) {
+                        if (_EnterExitCosts.SumGWC == 1)
+                        {
                             outsideGW = string.Format(@"公务舱:{0}    元/人", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
                             allPriceGW = string.Format(@"公务舱:{0}   元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
                         }
@@ -4493,6 +4531,186 @@ namespace OASystem.API.Controllers
                         string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
                         return Ok(JsonView(true, "成功", new { Url = url }));
                     }
+                    else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
+                    {
+                        //获取模板
+                        string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
+                        //载入模板
+                        Document doc = new Document(tempPath);
+
+                        DocumentBuilder builder = new DocumentBuilder(doc);
+
+                        Dictionary<string, string> dic = new Dictionary<string, string>();
+
+                        dic.Add("GroupName", _DelegationInfo.TeamName);
+                        dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
+
+                        string missionLeader = "";  //团负责人默认接团客户名单第一个人
+                        string missionLeaderJob = "";//负责人job
+                        int groupNumber = 0; //团人数
+                        if (DeleClientList.Count > 0)
+                        {
+                            missionLeader = DeleClientList[0]?.Name ?? "";
+                            missionLeaderJob = DeleClientList[0]?.Job ?? "";
+                        }
+                        dic.Add("MissionLeader", missionLeader); //团负责人
+                        dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
+                        dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
+
+
+                        #region MyRegion
+                        //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
+                        //{
+                        //    List<string> list = new List<string>();
+                        //    try
+                        //    {
+                        //        var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
+                        //        foreach (var item in spilitArr)
+                        //        {
+                        //            var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
+                        //            var depCode = spDotandEmpty[2].Substring(0, 3);
+                        //            var arrCode = spDotandEmpty[2].Substring(3, 3);
+                        //            string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
+                        //                   arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
+
+                        //            list.Add(depName);
+                        //            list.Add(arrName);
+                        //        }
+
+                        //        list = list.Distinct().ToList();
+                        //        dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
+                        //    }
+                        //    catch (Exception)
+                        //    {
+                        //        dic.Add("ReturnCode", "行程录入不正确!");
+                        //    }
+                        //}
+                        //else
+                        //{
+                        //    dic.Add("ReturnCode", "未录入行程!");
+                        //}
+
+                        List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
+                        dic.Add("ReturnCode", string.Join( "、", countrys));
+                        #endregion
+
+
+                        //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
+                        //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
+                        //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
+
+                        //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
+                        //{
+                        //    TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
+                        //    dic.Add("Day", sp.Days.ToString());
+
+                        //}
+                        dic.Add("Day", _DelegationInfo.VisitDays.ToString());
+
+                        dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
+                                                                     // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
+
+                        NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
+                        Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
+
+                        //培训人员名单
+                        int cultivateRowIndex = 7;
+                        foreach (var item in DeleClientList)
+                        {
+                            builder.MoveToCell(0, cultivateRowIndex, 0, 0);
+                            builder.Write(item.Name);
+                            builder.MoveToCell(0, cultivateRowIndex, 1, 0);
+                            builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
+
+                            builder.MoveToCell(0, cultivateRowIndex, 2, 0);
+
+                            string birthDay = "";
+                            if (item.Birthday != null)
+                            {
+                                DateTime dt = Convert.ToDateTime(item.Birthday);
+                                birthDay = $"{dt.Year}.{dt.Month}";
+                            }
+                            builder.Write(birthDay);
+
+                            builder.MoveToCell(0, cultivateRowIndex, 3, 0);
+                            builder.Write(item.Company);
+
+                            builder.MoveToCell(0, cultivateRowIndex, 4, 0);
+                            builder.Write(item.Job);
+
+                            cultivateRowIndex++;
+                        }
+
+                        //删除多余行
+                        //cultivateRowIndex -= 2;
+                        int delRows = 10 + 7  - cultivateRowIndex;
+                        if (delRows > 0)
+                        {
+                            for (int i = 0; i < delRows; i++)
+                            {
+
+                                table1.Rows.RemoveAt(cultivateRowIndex);
+                                //cultivateRowIndex++;
+                            }
+                        }
+
+                        decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
+                        dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
+                        decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
+                        dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
+                        decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
+                        dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
+                        decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
+                        dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
+                        decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
+                        dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
+                        //其他费用
+                        decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan+ _EnterExitCosts.Service;
+                        dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
+
+                        //其他费用合计
+                        decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
+
+                        decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
+                        decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
+                       
+                        //公务舱合计
+
+                        //国际旅费
+
+                        string outsideJJ = "";
+                        string allPriceJJ = "";
+                        if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
+                        {
+                            dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
+                            dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
+                        }
+                        if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
+                        {
+                            dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
+                            dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
+                        }
+
+                        if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
+                        {
+                            string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
+                            dic.Add("AirFeeTotal", airFeeTotalStr);
+                            string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
+                            dic.Add("FeeTotal", feeTotalStr);
+                        }
+
+                        foreach (var key in dic.Keys)
+                        {
+                            builder.MoveToBookmark(key);
+                            builder.Write(dic[key]);
+                        }
+
+                        //模板文件名
+                        string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
+                        doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
+                        string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
+                        return Ok(JsonView(true, "成功", new { Url = url }));
+                    }
                 }
                 else if (dto.ExportType == 2) //表格
                 {
@@ -10258,13 +10476,9 @@ namespace OASystem.API.Controllers
                             if (clientInfo == null)
                             {
 
-
-                                string format1 = "yyyy-MM-dd";
-
-                                string data111 = "1990-01-01";
-
-                                var data11_1 = IsValidDate(item.Birthday, format1);
-                                if (data11_1) data111 = item.OPdate;
+                                DateTime? dateTime = null;
+                                var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
+                                if (isDt) dateTime = birthDayDt;
 
                                 var addInfo1 = new Crm_DeleClient()
                                 {
@@ -10278,8 +10492,7 @@ namespace OASystem.API.Controllers
                                     Marriage = 0,
                                     Phone = item.Phone,
                                     Job = item.Job,
-                                    BirthDay = Convert.ToDateTime(data111).ToString("yyyy-MM-dd"),
-
+                                    BirthDay = dateTime
 
                                 };
 
@@ -10864,8 +11077,8 @@ namespace OASystem.API.Controllers
             dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
             dic.Add("SQRemark", info1.ApprovalRemark);
 
-            dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
-            dic.Add("CPJRemark", info1.ApprovalRemark);
+            dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
+            dic.Add("CPJRemark", info1.IssueApprovalRemark);
 
             //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
             //dic.Add("HZRemark", info1.ApplyPassportRemark);
@@ -10912,16 +11125,9 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> ChangeDataBase_Offi(PostTourClientListDownloadFile _dto)
+        public async Task<IActionResult> Test_SendMsg(PostTourClientListDownloadFile _dto)
         {
-            _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
-
-            string sqlOld = string.Format(@" Select * From AirTicketReservations With(nolock) ");
-
-            List<oa2021_AirTicketReservations> listOld = _airTicketResRep._sqlSugar.SqlQueryable<oa2021_AirTicketReservations>(sqlOld).ToList();
-
-
-            _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
+            DeleReminderMessage.PostMessageByWebhook();
 
             return Ok(JsonView(true, "操作成功!"));
         }

+ 3 - 1
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -584,6 +584,9 @@ namespace OASystem.API.Controllers
                             if (m_EnName.Success || m_ZHName.Success)
                             {
                                 itemClientName = item.ClientName;
+
+                                decimal unitCost = 0.00M;
+                                AirCNYTotalPrice += item.CNYPrice;
                                 continue;
                             }
 
@@ -663,7 +666,6 @@ namespace OASystem.API.Controllers
                                         });
                                     }
 
-
                                     //if (name.Length > 0)
                                     //{
                                     //    string nameLastStr = name[name.Length - 1].ToString();

+ 3 - 3
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/QiYeWeChatApiService.cs

@@ -1298,17 +1298,17 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI
         public async Task<ResponseBase> RobotSendMsg_GroupInfo(string msg)
         {
             string key = "b4fe152f-a97a-48b1-830f-ab447f6d2f5f";
-            string url = string.Format("/webhook/send?key={0}", key);
+            string url = string.Format("/cgi-bin/webhook/send?key={0}", key);
 
             RobotSendMsg_GroupInfo_Content contentStr = new RobotSendMsg_GroupInfo_Content() { content = msg };
 
-            RobotSendMsg_GroupInfo reqJson = new RobotSendMsg_GroupInfo()
+            RobotSendMsg_GroupInfo_Param reqJson = new RobotSendMsg_GroupInfo_Param()
             {
                 msgtype = "markdown",
                 markdown = contentStr
             };
 
-            var json = System.Text.Json.JsonSerializer.Serialize(RobotSendMsg_GroupInfo);
+            var json = System.Text.Json.JsonSerializer.Serialize(reqJson);
             var content = new StringContent(json, Encoding.UTF8, "application/json");
             var create_Req = await _httpClient.PostAsync(url, content);
             var stringResponse = await create_Req.Content.ReadAsStringAsync();

+ 12 - 7
OASystem/OASystem.Api/OAMethodLib/Quartz/Business/DeleReminderMessage.cs

@@ -1,4 +1,5 @@
 using OASystem.API.OAMethodLib.ALiYun;
+using OASystem.API.OAMethodLib.QiYeWeChatAPI;
 using OASystem.Domain.Dtos.Business;
 using OASystem.Domain.Entities.Business;
 using OASystem.Domain.Entities.Groups;
@@ -12,6 +13,7 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
     public static class DeleReminderMessage
     {
         private readonly static DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
+        private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
 
         /// <summary>
         /// 检查团组结束日期,将当天和2天后的团组整理并发送短信提醒
@@ -100,24 +102,27 @@ namespace OASystem.API.OAMethodLib.Quartz.Business
                 List<Grp_DelegationInfo> listAdd7day = list_source.Where(s => s.VisitStartDate.Equals(add7day)).ToList();
                 List<Grp_DelegationInfo> listAdd2day = list_source.Where(s => s.VisitEndDate.Equals(add2day)).ToList();
                 string dayStr = dtNow.ToString("yyyy年MM月dd日");
-                string content = string.Format(@" 今天是{0},\n ");
+                string content = string.Format(@" 今天是{0},\n ", dayStr);
 
                 if (listAdd7day.Count > 0)
                 {
-                    
-                    string tempStr1 = string.Format(@" 检查到7天后开始的团组数量: <font color='warning'>{1}</font>\n ", dayStr,listAdd7day.Count);
-                    listAdd7day.ForEach(s => tempStr1 += string.Format(@"> {0}", s.TeamName));
+
+                    string tempStr1 = string.Format(@" \n\n检查到7天后开始的团组数量: <font color='warning'>** {1} **</font>\n ", dayStr, listAdd7day.Count);
+                    listAdd7day.ForEach(s => tempStr1 += string.Format(@">{0} \n", s.TeamName));
                     content += tempStr1;
                 }
 
                 if (listAdd2day.Count > 0)
                 {
-                    string tempStr2 = string.Format(@" 检查到3天后结束的团组数量: <font color='warning'>{1}</font>\n ", dayStr, listAdd2day.Count);
-                    listAdd7day.ForEach(s => tempStr2 += string.Format(@"> {0}", s.TeamName));
+                    string tempStr2 = string.Format(@" \n\n检查到3天后结束的团组数量: <font color='info'>** {1} **</font>\n ", dayStr, listAdd2day.Count);
+                    listAdd7day.ForEach(s => tempStr2 += string.Format(@">{0} \n", s.TeamName));
                     content += tempStr2;
                 }
 
-                content += string.Format(@"");
+                content += string.Format(@"\n\n请注检查合同、款项等信息");
+
+
+                OASystem.Domain.ViewModels.QiYeWeChat.ResponseBase result = await _qiYeWeChatApiService.RobotSendMsg_GroupInfo(content);
             }
         }
     }

+ 1 - 1
OASystem/OASystem.Domain/Dtos/Groups/TourClientListDto.cs

@@ -75,7 +75,7 @@ namespace OASystem.Domain.Dtos.Groups
 
         /// <summary>
         /// 性别
-        /// 0 男1 女 其他值 未设置
+        /// 0 男1 女 -1 未设置
         /// </summary>
         public int Sex { get; set; }
 

+ 1 - 1
OASystem/OASystem.Domain/Dtos/QiYeWeChat/ApprovalData_Request.cs

@@ -108,7 +108,7 @@ namespace OASystem.Domain.Dtos.QiYeWeChat
 
     }
 
-    public class RobotSendMsg_GroupInfo
+    public class RobotSendMsg_GroupInfo_Param
     {
         public string msgtype { get; set; } = "markdown";
 

+ 2 - 2
OASystem/OASystem.Domain/Entities/Customer/Crm_DeleClient.cs

@@ -67,8 +67,8 @@ namespace OASystem.Domain.Entities.Customer
         /// <summary>
         /// 出生日期
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "DateTime")]
-        public string BirthDay { get; set; }
+        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
+        public DateTime? BirthDay { get; set; } = null;
 
         /// <summary>
         /// 机票喜好舱位

+ 8 - 1
OASystem/OASystem.Infrastructure/Repositories/CRM/VisaDeleClientRepository.cs

@@ -183,6 +183,13 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 else if (dto.Status == 2)//修改
                 {
                     deleId=dto.DeleClient.Id;
+
+                    DateTime? dateTime = null;
+                    bool isDt = DateTime.TryParse(dto.DeleClient.BirthDay, out DateTime dt);
+
+                    if (isDt) dateTime = dt;
+
+
                     bool res = await UpdateAsync(a => a.Id == dto.DeleClient.Id, a => new Crm_DeleClient
                     {
                         DiId = dto.DeleClient.DiId,
@@ -195,7 +202,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                         Phone = dto.DeleClient.Phone,
                         BirthProvince = dto.DeleClient.BirthProvince,
                         BirthCity = dto.DeleClient.BirthCity,
-                        BirthDay = dto.DeleClient.BirthDay,
+                        BirthDay = dateTime,
                         AirType = dto.DeleClient.AirType,
                         SeatPref = dto.DeleClient.SeatPref,
                         AirRemark = dto.DeleClient.AirRemark,

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

@@ -391,7 +391,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                             param.IDCardNo = clientIDInfo.CertNo;
                             param.Remark = item.Remark;
-                            param.BirthDay = DateTime.TryParse(clientInfo.BirthDay, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
+                            param.BirthDay = clientInfo.BirthDay == null ? "" : DateTime.TryParse(Convert.ToDateTime( clientInfo.BirthDay).ToString("yyyy-MM-dd"), out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
                             param.FirstName = clientInfo.FirstName;
                             param.LastName = clientInfo.LastName;
                             param.CompanyFullName = Company.CompanyFullName;
@@ -437,7 +437,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                             param.IDCardNo = clientIDInfo.CertNo;
                             param.Remark = item.Remark;
-                            param.BirthDay = DateTime.TryParse(clientInfo.BirthDay, out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
+                            param.BirthDay = clientInfo.BirthDay == null ? "" : DateTime.TryParse(Convert.ToDateTime(clientInfo.BirthDay).ToString("yyyy-MM-dd"), out timeParam) ? timeParam.ToString("yyyy-MM-dd") : "";
                             param.FirstName = clientInfo.FirstName;
                             param.LastName = clientInfo.LastName;
                             param.CompanyFullName = Company.CompanyFullName;

+ 38 - 5
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -227,6 +227,40 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     CreateUserId = dto.UserId
                 };
 
+                string idNo = "", birthDay = "";
+                int sex = -1;
+                #region 身份证验证 
+
+                if (!string.IsNullOrEmpty(dto.IDCardNo))
+                {
+                    
+                    var idBool = dto.IDCardNo.IsValidChineseId();
+                    if (idBool)
+                    {
+                        idNo = dto.IDCardNo;
+                        DateTime? birthDayDt = CommonFun.GetBirthDateFromIdentityCard(dto.IDCardNo);
+                        if (birthDayDt != null)
+                        {
+                            birthDay = birthDayDt?.ToString("yyyy-MM-dd") ?? "";
+                        }
+
+                        sex = CommonFun.GetGenderFromIdentityCard(dto.IDCardNo);
+                    }
+
+
+                    #region dto重新赋值
+
+                    if (string.IsNullOrEmpty(dto.BirthDay)) dto.BirthDay = birthDay;
+                    if (dto.Sex < 0) dto.Sex = sex;
+
+                    #endregion
+
+                }
+
+
+                #endregion
+
+
                 Crm_CustomerCert _CustomerCert = new Crm_CustomerCert()
                 {
                     SdId = 773,
@@ -241,7 +275,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     Pinyin = dto.Pinyin,
                     Phone = dto.Phone,
                     Sex = dto.Sex,
-                    BirthDay = dto.BirthDay,
+                    BirthDay = dto.BirthDay == null ? null : Convert.ToDateTime(dto.BirthDay),
                     Job = dto.Job,
                     CreateUserId = dto.UserId
                 };
@@ -468,7 +502,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return _result;
         }
 
-
         /// <summary>
         /// AddMultiple
         /// 添加多个
@@ -540,7 +573,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         Job = item.Job,
                         Sex = item.Sex,
                         Phone = item.Phone,
-                        BirthDay = item.BirthDay,
+                        BirthDay = item.BirthDay == null ? null : Convert.ToDateTime(item.BirthDay),
                     };
                     var clientAdd = await _sqlSugar.Insertable(_DeleClientInfo).ExecuteReturnIdentityAsync();
                     if (clientAdd < 0)
@@ -603,7 +636,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         Pinyin = item.Pinyin,
                         Sex = item.Sex,
                         Phone = item.Phone,
-                        BirthDay = item.BirthDay
+                        BirthDay = item.BirthDay == null ? null : Convert.ToDateTime(item.BirthDay)
                     };
                     var clientEdit = await _sqlSugar.Updateable(_DeleClient).UpdateColumns(it =>
                                                                                  new
@@ -717,7 +750,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         Pinyin = item.Pinyin,
                         Phone = item.Phone,
                         Sex = item.Sex,
-                        BirthDay = item.BirthDay,
+                        BirthDay = item.BirthDay == null ? null : Convert.ToDateTime(item.BirthDay),
                         Job = item.Job,
                         CreateUserId = userId
                     };

+ 44 - 2
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -380,12 +380,54 @@ public static class CommonFun
     /// </summary>
     /// <param name="idNumber"></param>
     /// <returns></returns>
-    public static bool ValidateIdNumber(this string idNumber)
+    public static bool IsValidChineseId(this string idNumber)
     {
-        string pattern = @"^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|X)$";
+        string pattern = @"^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$";
         Regex regex = new Regex(pattern);
         return regex.IsMatch(idNumber);
     }
+
+    /// <summary>
+    /// 通过身份证提取生日
+    /// </summary>
+    /// <param name="identityCard"></param>
+    /// <returns></returns>
+    public static DateTime? GetBirthDateFromIdentityCard(string identityCard)
+    {
+        // 身份证号码正则表达式验证,支持18位身份证号码
+        if (!Regex.IsMatch(identityCard, @"^\d{17}(\d|X|x)$"))
+        {
+            return null;
+        }
+
+        // 获取出生日期(8位数字)
+        string birthDateString = identityCard.Substring(6, 8);
+
+        // 尝试将出生日期字符串转换为DateTime类型
+        if (DateTime.TryParse(birthDateString, out DateTime birthDate))
+        {
+            return birthDate;
+        }
+
+        return null;
+    }
+
+    /// <summary>
+    /// 通过身份证判断性别
+    /// </summary>
+    /// <param name="idNumber"></param>
+    /// <returns>0 男1 女 -1 未设置</returns>
+    /// <exception cref="ArgumentException"></exception>
+    public static int GetGenderFromIdentityCard(string idNumber)
+    {
+        if (string.IsNullOrEmpty(idNumber) || idNumber.Length != 18)
+            return -1;
+
+        char genderChar = idNumber[16];
+        return int.Parse(genderChar.ToString()) % 2 == 0 ? 1 :0;
+    }
+
+
     #endregion
 
     #region string格式日期格式化