|
@@ -1,4 +1,6 @@
|
|
|
-using Microsoft.AspNetCore.Mvc;
|
|
|
+using Aspose.Cells;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using NetTaste;
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.Dtos.Groups;
|
|
@@ -6,6 +8,8 @@ using OASystem.Domain.Entities.Business;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+using OASystem.Infrastructure.Tools;
|
|
|
+using System.Web;
|
|
|
using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
@@ -22,7 +26,8 @@ namespace OASystem.API.Controllers
|
|
|
private readonly DelegationInfoRepository _groupRepository;
|
|
|
private readonly TaskAssignmentRepository _taskAssignmentRep;
|
|
|
private readonly AirTicketResRepository _airTicketResRep;
|
|
|
-
|
|
|
+ private string url;
|
|
|
+ private string path;
|
|
|
public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository, TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
@@ -30,6 +35,12 @@ namespace OASystem.API.Controllers
|
|
|
_groupRepository = groupRepository;
|
|
|
_taskAssignmentRep = taskAssignmentRep;
|
|
|
_airTicketResRep = airTicketResRep;
|
|
|
+ url = AppSettingsHelper.Get("ExcelBaseUrl");
|
|
|
+ path = AppSettingsHelper.Get("ExcelBasePath");
|
|
|
+ if (!System.IO.Directory.Exists(path))
|
|
|
+ {
|
|
|
+ System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#region 流程管控
|
|
@@ -505,7 +516,7 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
|
|
|
|
|
|
- _detail.Id=entity.Id;
|
|
|
+ _detail.Id = entity.Id;
|
|
|
|
|
|
/*
|
|
|
* Bus名称
|
|
@@ -696,7 +707,8 @@ namespace OASystem.API.Controllers
|
|
|
{
|
|
|
rst = -1;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
_groupRepository.RollbackTran();
|
|
|
return Ok(JsonView(false, "保存失败并回滚!"));
|
|
|
}
|
|
@@ -744,7 +756,7 @@ namespace OASystem.API.Controllers
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> AirTicketResList(AirTicketResListDto dto)
|
|
|
+ public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -800,6 +812,85 @@ namespace OASystem.API.Controllers
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
|
|
|
+ if (!res)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "删除失败"));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(true, "删除成功!"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 导出机票录入报表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
|
|
|
+ if (groupData.Code != 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, groupData.Msg));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
|
|
|
+ if (AirTicketReservations.Count != 0)
|
|
|
+ {
|
|
|
+ Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
|
|
|
+ Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
|
|
|
+ string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
|
|
|
+ string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
|
|
|
+ WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
+ designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
|
|
|
+ decimal countCost = 0;
|
|
|
+ foreach (var item in AirTicketReservations)
|
|
|
+ {
|
|
|
+ item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
|
|
|
+ item.Price = System.Decimal.Round(item.Price, 2);
|
|
|
+ countCost += Convert.ToDecimal(item.Price);
|
|
|
+ }
|
|
|
+ designer.SetDataSource("Export", AirTicketReservations);
|
|
|
+ designer.SetDataSource("ExportDiCode", diCode);
|
|
|
+ designer.SetDataSource("ExportDiName", diName);
|
|
|
+ designer.SetDataSource("ExportOpUserName", _Users.CnName);
|
|
|
+
|
|
|
+ designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
|
|
|
+ designer.Process();
|
|
|
+ string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
|
|
|
+ designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
+ string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
+ return Ok(JsonView(true, "成功",url=rst));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|