ソースを参照

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

jiangjc 2 年 前
コミット
c4f6d6a03b

+ 4 - 5
OASystem/OASystem.Api/Controllers/AuthController.cs

@@ -98,10 +98,11 @@ namespace OASystem.API.Controllers
                 AnnouncementUnReadCount = announcementUnReadCount
             };
 
+
             DateTime createZebraTime = DateTime.Now;
             string authorId = dto.Number + "Token";
             string authorToken = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(authorId);//string 取
-            if (authorToken !=  null)
+            if (authorToken != null)
             {
                 #region 解析出过期时间
                 var jwtHandler = new JwtSecurityTokenHandler();
@@ -112,7 +113,7 @@ namespace OASystem.API.Controllers
                 if (expDt >= createZebraTime)  //超时重新获取token
                 {
                     //authorToken = await GeneralMethod.GetToken(_config, dto.Number, uId,uName, createZebraTime);
-                    authorToken = await JwtHelper.IssueJwtAsync(new TokenModelJwt() { UserId = uId, UserName = uName,Role = role }); //
+                    authorToken = await JwtHelper.IssueJwtAsync(new TokenModelJwt() { UserId = uId, UserName = uName, Role = role }); //
                 }
 
                 view.Expires = expDt;
@@ -122,11 +123,9 @@ namespace OASystem.API.Controllers
             {
                 view.Expires = createZebraTime.AddMinutes(30);
                 //view.Token = await GeneralMethod.GetToken(_config, dto.Number, uId, uName, createZebraTime); //JwtHelper
-                view.Token = await JwtHelper.IssueJwtAsync(new TokenModelJwt (){ UserId = uId,UserName = uName,Role = role }); //
+                view.Token = await JwtHelper.IssueJwtAsync(new TokenModelJwt() { UserId = uId, UserName = uName, Role = role }); //
                 TimeSpan ts = view.Expires.AddMinutes(-1) - createZebraTime; //设置redis 过期时间 比 jwt 时间 快一分钟
                 await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>(authorId, view.Token, ts);//string 存
-
-
             }
 
             //#region 添加登录用户上线信息

+ 37 - 18
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -5485,26 +5485,32 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
         {
-            try
+            _sqlSugar.BeginTran();
+
+            var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
+
+            if (!res)
             {
-                var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
-                if (!res)
-                {
-                    return Ok(JsonView(false, "删除失败"));
-                }
-                var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
-                {
-                    IsDel = 1,
-                    DeleteUserId = dto.DeleteUserId,
-                    DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
-                }).ExecuteCommandAsync();
-                return Ok(JsonView(true, "删除成功!"));
+                _sqlSugar.RollbackTran();
+                return Ok(JsonView(false, "删除失败"));
             }
-            catch (Exception ex)
+
+            var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                                  .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
+                                  .SetColumns(a => new Grp_CreditCardPayment()
+                                  {
+                                      IsDel = 1,
+                                      DeleteUserId = dto.DeleteUserId,
+                                      DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                                  }).ExecuteCommand();
+            if (resSub < 1)
             {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
+                _sqlSugar.RollbackTran();
+                return Ok(JsonView(false, "删除失败"));
             }
+            _sqlSugar.CommitTran();
+            return Ok(JsonView(true, "删除成功!"));
+
         }
         /// <summary>
         /// 签证费用录入下拉框初始化
@@ -7098,6 +7104,14 @@ namespace OASystem.API.Controllers
             var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
             var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
             var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
+            groupCostMap = groupCostMap.Select(x =>
+            {
+                if (DateTime.TryParse(x.Date, out DateTime dataForamt))
+                {
+                    x.Date = dataForamt.ToString("yyyy-MM-dd");
+                }
+                return x;
+            }).ToList();
 
             //GroupCostParameter.Add(new
             //     Grp_GroupCostParameter());
@@ -11188,7 +11202,12 @@ namespace OASystem.API.Controllers
                     builder.Write(birthDayStr);
 
                     builder.MoveToCell(0, i + 1, 3, 0);
-                    builder.Write(DcList[i].CompanyFullName);
+                    string company = "";
+                    if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
+                    {
+                        company = DcList[i].CompanyFullName.ToString();
+                    }
+                    builder.Write(company);
 
                     builder.MoveToCell(0, i + 1, 4, 0);
                     builder.Write(DcList[i].Job);
@@ -11232,7 +11251,7 @@ namespace OASystem.API.Controllers
                     string company = "";
                     try
                     {
-                        if (!string.IsNullOrEmpty(DcList[i].CompanyFullName.ToString()))
+                        if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
                         {
                             //查询对照表
                             Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));

+ 319 - 89
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -4,6 +4,7 @@ using OASystem.API.OAMethodLib;
 using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
 using Org.BouncyCastle.Utilities;
 using Quartz.Util;
@@ -649,7 +650,7 @@ namespace OASystem.API.Controllers
 
         #region 酒店资料数据
         /// <summary>
-        /// 酒店信息查询
+        /// 酒店信息查询 Page
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -657,28 +658,98 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
         {
-            try
-            {
+            string sqlWhere = string.Empty;
+            if (!string.IsNullOrWhiteSpace(dto.Name))
+            {
+                sqlWhere += string.Format(@" And hd.Name like '%{0}%'", dto.Name);
+            }
+            if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
+            {
+                sqlWhere += string.Format(@" And hd.City like '%{0}%'", dto.City);
+            }
+            if (!string.IsNullOrWhiteSpace(dto.Contact))
+            {
+                sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", dto.Contact);
+            }
+            if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
+            {
+                sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", dto.ContactPhone);
+            }
+            sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
+            if (!string.IsNullOrEmpty(sqlWhere.Trim()))
+            {
+                Regex r = new Regex("And");
+                sqlWhere = r.Replace(sqlWhere, "Where", 1);
+            }
+
+            string sql = string.Format(@"SELECT
+                                           *
+                                         FROM
+                                           (
+                                             SELECT
+                                               ROW_NUMBER() OVER (
+                                                 ORDER BY
+                                                   hd.CreateTime DESC
+                                               ) AS Row_Number,
+                                               hd.Id,
+                                               hd.City,
+                                               hd.[Name],
+                                               hd.Tel,
+                                               hd.Fax,
+                                               hd.Contact,
+                                               hd.ContactPhone,
+                                               u.CnName AS CreateUserName,
+                                               hd.CreateTime
+                                             FROM
+                                               Res_HotelData hd
+                                             WITH
+                                               (NoLock)
+                                               LEFT JOIN Sys_Users u
+                                             WITH
+                                               (NoLock) ON hd.CreateUserId = u.Id {0} 
+                                           ) Temp
+                                         ", sqlWhere);
 
-                Result hotelData = await _hotelDataRep.QueryHotelData(dto);
-                if (hotelData.Code == 0)
-                {
-                    return Ok(JsonView(true, "查询成功", hotelData.Data));
-                }
-                else
+            if (dto.PortType == 1)
+            {
+                List<HotelDataItemView> HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
+                if (HotelDataData.Count == 0)
                 {
-                    return Ok(JsonView(false, hotelData.Msg));
+                    return Ok(JsonView(false, "暂无数据"));
                 }
-
+                return Ok(JsonView(true, "操作成功", HotelDataData));
             }
-            catch (Exception ex)
+            else if (dto.PortType == 2 || dto.PortType == 3)
             {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
+                RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
+                var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
+
+                return Ok(JsonView(true, "操作成功", data, total));
             }
+            else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
 
 
         }
+
+        /// <summary>
+        /// 酒店资料
+        /// 详情
+        /// add time:2024-05-14 11:57:10
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
+        {
+            var _view = await _hotelDataRep._Info(dto.PortType,dto.Id);
+            if (_view.Code == 0 )
+            {
+                return Ok(JsonView(true, _view.Msg,_view.Data));
+            }
+
+            return Ok(JsonView(false, _view.Msg));
+        }
+
         /// <summary>
         /// 酒店资料下拉框数据
         /// </summary>
@@ -722,36 +793,15 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
         {
-            try
-            {
-                if (dto.City == "")
-                {
-                    return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
-                }
-                if (dto.Name == "")
-                {
-                    return Ok(JsonView(false, "请检查酒店名称是否填写!"));
-                }
-                if (dto.Address == "")
-                {
-                    return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
-                }
-                if (dto.Tel == "")
-                {
-                    return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
-                }
+            if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
+            if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
+            if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!")); 
+            if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!")); 
+
+            Result result = await _hotelDataRep.OperationHotelData(dto);
+            if (result.Code != 0) return Ok(JsonView(false, result.Msg));
+            return Ok(JsonView(true, result.Msg));
 
-                Result result = await _hotelDataRep.OperationHotelData(dto);
-                if (result.Code != 0)
-                {
-                    return Ok(JsonView(false, result.Msg));
-                }
-                return Ok(JsonView(true, result.Msg));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, ex.Message));
-            }
         }
 
         /// <summary>
@@ -1569,20 +1619,13 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
         {
-            try
+            Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
+            if (groupData.Code != 0)
             {
-                Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
-                if (groupData.Code != 0)
-                {
-                    return Ok(JsonView(false, groupData.Msg));
-                }
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
+                return Ok(JsonView(false, groupData.Msg));
             }
+            return Ok(JsonView(true, groupData.Msg, groupData.Data));
+            
         }
         /// <summary>
         /// 根据公务出访数据Id查询数据
@@ -1750,6 +1793,26 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         }
 
 
+
+        /// <summary>
+        /// 公务出访
+        /// 请示范例提示 
+        /// Add Time:2024-05-13 13:56:44
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
+        {
+            var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area,dto.client);
+            if (res.Code == 0)
+            {
+                return Ok(JsonView(true, "操作成功!", res.Data));
+            }
+            return Ok(JsonView(false, res.Msg));
+        }
+
         /// <summary>
         /// 公务出访 (省外办,市外办) File Downlaod
         /// </summary>
@@ -1792,7 +1855,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 Dictionary<string, string> dic = new Dictionary<string, string>();
 
                 //××(组团单位):接团客户信息团组
-                dic.Add("GroupClient", groupInfo.ClientUnit);
+                dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
 
                 //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
                 string guestName = "";
@@ -1801,8 +1864,8 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 var guestFirstInfo = guestInfos.FirstOrDefault();
                 if (guestFirstInfo != null)
                 {
-                    guestName = guestFirstInfo.LastName + guestFirstInfo.FirstName;
-                    guestJob = guestFirstInfo.Job;
+                    guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
+                    guestJob = guestFirstInfo.Job.Trim();
                     guestInfoStr = $@"{guestJob}、{guestName}";
                 }
                 string askTitle = $@"关于{guestInfoStr}等{guestInfos.Count}人赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}的请示";
@@ -1811,12 +1874,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
                 string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
                 string obInfoStr = "";
-                string obBackgroundStr = "×××";//出访背景
                 foreach (var ob in obDatas)
                 {
-                    obInfoStr += @$"{ob.Client}{ob.Job}{ob.Contact}、";
-
-                    obBackgroundStr += $"{ob.Client}\r\n \t {ob.Setting}\r\n";
+                    obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
 
                 }
                 if (obInfoStr.Length > 0)
@@ -1826,10 +1886,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。现请示如下。";
                 dic.Add("AskSubTitle", askSubTitle);
 
-                //出访背景
-                obBackgroundStr = "×××";//出访背景
-                dic.Add("OBSetting", obBackgroundStr);
-
                 //出访目的
                 dic.Add("VisitPurpose", groupInfo.VisitPurpose);
 
@@ -1838,34 +1894,52 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
                 //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
 
-                string taskStr = "××××"; ;
-                //List<string> countrys = groupInfo.VisitCountry.Split("、").ToList();
-                //int countryIndex = 1;
-                //foreach (var item in countrys)
-                //{
-                //    string taskTitle = $"({GetToUpperNumber(countryIndex)}){item}\r\n";
+                string visitCountryStr1 = ""; // ××国家(或地区)×天,××国家(或地区)×天
+                string obBackgroundStr = "";//出访背景
+                string taskStr = ""; ; //出访任务
+                var countrys = obDatas.GroupBy(it => it.Country);
+                int countryIndex = 1;
+                foreach (var item in countrys)
+                {
+                    visitCountryStr1 += $"{item.Key}  天、";
+                    string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
+
+                    string taskContent = "";
+                    string obBackgroundContent = "";
+                    int obIndex = 1;
+                    foreach (var obInfo in item.ToList())
+                    {
+                        string reqSmaple = "";
+                        string settingStr = "";
+                        if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
+                        else reqSmaple = "[公务出访请示范例未录入]";
+
+                        if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
+                        else settingStr = "[公务方背景未录入]";
 
-                //    string taskContent = "";
-                //    var countryObDatas = obDatas.Where(it => it.Client.Contains(item)).ToList();
-                //    int obIndex = 1;
-                //    foreach (var obInfo in countryObDatas)
-                //    {
-                //        taskContent += $"{obIndex}. 拜访{obInfo.Client}({obInfo.Contact}、{obInfo.Job})洽谈“{groupInfo.VisitPurpose}”相关工作。\r\n";
-                //    }
+                        taskContent += $"{obIndex}. {reqSmaple}\r\n";
+                        obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
+                    }
 
-                //    taskStr += $"{taskTitle}{taskContent}";
+                    taskStr += $"{taskTitle}{taskContent}";
+                    obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
+                    countryIndex++;
+                }
 
-                //    countryIndex++;
-                //}
+                //出访背景
+                if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
+                dic.Add("OBSetting", obBackgroundStr);
 
                 //出访任务
+                if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
                 dic.Add("TaskContent", taskStr);
 
                 //出访时间
                 //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
-                string visitCountryStr = $"[OP行程单读取]";
+                if (visitCountryStr1.Length > 0) visitCountryStr1 = visitCountryStr1.Substring(0, visitCountryStr1.Length - 1);
+                string visitCountryStr = "";
                 visitCountryStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
-
+                if (visitCountryStr.Equals("[黑屏代码未录入]")) visitCountryStr = visitCountryStr1;
 
                 string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{groupInfo.VisitDays}天。其中,{visitCountryStr}。";
                 //出访时间
@@ -1920,7 +1994,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                     string sexStr = string.Empty;
                     if (sex == 0) sexStr = "男";
                     else if (sex == 1) sexStr = "女";
-                    else sexStr = "未设置";
+                    else sexStr = "-";
                     builder.Write(sexStr);
 
                     builder.MoveToCell(0, i + 1, 2, 0);
@@ -1930,9 +2004,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                     builder.MoveToCell(0, i + 1, 3, 0);
                     string birthDay = "";
                     string birthDayStr = string.Empty;
-                    if (!string.IsNullOrEmpty(birthDay))
+                    if (guestInfo.BirthDay != null)
                     {
-                        birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
+                        birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
                     }
                     builder.Write(birthDayStr);
                 }
@@ -1944,7 +2018,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 }
 
                 var fileDir = AppSettingsHelper.Get("WordBasePath");
-                string fileName = $"{groupInfo.TeamName}省外办出访请示.docx";
+                string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
                 string filePath = fileDir + $@"OfficialActivities/{fileName}";
                 doc.Save(filePath);
 
@@ -1953,7 +2027,164 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             }
             else if (dto.FileType == 2)
             {
+                //载入模板
+                string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
+                var doc = new Document(tempPath);
+                DocumentBuilder builder = new DocumentBuilder(doc);
+
+                //键值对存放数据
+                Dictionary<string, string> dic = new Dictionary<string, string>();
+
+                //××(组团单位):接团客户信息团组
+                dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
+                
+                dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
+                //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
+                string guestName = "";
+                string guestJob = "";
+                string guestInfoStr = "";
+                var guestFirstInfo = guestInfos.FirstOrDefault();
+                if (guestFirstInfo != null)
+                {
+                    guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
+                    guestJob = guestFirstInfo.Job;
+                    guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
+                }
+                string reqTitle = $@"关于{guestInfoStr}等{guestInfos.Count}人赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}的请示";
+                dic.Add("ReqTitle", reqTitle);
 
+                //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
+                string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
+                string obInfoStr = "";
+                string obBackgroundStr = "×××";//出访背景
+                foreach (var ob in obDatas)
+                {
+                    obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
+
+                    //obBackgroundStr += $"{ob.Client}\r\n \t {ob.Setting}\r\n";
+
+                }
+                if (obInfoStr.Length > 0)
+                {
+                    obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
+                }
+                string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。";
+                dic.Add("ReqSubTitle", reqSubTitle);
+
+                /*
+                 * 出访任务
+                 * (一)××(国家或地区)
+                 * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
+                 * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
+                 * 
+                 */
+                string visitCountryStr1 = ""; // ××国家(或地区)×天,××国家(或地区)×天
+                string taskStr = string.Empty ;
+                List<string> countrys = obDatas.Select(it => it.Country).ToList();
+                int countryIndex = 1;
+                foreach (var item in countrys)
+                {
+                    visitCountryStr1 += $"{item}  天,";
+                    string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
+
+                    string taskContent = "";
+                    var countryObDatas = obDatas.Where(it => it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
+                    int obIndex = 1;
+                    if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
+                    else
+                    {
+                        foreach (var obInfo in countryObDatas)
+                        {
+                            taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
+                        }
+                    }
+                    
+
+                    taskStr += $"{taskTitle}{taskContent}";
+
+                    countryIndex++;
+                }
+
+                if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
+                if (visitCountryStr1.Length > 0) visitCountryStr1 = visitCountryStr1.Substring(0, visitCountryStr1.Length - 1);
+
+                //出访任务
+                dic.Add("TaskContent", taskStr);
+
+                //出访目的
+                dic.Add("VisitPurpose", groupInfo.VisitPurpose);
+
+                //出访信息
+                //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
+
+                string tripInfoStr = "";
+                string visitCountryStr = $"[OP行程单读取]";
+                visitCountryStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
+                if (visitCountryStr.Equals("[黑屏代码未录入]")) visitCountryStr = visitCountryStr1;
+                string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—"); //出访路线
+                tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{groupInfo.VisitDays}天。其中,{visitCountryStr}。出访路线:{lineStr}出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
+
+
+                dic.Add("TripInfo", tripInfoStr);
+
+
+                #region 填充word模板书签内容
+                foreach (var key in dic.Keys)
+                {
+                    builder.MoveToBookmark(key);
+                    builder.Write(dic[key]);
+                }
+                #endregion
+
+                //获取word里所有表格
+                NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
+                //获取所填表格的序数
+                Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
+
+                var rowStart = tableOne.Rows[0]; //获取第1行
+
+                //循环赋值
+                for (int i = 0; i < guestInfos.Count; i++)
+                {
+                    var guestInfo = guestInfos[i];
+                    builder.MoveToCell(0, i + 1, 0, 0);
+                    builder.Write(guestInfo.LastName + guestInfo.FirstName);
+
+                    builder.MoveToCell(0, i + 1, 1, 0);
+                    int sex = guestInfo.Sex;
+                    string sexStr = string.Empty;
+                    if (sex == 0) sexStr = "男";
+                    else if (sex == 1) sexStr = "女";
+                    else sexStr = "未设置";
+                    builder.Write(sexStr);
+
+                    builder.MoveToCell(0, i + 1, 2, 0);
+                    builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
+
+
+                    builder.MoveToCell(0, i + 1, 3, 0);
+                    DateTime birthDay = guestInfo.BirthDay;
+                    string birthDayStr = string.Empty;
+                    if (birthDay != null)
+                    {
+                        birthDayStr = birthDay.ToString("yyyy.MM");
+                    }
+                    builder.Write(birthDayStr);
+                }
+
+                //删除多余行
+                while (tableOne.Rows.Count > guestInfos.Count + 1)
+                {
+                    tableOne.Rows.RemoveAt(guestInfos.Count + 1);
+                }
+
+                var fileDir = AppSettingsHelper.Get("WordBasePath");
+                string fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
+                string filePath = fileDir + $@"OfficialActivities/{fileName}";
+                doc.Save(filePath);
+
+                string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
+                return Ok(JsonView(true, "操作成功!", Url));
             }
 
 
@@ -1975,7 +2206,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             else if (num == 9) numStr = "九";
             else if (num == 10) numStr = "十";
 
-
             return numStr;
         }
 

+ 9 - 6
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1438,7 +1438,7 @@ namespace OASystem.API.OAMethodLib
         {
             DataTable datas =  GetTableByBlackCode(diId);
 
-            string countryStr = "";
+            string countryStr = "[黑屏代码未录入].";
             if (datas.Rows.Count > 0 )
             {
                 var airDatas = from row in datas.AsEnumerable()
@@ -1458,10 +1458,12 @@ namespace OASystem.API.OAMethodLib
                 //去掉开始和结束城市
                 foreach (var row in airDatas) 
                 {
-                    if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
-                    else if (airDatas.Count()-1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
-                    else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
-
+                    if (!string.IsNullOrEmpty(row.Three))
+                    {
+                        if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
+                        else if (airDatas.Count() - 1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
+                        else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
+                    }
                     index++;
                 }
                 cityCodes = cityCodes.Distinct().ToList();
@@ -1480,7 +1482,8 @@ namespace OASystem.API.OAMethodLib
                         DateTime arr_dt = Convert.ToDateTime(airData[0].ArrivedDate); //抵达时间
                         DateTime dep_dt = Convert.ToDateTime(airData[1].Day); //离开时间
                         days = (dep_dt - arr_dt).Days;
-                        countryStr += $@"{country}停留{days}日、";
+                        //countryStr += $@"{country}停留{days}日、";
+                        countryStr += $@"{country}停留  日、";
                     }
                 }
                 if (countryStr.Length > 0) countryStr = countryStr.Substring(0, countryStr.Length - 1);

+ 6 - 0
OASystem/OASystem.Domain/Dtos/Resource/HotelDataDto.cs

@@ -91,4 +91,10 @@ namespace OASystem.Domain.Dtos.Resource
         public int Id { get; set; }
         public int DeleteUserId { get; set; }
     }
+
+    public class QueryHotelDataInfoDto : PortDtoBase
+    {
+        public int Id { get; set; }
+
+    }
 }

+ 32 - 4
OASystem/OASystem.Domain/Dtos/Resource/OfficialActivitiesDto.cs

@@ -36,9 +36,7 @@ namespace OASystem.Domain.Dtos.Resource
         /// 邀请方 1  公务方 0 
         /// </summary>
         public int Type { get; set; }
-        /// <summary>
-        /// 公务单位
-        /// </summary>
+
         public string Client { get; set; }
         /// <summary>
         /// 公务日期
@@ -113,6 +111,28 @@ namespace OASystem.Domain.Dtos.Resource
         /// 是否付费
         /// </summary>
         public int IsPay { get; set; }
+
+
+        /// <summary>
+        /// 国家
+        /// </summary>
+        public string Country { get; set; }
+
+        /// <summary>
+        /// 区域
+        /// </summary>
+        public string Area { get; set; }
+
+        /// <summary>
+        /// 涉及领域
+        /// </summary>
+        public string Field { get; set; }
+
+        /// <summary>
+        /// 请示范例
+        /// </summary>
+        public string ReqSample { get; set; }
+
     }
 
     /// <summary>
@@ -129,6 +149,14 @@ namespace OASystem.Domain.Dtos.Resource
 
         public int DiId { get; set; }
 
-        public int[] IdList { get; set; }
+    }
+
+    public class PostOfficialActivitiesReqReqSampleTipsDto
+    {
+        public string country { get; set; }
+
+        public string area { get; set; }
+
+        public string client { get; set; }
     }
 }

+ 28 - 0
OASystem/OASystem.Domain/Entities/Resource/Res_OfficialActivities.cs

@@ -16,11 +16,25 @@ namespace OASystem.Domain.Entities.Resource
          /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int DiId { get; set; }
+
         /// <summary>
         /// 邀请方 1  公务方 0 
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int Type { get; set; }
+
+        /// <summary>
+        /// 所在国家
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
+        public string Country { get; set; }
+
+        /// <summary>
+        /// 所在区域(城市)
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
+        public string Area { get; set; }
+
         /// <summary>-
         /// 公务单位
         /// </summary>
@@ -62,6 +76,20 @@ namespace OASystem.Domain.Entities.Resource
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int OfficialForm { get; set; }
+
+
+        /// <summary>
+        /// 公务方所属领域
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
+        public string Field { get; set; }
+
+        /// <summary>
+        /// 请示范例
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string ReqSample { get; set; }
+
         /// <summary>
         /// 公务方背景
         /// </summary>

+ 2 - 0
OASystem/OASystem.Domain/ViewModels/Groups/TourClientListView.cs

@@ -57,6 +57,8 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public int Sex { get; set; }
 
+        public DateTime BirthDay { get; set; }
+
     }
 
     /// <summary>

+ 47 - 0
OASystem/OASystem.Domain/ViewModels/Resource/HotelDataView.cs

@@ -21,4 +21,51 @@ namespace OASystem.Domain.ViewModels.Resource
         public string City { get; set; }
     }
 
+    public class HotelDataInfoView
+    {
+        public int id { get; set; }
+
+        public string city { get; set; }
+
+        public string name { get; set; }
+
+        public string tel { get; set; }
+
+        public string fax { get; set; }
+
+        public string contact { get; set; }
+
+        public string contactPhone { get; set; }
+
+        public string level { get; set; }
+        public string address { get; set; }
+
+        public string otherInformation { get; set; }
+        public string remark { get; set; }
+
+    }
+
+    public class HotelDataItemView
+    {
+        public int Row_Number { get; set; }
+
+        public int Id { get; set; }
+
+        public string City { get; set; }
+
+        public string Name { get; set; }
+
+        public string Tel { get; set; }
+
+        public string Fax { get; set; }
+
+        public string Contact { get; set; }
+
+        public string CreateUserName { get; set; }
+
+        public string ContactPhone { get; set; }
+
+        public DateTime CreateTime { get; set; }
+    }
+
 }

+ 18 - 1
OASystem/OASystem.Domain/ViewModels/Resource/OfficialActivitiesView.cs

@@ -7,9 +7,26 @@ using System.Threading.Tasks;
 
 namespace OASystem.Domain.ViewModels.Resource
 {
-    public class OfficialActivitiesView:Res_OfficialActivities
+    public class OfficialActivitiesView : Res_OfficialActivities
     {
         public string CreateUserName { get; set; }
         public string OfficialFormName { get; set; }
     }
+
+    /// <summary>
+    /// 请示范例 Tips View
+    /// </summary>
+    public class ReqReqSampleTipsView
+    {
+        public string TeamName { get; set; }
+
+        public string Country { get; set; }
+
+        public string Area { get; set; }
+
+        public string Client { get; set; }
+
+        public string ReqSample { get; set; }
+    }
+
 }

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -293,7 +293,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
                 string feeSql = string.Format(@"Select * From Fin_DailyFeePayment 
                                                 Where IsDel=0 And Id = {0} ", dto.Id);
                 feeData = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentInfoAndroidlView>(feeSql).FirstAsync();
-                feeData.TransferTypeId = feeData.TransferTypeId == 0 ? 62 : feeData.TransferTypeId == 1 ? 63 : 0;
+                //feeData.TransferTypeId = feeData.TransferTypeId == 0 ? 62 : feeData.TransferTypeId == 1 ? 63 : 0;
                 string feeContentSql = string.Format(@"Select * From Fin_DailyFeePaymentContent 
                                                         Where IsDel=0 And DFPId = {0} ", dto.Id);
                 feeData.FeeContents = await _sqlSugar.SqlQueryable<Fin_DailyFeePaymentContentInfolView>(feeContentSql).ToListAsync();

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

@@ -74,7 +74,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
                 string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.* From Grp_TourClientList tcl
                                                  Left Join 
-	                                                 (Select dc.Id As DcId,dc.LastName,dc.FirstName,ccom.CompanyFullName,dc.Job,cc.CertNo As IDCardNo,dc.Sex 
+	                                                 (Select dc.Id As DcId,dc.LastName,dc.FirstName,ccom.CompanyFullName,dc.Job,
+                                                     cc.CertNo As IDCardNo,dc.Sex,dc.BirthDay
 	                                                 From Crm_DeleClient dc
 	                                                 Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id  And ccom.IsDel = 0
 	                                                 Left Join Crm_CustomerCert cc On dc.Id = cc.DcId And cc.SdId = 773 And cc.IsDel = 0

+ 72 - 170
OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs

@@ -1,4 +1,5 @@
 using AutoMapper;
+using MySqlX.XDevAPI.Common;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Resource;
@@ -9,6 +10,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Result = OASystem.Domain.Result;
 
 namespace OASystem.Infrastructure.Repositories.Resource
 {
@@ -19,198 +21,98 @@ namespace OASystem.Infrastructure.Repositories.Resource
         {
             _mapper= mapper;
         }
-        public async Task<Result> OperationHotelData(OperationHotelDto dto)
+
+        public async Task<Result> _Info(int portType, int id)
         {
-            Result result = new Result() { Code = -2, Msg = "未知错误" };
-            try
-            {
-                if (dto.Status == 1)//添加
-                {
-                    string selectSql = string.Format(@"select * from Res_HotelData where Name='{0}' and IsDel='{1}'"
-                                                       , dto.Name,0);
-                    var HotelData = await _sqlSugar.SqlQueryable<Res_HotelData>(selectSql).FirstAsync();//查询是否存在
-                    if (HotelData != null)
-                    {
-                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+            if (id< 1) return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
 
-                    }
-                    else//不存在,可添加
-                    {
-                        Res_HotelData _HotelDataDto = _mapper.Map<Res_HotelData>(dto);
-                        int id = await AddAsyncReturnId(_HotelDataDto);
-                        if (id == 0)
-                        {
-                            return result = new Result() { Code = -1, Msg = "添加失败!" };
 
-                        }
-                        return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
-                    }
-                }
-                else if (dto.Status == 2)//修改
-                {
-                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_HotelData
-                    {
-                        City = dto.City,
-                        Name = dto.Name,
-                        Level = dto.Level,
-                        Address = dto.Address,
-                        Tel = dto.Tel,
-                        Fax = dto.Fax,
-                        Contact = dto.Contact,
-                        ContactPhone = dto.ContactPhone,
-                        OtherInformation = dto.OtherInformation,
-                        Remark = dto.Remark,
-                    });
-                    if (!res)
-                    {
-                        return result = new Result() { Code = -1, Msg = "修改失败!" };
-                    }
-                    return result = new Result() { Code = 0, Msg = "修改成功!" };
-                }
-                else
-                {
-                    return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
-                }
-            }
-            catch (Exception ex)
+            string sql = string.Format(@"SELECT
+  Id,
+  City,
+  [Name],
+  [Level],
+  [Address],
+  Tel,
+  Fax,
+  Contact,
+  ContactPhone,
+  OtherInformation,
+  Remark
+FROM
+  Res_HotelData
+WHERE
+  IsDel = 0
+  AND Id = {0}", id);
+
+            if (portType == 1 || portType == 2 || portType == 3)
             {
-                return result = new Result() { Code = -2, Msg = ex.Message };
-                }
+                var info = await _sqlSugar.SqlQueryable<HotelDataInfoView>(sql).FirstAsync();
+                if (info != null) return new Result() { Code = 0, Msg = "操作成功!",Data = info };
+                return new Result() { Code = -1, Msg = "暂无数据!" };
+            }
+           
+
+            
+
+
+            return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
         }
 
-        public async Task<Result> QueryHotelData(QueryHotelDataDto dto)
+        public async Task<Result> OperationHotelData(OperationHotelDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
-            try
+
+            if (dto.Status == 1)//添加
             {
-                string sqlWhere = string.Empty;
-                if (!string.IsNullOrWhiteSpace(dto.Name))
-                {
-                    sqlWhere += string.Format(@" And Name like '%{0}%'", dto.Name);
-                }
-                if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
+                string selectSql = string.Format(@"select * from Res_HotelData where Name='{0}' and IsDel='{1}'"
+                                                   , dto.Name, 0);
+                var HotelData = await _sqlSugar.SqlQueryable<Res_HotelData>(selectSql).FirstAsync();//查询是否存在
+                if (HotelData != null)
                 {
-                    sqlWhere += string.Format(@" And City like '%{0}%'", dto.City);
-                }
-                if (!string.IsNullOrWhiteSpace(dto.Contact))
-                {
-                    sqlWhere += string.Format(@" And Contact like '%{0}%'", dto.Contact);
-                }
-                if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
-                {
-                    sqlWhere += string.Format(@" And ContactPhone like '%{0}%'", dto.ContactPhone);
-                }
-                sqlWhere += string.Format(@" And IsDel={0}", 0);
-                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
-                {
-                    Regex r = new Regex("And");
-                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
-                }
-                if (dto.PortType == 1)
-                {
-                    string sql = string.Format(@"select * from Res_HotelData {0}", sqlWhere);
-                    List<Res_HotelData> HotelDataData = await _sqlSugar.SqlQueryable<Res_HotelData>(sql).ToListAsync();
-                    if (HotelDataData.Count == 0)
-                    {
-                        return result = new Result() { Code = -1, Msg = "暂无数据" };
-                    }
-                    HotelDataData = HotelDataData.OrderByDescending(x => x.CreateTime).ToList();
-
-                    if (dto.PageSize == 0 && dto.PageIndex == 0)
-                    {
-                        return result = new Result()
-                        {
-                            Code = 0,
-                            Msg = "查询成功",
-                            Data = HotelDataData,
-                        };
-                    }
-                    else
-                    {
-                        int count = HotelDataData.Count;
-                        float totalPage = (float)count / dto.PageSize;//总页数
-                        if (totalPage == 0) totalPage = 1;
-                        else totalPage = (int)Math.Ceiling((double)totalPage);
-
-                        List<Res_HotelData> _HotelData = new List<Res_HotelData>();
-                        for (int i = 0; i < dto.PageSize; i++)
-                        {
-                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
-                            if (RowIndex < HotelDataData.Count)
-                            {
-                                _HotelData.Add(HotelDataData[RowIndex]);
-                            }
-                            else
-                            {
-                                break;
-                            }
-                        }
-                        return result = new Result()
-                        {
-                            Code = 0,
-                            Msg = "查询成功",
-                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _HotelData },
-                        };
-                    }
+                    return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
 
                 }
-                else if (dto.PortType == 2)
+                else//不存在,可添加
                 {
-                    string sql = string.Format(@"select * from Res_HotelData {0}", sqlWhere);
-                    List<Res_HotelData> HotelDataData = await _sqlSugar.SqlQueryable<Res_HotelData>(sql).ToListAsync();
-                    if (HotelDataData.Count == 0)
-                    {
-                        return result = new Result() { Code = -1, Msg = "暂无数据" };
-                    }
-                    HotelDataData = HotelDataData.OrderByDescending(x => x.CreateTime).ToList();
-
-                    if (dto.PageSize == 0 && dto.PageIndex == 0)
-                    {
-                        return result = new Result()
-                        {
-                            Code = 0,
-                            Msg = "查询成功",
-                            Data = HotelDataData,
-                        };
-                    }
-                    else
+                    Res_HotelData _HotelDataDto = _mapper.Map<Res_HotelData>(dto);
+                    int id = await AddAsyncReturnId(_HotelDataDto);
+                    if (id == 0)
                     {
-                        int count = HotelDataData.Count;
-                        float totalPage = (float)count / dto.PageSize;//总页数
-                        if (totalPage == 0) totalPage = 1;
-                        else totalPage = (int)Math.Ceiling((double)totalPage);
+                        return result = new Result() { Code = -1, Msg = "添加失败!" };
 
-                        List<Res_HotelData> _HotelData = new List<Res_HotelData>();
-                        for (int i = 0; i < dto.PageSize; i++)
-                        {
-                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
-                            if (RowIndex < HotelDataData.Count)
-                            {
-                                _HotelData.Add(HotelDataData[RowIndex]);
-                            }
-                            else
-                            {
-                                break;
-                            }
-                        }
-                        return result = new Result()
-                        {
-                            Code = 0,
-                            Msg = "查询成功",
-                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _HotelData },
-                        };
                     }
+                    return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
                 }
-                else
+            }
+            else if (dto.Status == 2)//修改
+            {
+                bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_HotelData
+                {
+                    City = dto.City,
+                    Name = dto.Name,
+                    Level = dto.Level,
+                    Address = dto.Address,
+                    Tel = dto.Tel,
+                    Fax = dto.Fax,
+                    Contact = dto.Contact,
+                    ContactPhone = dto.ContactPhone,
+                    OtherInformation = dto.OtherInformation,
+                    Remark = dto.Remark,
+                });
+                if (!res)
                 {
-                    return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };
+                    return result = new Result() { Code = -1, Msg = "修改失败!" };
                 }
+                return result = new Result() { Code = 0, Msg = "修改成功!" };
             }
-            catch (Exception)
+            else
             {
-                return result;
-                throw;
+                return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
             }
         }
+
+
+
     }
 }

+ 111 - 87
OASystem/OASystem.Infrastructure/Repositories/Resource/OfficialActivitiesRepository.cs

@@ -22,8 +22,6 @@ namespace OASystem.Infrastructure.Repositories.Resource
             _mapper = mapper;
         }
 
-
-
         /// <summary>
         /// 根据Diid查询公务出访数据List
         /// </summary>
@@ -174,113 +172,139 @@ namespace OASystem.Infrastructure.Repositories.Resource
         public async Task<Result> OpOfficialActivities(OpOfficialActivitiesDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
-            try
+
+            #region 特殊字符转码  037 - 4.28 15:17
+
+            if (!string.IsNullOrEmpty(dto.Contact))
             {
-                #region 特殊字符转码  037 - 4.28 15:17
+                byte[] utf8Bytes = Encoding.UTF8.GetBytes(dto.Contact);
+                byte[] utf16Bytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, utf8Bytes);
+                dto.Contact = Encoding.Unicode.GetString(utf16Bytes);
+            }
 
-                if (!string.IsNullOrEmpty(dto.Contact))
-                {
-                    byte[] utf8Bytes = Encoding.UTF8.GetBytes(dto.Contact);
-                    byte[] utf16Bytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, utf8Bytes);
-                    dto.Contact = Encoding.Unicode.GetString(utf16Bytes);
-                }
-                
-                #endregion
+            #endregion
+
+            if (dto.Status == 1)//添加
+            {
+                _sqlSugar.BeginTran();
 
+                string selectSql = string.Format(@"select * from Res_OfficialActivities where Client='{0}' and Address='{1}' and IsDel='{2}'", dto.Client, dto.Address, 0);
+                var res_InvitationOfficial = await _sqlSugar.SqlQueryable<Res_OfficialActivities>(selectSql).FirstAsync();//查询是否存在
+                if (res_InvitationOfficial != null)
+                {
+                    _sqlSugar.RollbackTran();
+                    return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
 
-                if (dto.Status == 1)//添加
+                }
+                else//不存在,可添加
                 {
-                    _sqlSugar.BeginTran();
 
-                    string selectSql = string.Format(@"select * from Res_OfficialActivities where Client='{0}' and Address='{1}' and IsDel='{2}'", dto.Client, dto.Address, 0);
-                    var res_InvitationOfficial = await _sqlSugar.SqlQueryable<Res_OfficialActivities>(selectSql).FirstAsync();//查询是否存在
-                    if (res_InvitationOfficial != null)
+                    Res_OfficialActivities _InvitationOfficialActivityData = _mapper.Map<Res_OfficialActivities>(dto);
+                    int id = await _sqlSugar.Insertable(_InvitationOfficialActivityData).ExecuteReturnIdentityAsync();
+                    if (id == 0)
                     {
                         _sqlSugar.RollbackTran();
-                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
-
+                        return result = new Result() { Code = -1, Msg = "添加失败!" };
                     }
-                    else//不存在,可添加
-                    {
 
-                        Res_OfficialActivities _InvitationOfficialActivityData = _mapper.Map<Res_OfficialActivities>(dto);
-                        int id = await _sqlSugar.Insertable(_InvitationOfficialActivityData).ExecuteReturnIdentityAsync();
-                        if (id == 0)
+                    //添加到资料库
+                    Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
+                    res_InvitationData.Country = dto.Country;
+                    res_InvitationData.City = dto.Area;
+                    res_InvitationData.UnitName = dto.Client;
+                    res_InvitationData.Delegation = dto.DiId.ToString();
+                    res_InvitationData.Address = dto.Address;
+                    res_InvitationData.CreateUserId = dto.CreateUserId;
+                    res_InvitationData.Contact = dto.Contact;
+                    res_InvitationData.Job = dto.Job;
+                    res_InvitationData.Tel = dto.Tel;
+
+                    Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
+                        (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
+
+                    if (ifNullUp == null)
+                    {
+                        int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
+                        if (DataID != 0)
                         {
-                            _sqlSugar.RollbackTran();
-                            return result = new Result() { Code = -1, Msg = "添加失败!" };
+                            _sqlSugar.CommitTran();
+                            return  new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
                         }
-
-                        //添加到资料库
-                        Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
-                        res_InvitationData.Country = "";
-                        res_InvitationData.City = "";
-                        res_InvitationData.UnitName = dto.Client;
-                        res_InvitationData.Delegation = dto.DiId.ToString();
-                        res_InvitationData.Address = dto.Address;
-                        res_InvitationData.CreateUserId = dto.CreateUserId;
-                        res_InvitationData.Contact = dto.Contact;
-                        res_InvitationData.Job = dto.Job;
-                        res_InvitationData.Tel = dto.Tel;
-
-                        Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
-                            (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
-
-                        if (ifNullUp == null)
+                        else
                         {
-                            int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
-                            if (DataID != 0)
-                            {
-                                result = new Result() { Code = 0, Msg = "添加成功!" };
-                            }
-                            else
-                            {
-                                result = new Result() { Code = -1, Msg = "添加失败!" };
-                            }
+                            _sqlSugar.RollbackTran();
+                            return  new Result() { Code = -1, Msg = "添加失败!" };
                         }
-
-                        _sqlSugar.CommitTran();
-                        return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
                     }
+
+                   
                 }
-                else if (dto.Status == 2)//修改
+            }
+            else if (dto.Status == 2)//修改
+            {
+                bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_OfficialActivities
                 {
-                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_OfficialActivities
-                    {
-                        Type = dto.Type,
-                        Client = dto.Client,
-                        Date = dto.Date,
-                        Time = dto.Time,
-                        Address = dto.Address,
-                        Contact = dto.Contact,
-                        Job = dto.Job,
-                        Tel = dto.Tel,
-                        OfficialForm = dto.OfficialForm,
-                        Setting = dto.Setting,
-                        Dresscode = dto.Dresscode,
-                        Attendees = dto.Attendees,
-                        IsNeedTrans = dto.IsNeedTrans,
-                        Translators = dto.Translators,
-                        language = dto.language,
-                        Trip = dto.Trip,
-                        CreateUserId = dto.CreateUserId,
-                        Remark = dto.Remark,
-                    });
-                    if (!res)
-                    {
-                        return result = new Result() { Code = -1, Msg = "修改失败!" };
-                    }
-                    return result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
-                }
-                else
+
+                    Country = dto.Country,
+                    Area = dto.Area,
+                    Type = dto.Type,
+                    Client = dto.Client,
+                    Date = dto.Date,
+                    Time = dto.Time,
+                    Address = dto.Address,
+                    Contact = dto.Contact,
+                    Job = dto.Job,
+                    Tel = dto.Tel,
+                    OfficialForm = dto.OfficialForm,
+                    Field = dto.Field,
+                    ReqSample = dto.ReqSample,
+                    Setting = dto.Setting,
+                    Dresscode = dto.Dresscode,
+                    Attendees = dto.Attendees,
+                    IsNeedTrans = dto.IsNeedTrans,
+                    Translators = dto.Translators,
+                    language = dto.language,
+                    Trip = dto.Trip,
+                    CreateUserId = dto.CreateUserId,
+                    Remark = dto.Remark,
+                });
+                if (!res)
                 {
-                    return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                    return result = new Result() { Code = -1, Msg = "修改失败!" };
                 }
+                return result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
             }
-            catch (Exception ex)
+            else
+            {
+                return new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+            }
+            return result;
+        }
+
+        public async Task<Result> PostReqReqSampleTips(string country, string Area,string client)
+        {
+            if (string.IsNullOrEmpty(country)) return new Result() { Code = -1, Msg = "国家为空!" };
+
+            string sqlWhere = string.Empty;
+            if (!string.IsNullOrEmpty(Area)) sqlWhere = string.Format(@$" And oa.Area Like '%{Area}%'");
+
+            if (!string.IsNullOrEmpty(client)) sqlWhere = string.Format(@$" And oa.Client Like '%{client}%'");
+
+
+            string sql = string.Format(@$"Select di.TeamName,oa.Id,oa.Country,oa.Area,oa.Client,oa.ReqSample 
+                                          From Res_OfficialActivities oa With(NoLock)
+                                          Left Join Grp_DelegationInfo di On oa.DiId = di.Id 
+                                          Where oa.IsDel = 0 And oa.Country='{country}' {sqlWhere}");
+
+            //ReqReqSampleTipsView
+            var _views = await _sqlSugar.SqlQueryable< ReqReqSampleTipsView >(sql).ToListAsync();
+            if (_views.Count > 0 )
             {
-                return result = new Result() { Code = -2, Msg = "程序错误!" };
+                return new Result() { Code = 0, Msg = "操作成功!", Data = _views };
             }
+
+            return new Result() { Code = -1, Msg = "暂无相关数据!" };
         }
+
     }
 }