GroupsController.cs 80 KB

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