Browse Source

地图api调整 -->
1、当前日期、时间匹配公务出访时间返回地址
2、当前日期、时间匹配酒店时间(晚上6点-早上9点之间)返回地址

LEIYI 2 months ago
parent
commit
09365b21a5

+ 264 - 153
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -1,5 +1,7 @@
 using Aspose.Cells;
 using Aspose.Words.Tables;
+using EyeSoft.Collections.Generic;
+using Google.Protobuf.WellKnownTypes;
 using Microsoft.AspNetCore.Mvc.ViewEngines;
 using Microsoft.EntityFrameworkCore.Metadata.Internal;
 using MySqlX.XDevAPI.Relational;
@@ -8,11 +10,13 @@ using NPOI.POIFS.Properties;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.Formula.PTG;
 using OASystem.API.OAMethodLib;
+using OASystem.API.OAMethodLib.JuHeAPI;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Statistics;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -38,22 +42,28 @@ namespace OASystem.API.Controllers
         private readonly SetDataRepository _setDataRep;
         private readonly TeamRateRepository _teamRateRep;
         private readonly VisitingClientsRepository _visitingClientsRep;
+        private readonly IJuHeApiService _juHeApiService;
 
         /// <summary>
         /// Init
         /// </summary>
         /// <param name="mapper"></param>
+        /// <param name="config"></param>
         /// <param name="sqlSugar"></param>
         /// <param name="groupRep"></param>
         /// <param name="setDataRep"></param>
+        /// <param name="teamRate"></param>
+        /// <param name="visitingClientsRep"></param>
+        /// <param name="juHeApiService"></param>
         public StatisticsController(
-            IMapper mapper, 
-            IConfiguration config, 
-            SqlSugarClient sqlSugar, 
-            DelegationInfoRepository groupRep, 
-            SetDataRepository setDataRep, 
-            TeamRateRepository teamRate, 
-            VisitingClientsRepository visitingClientsRep
+            IMapper mapper,
+            IConfiguration config,
+            SqlSugarClient sqlSugar,
+            DelegationInfoRepository groupRep,
+            SetDataRepository setDataRep,
+            TeamRateRepository teamRate,
+            VisitingClientsRepository visitingClientsRep,
+            IJuHeApiService juHeApiService
             )
         {
             _mapper = mapper;
@@ -63,6 +73,7 @@ namespace OASystem.API.Controllers
             _sqlSugar = sqlSugar;
             _teamRateRep = teamRate;
             _visitingClientsRep = visitingClientsRep;
+            _juHeApiService = juHeApiService;
         }
 
         #region 团组报表
@@ -254,63 +265,63 @@ namespace OASystem.API.Controllers
                  * 超支费用 
                  */
                 decimal exTotalAmount = 0.00M;
-            //    string ecSql = string.Format(@"Select gec.Id As GECId,gec.DiId As GECDiId,gec.PriceName,(gec.PriceSum * gec.Coefficient) As PayMoney,sd1.Name As PaymentCurrency,
-												//	   (gec.PriceSum * gec.Coefficient * ccp.DayRate) As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
-												//	   sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,gec.CreateTime
-												//From OA2023DB.dbo.Fin_GroupExtraCost gec
-												//Left Join Grp_CreditCardPayment ccp On gec.Id = ccp.CId
-            //                                    Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
-            //                                    Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id 
-            //                                    Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
-            //                                    Left Join Sys_Users u On ccp.CreateUserId = u.Id
-												//Where ccp.IsDel = 0 And ccp.CTable = 1015 {1} And ccp.DiId = {0} Order By CreateTime", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1 And ccp.IsPay = 1 " : " ");
-
-            //    List<Gsd_ExtraCostsView> _ExtraCostsViews = await _sqlSugar.SqlQueryable<Gsd_ExtraCostsView>(ecSql).ToListAsync();
-
-            //    #region 超支费用 - 模拟数据
-
-            //    //if (_ExtraCostsViews.Count < 1)
-            //    //{
-            //    //    _ExtraCostsViews.Add(new Gsd_ExtraCostsView()
-            //    //    {
-            //    //        GECId = 0,
-            //    //        GECDiId = 2334,
-            //    //        PriceName = "模拟数据-超支费用名称",
-            //    //        PayMoney = 1000.00M,
-            //    //        PaymentCurrency = "CNY",
-            //    //        DayRate = 1.0000M,
-            //    //        CNYPrice = 1000.00M,
-            //    //        Payee = "模拟数据-超支费用收款方",
-            //    //        OrbitalPrivateTransfer = 1,
-            //    //        PayWay = "刷卡",
-            //    //        CardType = "招行卡",
-            //    //        IsPay = 1,
-            //    //        Applicant = "刘华举"
-            //    //    });
-            //    //    _ExtraCostsViews.Add(new Gsd_ExtraCostsView()
-            //    //    {
-            //    //        GECId = 0,
-            //    //        GECDiId = 2334,
-            //    //        PriceName = "模拟数据-超支费用名称",
-            //    //        PayMoney = 1000.00M,
-            //    //        PaymentCurrency = "CNY",
-            //    //        DayRate = 1.0000M,
-            //    //        CNYPrice = 1000.00M,
-            //    //        Payee = "模拟数据-超支费用收款方",
-            //    //        OrbitalPrivateTransfer = 1,
-            //    //        PayWay = "刷卡",
-            //    //        CardType = "招行卡",
-            //    //        IsPay = 1,
-            //    //        Applicant = "刘华举"
-            //    //    });
-            //    //}
-            //    #endregion
-
-
-            //    exTotalAmount = _ExtraCostsViews.Sum(it => it.CNYPrice);
-
-            //    _giView.ExtraCostsViews = _ExtraCostsViews;
-            //    _giView.ExtraCostsStr = string.Format(@"人民币总费用:{0} CNY", exTotalAmount.ConvertToDecimal1().ToString("#0.00"));
+                //    string ecSql = string.Format(@"Select gec.Id As GECId,gec.DiId As GECDiId,gec.PriceName,(gec.PriceSum * gec.Coefficient) As PayMoney,sd1.Name As PaymentCurrency,
+                //	   (gec.PriceSum * gec.Coefficient * ccp.DayRate) As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
+                //	   sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,gec.CreateTime
+                //From OA2023DB.dbo.Fin_GroupExtraCost gec
+                //Left Join Grp_CreditCardPayment ccp On gec.Id = ccp.CId
+                //                                    Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                //                                    Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id 
+                //                                    Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
+                //                                    Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                //Where ccp.IsDel = 0 And ccp.CTable = 1015 {1} And ccp.DiId = {0} Order By CreateTime", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1 And ccp.IsPay = 1 " : " ");
+
+                //    List<Gsd_ExtraCostsView> _ExtraCostsViews = await _sqlSugar.SqlQueryable<Gsd_ExtraCostsView>(ecSql).ToListAsync();
+
+                //    #region 超支费用 - 模拟数据
+
+                //    //if (_ExtraCostsViews.Count < 1)
+                //    //{
+                //    //    _ExtraCostsViews.Add(new Gsd_ExtraCostsView()
+                //    //    {
+                //    //        GECId = 0,
+                //    //        GECDiId = 2334,
+                //    //        PriceName = "模拟数据-超支费用名称",
+                //    //        PayMoney = 1000.00M,
+                //    //        PaymentCurrency = "CNY",
+                //    //        DayRate = 1.0000M,
+                //    //        CNYPrice = 1000.00M,
+                //    //        Payee = "模拟数据-超支费用收款方",
+                //    //        OrbitalPrivateTransfer = 1,
+                //    //        PayWay = "刷卡",
+                //    //        CardType = "招行卡",
+                //    //        IsPay = 1,
+                //    //        Applicant = "刘华举"
+                //    //    });
+                //    //    _ExtraCostsViews.Add(new Gsd_ExtraCostsView()
+                //    //    {
+                //    //        GECId = 0,
+                //    //        GECDiId = 2334,
+                //    //        PriceName = "模拟数据-超支费用名称",
+                //    //        PayMoney = 1000.00M,
+                //    //        PaymentCurrency = "CNY",
+                //    //        DayRate = 1.0000M,
+                //    //        CNYPrice = 1000.00M,
+                //    //        Payee = "模拟数据-超支费用收款方",
+                //    //        OrbitalPrivateTransfer = 1,
+                //    //        PayWay = "刷卡",
+                //    //        CardType = "招行卡",
+                //    //        IsPay = 1,
+                //    //        Applicant = "刘华举"
+                //    //    });
+                //    //}
+                //    #endregion
+
+
+                //    exTotalAmount = _ExtraCostsViews.Sum(it => it.CNYPrice);
+
+                //    _giView.ExtraCostsViews = _ExtraCostsViews;
+                //    _giView.ExtraCostsStr = string.Format(@"人民币总费用:{0} CNY", exTotalAmount.ConvertToDecimal1().ToString("#0.00"));
 
                 /*
                  * 收款退还
@@ -1383,7 +1394,7 @@ ORDER BY
 
             //签证费用相关 
             var visaFeeSheet = worksheets["签证费用"];
-            var visaFeeDt = new DataTable($"VisaFeeView"); 
+            var visaFeeDt = new DataTable($"VisaFeeView");
             decimal visaCNYTotalCost = 0.00M;
 
             //邀请费用相关 
@@ -1428,7 +1439,7 @@ ORDER BY
 
             //团组收入支出利润
             var groupIEProfitDt = new DataTable($"IEProfitFeeView");
-            
+
             #endregion
 
             #region 酒店费用
@@ -1665,7 +1676,7 @@ ORDER BY
                 var groupOPFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
                 string CTGGRFeeStr = "";
                 var OPToDataTableViews = groupOPFeeViews;
-                
+
                 decimal CTGGRCNYTotalPrice = 0.00M;
 
                 //按1 地区,2 币种,3 汇率 分组计算
@@ -1739,7 +1750,7 @@ ORDER BY
                                                          Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
                                                          Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
                                                          Left Join Sys_Users u On ccp.CreateUserId = u.Id
-                                                         Where vi.IsDel = 0 {1} And vi.DIId = {0} Order By CreateTime", diId,isAudit ? "And ccp.IsAuditGM = 1" : " ");
+                                                         Where vi.IsDel = 0 {1} And vi.DIId = {0} Order By CreateTime", diId, isAudit ? "And ccp.IsAuditGM = 1" : " ");
 
                 var groupVisaFeeViews = _sqlSugar.SqlQueryable<GroupVisaFeeExcelView>(groupVisaFeeSql).ToList();
 
@@ -1878,13 +1889,13 @@ ORDER BY
                         {
                             List<int> output = new List<int>();
                             foreach (var clientId in clientIds)
-                                if (int.TryParse(clientId, out int id)) 
+                                if (int.TryParse(clientId, out int id))
                                     output.Add(id);
 
                             if (output.Count > 0)
                             {
                                 var clients = _clientDatas.Where(it => output.Contains(it.Id)).ToList();
-                                
+
                                 foreach (var client in clients)
                                 {
                                     EncryptionProcessor.DecryptProperties(client);
@@ -2023,7 +2034,7 @@ ORDER BY
 										        Left Join Sys_SetData sd On fr.Currency = sd.Id
 												Left Join Sys_Users u On fr.Auditor = u.Id
 										        Where fr.IsDel = 0 And fr.Diid = {0} Order By CreateTime", _dto.DiId);
-           var _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
+            var _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
 
             _frViews.ForEach(x =>
             {
@@ -2053,7 +2064,7 @@ ORDER BY
 										        Left Join Sys_SetData sd2 On pr.ReceivablesType = sd2.Id
 										        Where pr.IsDel = 0 and pr.Diid = {0} Order By CreateTime", _dto.DiId);
             var _prViews = await _sqlSugar.SqlQueryable<Gsd_ProceedsReceivedView>(_prSql).ToListAsync();
-            
+
             if (_prViews.Any())
             {
                 receivedAmount = _prViews.Sum(it => it.Price);
@@ -2200,7 +2211,7 @@ ORDER BY
             return Ok(JsonView(true, "成功", url));
         }
 
-        private void StatementExportExcelSetCell(WorkbookDesigner designer, Worksheet sheet,DataTable dt, Style style,string judgeLable,  int startIndex, string startRange,string endRange)
+        private void StatementExportExcelSetCell(WorkbookDesigner designer, Worksheet sheet, DataTable dt, Style style, string judgeLable, int startIndex, string startRange, string endRange)
         {
             if (designer == null) return;
             if (sheet == null) return;
@@ -3268,8 +3279,8 @@ ORDER BY
         {
             //全部人员Id
             //查询所有公司的市场部
-           var pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
-           var userIds = new List<int>();
+            var pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
+            var userIds = new List<int>();
             var userDatas = await _sqlSugar.Queryable<Sys_Users>()
                                            .InnerJoin<Sys_Company>((u, c) => u.CompanyId == c.Id)
                                            .Where((u, c) => u.IsDel == 0 && pickGroupIds.Contains(u.Id))
@@ -3617,7 +3628,7 @@ FROM
                 userSql += string.Format(@$" AND di.TeamName Like '%{_dto.SearchCriteria}%'");
             }
 
-            string beginDt = $"{_dto.BeginDt} 00:00:00", 
+            string beginDt = $"{_dto.BeginDt} 00:00:00",
                    endDt = $"{_dto.EndDt} 23:59:59";
 
             string sql = string.Format(@$"SELECT
@@ -3675,11 +3686,11 @@ FROM
       AND di.TeamName Not Like '%投标%'
       AND VisitDate Between '{beginDt}' And  '{endDt}'
   ) Temp ");
-            
+
             var view = await _sqlSugar.SqlQueryable<MarketingSalesGroupList>(sql).ToListAsync();
 
 
-            if (view.Count < 1 ) return Ok(JsonView(false, "暂无数据!"));
+            if (view.Count < 1) return Ok(JsonView(false, "暂无数据!"));
 
             //DataTable dt = GeneralMethod.
             DataTable dt = CommonFun.GetDataTableFromIList(view);
@@ -4963,16 +4974,18 @@ WHERE
                     platform = g.Key,
                     total = g.Sum(x => x.ClientNum),
                     children = g.GroupBy(g1 => g1.DIId)
-                                .Select(g1 => new { 
+                                .Select(g1 => new
+                                {
                                     diId = g1.Key,
                                     groupName = g1.FirstOrDefault()?.GroupName ?? "-",
                                     total = g1.Sum(x1 => x1.ClientNum),
-                                    children = g1.Select(x1 => new {
+                                    children = g1.Select(x1 => new
+                                    {
                                         //diId = x1.DIId,
                                         //groupName = x1.GroupName,
-                                                  flightsCityName=x1.FlightsCityName,
-                                                  total = x1.ClientNum
-                                                 })
+                                        flightsCityName = x1.FlightsCityName,
+                                        total = x1.ClientNum
+                                    })
                                                  .ToList()
                                 })
                                 .OrderByDescending(x1 => x1.total)
@@ -5192,9 +5205,9 @@ WHERE
                                   .OrderByDescending(x => x.TimeNum)
                                   .Take(10)
                                   .ToList();
-            
 
-            return Ok(JsonView(true, "操作成功!", new { groupByCountry= groupByCountry, groupByClient = groupByClient }));
+
+            return Ok(JsonView(true, "操作成功!", new { groupByCountry = groupByCountry, groupByClient = groupByClient }));
         }
 
         /// <summary>
@@ -5681,7 +5694,7 @@ ORDER BY
                 var monthData = opInfos.GroupBy(x => x.Month)
                                        .Select(x => new StatisticsOPMonthYOY(
                                                monthId: x.Key,
-                                               monthName: Enum.IsDefined(typeof(MonthEnum), (int)x.Key) ? ((MonthEnum)(int)x.Key).GetEnumDescription() : "",
+                                               monthName: System.Enum.IsDefined(typeof(MonthEnum), (int)x.Key) ? ((MonthEnum)(int)x.Key).GetEnumDescription() : "",
                                                feeDatas: x.GroupBy(x1 => x1.ParentFeeId)
                                                          .Select(x1 => new StatisticsOPYOY(
                                                                        feeId: x1.Key,
@@ -5725,7 +5738,7 @@ ORDER BY
                     {
                         monthData.Add(new StatisticsOPMonthYOY(
                                           monthId: item,
-                                          monthName: Enum.IsDefined(typeof(MonthEnum), (int)item) ? ((MonthEnum)(int)item).GetEnumDescription() : "",
+                                          monthName: System.Enum.IsDefined(typeof(MonthEnum), (int)item) ? ((MonthEnum)(int)item).GetEnumDescription() : "",
                                           feeDatas: Array.Empty<StatisticsOPYOY>()
                                           ));
                     }
@@ -6058,7 +6071,7 @@ WHERE
                 var diIds = data.Select(x => x.Id).ToList();
                 var currencyData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
                 var ccpData = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
-                    .Where(x => x.IsDel == 0 && 
+                    .Where(x => x.IsDel == 0 &&
                                 diIds.Contains(x.DIId) &&
                                 x.IsPay == 1 &&
                                 x.IsAuditGM == 1
@@ -6102,7 +6115,7 @@ WHERE
                     #endregion
 
                     #region 3:酒店 76
-                    var hotelDatas = ccpData.Where(x => x.DIId == info.Id && x.CTable == 76 && x.PayMoney != 0 ).ToList();
+                    var hotelDatas = ccpData.Where(x => x.DIId == info.Id && x.CTable == 76 && x.PayMoney != 0).ToList();
                     var hotelDesc = "-";
                     if (hotelDatas.Count > 0)
                     {
@@ -6179,106 +6192,204 @@ WHERE
         public async Task<IActionResult> StatisticsNowCityOfGroup(StatisticsNowCityOfGroupDto dto)
         {
             if (!SharingStaticData.PortTypes.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
-            var nowLable = dto.Now;
-            var nowBool = DateTime.TryParse(nowLable, out DateTime now);
-            if (!nowBool) return Ok(JsonView(false, $"请传入有效的当前时间(2024-11-27)!"));
+
+            var nowLable = DateTime.Now.ToString("yyyy-MM-dd");
 
             var sql = string.Format(@"SELECT * FROM Grp_DelegationInfo WHERE ISdel = 0  AND '{0}' BETWEEN VisitStartDate AND VisitEndDate", nowLable);
-            var groupInfos = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).Select(x => new { x.Id, x.VisitCountry, x.TeamName, x.VisitStartDate, x.VisitEndDate }).ToListAsync();
+            var groupInfos = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql)
+                .Select(x => new { x.Id, x.VisitCountry, x.TeamName,x.ClientUnit, x.VisitStartDate, x.VisitEndDate }).
+                ToListAsync();
+
+            if (!groupInfos.Any()) return Ok(JsonView(false, "今日暂无团组出行!"));
 
             var groupIds = groupInfos.Select(x => x.Id).ToList();
-            #region 舱位类型
-            //457   头等舱
-            //458   公务舱
-            //459   超经舱
-            //460   经济舱
-            //461   退票
-            //565   其他
-            //574   长段公务舱
-            //575   短途经济舱
-            //1023  行程单打印费
-            //1024  选座费
 
-            var classTypes = new int[] { 457, 458, 459, 460, 574, 575 };
+            //三字码
+            var threeDatas = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
 
-            #endregion
+            //国家
+            var countryDatas = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.Country) && !string.IsNullOrEmpty(x.City)).ToListAsync();
 
-            var throughCities = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
-                .LeftJoin<Grp_DelegationInfo>((atr, di) => atr.DIId == di.Id)
-                .Where((atr, di) => atr.IsDel == 0 && 
-                                    groupIds.Contains(atr.DIId) && 
-                                    atr.FlightsDate.Trim().Equals(nowLable) && 
-                                    classTypes.Contains(atr.CType))
-                .Select((atr, di) => new
-                {
-                    atr.DIId,
-                    di.TeamName,
-                    atr.FlightsDate,
-                    atr.FlightsCode,
-                    atr.FlightsCity,
-                    atr.FlightsDescription
+            //公务
+            var OADatas = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && groupIds.Contains(x.DiId) && !string.IsNullOrEmpty(x.Area)).ToListAsync();
+
+            //酒店
+            var hotelDatas = await _sqlSugar.Queryable<Grp_HotelReservations>()
+                .LeftJoin<Grp_NationalTravelFee>((hr, ntf) => hr.AreaId == ntf.Id)
+                .Where((hr, ntf) => hr.IsDel == 0 && groupIds.Contains(hr.DiId))
+                .Select((hr, ntf) => new { 
+                    hr.DiId,
+                    hr.HotelName,
+                    hr.CheckInDate,
+                    hr.CheckOutDate,
+                    hr.HotelAddress,
+                    ntf.Country,
+                    ntf.City
                 })
                 .ToListAsync();
 
-            if (!throughCities.Any()) return Ok(JsonView(false,"今日暂无团组出行!"));
+            //机票
+            /*
+            *舱位类型
+            *457   头等舱
+            *458   公务舱
+            *459   超经舱
+            *460   经济舱
+            *461   退票
+            *565   其他
+            *574   长段公务舱
+            *575   短途经济舱
+            *1023  行程单打印费
+            *1024  选座费
+            */
+            var classTypes = new int[] { 457, 458, 459, 460, 574, 575 };
+
+            var airDatas = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
+                .Where(atr => atr.IsDel == 0 && groupIds.Contains(atr.DIId) && classTypes.Contains(atr.CType))
+                .ToListAsync();
 
-            foreach (var item in throughCities)
+            //洲 当前时间data
+            var continents = new List<string>();
+            var groupCountrys = new List<string>();
+            string[] characters = { "|", "、" };
+            foreach (var item in groupInfos)
             {
-                var dt = GeneralMethod.GetTableByBlackCode(item.DIId);
+                var country = item.VisitCountry;
+                if (string.IsNullOrEmpty(country)) continue;
 
-                foreach (var row in dt.Rows)
+                if (characters.Any(x => country.Contains(x)))
+                {
+                    var countryArray = country.Split(characters, StringSplitOptions.RemoveEmptyEntries);
+                    foreach (var country1 in countryArray)
+                    {
+                        groupCountrys.Add(country1);
+                        var continent = countryDatas.Find(x => x.Country.Equals(country1))?.Continent ?? countryDatas.Find(x => x.City.Equals(country1))?.Continent ?? "";
+                        if (!string.IsNullOrEmpty(continent)) continents.Add(continent);
+                    }
+                }
+                else
                 {
+                    groupCountrys.Add(country);
+                    var continent = countryDatas.Find(x => x.Country.Equals(country))?.Continent ?? countryDatas.Find(x => x.City.Equals(country))?.Continent ?? "";
+                    if (!string.IsNullOrEmpty(continent)) continents.Add(continent);
+                }
+            }
 
-                    
+            if (!continents.Any()) return Ok(JsonView(false, "未查询出国家所属洲!"));
+
+            continents = continents.Distinct().ToList();
+            var tzDatas = new List<TimezoneInfoView>();
+            var juHeApiMsg = "";
+            foreach (var continent in continents)
+            {
+                var tzResult = await _juHeApiService.GetContinentTimezoneAsync(continent);
+                if (tzResult.Error_code != 0)
+                {
+                    juHeApiMsg += string.Format("{0}\r", tzResult.Reason);
+                    continue;
+                }
 
+                if (tzResult.Result == null)
+                {
+                    juHeApiMsg += string.Format("聚合api响应数据为空\r");
+                    continue;
                 }
 
-            }
+                var info = JsonConvert.DeserializeObject<ContinentInfoView>(tzResult.Result.ToJson());
+                if (info == null && !info.tz.Any())
+                {
+                    juHeApiMsg += string.Format("聚合api响应数据为空\r");
+                    continue;
+                }
 
+                tzDatas.AddRange(info.tz);
+            }
 
+            if (!tzDatas.Any()) return Ok(JsonView(false, $"聚合API获取世界时间失败!! Message:{juHeApiMsg}"));
 
+            var groupCountrytz = tzDatas.Where(x => groupCountrys.Contains(x.tz_simple)).ToList();
+            
 
-            throughCities = throughCities.Distinct().ToList(); // 去重
-            var cities = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
+            var result = new List<StatisticsNowCityOfGroupResultView>();
 
-            var view = new List<StatisticsNowCityOfGroupView>();
-            foreach (var item in throughCities)
+            foreach (var item in groupInfos)
             {
-                var viewInfo = new StatisticsNowCityOfGroupView();
+                string statusText = string.Empty,
+                       address = string.Empty;
+                var countrys = item.VisitCountry;
+                if (string.IsNullOrEmpty(countrys)) continue;
 
-                string flightCityLable = item.FlightsCity,
-                       flightNoLable = item.FlightsCode;
+                var currCountrys = item.VisitCountry.Split(characters, StringSplitOptions.RemoveEmptyEntries);
 
-                if (flightCityLable.Contains(@"/") && flightNoLable.Contains(@"/"))
+                var stutus = true;
+                //公务
+                var currOADatas = OADatas.Where(x => x.DiId == item.Id && currCountrys.Any(c => x.Country.Contains(c))).ToList();
+                if (currOADatas.Any())
                 {
-                    var flightCityArray = flightCityLable.Split(@"/"); 
-                    var flightNoArray = flightNoLable.Split(@"/");
-                    int index = 0;
-                    foreach (var citys in flightCityArray)
+                    foreach (var curr_oa in currOADatas)
                     {
-                        viewInfo = CitySplit(citys, cities);
-                        viewInfo.CurrDate = nowLable;
-                        viewInfo.GroupName = item.TeamName;
-                        viewInfo.FlightNo = flightNoArray[index];
-                        view.Add(viewInfo);
-                        index++;
+                        var currOaDtStart = Convert.ToDateTime($"{Convert.ToDateTime(curr_oa.Date).ToString("yyyy-MM-dd")} {curr_oa.Time}");
+                        var currOaDtEnd = currOaDtStart.AddHours(2);
+
+                        var curr_tz1 = tzDatas.Where(x => curr_oa.Area.Contains(x.tz_simple)).ToList();
+                        var curr_tz2 = curr_tz1.Where(x => Convert.ToDateTime(x.time) >= currOaDtStart && Convert.ToDateTime(x.time) <= currOaDtEnd).FirstOrDefault();
+                        if (curr_tz2 == null) continue;
+
+                        stutus = false;
+                        statusText = "公务活动中";
+                        address = curr_oa.Address;
+                        break;
                     }
                 }
-                else
+
+                //酒店
+                var currHotelDatas = hotelDatas.Where(x => x.DiId == item.Id && !string.IsNullOrEmpty(x.Country) && currCountrys.Any(c => x.Country.Contains(c))).ToList();
+                if (stutus && hotelDatas.Any())
                 {
-                    viewInfo = CitySplit(flightCityLable, cities);
-                    viewInfo.CurrDate = nowLable;
-                    viewInfo.GroupName = item.TeamName;
-                    viewInfo.FlightNo = flightNoLable;
-                    view.Add(viewInfo);
+                    foreach (var curr_hotel in currHotelDatas)
+                    {
+                        var checkInDt = Convert.ToDateTime(curr_hotel.CheckInDate);
+                        List<(DateTime start, DateTime end)> timeRanges = new List<(DateTime, DateTime)>();
+                        while (checkInDt <= Convert.ToDateTime(curr_hotel.CheckOutDate))
+                        {
+                            int year = checkInDt.Year,
+                                month = checkInDt.Month,
+                                day = checkInDt.Day;
+
+                            timeRanges.Add((new DateTime(year, month, day, 0, 0, 0), new DateTime(year, month, day, 18, 0, 0)));
+                            timeRanges.Add((new DateTime(year, month, day, 18, 0, 0), new DateTime(year, month, day, 23, 59, 59)));
+
+                            checkInDt = checkInDt.AddDays(1);
+                        }
+                        if (!timeRanges.Any()) continue;
+
+                        if (string.IsNullOrEmpty(curr_hotel.Country) && string.IsNullOrEmpty(curr_hotel.City)) continue;
+
+                        var curr_tz1 = tzDatas.Where(x => curr_hotel.Country.Contains(x.tz_simple) || curr_hotel.City.Contains(x.tz_simple)).ToList();
+
+
+                        var curr_tz2 = curr_tz1.Where(x => timeRanges.Any(range => Convert.ToDateTime(x.time) >= range.start && Convert.ToDateTime(x.time) <= range.end)).FirstOrDefault();
+                        if (curr_tz2 == null) continue;
+                        stutus = false;
+                        statusText = "入住酒店中";
+                        address = curr_hotel.HotelAddress;
+                        break;
+                    }
                 }
+
+                result.Add(new StatisticsNowCityOfGroupResultView()
+                {
+                    GroupName = item.TeamName,
+                    Client = item.ClientUnit,
+                    StatusText = statusText,
+                    Address = address
+                });
             }
-            if (!view.Any()) return Ok(JsonView(false, "今日暂无团组出行!"));
 
-            return Ok(JsonView(view));
+            return Ok(JsonView(result));
         }
 
-        private StatisticsNowCityOfGroupView CitySplit(string cityLable,List<Res_ThreeCode> cities)
+        private StatisticsNowCityOfGroupView CitySplit(string cityLable, List<Res_ThreeCode> cities)
         {
             var info = new StatisticsNowCityOfGroupView();
             if (string.IsNullOrEmpty(cityLable)) return info;

+ 9 - 0
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs

@@ -42,5 +42,14 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// <returns></returns>
         /// <returns></returns>
         Task<string> GetTextTranslateAsync(string source, string trans_type = "zh2en");
+
+        /// <summary>
+        /// 获取全球当前时间
+        /// </summary>
+        /// <param name="continent">
+        /// 洲际:非洲、美洲、南极洲、北极、亚洲、大西洋、 欧洲、太平洋
+        /// <returns></returns>
+        Task<JuHeAPIResult> GetContinentTimezoneAsync(string continent);
+
     }
 }

+ 56 - 0
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs

@@ -385,5 +385,61 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         }
 
         #endregion
+
+        #region 洲 当前时间
+
+        /// <summary>
+        /// 获取全球当前时间
+        /// </summary>
+        /// <param name="continent">
+        /// 洲际:非洲、美洲、南极洲、北极、亚洲、大西洋、 欧洲、太平洋
+        /// </param>
+        /// <returns></returns>
+        public async Task<JuHeAPIResult> GetContinentTimezoneAsync(string continent)
+        {
+
+            var continentEn = string.Empty;
+
+            if (string.IsNullOrEmpty(continent)) return new JuHeAPIResult(-1, "请输入州");
+
+            if (continent.Equals("非洲")) continent = $"africa";
+            else if (continent.Equals("非洲")) continent = $"africa";
+            else if (continent.Equals("美洲")) continent = $"america";
+            else if (continent.Equals("南极洲")) continent = $"antarctica";
+            else if (continent.Equals("北极")) continent = $"arctic";
+            else if (continent.Equals("亚洲")) continent = $"asia";
+            else if (continent.Equals("大西洋")) continent = $"atlantic";
+            else if (continent.Equals("欧洲")) continent = $"europe";
+            else if (continent.Equals("太平洋")) continent = $"pacific";
+            else return new JuHeAPIResult(-1, "请输入正确的州");
+
+
+            #region 请求接口
+            string url = string.Format($"/fapig/timezone/show");
+
+            var exchangeReq = await _httpClientTranslate.PostAsync(url,
+                                     new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
+                                     {
+                                             //new KeyValuePair<string, string>("key",_appkey_textTranslate),//你申请的key
+                                             new KeyValuePair<string, string>("key","f3d6b2272d46e0ca9d1c9aca38d8a92c"),//你申请的key 
+                                             new KeyValuePair<string, string>("c",continent)
+
+                                     }));
+            if (exchangeReq.IsSuccessStatusCode)
+            {
+                var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
+
+                var result = System.Text.Json.JsonSerializer.Deserialize<JuHeAPIResult>(stringResponse,
+                new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+               
+                return result;
+            }
+
+            #endregion
+
+            return new JuHeAPIResult(-1, "世界时间接口请求失败!");
+        }
+
+        #endregion
     }
 }

+ 4 - 4
OASystem/OASystem.Domain/Dtos/Statistics/MarketingSalesDto.cs

@@ -223,10 +223,10 @@ namespace OASystem.Domain.Dtos.Statistics
 
     public class StatisticsNowCityOfGroupDto : PortDtoBase
     {
-        /// <summary>
-        /// 当前时间
-        /// </summary>
-        public string Now { get; set; }
+        ///// <summary>
+        ///// 当前时间
+        ///// </summary>
+        //public string Now { get; set; }
     }
 
 }

+ 1 - 1
OASystem/OASystem.Domain/Entities/Financial/Fin_DailyFeePayment.cs

@@ -15,7 +15,7 @@ namespace OASystem.Domain.Entities.Financial
         /// <summary>
         /// 申请说明
         /// </summary>
-        [SugarColumn(IsNullable = true,ColumnDataType = "varchar(225)")]
+        [SugarColumn(IsNullable = true,ColumnDataType = "nvarchar(4000)")]
         public string? Instructions { get; set; }
 
         /// <summary>

+ 28 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -1625,6 +1625,34 @@ namespace OASystem.Domain.ViewModels.Financial
         public string ArriveCityName { get; set; }
     }
 
+    #endregion
+
+
+    #region 
+
+    /// <summary>
+    /// 当前时间团组所在城市 View
+    /// </summary>
+    public class StatisticsNowCityOfGroupResultView
+    {
+        /// <summary>
+        /// 团组名称
+        /// </summary>
+        public string GroupName { get; set; }
+
+        /// <summary>
+        /// 单位
+        /// </summary>
+        public string Client { get; set; }
+
+        /// <summary>
+        /// 当前状态
+        /// </summary>
+        public string StatusText { get; set; }
+
+        public string Address { get; set; }
+    }
+
     #endregion
     #endregion
 }

+ 39 - 0
OASystem/OASystem.Domain/ViewModels/JuHeExchangeRate/JuHeAPIResult.cs

@@ -47,6 +47,24 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         /// 数据源
         /// </summary>
         public object? Result { get; set; }
+
+        public JuHeAPIResult() { }
+
+        public JuHeAPIResult(int code, string reason)
+        {
+            Error_code = code;
+            Resultcode = "-1 参数错误";
+            Reason = reason;
+            Result = new { };
+        }
+
+        public JuHeAPIResult(int code,string resultcode,string reason,object? result)
+        {
+            Error_code = code;
+            Resultcode = resultcode;
+            Reason = reason;
+            Result = result;
+        }
     }
 
     /// <summary>
@@ -132,4 +150,25 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         public string res { get; set; }
         public double confidence { get; set; }
     }
+
+
+    public class ContinentInfoView
+    {
+        public string name { get; set; }
+
+        public string name_en { get; set; }
+
+        public TimezoneInfoView[] tz { get; set; }
+    }
+
+    public class TimezoneInfoView
+    {
+        public string tz_name { get; set; }
+        public string tz_simple { get; set; }
+        public string time { get; set; }
+        public long timestamp { get; set; }
+        public string timezone { get; set; }
+        public string week { get; set; }
+        public string timezone_abbreviation { get; set; }
+    }
 }