|
@@ -1,7 +1,9 @@
|
|
|
-using NPOI.HPSF;
|
|
|
+using Aspose.Words;
|
|
|
+using NPOI.HPSF;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.Dtos.Resource;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
using Org.BouncyCastle.Utilities;
|
|
|
using Quartz.Util;
|
|
@@ -35,12 +37,13 @@ namespace OASystem.API.Controllers
|
|
|
private readonly OfficialActivitiesRepository _officialActivitiesRep;
|
|
|
private readonly AskDataRepository _askDataRep;
|
|
|
private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
|
|
|
+ private readonly TourClientListRepository _tourClientListRep;
|
|
|
|
|
|
- public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,LocalGuideDataRepository localGuideDataRep,
|
|
|
- ThreeCodeRepository threeCodeRep,HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
|
|
|
+ public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep, LocalGuideDataRepository localGuideDataRep,
|
|
|
+ ThreeCodeRepository threeCodeRep, HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
|
|
|
CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
|
|
|
- InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep,
|
|
|
- TicketBlackCodeRepository ticketBlackCodeRep)
|
|
|
+ InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep,
|
|
|
+ TicketBlackCodeRepository ticketBlackCodeRep, TourClientListRepository tourClientListRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_config = config;
|
|
@@ -57,7 +60,8 @@ namespace OASystem.API.Controllers
|
|
|
_InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
|
|
|
_officialActivitiesRep = officialActivitiesRep;
|
|
|
_askDataRep = askDataRep;
|
|
|
- _ticketBlackCodeRep=ticketBlackCodeRep;
|
|
|
+ _ticketBlackCodeRep = ticketBlackCodeRep;
|
|
|
+ _tourClientListRep = tourClientListRep;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1845,57 +1849,113 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> AskAdviceDerive(AskAdviceDerive dto)
|
|
|
+ public async Task<IActionResult> AskFileDownload(AskFileDownloadDto dto)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- string Air = "";//机票信息
|
|
|
- string Area = "";//城市
|
|
|
- string Area2 = "";//城市
|
|
|
- string ClientName = "";//人员
|
|
|
- string ClientName2 = "";//人员
|
|
|
- int ClientNumber =0;//总人数
|
|
|
- string Content = "";//行程安排
|
|
|
- string CountryAndDay = "";//各个国家待的天数
|
|
|
- string Destination = "";//此行目的
|
|
|
- string Destination2 = "";//此行目的
|
|
|
- string Duration = "";//出访时间
|
|
|
- int Durationdays = 0;//出访天数
|
|
|
- int Durationdays2 =0;//出访天数
|
|
|
- string Official = "";//对谁的邀请
|
|
|
- string Temp = "";//出访任务
|
|
|
- string VisitDate = "";//出访日期,多少号到多少号
|
|
|
-
|
|
|
-
|
|
|
- return Ok(JsonView(true, "导出成功!"));
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ #region 参数验证
|
|
|
+
|
|
|
+ if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示"));
|
|
|
+ if (dto.DiId < 1 ) return Ok(JsonView(false, "请传入有效的DiId参数."));
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ //团组基础信息
|
|
|
+ var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
|
|
|
+ if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在"));
|
|
|
+
|
|
|
+ //团组客户名单
|
|
|
+ var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
|
|
|
+ List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
|
|
|
+ if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
|
|
|
+
|
|
|
+ //团组公务信息
|
|
|
+ var officialBusiness = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
|
|
|
+ var obInfo = officialBusiness.FirstOrDefault();
|
|
|
+
|
|
|
+ //载入模板
|
|
|
+ string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
|
|
|
+ var doc = new Document(tempPath);
|
|
|
+ DocumentBuilder builder = new DocumentBuilder(doc);
|
|
|
+
|
|
|
+ //键值对存放数据
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ //××(组团单位):接团客户信息团组
|
|
|
+ dic.Add("GroupClient",groupInfo.ClientUnit);
|
|
|
+
|
|
|
+ //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
|
|
|
+ string guestName = "";
|
|
|
+ string guestJob = "";
|
|
|
+ string guestInfoStr = "";
|
|
|
+ var guestFirstInfo = guestInfos.FirstOrDefault();
|
|
|
+ if (guestFirstInfo != null)
|
|
|
{
|
|
|
- return Ok(JsonView(false, "程序错误!"));
|
|
|
- throw;
|
|
|
+ guestName = guestFirstInfo.LastName + guestFirstInfo.FirstName;
|
|
|
+ guestJob = guestFirstInfo.Job;
|
|
|
+ guestInfoStr = $@"{guestJob}、{guestName}";
|
|
|
}
|
|
|
- }
|
|
|
+ string askTitle = $@"关于{guestInfoStr}等{guestInfos.Count}人赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}的请示";
|
|
|
+ dic.Add("AskTitle", askTitle);
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 导出市外办请示
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [HttpPost]
|
|
|
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
- public async Task<IActionResult> AskCityDerive(AskAdviceDerive dto)
|
|
|
- {
|
|
|
- try
|
|
|
+ //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
|
|
|
+ string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
|
|
|
+ string askSubTitle = $@"应{obInfo.Client}{obInfo.Job}{obInfo.Contact}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。现请示如下。";
|
|
|
+ dic.Add("AskSubTitle", askSubTitle);
|
|
|
+
|
|
|
+ //出访背景
|
|
|
+ dic.Add("AskTitle", askTitle);
|
|
|
+
|
|
|
+ #region 填充word模板书签内容
|
|
|
+ foreach (var key in dic.Keys)
|
|
|
{
|
|
|
-
|
|
|
- return Ok(JsonView(true, "导出成功!"));
|
|
|
+ builder.MoveToBookmark(key);
|
|
|
+ builder.Write(dic[key]);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //获取word里所有表格
|
|
|
+ NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
|
|
|
+ //获取所填表格的序数
|
|
|
+ Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
|
|
|
+
|
|
|
+ var rowStart = tableOne.Rows[0]; //获取第1行
|
|
|
+
|
|
|
+ //循环赋值
|
|
|
+ for (int i = 0; i < guestInfos.Count; i++)
|
|
|
{
|
|
|
- return Ok(JsonView(false, "程序错误!"));
|
|
|
- throw;
|
|
|
+ var guestInfo = guestInfos[i];
|
|
|
+ builder.MoveToCell(0, i + 1, 0, 0);
|
|
|
+ builder.Write(guestInfo.LastName + guestInfo.FirstName);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 1, 0);
|
|
|
+ int sex = guestInfo.Sex;
|
|
|
+ string sexStr = string.Empty;
|
|
|
+ if (sex == 0) sexStr = "男";
|
|
|
+ else if (sex == 1) sexStr = "女";
|
|
|
+ else sexStr = "未设置";
|
|
|
+ builder.Write(sexStr);
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 2, 0);
|
|
|
+ builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
|
|
|
+
|
|
|
+
|
|
|
+ builder.MoveToCell(0, i + 1, 3, 0);
|
|
|
+ string birthDay = guestInfo.;
|
|
|
+ string birthDayStr = string.Empty;
|
|
|
+ if (!string.IsNullOrEmpty(birthDay))
|
|
|
+ {
|
|
|
+ birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
|
|
|
+ }
|
|
|
+ builder.Write(birthDayStr);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ var fileDir = AppSettingsHelper.Get("WordBasePath");
|
|
|
+ string fileName = $"{groupInfo.TeamName}省外办出访请示.docx";
|
|
|
+ string filePath = fileDir + $@"Ask/{fileName}";
|
|
|
+ doc.Save(filePath);
|
|
|
+ string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/Ask/{fileName}";
|
|
|
+ return Ok(JsonView(true, "操作成功!", Url));
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 机票黑屏代码
|