|  | @@ -11,6 +11,7 @@ using Serilog;
 | 
	
		
			
				|  |  |  using SqlSugar;
 | 
	
		
			
				|  |  |  using System;
 | 
	
		
			
				|  |  |  using System.Collections.Generic;
 | 
	
		
			
				|  |  | +using System.Diagnostics;
 | 
	
		
			
				|  |  |  using System.Linq;
 | 
	
		
			
				|  |  |  using System.Text;
 | 
	
		
			
				|  |  |  using System.Threading.Tasks;
 | 
	
	
		
			
				|  | @@ -41,6 +42,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              Result result = new() { Code = -2 };
 | 
	
		
			
				|  |  | +            Stopwatch stopwatch = Stopwatch.StartNew(); 
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              GroupNameDto groupNameDto = new GroupNameDto() { PortType = dto.PortType };
 | 
	
		
			
				|  |  |              var groups = await _deleInfoRep.GetGroupNameList(groupNameDto);
 | 
	
	
		
			
				|  | @@ -51,19 +53,47 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (dto.PortType == 1)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                List<Sys_SetData> sys_SetDatas = new List<Sys_SetData>();
 | 
	
		
			
				|  |  | -                sys_SetDatas = JsonConvert.DeserializeObject<List<Sys_SetData>>(JsonConvert.SerializeObject(teamRateDatas.Data));
 | 
	
		
			
				|  |  | -                List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
 | 
	
		
			
				|  |  | -                foreach (Sys_SetData item in sys_SetDatas)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    teamRateDescViews.Add(new TeamRateDescView()
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        CurrencyName = item.Remark,
 | 
	
		
			
				|  |  | -                        CurrencyCode = item.Name,
 | 
	
		
			
				|  |  | -                        Rate = 0.0000M
 | 
	
		
			
				|  |  | -                    });
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                _data = new { GroupData = groups.Data, TeamRateData = teamRateDescViews };
 | 
	
		
			
				|  |  | +                //List<Sys_SetData> sys_SetDatas = new List<Sys_SetData>();
 | 
	
		
			
				|  |  | +                //sys_SetDatas = JsonConvert.DeserializeObject<List<Sys_SetData>>(JsonConvert.SerializeObject(teamRateDatas.Data));
 | 
	
		
			
				|  |  | +                //List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //teamRateDescViews = sys_SetDatas.Select(it => new TeamRateDescView() { CurrencyName = it.Remark, CurrencyCode = it.Name, Rate = 0.0000M }).ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ///*
 | 
	
		
			
				|  |  | +                // * 放在首位币种
 | 
	
		
			
				|  |  | +                // * 人名币 CNY Rate = 1,美元 USD,欧元 EUR,港币 HKD,日元 JPY ,澳大利 AUD,英镑 GBP
 | 
	
		
			
				|  |  | +                // * 依次排序
 | 
	
		
			
				|  |  | +                // */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////人名币
 | 
	
		
			
				|  |  | +                //var cnyData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("CNY"));
 | 
	
		
			
				|  |  | +                //if (cnyData != null) { teamRateDescViews.Remove(cnyData); cnyData.Rate = 1.0000M; teamRateDescViews.Insert(0, cnyData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////美元
 | 
	
		
			
				|  |  | +                //var usdData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("USD"));
 | 
	
		
			
				|  |  | +                //if (usdData != null) { teamRateDescViews.Remove(usdData); teamRateDescViews.Insert(1, usdData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////欧元
 | 
	
		
			
				|  |  | +                //var eurData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("EUR"));
 | 
	
		
			
				|  |  | +                //if (eurData != null) { teamRateDescViews.Remove(eurData); teamRateDescViews.Insert(2, eurData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////港币
 | 
	
		
			
				|  |  | +                //var hkdData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("HKD"));
 | 
	
		
			
				|  |  | +                //if (hkdData != null) { teamRateDescViews.Remove(hkdData); teamRateDescViews.Insert(3, hkdData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////日元
 | 
	
		
			
				|  |  | +                //var jpyData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("JPY"));
 | 
	
		
			
				|  |  | +                //if (jpyData != null) { teamRateDescViews.Remove(jpyData); teamRateDescViews.Insert(4, jpyData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////澳大利
 | 
	
		
			
				|  |  | +                //var audData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("AUD"));
 | 
	
		
			
				|  |  | +                //if (audData != null) { teamRateDescViews.Remove(audData); teamRateDescViews.Insert(5, audData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                ////英镑
 | 
	
		
			
				|  |  | +                //var gbpData = teamRateDescViews.Find(it => it.CurrencyCode.Equals("GBP"));
 | 
	
		
			
				|  |  | +                //if (gbpData != null) { teamRateDescViews.Remove(gbpData); teamRateDescViews.Insert(6, gbpData); }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                _data = new { GroupData = groups.Data, TeamRateData = await PostGroupTeamRateHot() };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else if (dto.PortType == 2)
 | 
	
	
		
			
				|  | @@ -76,9 +106,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            stopwatch.Stop();
 | 
	
		
			
				|  |  |              result.Code = 0;
 | 
	
		
			
				|  |  | -            result.Msg = "查询成功!";
 | 
	
		
			
				|  |  | +            result.Msg = $"查询成功!耗时:{stopwatch.ElapsedMilliseconds / 1000}s";
 | 
	
		
			
				|  |  |              result.Data = _data;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return result;
 | 
	
	
		
			
				|  | @@ -637,5 +667,120 @@ namespace OASystem.Infrastructure.Repositories.Groups
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return teamRateDescAddCurrencyIdViews;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 获取团组汇率 币种使用次数
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        public async Task<List<CurrencyHot>> PostGroupTeamRateHot()
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            List<CurrencyHot> _view = new List<CurrencyHot>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr 
 | 
	
		
			
				|  |  | +                                                         Left Join Sys_SetData  sd On sd.IsDel=0 And sd.STid=16  And tr.CTable = sd.Id 
 | 
	
		
			
				|  |  | +                                                         Where tr.IsDel = 0 ");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var teamRateInfo = _sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
 | 
	
		
			
				|  |  | +            #region 获取所有币种
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string sql = string.Format(@"Select * From Sys_SetData Where STid = {0} And IsDel = 0", 66);
 | 
	
		
			
				|  |  | +            var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (DBdata == null || DBdata.Count == 0)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return _view;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            currencyDatas = DBdata.Select(x => new SetDataInfoView
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                Name = x.Name,
 | 
	
		
			
				|  |  | +                Id = x.Id,
 | 
	
		
			
				|  |  | +                Remark = x.Remark,
 | 
	
		
			
				|  |  | +            }).ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            _view = currencyDatas.Select(it => new CurrencyHot() { CurrencyId = it.Id,  CurrencyCode = it.Name, CurrencyName = it.Remark}).ToList();
 | 
	
		
			
				|  |  | +            #endregion
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<TeamRateDescAddCurrencyIdView> teamRateDatas = new List<TeamRateDescAddCurrencyIdView>();
 | 
	
		
			
				|  |  | +            foreach (TeamRateInfoView item in teamRateInfo)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                #region 拆分remark里的汇率
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (item.Remark.Contains("|"))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    string[] currencyArr = item.Remark.Split("|");
 | 
	
		
			
				|  |  | +                    foreach (string currency in currencyArr)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        string[] currency1 = currency.Split(":");
 | 
	
		
			
				|  |  | +                        string[] currency2 = currency1[0].Split("(");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        string currencyCode = currency2[1].Replace(")", "").TrimEnd();
 | 
	
		
			
				|  |  | +                        SetDataInfoView dataInfoView = new SetDataInfoView();
 | 
	
		
			
				|  |  | +                        dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
 | 
	
		
			
				|  |  | +                        int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
 | 
	
		
			
				|  |  | +                        TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            CurrencyId = dataInfoView.Id,
 | 
	
		
			
				|  |  | +                            CurrencyCode = currencyCode,
 | 
	
		
			
				|  |  | +                            CurrencyName = currency2[0],
 | 
	
		
			
				|  |  | +                            Rate = decimal.Parse(currency1[1]),
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                        teamRateDescViews.Add(rateDescView);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    if (!string.IsNullOrEmpty(item.Remark))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        string[] currency1 = item.Remark.Split(":");
 | 
	
		
			
				|  |  | +                        string[] currency2 = currency1[0].Split("(");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        string currencyCode = currency2[1].Replace(")", "").TrimEnd();
 | 
	
		
			
				|  |  | +                        SetDataInfoView dataInfoView = new SetDataInfoView();
 | 
	
		
			
				|  |  | +                        dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
 | 
	
		
			
				|  |  | +                        int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
 | 
	
		
			
				|  |  | +                        TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            CurrencyId = dataInfoView.Id,
 | 
	
		
			
				|  |  | +                            CurrencyCode = currencyCode,
 | 
	
		
			
				|  |  | +                            CurrencyName = currency2[0],
 | 
	
		
			
				|  |  | +                            Rate = decimal.Parse(currency1[1]),
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                        teamRateDescViews.Add(rateDescView);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                #endregion
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (teamRateDescViews.Count > 0)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
 | 
	
		
			
				|  |  | +                    teamRateDatas.AddRange(teamRateDescViews);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            foreach (var item in _view)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                if (item.CurrencyId == 836) // 人名币
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    item.Rate = 1.0000M;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                item.Number = teamRateDatas.Where(it => item.CurrencyId == it.CurrencyId).ToList().Count;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (_view.Count > 0)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                _view = _view.OrderByDescending(it => it.Number).ToList();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return _view;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |