GroupsController.cs 83 KB

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