|
@@ -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;
|