GroupsController.cs 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853
  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. }