GroupsController.cs 74 KB

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