GroupsController.cs 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. namespace OASystem.API.Controllers
  23. {
  24. /// <summary>
  25. /// 团组相关
  26. /// </summary>
  27. //[Authorize]
  28. [Route("api/[controller]/[action]")]
  29. public class GroupsController : ControllerBase
  30. {
  31. private readonly GrpScheduleRepository _grpScheduleRep;
  32. private readonly IMapper _mapper;
  33. private readonly DelegationInfoRepository _groupRepository;
  34. private readonly TaskAssignmentRepository _taskAssignmentRep;
  35. private readonly AirTicketResRepository _airTicketResRep;
  36. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  37. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  38. private readonly SqlSugarClient _sqlSugar;
  39. private string url;
  40. private string path;
  41. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  42. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  43. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep)
  44. {
  45. _mapper = mapper;
  46. _grpScheduleRep = grpScheduleRep;
  47. _groupRepository = groupRepository;
  48. _taskAssignmentRep = taskAssignmentRep;
  49. _airTicketResRep = airTicketResRep;
  50. _sqlSugar = sqlSugar;
  51. url = AppSettingsHelper.Get("ExcelBaseUrl");
  52. path = AppSettingsHelper.Get("ExcelBasePath");
  53. if (!System.IO.Directory.Exists(path))
  54. {
  55. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  56. }
  57. _decreasePaymentsRep = decreasePaymentsRep;
  58. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  59. }
  60. #region 流程管控
  61. /// <summary>
  62. /// 获取团组流程管控信息
  63. /// </summary>
  64. /// <param name="paras">参数Json字符串</param>
  65. /// <returns></returns>
  66. [HttpPost]
  67. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  68. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  69. {
  70. if (string.IsNullOrEmpty(_jsonDto.Paras))
  71. {
  72. return Ok(JsonView(false, "参数为空"));
  73. }
  74. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  75. if (_ScheduleDto != null)
  76. {
  77. if (_ScheduleDto.SearchType == 2)//获取列表
  78. {
  79. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  80. return Ok(JsonView(_grpScheduleViewList));
  81. }
  82. else//获取对象
  83. {
  84. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  85. if (_grpScheduleView != null)
  86. {
  87. return Ok(JsonView(_grpScheduleView));
  88. }
  89. }
  90. }
  91. else
  92. {
  93. return Ok(JsonView(false, "参数反序列化失败"));
  94. }
  95. return Ok(JsonView(false, "暂无数据!"));
  96. }
  97. /// <summary>
  98. /// 修改团组流程管控详细表数据
  99. /// </summary>
  100. /// <param name="paras"></param>
  101. /// <returns></returns>
  102. [HttpPost]
  103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  104. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  105. {
  106. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  107. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  108. .SetColumns(it => it.Duty == _detail.Duty)
  109. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  110. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  111. .SetColumns(it => it.JobContent == _detail.JobContent)
  112. .SetColumns(it => it.Remark == _detail.Remark)
  113. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  114. .Where(s => s.Id == dto.Id)
  115. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  116. .ExecuteCommandAsync();
  117. if (result > 0)
  118. {
  119. return Ok(JsonView(true, "保存成功!"));
  120. }
  121. return Ok(JsonView(false, "保存失败!"));
  122. }
  123. /// <summary>
  124. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  125. /// </summary>
  126. /// <param name="dto"></param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  130. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  131. {
  132. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  133. _detail.IsDel = 1;
  134. _detail.DeleteUserId = dto.Duty;
  135. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  136. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  137. .SetColumns(it => it.IsDel == _detail.IsDel)
  138. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  139. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  140. .Where(it => it.Id == dto.Id)
  141. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  142. //.WhereColumns(s => s.Id == dto.Id)
  143. .ExecuteCommandAsync();
  144. if (result > 0)
  145. {
  146. return Ok(JsonView(true, "删除成功!"));
  147. }
  148. return Ok(JsonView(false, "删除失败!"));
  149. }
  150. /// <summary>
  151. /// 增加团组流程管控详细表数据
  152. /// </summary>
  153. /// <param name="dto"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  158. {
  159. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  160. if (DateTime.Now < _detail.ExpectBeginDt)
  161. {
  162. _detail.StepStatus = 0;
  163. }
  164. else
  165. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  166. _detail.StepStatus = 1;
  167. }
  168. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  169. if (result > 0)
  170. {
  171. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  172. return Ok(JsonView(true, "添加成功!", _result));
  173. }
  174. return Ok(JsonView(false, "添加失败!"));
  175. }
  176. #endregion
  177. #region 团组基本信息
  178. /// <summary>
  179. /// 接团信息列表
  180. /// </summary>
  181. /// <param name="dto">团组列表请求dto</param>
  182. /// <returns></returns>
  183. [HttpPost]
  184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  185. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  186. {
  187. var groupData = await _groupRepository.GetGroupList(dto);
  188. if (groupData.Code != 0)
  189. {
  190. return Ok(JsonView(false, groupData.Msg));
  191. }
  192. return Ok(JsonView(groupData.Data));
  193. }
  194. /// <summary>
  195. /// 获取团组所有信息
  196. /// </summary>
  197. /// <param name="dto"></param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  201. public async Task<IActionResult> GetGroupAllList()
  202. {
  203. List<Grp_DelegationInfo> _DelegationInfos=_sqlSugar.Queryable<Grp_DelegationInfo>().Where(a=>a.IsDel==0).OrderBy(a=>a.CreateTime,OrderByType.Desc).ToList();
  204. if (_DelegationInfos.Count == 0)
  205. {
  206. return Ok(JsonView(false, "暂无数据!"));
  207. }
  208. return Ok(JsonView(true,"查询成功!",_DelegationInfos));
  209. }
  210. /// <summary>
  211. /// 接团信息详情
  212. /// </summary>
  213. /// <param name="dto">团组info请求dto</param>
  214. /// <returns></returns>
  215. [HttpPost]
  216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  217. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  218. {
  219. var groupData = await _groupRepository.GetGroupInfo(dto);
  220. if (groupData.Code != 0)
  221. {
  222. return Ok(JsonView(false, groupData.Msg));
  223. }
  224. return Ok(JsonView(groupData.Data));
  225. }
  226. /// <summary>
  227. /// 接团信息 编辑添加
  228. /// 基础信息数据源
  229. /// </summary>
  230. /// <param name="dto"></param>
  231. /// <returns></returns>
  232. [HttpPost]
  233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  234. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  235. {
  236. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  237. if (groupData.Code != 0)
  238. {
  239. return Ok(JsonView(false, groupData.Msg));
  240. }
  241. return Ok(JsonView(groupData.Data));
  242. }
  243. /// <summary>
  244. /// 接团信息 操作(增改)
  245. /// </summary>
  246. /// <param name="dto"></param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  251. {
  252. try
  253. {
  254. var groupData = await _groupRepository.GroupOperation(dto);
  255. if (groupData.Code != 0)
  256. {
  257. return Ok(JsonView(false, groupData.Msg));
  258. }
  259. return Ok(JsonView(true));
  260. }
  261. catch (Exception ex)
  262. {
  263. Logs("[response]" + JsonConvert.SerializeObject(dto));
  264. Logs(ex.Message);
  265. return Ok(JsonView(false, ex.Message));
  266. }
  267. }
  268. /// <summary>
  269. /// 接团信息 操作(删除)
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  276. {
  277. try
  278. {
  279. var groupData = await _groupRepository.GroupDel(dto);
  280. if (groupData.Code != 0)
  281. {
  282. return Ok(JsonView(false, groupData.Msg));
  283. }
  284. return Ok(JsonView(true));
  285. }
  286. catch (Exception ex)
  287. {
  288. Logs("[response]" + JsonConvert.SerializeObject(dto));
  289. Logs(ex.Message);
  290. return Ok(JsonView(false, ex.Message));
  291. }
  292. }
  293. /// <summary>
  294. /// 获取团组销售报价号
  295. /// 团组添加时 使用
  296. /// </summary>
  297. /// <returns></returns>
  298. [HttpPost]
  299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  300. public async Task<IActionResult> GetGroupSalesQuoteNo()
  301. {
  302. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  303. if (groupData.Code != 0)
  304. {
  305. return Ok(JsonView(false, groupData.Msg));
  306. }
  307. object salesQuoteNo = new
  308. {
  309. SalesQuoteNo = groupData.Data
  310. };
  311. return Ok(JsonView(salesQuoteNo));
  312. }
  313. /// <summary>
  314. /// 设置确认出团
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  321. {
  322. var groupData = await _groupRepository.ConfirmationGroup(dto);
  323. if (groupData.Code != 0)
  324. {
  325. return Ok(JsonView(false, groupData.Msg));
  326. }
  327. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  328. return Ok(JsonView(groupData.Data));
  329. }
  330. /// <summary>
  331. /// 获取团组名称 List
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  338. {
  339. var groupData = await _groupRepository.GetGroupNameList(dto);
  340. if (groupData.Code != 0)
  341. {
  342. return Ok(JsonView(false, groupData.Msg));
  343. }
  344. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  345. }
  346. /// <summary>
  347. /// 获取团组名称data And 签证国别Data
  348. /// </summary>
  349. /// <param name="dto"></param>
  350. /// <returns></returns>
  351. [HttpPost]
  352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  353. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  354. {
  355. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  356. if (groupData.Code != 0)
  357. {
  358. return Ok(JsonView(false, groupData.Msg));
  359. }
  360. return Ok(JsonView(groupData.Data));
  361. }
  362. #endregion
  363. #region 团组&签证
  364. /// <summary>
  365. /// 根据团组Id获取签证客户信息List
  366. /// </summary>
  367. /// <param name="dto">请求dto</param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  372. {
  373. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  374. if (groupData.Code != 0)
  375. {
  376. return Ok(JsonView(false, groupData.Msg));
  377. }
  378. return Ok(JsonView(groupData.Data));
  379. }
  380. #endregion
  381. #region 团组任务分配
  382. /// <summary>
  383. /// 团组任务分配初始化
  384. /// </summary>
  385. /// <param name="dto"></param>
  386. /// <returns></returns>
  387. [HttpPost]
  388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  389. public async Task<IActionResult> GetTaskAssignmen()
  390. {
  391. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  392. if (groupData.Code != 0)
  393. {
  394. return Ok(JsonView(false, groupData.Msg));
  395. }
  396. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  397. }
  398. /// <summary>
  399. /// 团组任务分配查询
  400. /// </summary>
  401. /// <param name="dto"></param>
  402. /// <returns></returns>
  403. [HttpPost]
  404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  405. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  406. {
  407. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  408. if (groupData.Code != 0)
  409. {
  410. return Ok(JsonView(false, groupData.Msg));
  411. }
  412. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  413. }
  414. /// <summary>
  415. /// 团组任务分配操作
  416. /// </summary>
  417. /// <param name="dto"></param>
  418. /// <returns></returns>
  419. [HttpPost]
  420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  421. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  422. {
  423. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  424. if (groupData.Code != 0)
  425. {
  426. return Ok(JsonView(false, groupData.Msg));
  427. }
  428. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  429. }
  430. #endregion
  431. #region 团组费用审核
  432. /// <summary>
  433. /// 获取团组费用审核
  434. /// </summary>
  435. /// <param name="paras">参数Json字符串</param>
  436. /// <returns></returns>
  437. [HttpPost]
  438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  439. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  440. {
  441. if (_dto.DiId < 1)
  442. {
  443. return Ok(JsonView(false, "团组Id为空"));
  444. }
  445. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  446. #region 团组基本信息
  447. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  448. if (_delegation != null)
  449. {
  450. _view.ClientName = _delegation.ClientName;
  451. _view.DiId = _dto.DiId;
  452. _view.TeamName = _delegation.TeamName;
  453. _view.VisitCountry = _delegation.VisitCountry;
  454. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  455. _view.VisitDays = _delegation.VisitDays;
  456. _view.VisitPNumber = _delegation.VisitPNumber;
  457. }
  458. else
  459. {
  460. return Ok(JsonView(false, "团组信息为空"));
  461. }
  462. #endregion
  463. #region 费用清单
  464. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  465. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  466. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  467. List<Grp_CreditCardPayment> entityList = _groupRepository
  468. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  469. .Where(exp.ToExpression())
  470. .ToList();
  471. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  472. decimal CNY = 0;
  473. decimal PayCNY = 0;
  474. decimal BalanceCNY = 0;
  475. decimal YSFYCNY = 0;
  476. decimal USD = 0;
  477. decimal PayUSD = 0;
  478. decimal BalanceUSD = 0;
  479. decimal YSFYUSD = 0;
  480. decimal EUR = 0;
  481. decimal PayEUR = 0;
  482. decimal BalanceEUR = 0;
  483. decimal YSFYEUR = 0;
  484. foreach (var entity in entityList)
  485. {
  486. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  487. _detail.Id = entity.Id;
  488. /*
  489. * Bus名称
  490. */
  491. _detail.BusName = "";
  492. /*
  493. *费用所属
  494. */
  495. switch (entity.CTable)
  496. {
  497. case 85:
  498. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  499. if (jpRes != null)
  500. {
  501. string FlightsDescription = jpRes.FlightsDescription;
  502. string PriceDescription = jpRes.PriceDescription;
  503. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  504. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  505. }
  506. break;
  507. case 79:
  508. _detail.BusName = "待增加";
  509. break;
  510. case 98:
  511. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  512. if (gdpRes != null)
  513. {
  514. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  515. _detail.PriceNameContent = gdpRes.PriceName;
  516. }
  517. break;
  518. default:
  519. break;
  520. }
  521. /*
  522. * 费用模块
  523. */
  524. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  525. if (sdPriceName != null)
  526. {
  527. _detail.PriceName = sdPriceName.Name;
  528. }
  529. /*
  530. * 应付款金额
  531. */
  532. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  533. string PaymentCurrency_WaitPay = "Unknown";
  534. if (sdPaymentCurrency_WaitPay != null)
  535. {
  536. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  537. }
  538. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  539. /*
  540. * 此次付款金额
  541. */
  542. decimal CurrPayStr = 0;
  543. if (entity.PayPercentage == 0)
  544. {
  545. if (entity.PayThenMoney != 0)
  546. CurrPayStr = entity.PayThenMoney * entity.DayRate;
  547. }
  548. else
  549. {
  550. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate);
  551. }
  552. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  553. /*
  554. * 剩余尾款
  555. */
  556. decimal BalanceStr = 0;
  557. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  558. BalanceStr = 0;
  559. else
  560. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate);
  561. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  562. /*
  563. * 申请人
  564. */
  565. string operatorName = "无";
  566. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
  567. if (_opUser != null)
  568. {
  569. operatorName = _opUser.CnName;
  570. }
  571. _detail.OperatorName = operatorName;
  572. /*
  573. * 审核人
  574. */
  575. string auditOperatorName = "Unknown";
  576. if (entity.AuditGMOperate == 0)
  577. auditOperatorName = "无";
  578. else if (entity.AuditGMOperate == 4)
  579. auditOperatorName = "自动审核";
  580. else
  581. {
  582. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
  583. if (_adUser != null)
  584. {
  585. auditOperatorName = _adUser.CnName;
  586. }
  587. }
  588. _detail.AuditOperatorName = auditOperatorName;
  589. /*
  590. *
  591. * *超预算比例
  592. */
  593. string overBudgetStr = "";
  594. if (entity.ExceedBudget == -1)
  595. overBudgetStr = sdPriceName.Name + "尚无预算";
  596. else if (entity.ExceedBudget == 0)
  597. overBudgetStr = "未超预算";
  598. else
  599. overBudgetStr = entity.ExceedBudget.ToString("P");
  600. _detail.OverBudget = overBudgetStr;
  601. /*
  602. * 费用总计
  603. */
  604. if (entity.PaymentCurrency == 48)
  605. {
  606. CNY += entity.PayMoney;
  607. PayCNY += CurrPayStr;
  608. BalanceCNY += BalanceStr;
  609. YSFYCNY += CurrPayStr;
  610. }
  611. if (entity.PaymentCurrency == 49)
  612. {
  613. USD += entity.PayMoney;
  614. PayUSD += CurrPayStr;
  615. BalanceUSD += BalanceStr;
  616. YSFYUSD += CurrPayStr;
  617. }
  618. if (entity.PaymentCurrency == 51)
  619. {
  620. EUR += entity.PayMoney;
  621. PayEUR += CurrPayStr;
  622. BalanceEUR += BalanceStr;
  623. YSFYEUR += CurrPayStr;
  624. }
  625. _detail.IsAuditGM = entity.IsAuditGM;
  626. detailList.Add(_detail);
  627. }
  628. #endregion
  629. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  630. _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  631. _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  632. _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  633. _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  634. return Ok(JsonView(_view));
  635. }
  636. /// <summary>
  637. /// 修改团组费用审核状态
  638. /// </summary>
  639. /// <param name="paras">参数Json字符串</param>
  640. /// <returns></returns>
  641. [HttpPost]
  642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  643. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  644. {
  645. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  646. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  647. DateTime dtNow = DateTime.Now;
  648. _groupRepository.BeginTran();
  649. int rst = 0;
  650. foreach (var item in idList)
  651. {
  652. int CreditId = int.Parse(item);
  653. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  654. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  655. .SetColumns(it => it.AuditGMOperate == _dto.User)
  656. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  657. .Where(s => s.Id == CreditId)
  658. .ExecuteCommandAsync();
  659. if (result < 1)
  660. {
  661. rst = -1;
  662. }
  663. else
  664. {
  665. _groupRepository.RollbackTran();
  666. return Ok(JsonView(false, "保存失败并回滚!"));
  667. }
  668. }
  669. _groupRepository.CommitTran();
  670. if (rst == 0)
  671. {
  672. return Ok(JsonView(true, "保存成功!"));
  673. }
  674. return Ok(JsonView(false, "保存失败!"));
  675. }
  676. #endregion
  677. #region 机票费用录入
  678. /// <summary>
  679. /// 机票录入当前登录人可操作团组
  680. /// </summary>
  681. /// <param name="dto"></param>
  682. /// <returns></returns>
  683. [HttpPost]
  684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  685. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  686. {
  687. try
  688. {
  689. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  690. if (groupData.Code != 0)
  691. {
  692. return Ok(JsonView(false, groupData.Msg));
  693. }
  694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  695. }
  696. catch (Exception ex)
  697. {
  698. return Ok(JsonView(false, "程序错误!"));
  699. throw;
  700. }
  701. }
  702. /// <summary>
  703. /// 机票费用录入列表
  704. /// </summary>
  705. /// <param name="dto"></param>
  706. /// <returns></returns>
  707. [HttpPost]
  708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  709. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  710. {
  711. try
  712. {
  713. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  714. if (groupData.Code != 0)
  715. {
  716. return Ok(JsonView(false, groupData.Msg));
  717. }
  718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  719. }
  720. catch (Exception ex)
  721. {
  722. return Ok(JsonView(false, "程序错误!"));
  723. throw;
  724. }
  725. }
  726. /// <summary>
  727. /// 根据id查询费用录入信息
  728. /// </summary>
  729. /// <param name="dto"></param>
  730. /// <returns></returns>
  731. [HttpPost]
  732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  733. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  734. {
  735. try
  736. {
  737. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  738. if (groupData.Code != 0)
  739. {
  740. return Ok(JsonView(false, groupData.Msg));
  741. }
  742. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  743. }
  744. catch (Exception ex)
  745. {
  746. return Ok(JsonView(false, "程序错误!"));
  747. throw;
  748. }
  749. }
  750. /// <summary>
  751. /// 机票费用录入操作(Status:1.新增,2.修改)
  752. /// </summary>
  753. /// <param name="dto"></param>
  754. /// <returns></returns>
  755. [HttpPost]
  756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  757. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  758. {
  759. try
  760. {
  761. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  762. if (groupData.Code != 0)
  763. {
  764. return Ok(JsonView(false, groupData.Msg));
  765. }
  766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  767. }
  768. catch (Exception ex)
  769. {
  770. return Ok(JsonView(false, "程序错误!"));
  771. throw;
  772. }
  773. }
  774. /// <summary>
  775. /// 机票费用录入,删除
  776. /// </summary>
  777. /// <param name="dto"></param>
  778. /// <returns></returns>
  779. [HttpPost]
  780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  781. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  782. {
  783. try
  784. {
  785. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  786. if (!res)
  787. {
  788. return Ok(JsonView(false, "删除失败"));
  789. }
  790. return Ok(JsonView(true, "删除成功!"));
  791. }
  792. catch (Exception ex)
  793. {
  794. return Ok(JsonView(false, "程序错误!"));
  795. throw;
  796. }
  797. }
  798. /// <summary>
  799. /// 导出机票录入报表
  800. /// </summary>
  801. /// <param name="dto"></param>
  802. /// <returns></returns>
  803. [HttpPost]
  804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  805. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  806. {
  807. try
  808. {
  809. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  810. if (groupData.Code != 0)
  811. {
  812. return Ok(JsonView(false, groupData.Msg));
  813. }
  814. else
  815. {
  816. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  817. if (AirTicketReservations.Count != 0)
  818. {
  819. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  820. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  821. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  822. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  823. WorkbookDesigner designer = new WorkbookDesigner();
  824. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  825. decimal countCost = 0;
  826. foreach (var item in AirTicketReservations)
  827. {
  828. if (item.BankType == "其他")
  829. {
  830. item.BankNo = "--";
  831. }
  832. else
  833. {
  834. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  835. }
  836. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  837. item.Price = System.Decimal.Round(item.Price, 2);
  838. countCost += Convert.ToDecimal(item.Price);
  839. }
  840. designer.SetDataSource("Export", AirTicketReservations);
  841. designer.SetDataSource("ExportDiCode", diCode);
  842. designer.SetDataSource("ExportDiName", diName);
  843. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  844. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  845. designer.Process();
  846. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  847. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  848. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  849. return Ok(JsonView(true, "成功", url = rst));
  850. }
  851. else
  852. {
  853. return Ok(JsonView(false, "暂无数据!"));
  854. }
  855. }
  856. }
  857. catch (Exception ex)
  858. {
  859. return Ok(JsonView(false, "程序错误!"));
  860. throw;
  861. }
  862. }
  863. Dictionary<string, string> transDic = new Dictionary<string, string>();
  864. /// <summary>
  865. /// 行程单导出
  866. /// </summary>
  867. /// <param name="dto"></param>
  868. /// <returns></returns>
  869. [HttpPost]
  870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  871. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  872. {
  873. try
  874. {
  875. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  876. if (groupData.Code != 0)
  877. {
  878. return Ok(JsonView(false, groupData.Msg));
  879. }
  880. else
  881. {
  882. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  883. if (dto.Language == "CN")
  884. {
  885. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  886. DocumentBuilder builder = new DocumentBuilder(doc);
  887. int tableIndex = 0;//表格索引
  888. //得到文档中的第一个表格
  889. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  890. foreach (var item in _AirTicketReservations)
  891. {
  892. #region 处理固定数据
  893. string[] FlightsCode = item.FlightsCode.Split('/');
  894. if (FlightsCode.Length != 0)
  895. {
  896. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  897. if (_AirCompany != null)
  898. {
  899. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  900. }
  901. else
  902. {
  903. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  904. }
  905. }
  906. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  907. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  908. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  909. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  910. string name = "";
  911. foreach (string clientName in nameArray)
  912. {
  913. if (!name.Contains(clientName))
  914. {
  915. name += clientName + ",";
  916. }
  917. }
  918. if (!string.IsNullOrWhiteSpace(name))
  919. {
  920. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  921. }
  922. else
  923. {
  924. table.Range.Bookmarks["ClientName"].Text = "--";
  925. }
  926. table.Range.Bookmarks["TicketNumber"].Text = "--";
  927. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  928. table.Range.Bookmarks["JointTicket"].Text = "--";
  929. table.Range.Bookmarks["TimeIssue"].Text = "--";
  930. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  931. table.Range.Bookmarks["NavigationCode"].Text = "--";
  932. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  933. table.Range.Bookmarks["AgentPhone"].Text = "--";
  934. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  935. #endregion
  936. #region 循环数据处理
  937. List<AirInfo> airs = new List<AirInfo>();
  938. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  939. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  940. for (int i = 0; i < FlightsCode.Length; i++)
  941. {
  942. AirInfo air = new AirInfo();
  943. string[] tempstr = DayArray[i]
  944. .Replace("\r\n", string.Empty)
  945. .Replace("\\r\\n", string.Empty)
  946. .TrimStart().TrimEnd()
  947. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  948. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  949. string starCity = "";
  950. if (star_Three != null)
  951. {
  952. starCity = star_Three.AirPort;
  953. }
  954. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  955. string EndCity = "";
  956. if (End_Three != null)
  957. {
  958. EndCity = End_Three.AirPort;
  959. }
  960. air.Destination = starCity + "/" + EndCity;
  961. air.Flight = FlightsCode[i];
  962. air.SeatingClass = item.CTypeName;
  963. string dateTime = tempstr[2];
  964. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  965. air.FlightDate = DateTemp;
  966. air.DepartureTime = tempstr[5];
  967. air.LandingTime = tempstr[6];
  968. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  969. air.TicketStatus = "--";
  970. air.Luggage = "--";
  971. air.DepartureTerminal = "--";
  972. air.LandingTerminal = "--";
  973. airs.Add(air);
  974. }
  975. int row = 13;
  976. for (int i = 0; i < airs.Count; i++)
  977. {
  978. if (airs.Count > 2)
  979. {
  980. for (int j = 0; j < airs.Count - 2; j++)
  981. {
  982. var CopyRow = table.Rows[12].Clone(true);
  983. table.Rows.Add(CopyRow);
  984. }
  985. }
  986. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  987. int index = 0;
  988. foreach (PropertyInfo property in properties)
  989. {
  990. string value = property.GetValue(airs[i]).ToString();
  991. Cell ishcel0 = table.Rows[row].Cells[index];
  992. Paragraph p = new Paragraph(doc);
  993. string s = value;
  994. p.AppendChild(new Run(doc, s));
  995. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  996. ishcel0.AppendChild(p);
  997. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  998. index++;
  999. }
  1000. row++;
  1001. }
  1002. #endregion
  1003. Paragraph lastParagraph = new Paragraph(doc);
  1004. //第一个表格末尾加段落
  1005. table.ParentNode.InsertAfter(lastParagraph, table);
  1006. //复制第一个表格
  1007. Table cloneTable = (Table)table.Clone(true);
  1008. //在文档末尾段落后面加入复制的表格
  1009. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1010. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1011. {
  1012. int rownewsIndex = 13;
  1013. for (int i = 0; i < 2; i++)
  1014. {
  1015. var CopyRow = table.Rows[12].Clone(true);
  1016. table.Rows.RemoveAt(13);
  1017. table.Rows.Add(CopyRow);
  1018. rownewsIndex++;
  1019. }
  1020. }
  1021. else
  1022. {
  1023. table.Rows.RemoveAt(12);
  1024. }
  1025. cloneTable.Rows.RemoveAt(12);
  1026. }
  1027. if (_AirTicketReservations.Count != 0)
  1028. {
  1029. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1030. if (FlightsCode.Length != 0)
  1031. {
  1032. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1033. if (_AirCompany != null)
  1034. {
  1035. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1036. }
  1037. else
  1038. {
  1039. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1040. }
  1041. }
  1042. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1043. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1044. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1045. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1046. string name = "";
  1047. foreach (string clientName in nameArray)
  1048. {
  1049. if (!name.Contains(clientName))
  1050. {
  1051. name += clientName + ",";
  1052. }
  1053. }
  1054. if (!string.IsNullOrWhiteSpace(name))
  1055. {
  1056. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1057. }
  1058. else
  1059. {
  1060. table.Range.Bookmarks["ClientName"].Text = "--";
  1061. }
  1062. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1063. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1064. table.Range.Bookmarks["JointTicket"].Text = "--";
  1065. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1066. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1067. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1068. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1069. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1070. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1071. }
  1072. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1073. //保存合并后的文档
  1074. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1075. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1076. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1077. return Ok(JsonView(true, "成功!", rst));
  1078. }
  1079. else
  1080. {
  1081. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1082. DocumentBuilder builder = new DocumentBuilder(doc);
  1083. int tableIndex = 0;//表格索引
  1084. //得到文档中的第一个表格
  1085. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1086. List<string> texts = new List<string>();
  1087. foreach (var item in _AirTicketReservations)
  1088. {
  1089. string[] FlightsCode = item.FlightsCode.Split('/');
  1090. if (FlightsCode.Length != 0)
  1091. {
  1092. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1093. if (_AirCompany != null)
  1094. {
  1095. if (!transDic.ContainsKey(_AirCompany.CnName))
  1096. {
  1097. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1098. }
  1099. }
  1100. else
  1101. {
  1102. if (!transDic.ContainsKey("--"))
  1103. {
  1104. transDic.Add("--", "--");
  1105. }
  1106. }
  1107. }
  1108. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1109. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1110. string name = "";
  1111. foreach (string clientName in nameArray)
  1112. {
  1113. name += clientName + ",";
  1114. }
  1115. if (!texts.Contains(name))
  1116. {
  1117. texts.Add(name);
  1118. }
  1119. List<AirInfo> airs = new List<AirInfo>();
  1120. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1121. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1122. for (int i = 0; i < FlightsCode.Length; i++)
  1123. {
  1124. AirInfo air = new AirInfo();
  1125. string[] tempstr = DayArray[i]
  1126. .Replace("\r\n", string.Empty)
  1127. .Replace("\\r\\n", string.Empty)
  1128. .TrimStart().TrimEnd()
  1129. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1130. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1131. if (star_Three != null)
  1132. {
  1133. if (!transDic.ContainsKey(star_Three.AirPort))
  1134. {
  1135. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1136. }
  1137. }
  1138. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1139. if (End_Three != null)
  1140. {
  1141. if (!transDic.ContainsKey(End_Three.AirPort))
  1142. {
  1143. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1144. }
  1145. }
  1146. if (!texts.Contains(item.CTypeName))
  1147. {
  1148. texts.Add(item.CTypeName);
  1149. }
  1150. }
  1151. }
  1152. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1153. if (transData.Count > 0)
  1154. {
  1155. foreach (TranslateResult item in transData)
  1156. {
  1157. if (!transDic.ContainsKey(item.Query))
  1158. {
  1159. transDic.Add(item.Query, item.Translation);
  1160. }
  1161. }
  1162. }
  1163. foreach (var item in _AirTicketReservations)
  1164. {
  1165. #region 处理固定数据
  1166. string[] FlightsCode = item.FlightsCode.Split('/');
  1167. if (FlightsCode.Length != 0)
  1168. {
  1169. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1170. if (_AirCompany != null)
  1171. {
  1172. string str = "--";
  1173. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1174. if (!string.IsNullOrEmpty(translateResult))
  1175. {
  1176. str = translateResult;
  1177. str = _airTicketResRep.Processing(str);
  1178. }
  1179. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1180. }
  1181. else
  1182. {
  1183. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1184. }
  1185. }
  1186. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1187. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1188. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1189. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1190. string names = "";
  1191. foreach (string clientName in nameArray)
  1192. {
  1193. names += clientName + ",";
  1194. }
  1195. if (!string.IsNullOrWhiteSpace(names))
  1196. {
  1197. string str = "--";
  1198. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1199. if (!string.IsNullOrEmpty(translateResult))
  1200. {
  1201. str = translateResult;
  1202. str = _airTicketResRep.Processing(str);
  1203. }
  1204. table.Range.Bookmarks["ClientName"].Text = str;
  1205. }
  1206. else
  1207. {
  1208. table.Range.Bookmarks["ClientName"].Text = "--";
  1209. }
  1210. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1211. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1212. table.Range.Bookmarks["JointTicket"].Text = "--";
  1213. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1214. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1215. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1216. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1217. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1218. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1219. #endregion
  1220. #region 循环数据处理
  1221. List<AirInfo> airs = new List<AirInfo>();
  1222. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1223. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1224. for (int i = 0; i < FlightsCode.Length; i++)
  1225. {
  1226. AirInfo air = new AirInfo();
  1227. string[] tempstr = DayArray[i]
  1228. .Replace("\r\n", string.Empty)
  1229. .Replace("\\r\\n", string.Empty)
  1230. .TrimStart().TrimEnd()
  1231. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1232. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1233. string starCity = "";
  1234. if (star_Three != null)
  1235. {
  1236. string str2 = "--";
  1237. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1238. if (!string.IsNullOrEmpty(translateResult2))
  1239. {
  1240. str2 = translateResult2;
  1241. str2 = _airTicketResRep.Processing(str2);
  1242. }
  1243. starCity = str2;
  1244. }
  1245. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1246. string EndCity = "";
  1247. if (End_Three != null)
  1248. {
  1249. string str1 = "--";
  1250. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1251. if (!string.IsNullOrEmpty(translateResult1))
  1252. {
  1253. str1 = translateResult1;
  1254. str1 = _airTicketResRep.Processing(str1);
  1255. }
  1256. EndCity = str1;
  1257. }
  1258. air.Destination = starCity + "/" + EndCity;
  1259. air.Flight = FlightsCode[i];
  1260. string str = "--";
  1261. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1262. if (!string.IsNullOrEmpty(translateResult))
  1263. {
  1264. str = translateResult;
  1265. str = _airTicketResRep.Processing(str);
  1266. }
  1267. air.SeatingClass = str;
  1268. string dateTime = tempstr[2];
  1269. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1270. air.FlightDate = DateTemp;
  1271. air.DepartureTime = tempstr[5];
  1272. air.LandingTime = tempstr[6];
  1273. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1274. air.TicketStatus = "--";
  1275. air.Luggage = "--";
  1276. air.DepartureTerminal = "--";
  1277. air.LandingTerminal = "--";
  1278. airs.Add(air);
  1279. }
  1280. int row = 13;
  1281. for (int i = 0; i < airs.Count; i++)
  1282. {
  1283. if (airs.Count > 2)
  1284. {
  1285. for (int j = 0; j < airs.Count - 2; j++)
  1286. {
  1287. var CopyRow = table.Rows[12].Clone(true);
  1288. table.Rows.Add(CopyRow);
  1289. }
  1290. }
  1291. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1292. int index = 0;
  1293. foreach (PropertyInfo property in properties)
  1294. {
  1295. string value = property.GetValue(airs[i]).ToString();
  1296. Cell ishcel0 = table.Rows[row].Cells[index];
  1297. Paragraph p = new Paragraph(doc);
  1298. string s = value;
  1299. p.AppendChild(new Run(doc, s));
  1300. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1301. ishcel0.AppendChild(p);
  1302. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1303. //ishcel0.CellFormat.VerticalAlignment=
  1304. index++;
  1305. }
  1306. row++;
  1307. }
  1308. #endregion
  1309. Paragraph lastParagraph = new Paragraph(doc);
  1310. //第一个表格末尾加段落
  1311. table.ParentNode.InsertAfter(lastParagraph, table);
  1312. //复制第一个表格
  1313. Table cloneTable = (Table)table.Clone(true);
  1314. //在文档末尾段落后面加入复制的表格
  1315. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1316. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1317. {
  1318. int rownewsIndex = 13;
  1319. for (int i = 0; i < 2; i++)
  1320. {
  1321. var CopyRow = table.Rows[12].Clone(true);
  1322. table.Rows.RemoveAt(13);
  1323. table.Rows.Add(CopyRow);
  1324. rownewsIndex++;
  1325. }
  1326. }
  1327. else
  1328. {
  1329. table.Rows.RemoveAt(12);
  1330. }
  1331. cloneTable.Rows.RemoveAt(12);
  1332. }
  1333. if (_AirTicketReservations.Count != 0)
  1334. {
  1335. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1336. if (FlightsCode.Length != 0)
  1337. {
  1338. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1339. if (_AirCompany != null)
  1340. {
  1341. string str = "--";
  1342. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1343. if (!string.IsNullOrEmpty(translateResult))
  1344. {
  1345. str = translateResult;
  1346. str = _airTicketResRep.Processing(str);
  1347. }
  1348. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1349. }
  1350. else
  1351. {
  1352. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1353. }
  1354. }
  1355. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1356. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1357. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1358. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1359. string names = "";
  1360. foreach (string clientName in nameArray)
  1361. {
  1362. names += clientName + ",";
  1363. }
  1364. if (!string.IsNullOrWhiteSpace(names))
  1365. {
  1366. string str = "--";
  1367. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1368. if (!string.IsNullOrEmpty(translateResult))
  1369. {
  1370. str = translateResult;
  1371. str = _airTicketResRep.Processing(str);
  1372. }
  1373. table.Range.Bookmarks["ClientName"].Text = str;
  1374. }
  1375. else
  1376. {
  1377. table.Range.Bookmarks["ClientName"].Text = "--";
  1378. }
  1379. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1380. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1381. table.Range.Bookmarks["JointTicket"].Text = "--";
  1382. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1383. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1384. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1385. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1386. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1387. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1388. }
  1389. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1390. //保存合并后的文档
  1391. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1392. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1393. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1394. return Ok(JsonView(true, "成功!", rst));
  1395. }
  1396. }
  1397. }
  1398. catch (Exception ex)
  1399. {
  1400. return Ok(JsonView(false, "程序错误!"));
  1401. throw;
  1402. }
  1403. }
  1404. #endregion
  1405. #region 团组增减款项
  1406. /// <summary>
  1407. /// 团组增减款项下拉框绑定
  1408. /// </summary>
  1409. /// <param name="dto"></param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1414. {
  1415. try
  1416. {
  1417. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1418. if (groupData.Code != 0)
  1419. {
  1420. return Ok(JsonView(false, groupData.Msg));
  1421. }
  1422. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1423. }
  1424. catch (Exception ex)
  1425. {
  1426. return Ok(JsonView(false, "程序错误!"));
  1427. throw;
  1428. }
  1429. }
  1430. /// <summary>
  1431. /// 根据团组Id查询团组增减款项
  1432. /// </summary>
  1433. /// <param name="dto"></param>
  1434. /// <returns></returns>
  1435. [HttpPost]
  1436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1437. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1438. {
  1439. try
  1440. {
  1441. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1442. if (groupData.Code != 0)
  1443. {
  1444. return Ok(JsonView(false, groupData.Msg));
  1445. }
  1446. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1447. }
  1448. catch (Exception ex)
  1449. {
  1450. return Ok(JsonView(false, "程序错误!"));
  1451. throw;
  1452. }
  1453. }
  1454. /// <summary>
  1455. /// 团组增减款项操作(Status:1.新增,2.修改)
  1456. /// </summary>
  1457. /// <param name="dto"></param>
  1458. /// <returns></returns>
  1459. [HttpPost]
  1460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1461. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1462. {
  1463. try
  1464. {
  1465. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1466. if (groupData.Code != 0)
  1467. {
  1468. return Ok(JsonView(false, groupData.Msg));
  1469. }
  1470. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1471. }
  1472. catch (Exception ex)
  1473. {
  1474. return Ok(JsonView(false, "程序错误!"));
  1475. throw;
  1476. }
  1477. }
  1478. /// <summary>
  1479. /// 团组增减款项操作 删除
  1480. /// </summary>
  1481. /// <param name="dto"></param>
  1482. /// <returns></returns>
  1483. [HttpPost]
  1484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1485. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1486. {
  1487. try
  1488. {
  1489. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1490. if (!res)
  1491. {
  1492. return Ok(JsonView(false, "删除失败"));
  1493. }
  1494. return Ok(JsonView(true, "删除成功!"));
  1495. }
  1496. catch (Exception ex)
  1497. {
  1498. return Ok(JsonView(false, "程序错误!"));
  1499. throw;
  1500. }
  1501. }
  1502. /// <summary>
  1503. /// 根据团组增减款项Id查询
  1504. /// </summary>
  1505. /// <param name="dto"></param>
  1506. /// <returns></returns>
  1507. [HttpPost]
  1508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1509. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1510. {
  1511. try
  1512. {
  1513. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1514. if (groupData.Code != 0)
  1515. {
  1516. return Ok(JsonView(false, groupData.Msg));
  1517. }
  1518. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1519. }
  1520. catch (Exception ex)
  1521. {
  1522. return Ok(JsonView(false, "程序错误!"));
  1523. throw;
  1524. }
  1525. }
  1526. #endregion
  1527. #region 文件上传、删除
  1528. /// <summary>
  1529. /// region 文件上传 可以带参数
  1530. /// </summary>
  1531. /// <param name="file"></param>
  1532. /// <returns></returns>
  1533. [HttpPost]
  1534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1535. public async Task<IActionResult> UploadProject(IFormFile file)
  1536. {
  1537. try
  1538. {
  1539. var TypeName = Request.Headers["TypeName"].ToString();
  1540. if (file != null)
  1541. {
  1542. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1543. //文件名称
  1544. string projectFileName = file.FileName;
  1545. //上传的文件的路径
  1546. string filePath = "";
  1547. if (TypeName == "A")//A代表团组增减款项
  1548. {
  1549. if (!Directory.Exists(fileDir))
  1550. {
  1551. Directory.CreateDirectory(fileDir);
  1552. }
  1553. //上传的文件的路径
  1554. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  1555. }
  1556. else if (TypeName == "B")//B代表商邀相关文件
  1557. {
  1558. if (!Directory.Exists(fileDir))
  1559. {
  1560. Directory.CreateDirectory(fileDir);
  1561. }
  1562. //上传的文件的路径
  1563. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1564. }
  1565. using (FileStream fs = System.IO.File.Create(filePath))
  1566. {
  1567. file.CopyTo(fs);
  1568. fs.Flush();
  1569. }
  1570. return Ok(JsonView(true, "上传成功!", projectFileName));
  1571. }
  1572. else
  1573. {
  1574. return Ok(JsonView(false, "上传失败!"));
  1575. }
  1576. }
  1577. catch (Exception ex)
  1578. {
  1579. return Ok(JsonView(false, "程序错误!"));
  1580. throw;
  1581. }
  1582. }
  1583. /// <summary>
  1584. /// 删除指定文件
  1585. /// </summary>
  1586. /// <param name="dto"></param>
  1587. /// <returns></returns>
  1588. [HttpPost]
  1589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1590. public async Task<IActionResult> DelFile(DelFileDto dto)
  1591. {
  1592. try
  1593. {
  1594. var TypeName = Request.Headers["TypeName"].ToString();
  1595. string filePath = "";
  1596. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1597. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  1598. int id = 0;
  1599. if (TypeName == "A")
  1600. {
  1601. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  1602. // 删除该文件
  1603. System.IO.File.Delete(filePath);
  1604. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  1605. }
  1606. else if (TypeName == "B")
  1607. {
  1608. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  1609. // 删除该文件
  1610. System.IO.File.Delete(filePath);
  1611. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  1612. }
  1613. if (id != 0)
  1614. {
  1615. return Ok(JsonView(true, "成功!"));
  1616. }
  1617. else
  1618. {
  1619. return Ok(JsonView(false, "失败!"));
  1620. }
  1621. }
  1622. catch (Exception ex)
  1623. {
  1624. return Ok(JsonView(false, "程序错误!"));
  1625. throw;
  1626. }
  1627. }
  1628. #endregion
  1629. #region 商邀费用录入
  1630. /// <summary>
  1631. /// 根据团组Id查询商邀费用列表
  1632. /// </summary>
  1633. /// <param name="dto"></param>
  1634. /// <returns></returns>
  1635. [HttpPost]
  1636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1637. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  1638. {
  1639. try
  1640. {
  1641. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  1642. if (groupData.Code != 0)
  1643. {
  1644. return Ok(JsonView(false, groupData.Msg));
  1645. }
  1646. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1647. }
  1648. catch (Exception ex)
  1649. {
  1650. return Ok(JsonView(false, "程序错误!"));
  1651. throw;
  1652. }
  1653. }
  1654. /// <summary>
  1655. /// 根据商邀费用ID查询C表和商邀费用数据
  1656. /// </summary>
  1657. /// <param name="dto"></param>
  1658. /// <returns></returns>
  1659. [HttpPost]
  1660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1661. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  1662. {
  1663. try
  1664. {
  1665. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  1666. if (groupData.Code != 0)
  1667. {
  1668. return Ok(JsonView(false, groupData.Msg));
  1669. }
  1670. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1671. }
  1672. catch (Exception ex)
  1673. {
  1674. return Ok(JsonView(false, "程序错误!"));
  1675. throw;
  1676. }
  1677. }
  1678. /// <summary>
  1679. /// 商邀费用录入操作(Status:1.新增,2.修改)
  1680. /// </summary>
  1681. /// <param name="dto"></param>
  1682. /// <returns></returns>
  1683. [HttpPost]
  1684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1685. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  1686. {
  1687. try
  1688. {
  1689. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  1690. if (groupData.Code != 0)
  1691. {
  1692. return Ok(JsonView(false, groupData.Msg));
  1693. }
  1694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1695. }
  1696. catch (Exception ex)
  1697. {
  1698. return Ok(JsonView(false, "程序错误!"));
  1699. throw;
  1700. }
  1701. }
  1702. /// <summary>
  1703. /// 商邀删除
  1704. /// </summary>
  1705. /// <param name="dto"></param>
  1706. /// <returns></returns>
  1707. [HttpPost]
  1708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1709. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  1710. {
  1711. try
  1712. {
  1713. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1714. if (!res)
  1715. {
  1716. return Ok(JsonView(false, "删除失败"));
  1717. }
  1718. return Ok(JsonView(true, "删除成功!"));
  1719. }
  1720. catch (Exception ex)
  1721. {
  1722. return Ok(JsonView(false, "程序错误!"));
  1723. throw;
  1724. }
  1725. }
  1726. #endregion
  1727. }
  1728. }