Browse Source

新增团组合同下载功能及相关优化

在 `GroupsController.cs` 中添加了 `DownGroupContractFile` 方法,用于下载团组合同文件,包含权限校验和文件生成逻辑。将 `SharedFileInit` 方法改为异步以支持省市数据查询。增强了 `SearchGroupByKeyword` 方法的关键字搜索功能。新增 `GetGroupCityLine` 方法以处理团组城市路径信息。新增 DTO 类 `SearchGroupByKeywordDto` 和 `DownGroupContractFileDto`。优化了 `NewClientDataRepository.cs` 中的 SQL 查询和用户权限处理逻辑。
LEIYI 3 weeks ago
parent
commit
dd0a40a2d8

+ 493 - 102
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -42,6 +42,7 @@ using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Infrastructure.Tools;
+using OASystem.RedisRepository;
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Utilities;
 using Quartz.Util;
@@ -1882,9 +1883,313 @@ FROM
             return Ok(JsonView(true, "操作成功!", rst));
         }
 
+        [HttpPost]
+        public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
+        {
+            var jw = JsonView(false);
+            var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                                     .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
+
+            if (di == null)
+            {
+                jw.Msg = "团组Id有误!";
+                return Ok(jw);
+            }
+
+
+            #region 权限校验
+
+            var allDownFile = new List<int>() { 21 };
+            try
+            {
+                var setting = _sqlSugar.Queryable<Sys_SetData>()
+                                 .First(x => x.Id == 1418 && x.IsDel == 0);
+                allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
+            }
+            catch (Exception)
+            { }
+
+            var guojiaoDownFile = new List<int>() { 330 };
+            var shichangDownFile = new List<int>() { 95 };
+            if (allDownFile.Contains(dto.UserId))
+            {
+
+            }
+            else if (guojiaoDownFile.Contains(dto.UserId))
+            {
+                var guojiaobuDi = new List<int>() { 4, 21 };
+                var departmentStr = _sqlSugar.Queryable<Sys_Department>()
+                                                .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
+                                                .Where((d, u) => u.Id == di.JietuanOperator)
+                                                .Select((d, u) => d.DepName)
+                                                .First();
+                if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
+                {
+                    jw.Msg = "暂无下载权限!";
+                    return Ok(jw);
+                }
+            }
+            else if (shichangDownFile.Contains(dto.UserId))
+            {
+                var dic = new Dictionary<int, int[]>()
+                 {
+                     { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
+                 };
+
+                try
+                {
+                    var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
+                    if (sqSetting != null)
+                    {
+                        Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
+                        foreach (var item in result.Keys)
+                        {
+                            if (dic.Keys.Contains(item))
+                            {
+                                int[] dilatation = new int[dic[item].Length + result[item].Length];
+                                Array.Copy(dic[item], dilatation, dic[item].Length);
+                                Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
+                                dic[item] = dilatation;
+                            }
+                            else
+                            {
+                                dic.Add(item, result[item]);
+                            }
+                        }
+                    }
+
+                    if (!dic[95].Contains(di.CreateUserId))
+                    {
+                        jw.Msg = "暂无下载权限!";
+                        return Ok(jw);
+                    }
+                }
+                catch (Exception)
+                { }
+            }
+            else if (dto.UserId == di.CreateUserId)
+            {
+
+            }
+            else
+            {
+                jw.Msg = "暂无下载权限!";
+                return Ok(jw);
+            }
+
+            #endregion
+
+
+            var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
+                                                .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
+                                                .ToListAsync();
+
+            if (!blackCodeList.Any())
+            {
+                jw.Msg = "该团无机票行程代码!";
+                return Ok(jw);
+            }
+
+            var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
+                                                    .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
+
+            if (groupEnterExitCost == null)
+            {
+                jw.Msg = "暂无三公费用信息!";
+                return Ok(jw);
+            }
+
+            var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
+            var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
+                                .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
+                                .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
+                                .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
+                                .Select((x, a, b) => new
+                                {
+                                    x.Index,
+                                    itemName = a.Name,
+                                    CurrencyStr = b.Name,
+                                    x.Cost,
+                                    x.SubTotal,
+                                    x.Remark
+                                })
+                                .OrderBy((x) => x.Index)
+                                .ToList();
+
+            decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M;  // 住宿费
+            decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M;  // 伙食费费
+            decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
+            decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M;  // 培训费
+            decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
+            decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
+
+            decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
+
+            decimal subJJC = 0.00M,
+                    subGWC = 0.00M,
+                    subTDC = 0.00M;
+
+            //经济舱
+            if (groupEnterExitCost.SumJJC == 1)
+            {
+                subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
+            }
+            //公务舱
+            if (groupEnterExitCost.SumGWC == 1)
+            {
+                subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
+            }
+            //头等舱
+            if (groupEnterExitCost.SumTDC == 1)
+            {
+                subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
+            }
+
+
+            var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
+                                             .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
+                                             .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
+                                             .Select((x, s) => new
+                                             {
+                                                 x.Id,
+                                                 s.Name,
+                                             })
+                                             .ToListAsync();
+
+            //获取舱位人数
+            var cabinCount = groupClints.GroupBy(x => x.Name)
+                                        .Select(x => new { Cabin = x.Key, Count = x.Count() })
+                                        .ToList();
+
+            string cityPath = string.Empty;
+            string startCity = string.Empty;
+            string endCity = string.Empty;
+
+            foreach (var item in blackCodeList)
+            {
+                string city = GeneralMethod.GetGroupCityLine(item, "-");
+                cityPath += city + "\r\n";
+                if (item.Equals(blackCodeList.First()))
+                {
+                    var sp = city.Split('-');
+                    startCity = sp[0];
+                    endCity = sp[sp.Length - 1];
+                }
+            }
+
+            Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
+            bookMarkDic.Add("ClientUnit",di.ClientUnit);
+            bookMarkDic.Add("VisitCountry", di.VisitCountry);
+            bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
+            bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
+            bookMarkDic.Add("CityPath", cityPath);
+            bookMarkDic.Add("StartCity", startCity);
+            bookMarkDic.Add("EndCity", endCity);
+            bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
+
+            Document doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
+            DocumentBuilder builder = new DocumentBuilder(doc);
+
+            decimal totalPrice = 0.00M;
+            Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
+            if (firstTable != null)
+            {
+                // 遍历表格的行和单元格
+                foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
+                {
+                    for (int i = 0; i < row.Cells.Count; i++)
+                    {
+                        var cell = row.Cells[i];
+
+                        // 读取单元格内容
+                        string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim(); 
+
+                        if (cellTextFirst.Contains("舱位"))
+                        {
+                            break;
+                        }
+
+                        if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
+                        {
+                            if (i == 2)
+                            {
+                                if (cellTextFirst == "经济舱")
+                                {
+                                    // 设置单元格内容
+                                    cell.FirstParagraph.Runs.Clear(); // 清除原有内容
+                                    cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
+                                }
+                                else
+                                {
+                                    // 设置单元格内容
+                                    cell.FirstParagraph.Runs.Clear(); // 清除原有内容
+                                    cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
+                                }
+                            }
+
+                            if (i == 3)
+                            {
+                                var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
+
+                                if (count != null)
+                                {
+                                    // 设置单元格内容
+                                    cell.FirstParagraph.Runs.Clear(); // 清除原有内容
+                                    cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
+                                }
+                            }
+
+                            if (i == 4)
+                            {
+                                var rowPrice = 0.00M;
+                                var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
+                                count ??= 0;
+                                if (cellTextFirst == "经济舱")
+                                {
+                                    rowPrice = subJJC * (int)count;
+                                }
+                                else
+                                {
+                                    rowPrice = subGWC * (int)count;
+                                }
+
+                                totalPrice += rowPrice;
+
+                                // 设置单元格内容
+                                cell.FirstParagraph.Runs.Clear(); // 清除原有内容
+                                cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
+                            }
+                        }
+                    }
+                }
+            }
+
+            bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
+            bookMarkDic.Add("TotalPrice1", (totalPrice * 0.8M).ToString("#0.00"));
+            bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * 0.8M).ToString("#0.00")).ConvertCNYUpper());
+
+            foreach (var bookmarkName in bookMarkDic.Keys)
+            {
+                Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
+                if (bookmark != null)
+                {
+                    builder.MoveToBookmark(bookmarkName);
+                    builder.Write(bookMarkDic[bookmarkName]);
+                }
+            }
+
+            string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_预付版本合同文件.doc";
+            doc.Save(savePaht);
+
+            jw.Msg = "生成成功!";
+            jw.Code = 200;
+            jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
+            return Ok(jw);
+        }
+
         #endregion
 
-        #region 团组&签证
+            #region 团组&签证
 
         /// <summary>
         ///  根据团组Id获取签证客户信息List
@@ -5338,7 +5643,7 @@ FROM
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult SharedFileInit(int userid ,int portType)
+        public async Task<IActionResult> SharedFileInit(int userid ,int portType)
         {
 
             var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
@@ -5364,13 +5669,45 @@ FROM
 
             if (portType == 1)
             {
+                var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
+
                 var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
                     .Where(x => x.IsDel == 0)
+                    .OrderByDescending(x=> x.VisitDate )
                     .Select(x => new
                     {
                         x.TeamName,
                         x.Id,
-                    }).ToList();
+                        x.CityId,
+                    })
+                    .ToList()
+                    .Select(x=>
+                    {
+                        var provinceId = x.CityId;
+                        var isDefualtVal = true;
+                        if (provinceId > 0)
+                        {
+                            var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
+                            if (parentId != null)
+                            {
+                                isDefualtVal = false;
+                                provinceId = (int)parentId;
+                            }
+                        }
+
+                        if (isDefualtVal)
+                        {
+                            provinceId = 122; //默认四川
+                        }
+
+                        return new
+                        {
+                            x.TeamName,
+                            x.Id,
+                            provinceId,
+                        };
+                    })
+                    .ToList();
 
                 return Ok(JsonView(true, "SUCCESS!", new
                 {
@@ -17203,6 +17540,60 @@ ORDER by  gctggrc.id DESC
             return Ok(jw);
         }
 
+
+        [HttpPost]
+        public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
+        {
+            var jw = JsonView(true);
+
+            List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
+
+            if (string.IsNullOrWhiteSpace(dto.Keyword))
+            {
+                matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
+                     Select  a.Id,TeamName GroupName,b.isTrue From  Grp_DelegationInfo  a left join  (select top 100 percent Diid, CASE 
+                      WHEN COUNT(*) >= 0 THEN 'True' 
+                      ELSE 'False' END as isTrue  from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
+                       Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
+                   ")
+               .ToList();
+            }
+            else
+            {
+                string likeKey = string.Empty;
+
+                foreach (var item in dto.Keyword)
+                {
+                    likeKey += "%" + item;
+                }
+
+                likeKey += "%";
+
+                matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
+                     Select  a.Id,TeamName GroupName,b.isTrue From  Grp_DelegationInfo  a left join  (select top 100 percent Diid, CASE 
+                      WHEN COUNT(*) >= 0 THEN 'True' 
+                      ELSE 'False' END as isTrue  from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
+                       Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}'   Order By a.VisitStartDate Desc
+                   ")
+               .ToList();
+            }
+
+            if (matches.Any())
+            {
+                jw.Data = matches;
+            }
+            else
+            {
+                jw.Code = 201;
+                jw.Msg = "empty list";
+                jw.Data = new List<string>(1);
+            }
+
+
+
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 酒店预订 新 雷怡 2023-12-28 17:45
@@ -22955,118 +23346,118 @@ And (UnitName != '' Or UnitName != null) {sqlWhere}");
             }
         }
 
-        [HttpPost]
-        public async Task<IActionResult> ServerHttp(string paramStr)
-        {
-            paramStr = paramStr.TrimEnd('\'');
-            paramStr = paramStr.TrimStart('\'');
-            JsonView jw = JsonView(false);
-            JObject param = JObject.Parse(paramStr);
-            if (!param.ContainsKey("url"))
-            {
-                jw.Msg = "url null";
-                return Ok(jw);
-            }
+        //[HttpPost]
+        //public async Task<IActionResult> ServerHttp(string paramStr)
+        //{
+        //    paramStr = paramStr.TrimEnd('\'');
+        //    paramStr = paramStr.TrimStart('\'');
+        //    JsonView jw = JsonView(false);
+        //    JObject param = JObject.Parse(paramStr);
+        //    if (!param.ContainsKey("url"))
+        //    {
+        //        jw.Msg = "url null";
+        //        return Ok(jw);
+        //    }
 
-            string url = param["url"]!.ToString();
-            var methon = "get";
+        //    string url = param["url"]!.ToString();
+        //    var methon = "get";
 
-            Dictionary<string, string> headValues = null;
-            string bodyStr = string.Empty;
+        //    Dictionary<string, string> headValues = null;
+        //    string bodyStr = string.Empty;
 
-            if (param.ContainsKey("methon"))
-            {
-                methon = param["methon"]!.ToString().ToLower();
-            }
+        //    if (param.ContainsKey("methon"))
+        //    {
+        //        methon = param["methon"]!.ToString().ToLower();
+        //    }
 
-            if (param.ContainsKey("header"))
-            {
-                var header = param["header"]!.ToString();
-                JObject headerJobject = JObject.Parse(header);
-                headValues = new Dictionary<string, string>();
-                foreach (JProperty item in headerJobject.Properties())
-                {
-                    var value = item.Value.ToString();
-                    var head = item.Path;
-                    headValues.Add(head, value);
-                }
-            }
+        //    if (param.ContainsKey("header"))
+        //    {
+        //        var header = param["header"]!.ToString();
+        //        JObject headerJobject = JObject.Parse(header);
+        //        headValues = new Dictionary<string, string>();
+        //        foreach (JProperty item in headerJobject.Properties())
+        //        {
+        //            var value = item.Value.ToString();
+        //            var head = item.Path;
+        //            headValues.Add(head, value);
+        //        }
+        //    }
 
-            HttpClient client = new HttpClient();
-            string responseString = string.Empty;
-            StringContent content = null;
+        //    HttpClient client = new HttpClient();
+        //    string responseString = string.Empty;
+        //    StringContent content = null;
 
-            if (headValues != null)
-            {
-                foreach (var item in headValues.Keys)
-                {
-                    if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
-                    {
-                        if (param.ContainsKey("body"))
-                        {
-                            bodyStr = param["body"]!.ToString();
-                        }
-                        content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
-                    }
-                    else
-                    {
-                        client.DefaultRequestHeaders.Add(item, headValues[item]);
-                    }
-                }
-            }
+        //    if (headValues != null)
+        //    {
+        //        foreach (var item in headValues.Keys)
+        //        {
+        //            if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
+        //            {
+        //                if (param.ContainsKey("body"))
+        //                {
+        //                    bodyStr = param["body"]!.ToString();
+        //                }
+        //                content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
+        //            }
+        //            else
+        //            {
+        //                client.DefaultRequestHeaders.Add(item, headValues[item]);
+        //            }
+        //        }
+        //    }
 
-            try
-            {
-                if (methon == "get")
-                {
-                    responseString = await client.GetStringAsync(url);
+        //    try
+        //    {
+        //        if (methon == "get")
+        //        {
+        //            responseString = await client.GetStringAsync(url);
 
-                }
-                else if (methon == "post")
-                {
-                    var request = new HttpRequestMessage(HttpMethod.Post, url)
-                    {
-                        Content = content
-                    };
-                    var response = await client.SendAsync(request);
+        //        }
+        //        else if (methon == "post")
+        //        {
+        //            var request = new HttpRequestMessage(HttpMethod.Post, url)
+        //            {
+        //                Content = content
+        //            };
+        //            var response = await client.SendAsync(request);
 
-                    try
-                    {
-                        Stream responseStream = await response.Content.ReadAsStreamAsync();
+        //            try
+        //            {
+        //                Stream responseStream = await response.Content.ReadAsStreamAsync();
 
-                        using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
-                        {
-                            using (StreamReader reader = new StreamReader(gzipStream))
-                            {
-                                responseString = await reader.ReadToEndAsync();
-                            }
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        responseString = await response.Content.ReadAsStringAsync();
-                    }
+        //                using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
+        //                {
+        //                    using (StreamReader reader = new StreamReader(gzipStream))
+        //                    {
+        //                        responseString = await reader.ReadToEndAsync();
+        //                    }
+        //                }
+        //            }
+        //            catch (Exception)
+        //            {
+        //                responseString = await response.Content.ReadAsStringAsync();
+        //            }
 
-                }
-                else
-                {
-                    responseString = "methon error";
-                }
+        //        }
+        //        else
+        //        {
+        //            responseString = "methon error";
+        //        }
 
-                jw = JsonView(true, "success", responseString);
-            }
-            catch (Exception ex)
-            {
-                jw.Msg = "error " + ex.Message;
-                jw.Data = ex.StackTrace;
-            }
-            finally
-            {
-                client.Dispose();
-            }
+        //        jw = JsonView(true, "success", responseString);
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        jw.Msg = "error " + ex.Message;
+        //        jw.Data = ex.StackTrace;
+        //    }
+        //    finally
+        //    {
+        //        client.Dispose();
+        //    }
 
-            return Ok(jw);
-        }
+        //    return Ok(jw);
+        //}
 
         #endregion
 

+ 76 - 0
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -2705,6 +2705,82 @@ namespace OASystem.API.OAMethodLib
         }
 
 
+        /// <summary>
+        /// op行程单 团组 城市路径
+        /// </summary>
+        /// <param name="black">黑屏代码实例</param>
+        /// <param name="separator">分隔符</param>
+        /// <returns></returns>
+        public static string GetGroupCityLine(Air_TicketBlackCode black, string separator)
+        {
+            string city = string.Empty;
+            if (black != null)
+            {
+                black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
+                var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
+                if (blackSp.Length > 0)
+                {
+                    try
+                    {
+                        var cityArrCode = new List<string>(20);
+                        foreach (var item in blackSp)
+                        {
+                            var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
+                            var IndexSelect = itemSp[2];
+                            var cityArrCodeLength = cityArrCode.Count - 1;
+                            var startCity = IndexSelect.Substring(0, 3);
+                            if (cityArrCodeLength > 0)
+                            {
+                                var arrEndCity = cityArrCode[cityArrCodeLength];
+                                if (arrEndCity != startCity)
+                                {
+                                    cityArrCode.Add(startCity.ToUpper());
+                                }
+                            }
+                            else
+                            {
+                                cityArrCode.Add(startCity.ToUpper());
+                            }
+
+                            var endCity = IndexSelect.Substring(3, 3);
+                            cityArrCode.Add(endCity.ToUpper());
+                        }
+
+                        var cityThree = string.Empty;
+                        cityArrCode.ForEach(x => cityThree += "'" + x + "',");
+                        cityThree = cityThree.TrimEnd(',');
+                        if (string.IsNullOrWhiteSpace(cityThree))
+                        {
+                            throw new Exception("error");
+                        }
+
+                        string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
+                        var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
+                        foreach (var item in cityArrCode)
+                        {
+                            var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
+                            if (find != null)
+                            {
+                                city += find.City + separator;
+                            }
+                            else
+                            {
+                                city += item + "[三字码未收录]" + separator;
+                            }
+                        }
+                        city = city.TrimEnd(char.Parse(separator));
+                    }
+                    catch (Exception e)
+                    {
+                        city = "[黑屏代码格式不正确!]";
+                    }
+                }
+            }
+            else city = "[黑屏代码有误!]";
+            return city;
+        }
+
+
         /// <summary>
         /// op行程单 团组 城市路径
         /// </summary>

+ 5 - 0
OASystem/OASystem.Domain/Dtos/Groups/GroupCostSavaDto.cs

@@ -1374,6 +1374,11 @@ namespace OASystem.Domain.Dtos.Groups
         public string Param { get; set; }
     }
 
+    public class SearchGroupByKeywordDto
+    {
+        public string Keyword { get; set; }
+    }
+
     public class HistoryCarDataView
     {
         public int id { get; set; }

+ 19 - 0
OASystem/OASystem.Domain/Dtos/Groups/GroupListDto.cs

@@ -272,6 +272,25 @@ namespace OASystem.Domain.Dtos.Groups
 
     }
 
+    public class DownGroupContractFileDto
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int GroupId { get; set; }
+
+        /// <summary>
+        /// 文件类型
+        /// </summary>
+        public int FileType { get; set; }
+
+
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        public int UserId { get; set; }
+    }
+
     public class GroupNameScreenDto : DtoBase
     {
         public string groupName { get; set; } = "";

+ 29 - 2
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -1,11 +1,13 @@
 using AutoMapper;
 using AutoMapper.Execution;
+using EyeSoft.Collections.Generic;
 using EyeSoft.Extensions;
 using MySqlX.XDevAPI.Relational;
 using Newtonsoft.Json;
 using NPOI.OpenXmlFormats.Dml.Diagram;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
+using NPOI.Util;
 using OASystem.Domain;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.AutoMappers;
@@ -399,7 +401,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 .WhereIF(rangeSetDataList.Count > 0, x => rangeSetDataList.Contains(x.Lvlid)) //省域条件
                 .WhereIF(dto.Category > 0, x => x.Category == dto.Category) //客户类别
                 .WhereIF(isSelectSearch && searchDataIds.Count > 0 , x => searchDataIds.Contains(x.Id)) //条件模糊查询
-                .OrderByDescending(x => x.CreateTime)
+                .OrderByDescending(x => x.LastUpdateTime)
                 .ToPageListAsync(pageIndex, pageSize, total);
 
                 NewClientDataView = _mapper.Map<List<NewClientDataView>>(clientDatas);
@@ -1389,9 +1391,34 @@ namespace OASystem.Infrastructure.Repositories.CRM
             var userArr =  _sqlSugar.SqlQueryable<Sys_Users>(sql).ToList();
             var dic = new Dictionary<int, int[]>()
             {
-                { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369 } }
+                { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
             };
 
+            try
+            {
+                var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
+                if (sqSetting != null)
+                {
+                    Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
+                    foreach (var item in result.Keys)
+                    {
+                        if (dic.Keys.Contains(item))
+                        {
+                            int[] dilatation = new int[dic[item].Length + result[item].Length];
+                            Array.Copy(dic[item], dilatation, dic[item].Length);
+                            Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
+                            dic[item] = dilatation;
+                        }
+                        else
+                        {
+                            dic.Add(item, result[item]);
+                        }
+                    }
+                }
+            }
+            catch (Exception)
+            {}
+
             if (dic.Keys.Contains(userid))
             {
                 return userArr.Where(x=> dic[userid].Contains(x.Id)).ToList();