|
@@ -6,6 +6,7 @@ using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.Resource;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Tools;
|
|
|
+using SqlSugar.Extensions;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace OASystem.Infrastructure.Repositories.Groups
|
|
@@ -114,11 +115,25 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public async Task<Result> CarTouristGuideGroundContent(CarTouristGuideGroundContentDto dto)
|
|
|
+ public Result CarTouristGuideGroundContent(CarTouristGuideGroundContentDto dto)
|
|
|
{
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
try
|
|
|
{
|
|
|
+
|
|
|
+ DateTime start = new DateTime();
|
|
|
+ var dayResult = GetDifferenceDate(dto.Id, out start);
|
|
|
+ var day = 0;
|
|
|
+ if (dayResult.Code == 0)
|
|
|
+ {
|
|
|
+ day = Convert.ToInt32(dayResult.Data);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return dayResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 79).ToList();
|
|
|
|
|
|
string DiId = "0";
|
|
@@ -145,23 +160,80 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
//列表初始化
|
|
|
List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
|
|
|
- List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
|
|
|
- _TableInitialization= _TableInitialization.OrderBy(a=>a.Name).ToList();
|
|
|
+ //List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
|
|
|
+ //_TableInitialization= _TableInitialization.OrderBy(a=>a.Name).ToList();
|
|
|
+
|
|
|
+ List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.IsDel == 0 && a.CTGGRId == dto.Id).ToList();
|
|
|
+ List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
|
|
|
+
|
|
|
+ foreach (var itemSt in TableInitialization)
|
|
|
+ {
|
|
|
+ if (carTouristGuides.Find(x=>x.SId == itemSt.Id) == null)
|
|
|
+ {
|
|
|
+ carTouristGuides.Add(new CarTouristGuideGroundReservationsContentView
|
|
|
+ {
|
|
|
+ SId = itemSt.Id,
|
|
|
+ Count = 1,
|
|
|
+ SidName = itemSt.Name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x => x.Key, x => x.ToList());
|
|
|
+ foreach (var item in groupResult.Keys)
|
|
|
+ {
|
|
|
+ while (groupResult[item].Count < day)
|
|
|
+ {
|
|
|
+ groupResult[item] = groupResult[item].OrderByDescending(x => x.DatePrice).ToList();
|
|
|
+ if (groupResult[item][0]?.DatePrice is not null)
|
|
|
+ {
|
|
|
+ groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
|
|
|
+ {
|
|
|
+ DatePrice = groupResult[item][0].DatePrice.ObjToDate().AddDays(1),
|
|
|
+ SId = item,
|
|
|
+ Count = 1,
|
|
|
+ SidName = TableInitialization.Find(x=>x.Id == item)?.Name
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
|
|
|
+ {
|
|
|
+ DatePrice = start,
|
|
|
+ SId = item,
|
|
|
+ Count = 1,
|
|
|
+ SidName = TableInitialization.Find(x => x.Id == item)?.Name
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).ToList();
|
|
|
+
|
|
|
+ Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
|
|
|
+ CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
|
|
|
+ if (_CreditCardPayment != null)
|
|
|
+ {
|
|
|
+ _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
|
|
|
+ _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
|
|
|
+ if (_CreditCardPayment.OrbitalPrivateTransfer == 0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
|
|
|
+ else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
|
|
|
+ }
|
|
|
|
|
|
var data = new
|
|
|
{
|
|
|
Payment = _Payment,
|
|
|
CurrencyList = _CurrencyList,
|
|
|
Delegations = grp_Delegations,
|
|
|
- TableInitialization = _TableInitialization
|
|
|
+ carTouristGuides = carTouristGuides,
|
|
|
+ CreditCardPayment = _CreditCardPayment,
|
|
|
};
|
|
|
+
|
|
|
return result = new Result() { Code = 0, Msg = "查询成功",Data=data };
|
|
|
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
return result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
- throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -170,9 +242,51 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
try
|
|
|
{
|
|
|
+
|
|
|
|
|
|
List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.IsDel==0 && a.CTGGRId==dto.Id).ToList();
|
|
|
List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
|
|
|
+ DateTime start = new DateTime();
|
|
|
+ var dayResult = GetDifferenceDate(dto.Id, out start);
|
|
|
+ var day = 0;
|
|
|
+ if (dayResult.Code == 0)
|
|
|
+ {
|
|
|
+ day = Convert.ToInt32(dayResult.Data);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return dayResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ var groupResult = carTouristGuides.GroupBy(x => x.SId).ToDictionary(x=>x.Key,x=>x.ToList());
|
|
|
+ foreach (var item in groupResult.Keys)
|
|
|
+ {
|
|
|
+ while (groupResult[item].Count < day)
|
|
|
+ {
|
|
|
+ groupResult[item] = groupResult[item].OrderByDescending(x=>x.DatePrice).ToList();
|
|
|
+ if (groupResult[item][0]?.DatePrice is not null)
|
|
|
+ {
|
|
|
+ groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
|
|
|
+ {
|
|
|
+ DatePrice = groupResult[item][0].DatePrice.ObjToDate().AddDays(1),
|
|
|
+ SId = item,
|
|
|
+ Count = 1,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupResult[item].Add(new CarTouristGuideGroundReservationsContentView
|
|
|
+ {
|
|
|
+ DatePrice = start,
|
|
|
+ SId = item,
|
|
|
+ Count = 1,
|
|
|
+ }) ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ carTouristGuides = groupResult.Values.SelectMany(sublist => sublist).ToList();
|
|
|
+
|
|
|
foreach (var item in carTouristGuides)
|
|
|
{
|
|
|
item.SidName= _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == item.SId).Name;
|
|
@@ -194,10 +308,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
|
|
|
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- return result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
- throw;
|
|
|
+ return result = new Result() { Code = -2, Msg = "未知错误(" + ex.Message+")" };
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -486,5 +599,39 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Result GetDifferenceDate(int id,out DateTime start)
|
|
|
+ {
|
|
|
+ Result result = new Domain.Result();
|
|
|
+
|
|
|
+ Grp_CarTouristGuideGroundReservations grpCarOp = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x => x.Id == id);
|
|
|
+
|
|
|
+ DateTime end = new DateTime();
|
|
|
+ if (!DateTime.TryParse(grpCarOp?.ServiceStartTime, out start))
|
|
|
+ {
|
|
|
+ result.Msg = "服务开始时间不存在!";
|
|
|
+ result.Code = -1;
|
|
|
+ result.Data = 0;
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!DateTime.TryParse(grpCarOp?.ServiceEndTime, out end))
|
|
|
+ {
|
|
|
+ result.Msg = "服务结束时间不存在!";
|
|
|
+ result.Code = -1;
|
|
|
+ result.Data = 0;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ TimeSpan ts = end - start; //计算时间差
|
|
|
+ int day = ts.Days;
|
|
|
+
|
|
|
+ result.Msg = "success!";
|
|
|
+ result.Code = 0;
|
|
|
+ result.Data = day;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
}
|