GroupsController.cs 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648
  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. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. namespace OASystem.API.Controllers
  30. {
  31. /// <summary>
  32. /// 团组相关
  33. /// </summary>
  34. //[Authorize]
  35. [Route("api/[controller]/[action]")]
  36. public class GroupsController : ControllerBase
  37. {
  38. private readonly GrpScheduleRepository _grpScheduleRep;
  39. private readonly IMapper _mapper;
  40. private readonly DelegationInfoRepository _groupRepository;
  41. private readonly TaskAssignmentRepository _taskAssignmentRep;
  42. private readonly AirTicketResRepository _airTicketResRep;
  43. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  44. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  45. private readonly DelegationEnDataRepository _delegationEnDataRep;
  46. private readonly DelegationVisaRepository _delegationVisaRep;
  47. private readonly SqlSugarClient _sqlSugar;
  48. private string url;
  49. private string path;
  50. private readonly EnterExitCostRepository _enterExitCostRep;
  51. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  52. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  53. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  54. , DelegationVisaRepository delegationVisaRep)
  55. {
  56. _mapper = mapper;
  57. _grpScheduleRep = grpScheduleRep;
  58. _groupRepository = groupRepository;
  59. _taskAssignmentRep = taskAssignmentRep;
  60. _airTicketResRep = airTicketResRep;
  61. _sqlSugar = sqlSugar;
  62. url = AppSettingsHelper.Get("ExcelBaseUrl");
  63. path = AppSettingsHelper.Get("ExcelBasePath");
  64. if (!System.IO.Directory.Exists(path))
  65. {
  66. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  67. }
  68. _decreasePaymentsRep = decreasePaymentsRep;
  69. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  70. _delegationEnDataRep = delegationEnDataRep;
  71. _enterExitCostRep = enterExitCostRep;
  72. _delegationVisaRep = delegationVisaRep;
  73. }
  74. #region 流程管控
  75. /// <summary>
  76. /// 获取团组流程管控信息
  77. /// </summary>
  78. /// <param name="paras">参数Json字符串</param>
  79. /// <returns></returns>
  80. [HttpPost]
  81. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  82. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  83. {
  84. if (string.IsNullOrEmpty(_jsonDto.Paras))
  85. {
  86. return Ok(JsonView(false, "参数为空"));
  87. }
  88. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  89. if (_ScheduleDto != null)
  90. {
  91. if (_ScheduleDto.SearchType == 2)//获取列表
  92. {
  93. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  94. return Ok(JsonView(_grpScheduleViewList));
  95. }
  96. else//获取对象
  97. {
  98. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  99. if (_grpScheduleView != null)
  100. {
  101. return Ok(JsonView(_grpScheduleView));
  102. }
  103. }
  104. }
  105. else
  106. {
  107. return Ok(JsonView(false, "参数反序列化失败"));
  108. }
  109. return Ok(JsonView(false, "暂无数据!"));
  110. }
  111. /// <summary>
  112. /// 修改团组流程管控详细表数据
  113. /// </summary>
  114. /// <param name="paras"></param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  118. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  119. {
  120. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  121. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  122. .SetColumns(it => it.Duty == _detail.Duty)
  123. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  124. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  125. .SetColumns(it => it.JobContent == _detail.JobContent)
  126. .SetColumns(it => it.Remark == _detail.Remark)
  127. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  128. .Where(s => s.Id == dto.Id)
  129. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  130. .ExecuteCommandAsync();
  131. if (result > 0)
  132. {
  133. return Ok(JsonView(true, "保存成功!"));
  134. }
  135. return Ok(JsonView(false, "保存失败!"));
  136. }
  137. /// <summary>
  138. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  139. /// </summary>
  140. /// <param name="dto"></param>
  141. /// <returns></returns>
  142. [HttpPost]
  143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  144. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  145. {
  146. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  147. _detail.IsDel = 1;
  148. _detail.DeleteUserId = dto.Duty;
  149. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  150. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  151. .SetColumns(it => it.IsDel == _detail.IsDel)
  152. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  153. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  154. .Where(it => it.Id == dto.Id)
  155. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  156. //.WhereColumns(s => s.Id == dto.Id)
  157. .ExecuteCommandAsync();
  158. if (result > 0)
  159. {
  160. return Ok(JsonView(true, "删除成功!"));
  161. }
  162. return Ok(JsonView(false, "删除失败!"));
  163. }
  164. /// <summary>
  165. /// 增加团组流程管控详细表数据
  166. /// </summary>
  167. /// <param name="dto"></param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  171. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  172. {
  173. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  174. if (DateTime.Now < _detail.ExpectBeginDt)
  175. {
  176. _detail.StepStatus = 0;
  177. }
  178. else
  179. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  180. _detail.StepStatus = 1;
  181. }
  182. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  183. if (result > 0)
  184. {
  185. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  186. return Ok(JsonView(true, "添加成功!", _result));
  187. }
  188. return Ok(JsonView(false, "添加失败!"));
  189. }
  190. #endregion
  191. #region 团组基本信息
  192. /// <summary>
  193. /// 接团信息列表
  194. /// </summary>
  195. /// <param name="dto">团组列表请求dto</param>
  196. /// <returns></returns>
  197. [HttpPost]
  198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  199. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  200. {
  201. var groupData = await _groupRepository.GetGroupList(dto);
  202. if (groupData.Code != 0)
  203. {
  204. return Ok(JsonView(false, groupData.Msg));
  205. }
  206. return Ok(JsonView(groupData.Data));
  207. }
  208. /// <summary>
  209. /// 接团信息详情
  210. /// </summary>
  211. /// <param name="dto">团组info请求dto</param>
  212. /// <returns></returns>
  213. [HttpPost]
  214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  215. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  216. {
  217. var groupData = await _groupRepository.GetGroupInfo(dto);
  218. if (groupData.Code != 0)
  219. {
  220. return Ok(JsonView(false, groupData.Msg));
  221. }
  222. return Ok(JsonView(groupData.Data));
  223. }
  224. /// <summary>
  225. /// 接团信息 编辑添加
  226. /// 基础信息数据源
  227. /// </summary>
  228. /// <param name="dto"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  233. {
  234. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  235. if (groupData.Code != 0)
  236. {
  237. return Ok(JsonView(false, groupData.Msg));
  238. }
  239. return Ok(JsonView(groupData.Data));
  240. }
  241. /// <summary>
  242. /// 接团信息 操作(增改)
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  249. {
  250. try
  251. {
  252. var groupData = await _groupRepository.GroupOperation(dto);
  253. if (groupData.Code != 0)
  254. {
  255. return Ok(JsonView(false, groupData.Msg));
  256. }
  257. return Ok(JsonView(true));
  258. }
  259. catch (Exception ex)
  260. {
  261. Logs("[response]" + JsonConvert.SerializeObject(dto));
  262. Logs(ex.Message);
  263. return Ok(JsonView(false, ex.Message));
  264. }
  265. }
  266. /// <summary>
  267. /// 接团信息 操作(删除)
  268. /// </summary>
  269. /// <param name="dto"></param>
  270. /// <returns></returns>
  271. [HttpPost]
  272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  273. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  274. {
  275. try
  276. {
  277. var groupData = await _groupRepository.GroupDel(dto);
  278. if (groupData.Code != 0)
  279. {
  280. return Ok(JsonView(false, groupData.Msg));
  281. }
  282. return Ok(JsonView(true));
  283. }
  284. catch (Exception ex)
  285. {
  286. Logs("[response]" + JsonConvert.SerializeObject(dto));
  287. Logs(ex.Message);
  288. return Ok(JsonView(false, ex.Message));
  289. }
  290. }
  291. /// <summary>
  292. /// 获取团组销售报价号
  293. /// 团组添加时 使用
  294. /// </summary>
  295. /// <returns></returns>
  296. [HttpPost]
  297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  298. public async Task<IActionResult> GetGroupSalesQuoteNo()
  299. {
  300. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  301. if (groupData.Code != 0)
  302. {
  303. return Ok(JsonView(false, groupData.Msg));
  304. }
  305. object salesQuoteNo = new
  306. {
  307. SalesQuoteNo = groupData.Data
  308. };
  309. return Ok(JsonView(salesQuoteNo));
  310. }
  311. /// <summary>
  312. /// 设置确认出团
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. [HttpPost]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  319. {
  320. var groupData = await _groupRepository.ConfirmationGroup(dto);
  321. if (groupData.Code != 0)
  322. {
  323. return Ok(JsonView(false, groupData.Msg));
  324. }
  325. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  326. return Ok(JsonView(groupData.Data));
  327. }
  328. /// <summary>
  329. /// 获取团组名称 List
  330. /// </summary>
  331. /// <param name="dto"></param>
  332. /// <returns></returns>
  333. [HttpPost]
  334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  335. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  336. {
  337. var groupData = await _groupRepository.GetGroupNameList(dto);
  338. if (groupData.Code != 0)
  339. {
  340. return Ok(JsonView(false, groupData.Msg));
  341. }
  342. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  343. }
  344. /// <summary>
  345. /// 获取团组名称data And 签证国别Data
  346. /// </summary>
  347. /// <param name="dto"></param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  351. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  352. {
  353. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  354. if (groupData.Code != 0)
  355. {
  356. return Ok(JsonView(false, groupData.Msg));
  357. }
  358. return Ok(JsonView(groupData.Data));
  359. }
  360. /// <summary>
  361. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  362. /// </summary>
  363. /// <returns></returns>
  364. [HttpPost]
  365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  366. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  367. {
  368. try
  369. {
  370. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  371. if (groupData.Code != 0)
  372. {
  373. return Ok(JsonView(false, groupData.Msg));
  374. }
  375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  376. }
  377. catch (Exception ex)
  378. {
  379. return Ok(JsonView(false, "程序错误!"));
  380. throw;
  381. }
  382. }
  383. #endregion
  384. #region 团组&签证
  385. /// <summary>
  386. /// 根据团组Id获取签证客户信息List
  387. /// </summary>
  388. /// <param name="dto">请求dto</param>
  389. /// <returns></returns>
  390. [HttpPost]
  391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  392. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  393. {
  394. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  395. if (groupData.Code != 0)
  396. {
  397. return Ok(JsonView(false, groupData.Msg));
  398. }
  399. return Ok(JsonView(groupData.Data));
  400. }
  401. /// <summary>
  402. /// IOS获取团组签证拍照上传进度01(团组列表)
  403. /// </summary>
  404. /// <param name="dto">请求dto</param>
  405. /// <returns></returns>
  406. [HttpPost]
  407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  408. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  409. {
  410. if (dto == null)
  411. {
  412. return Ok(JsonView(false, "参数为空"));
  413. }
  414. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  415. return Ok(JsonView(visaList));
  416. }
  417. /// <summary>
  418. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  419. /// </summary>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  423. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  424. {
  425. if (dto == null)
  426. {
  427. return Ok(JsonView(false, "请求错误:"));
  428. }
  429. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  430. return Ok(JsonView(list));
  431. }
  432. /// <summary>
  433. /// IOS获取团组签证拍照上传进度03(相册)
  434. /// </summary>
  435. /// <returns></returns>
  436. [HttpPost]
  437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  438. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  439. {
  440. if (dto == null)
  441. {
  442. return Ok(JsonView(false, "请求错误:"));
  443. }
  444. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  445. return Ok(JsonView(list));
  446. }
  447. /// <summary>
  448. /// IOS获取团组签证拍照上传进度04(图片上传)
  449. /// </summary>
  450. /// <param name="dto"></param>
  451. /// <returns></returns>
  452. [HttpPost]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  455. {
  456. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  457. //if (!string.IsNullOrEmpty(result))
  458. //{
  459. //}
  460. //else {
  461. // return Ok(JsonView(false, "上传失败"));
  462. //}
  463. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  464. int sucNum = 0;
  465. try
  466. {
  467. foreach (var item in dto.base64DataList)
  468. {
  469. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  470. string result = decodeBase64ToImage(item, imageName);
  471. if (!string.IsNullOrEmpty(result))
  472. {
  473. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  474. pic.CreateUserId = dto.CreateUserId;
  475. pic.PicName = imageName;
  476. pic.PicPath = result;
  477. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  478. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  479. if (insertResult > 0)
  480. {
  481. sucNum++;
  482. }
  483. }
  484. }
  485. }
  486. catch (Exception ex)
  487. {
  488. return Ok(JsonView(false, ex.Message));
  489. }
  490. string msg = string.Format(@"成功上传{0}张", sucNum);
  491. return Ok(JsonView(true, msg));
  492. }
  493. private string decodeBase64ToImage(string base64DataURL, string imgName)
  494. {
  495. string filename = "";//声明一个string类型的相对路径
  496. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  497. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  498. try//会有异常抛出,try,catch一下
  499. {
  500. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  501. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  502. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  503. var fileDir = AppSettingsHelper.Get("VisaProgressImageFtpPath");
  504. //文件名称
  505. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpg";//所要保存的相对路径及名字
  506. //上传的文件的路径
  507. string filePath = "";
  508. if (!Directory.Exists(fileDir))
  509. {
  510. Directory.CreateDirectory(fileDir);
  511. }
  512. //上传的文件的路径
  513. filePath = fileDir + filename;
  514. //string url = HttpRuntime.AppDomainAppPath.ToString();
  515. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  516. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  517. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  518. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  519. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  520. //bitmap.Save(filePath + ".png", System.Drawing.Imaging.ImageFormat.Png);
  521. ms.Close();//关闭当前流,并释放所有与之关联的资源
  522. bitmap.Dispose();
  523. }
  524. catch (Exception e)
  525. {
  526. string massage = e.Message;
  527. filename=e.Message
  528. }
  529. return filename;//返回相对路径
  530. }
  531. #endregion
  532. #region 团组任务分配
  533. /// <summary>
  534. /// 团组任务分配初始化
  535. /// </summary>
  536. /// <param name="dto"></param>
  537. /// <returns></returns>
  538. [HttpPost]
  539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  540. public async Task<IActionResult> GetTaskAssignmen()
  541. {
  542. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  543. if (groupData.Code != 0)
  544. {
  545. return Ok(JsonView(false, groupData.Msg));
  546. }
  547. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  548. }
  549. /// <summary>
  550. /// 团组任务分配查询
  551. /// </summary>
  552. /// <param name="dto"></param>
  553. /// <returns></returns>
  554. [HttpPost]
  555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  556. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  557. {
  558. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  559. if (groupData.Code != 0)
  560. {
  561. return Ok(JsonView(false, groupData.Msg));
  562. }
  563. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  564. }
  565. /// <summary>
  566. /// 团组任务分配操作
  567. /// </summary>
  568. /// <param name="dto"></param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  573. {
  574. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  575. if (groupData.Code != 0)
  576. {
  577. return Ok(JsonView(false, groupData.Msg));
  578. }
  579. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  580. }
  581. #endregion
  582. #region 团组费用审核
  583. /// <summary>
  584. /// 获取团组费用审核
  585. /// </summary>
  586. /// <param name="paras">参数Json字符串</param>
  587. /// <returns></returns>
  588. [HttpPost]
  589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  590. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  591. {
  592. if (_dto.DiId < 1)
  593. {
  594. return Ok(JsonView(false, "团组Id为空"));
  595. }
  596. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  597. #region 团组基本信息
  598. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  599. if (_delegation != null)
  600. {
  601. _view.ClientName = _delegation.ClientName;
  602. _view.DiId = _dto.DiId;
  603. _view.TeamName = _delegation.TeamName;
  604. _view.VisitCountry = _delegation.VisitCountry;
  605. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  606. _view.VisitDays = _delegation.VisitDays;
  607. _view.VisitPNumber = _delegation.VisitPNumber;
  608. }
  609. else
  610. {
  611. return Ok(JsonView(false, "团组信息为空"));
  612. }
  613. #endregion
  614. #region 费用清单
  615. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  616. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  617. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  618. List<Grp_CreditCardPayment> entityList = _groupRepository
  619. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  620. .Where(exp.ToExpression())
  621. .ToList();
  622. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  623. decimal CNY = 0;
  624. decimal PayCNY = 0;
  625. decimal BalanceCNY = 0;
  626. decimal YSFYCNY = 0;
  627. decimal USD = 0;
  628. decimal PayUSD = 0;
  629. decimal BalanceUSD = 0;
  630. decimal YSFYUSD = 0;
  631. decimal EUR = 0;
  632. decimal PayEUR = 0;
  633. decimal BalanceEUR = 0;
  634. decimal YSFYEUR = 0;
  635. foreach (var entity in entityList)
  636. {
  637. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  638. _detail.Id = entity.Id;
  639. /*
  640. * Bus名称
  641. */
  642. _detail.BusName = "";
  643. /*
  644. *费用所属
  645. */
  646. switch (entity.CTable)
  647. {
  648. case 85:
  649. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  650. if (jpRes != null)
  651. {
  652. string FlightsDescription = jpRes.FlightsDescription;
  653. string PriceDescription = jpRes.PriceDescription;
  654. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  655. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  656. }
  657. break;
  658. case 79:
  659. _detail.BusName = "待增加";
  660. break;
  661. case 98:
  662. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  663. if (gdpRes != null)
  664. {
  665. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  666. _detail.PriceNameContent = gdpRes.PriceName;
  667. }
  668. break;
  669. default:
  670. break;
  671. }
  672. /*
  673. * 费用模块
  674. */
  675. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  676. if (sdPriceName != null)
  677. {
  678. _detail.PriceName = sdPriceName.Name;
  679. }
  680. /*
  681. * 应付款金额
  682. */
  683. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  684. string PaymentCurrency_WaitPay = "Unknown";
  685. if (sdPaymentCurrency_WaitPay != null)
  686. {
  687. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  688. }
  689. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  690. /*
  691. * 此次付款金额
  692. */
  693. decimal CurrPayStr = 0;
  694. if (entity.PayPercentage == 0)
  695. {
  696. if (entity.PayThenMoney != 0)
  697. CurrPayStr = entity.PayThenMoney * entity.DayRate;
  698. }
  699. else
  700. {
  701. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate);
  702. }
  703. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  704. /*
  705. * 剩余尾款
  706. */
  707. decimal BalanceStr = 0;
  708. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  709. BalanceStr = 0;
  710. else
  711. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate);
  712. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  713. /*
  714. * 申请人
  715. */
  716. string operatorName = "无";
  717. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
  718. if (_opUser != null)
  719. {
  720. operatorName = _opUser.CnName;
  721. }
  722. _detail.OperatorName = operatorName;
  723. /*
  724. * 审核人
  725. */
  726. string auditOperatorName = "Unknown";
  727. if (entity.AuditGMOperate == 0)
  728. auditOperatorName = "无";
  729. else if (entity.AuditGMOperate == 4)
  730. auditOperatorName = "自动审核";
  731. else
  732. {
  733. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
  734. if (_adUser != null)
  735. {
  736. auditOperatorName = _adUser.CnName;
  737. }
  738. }
  739. _detail.AuditOperatorName = auditOperatorName;
  740. /*
  741. *
  742. * *超预算比例
  743. */
  744. string overBudgetStr = "";
  745. if (entity.ExceedBudget == -1)
  746. overBudgetStr = sdPriceName.Name + "尚无预算";
  747. else if (entity.ExceedBudget == 0)
  748. overBudgetStr = "未超预算";
  749. else
  750. overBudgetStr = entity.ExceedBudget.ToString("P");
  751. _detail.OverBudget = overBudgetStr;
  752. /*
  753. * 费用总计
  754. */
  755. if (entity.PaymentCurrency == 48)
  756. {
  757. CNY += entity.PayMoney;
  758. PayCNY += CurrPayStr;
  759. BalanceCNY += BalanceStr;
  760. YSFYCNY += CurrPayStr;
  761. }
  762. if (entity.PaymentCurrency == 49)
  763. {
  764. USD += entity.PayMoney;
  765. PayUSD += CurrPayStr;
  766. BalanceUSD += BalanceStr;
  767. YSFYUSD += CurrPayStr;
  768. }
  769. if (entity.PaymentCurrency == 51)
  770. {
  771. EUR += entity.PayMoney;
  772. PayEUR += CurrPayStr;
  773. BalanceEUR += BalanceStr;
  774. YSFYEUR += CurrPayStr;
  775. }
  776. _detail.IsAuditGM = entity.IsAuditGM;
  777. detailList.Add(_detail);
  778. }
  779. #endregion
  780. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  781. _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  782. _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  783. _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  784. _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  785. return Ok(JsonView(_view));
  786. }
  787. /// <summary>
  788. /// 修改团组费用审核状态
  789. /// </summary>
  790. /// <param name="paras">参数Json字符串</param>
  791. /// <returns></returns>
  792. [HttpPost]
  793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  794. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  795. {
  796. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  797. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  798. DateTime dtNow = DateTime.Now;
  799. _groupRepository.BeginTran();
  800. int rst = 0;
  801. foreach (var item in idList)
  802. {
  803. int CreditId = int.Parse(item);
  804. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  805. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  806. .SetColumns(it => it.AuditGMOperate == _dto.User)
  807. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  808. .Where(s => s.Id == CreditId)
  809. .ExecuteCommandAsync();
  810. if (result < 1)
  811. {
  812. rst = -1;
  813. }
  814. else
  815. {
  816. _groupRepository.RollbackTran();
  817. return Ok(JsonView(false, "保存失败并回滚!"));
  818. }
  819. }
  820. _groupRepository.CommitTran();
  821. if (rst == 0)
  822. {
  823. return Ok(JsonView(true, "保存成功!"));
  824. }
  825. return Ok(JsonView(false, "保存失败!"));
  826. }
  827. #endregion
  828. #region 机票费用录入
  829. /// <summary>
  830. /// 机票录入当前登录人可操作团组
  831. /// </summary>
  832. /// <param name="dto"></param>
  833. /// <returns></returns>
  834. [HttpPost]
  835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  836. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  837. {
  838. try
  839. {
  840. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  841. if (groupData.Code != 0)
  842. {
  843. return Ok(JsonView(false, groupData.Msg));
  844. }
  845. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  846. }
  847. catch (Exception ex)
  848. {
  849. return Ok(JsonView(false, "程序错误!"));
  850. throw;
  851. }
  852. }
  853. /// <summary>
  854. /// 机票费用录入列表
  855. /// </summary>
  856. /// <param name="dto"></param>
  857. /// <returns></returns>
  858. [HttpPost]
  859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  860. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  861. {
  862. try
  863. {
  864. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  865. if (groupData.Code != 0)
  866. {
  867. return Ok(JsonView(false, groupData.Msg));
  868. }
  869. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  870. }
  871. catch (Exception ex)
  872. {
  873. return Ok(JsonView(false, "程序错误!"));
  874. throw;
  875. }
  876. }
  877. /// <summary>
  878. /// 根据id查询费用录入信息
  879. /// </summary>
  880. /// <param name="dto"></param>
  881. /// <returns></returns>
  882. [HttpPost]
  883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  884. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  885. {
  886. try
  887. {
  888. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  889. if (groupData.Code != 0)
  890. {
  891. return Ok(JsonView(false, groupData.Msg));
  892. }
  893. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  894. }
  895. catch (Exception ex)
  896. {
  897. return Ok(JsonView(false, "程序错误!"));
  898. throw;
  899. }
  900. }
  901. /// <summary>
  902. /// 机票费用录入操作(Status:1.新增,2.修改)
  903. /// </summary>
  904. /// <param name="dto"></param>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  909. {
  910. try
  911. {
  912. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  913. if (groupData.Code != 0)
  914. {
  915. return Ok(JsonView(false, groupData.Msg));
  916. }
  917. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  918. }
  919. catch (Exception ex)
  920. {
  921. return Ok(JsonView(false, "程序错误!"));
  922. throw;
  923. }
  924. }
  925. /// <summary>
  926. /// 根据舱位类型查询接团客户名单信息
  927. /// </summary>
  928. /// <param name="dto"></param>
  929. /// <returns></returns>
  930. [HttpPost]
  931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  932. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  933. {
  934. try
  935. {
  936. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  937. if (crm_Groups.Count != 0)
  938. {
  939. List<dynamic> Customer = new List<dynamic>();
  940. foreach (var item in crm_Groups)
  941. {
  942. var data = new
  943. {
  944. Id = item.Id,
  945. Pinyin = item.Pinyin,
  946. Name = item.LastName + item.FirstName
  947. };
  948. Customer.Add(data);
  949. }
  950. return Ok(JsonView(true, "查询成功!", Customer));
  951. }
  952. return Ok(JsonView(true, "暂无数据", crm_Groups));
  953. }
  954. catch (Exception ex)
  955. {
  956. return Ok(JsonView(false, "程序错误!"));
  957. throw;
  958. }
  959. }
  960. /// <summary>
  961. /// 机票费用录入,删除
  962. /// </summary>
  963. /// <param name="dto"></param>
  964. /// <returns></returns>
  965. [HttpPost]
  966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  967. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  968. {
  969. try
  970. {
  971. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  972. if (!res)
  973. {
  974. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  975. {
  976. IsDel = 1,
  977. DeleteUserId = dto.DeleteUserId,
  978. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  979. }).ExecuteCommandAsync();
  980. return Ok(JsonView(false, "删除失败"));
  981. }
  982. return Ok(JsonView(true, "删除成功!"));
  983. }
  984. catch (Exception ex)
  985. {
  986. return Ok(JsonView(false, "程序错误!"));
  987. throw;
  988. }
  989. }
  990. /// <summary>
  991. /// 导出机票录入报表
  992. /// </summary>
  993. /// <param name="dto"></param>
  994. /// <returns></returns>
  995. [HttpPost]
  996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  997. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  998. {
  999. try
  1000. {
  1001. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1002. if (groupData.Code != 0)
  1003. {
  1004. return Ok(JsonView(false, groupData.Msg));
  1005. }
  1006. else
  1007. {
  1008. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1009. if (AirTicketReservations.Count != 0)
  1010. {
  1011. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1012. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1013. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1014. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1015. WorkbookDesigner designer = new WorkbookDesigner();
  1016. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1017. decimal countCost = 0;
  1018. foreach (var item in AirTicketReservations)
  1019. {
  1020. if (item.BankType == "其他")
  1021. {
  1022. item.BankNo = "--";
  1023. }
  1024. else
  1025. {
  1026. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1027. }
  1028. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1029. item.Price = System.Decimal.Round(item.Price, 2);
  1030. countCost += Convert.ToDecimal(item.Price);
  1031. }
  1032. designer.SetDataSource("Export", AirTicketReservations);
  1033. designer.SetDataSource("ExportDiCode", diCode);
  1034. designer.SetDataSource("ExportDiName", diName);
  1035. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1036. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1037. designer.Process();
  1038. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1039. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1040. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1041. return Ok(JsonView(true, "成功", url = rst));
  1042. }
  1043. else
  1044. {
  1045. return Ok(JsonView(false, "暂无数据!"));
  1046. }
  1047. }
  1048. }
  1049. catch (Exception ex)
  1050. {
  1051. return Ok(JsonView(false, "程序错误!"));
  1052. throw;
  1053. }
  1054. }
  1055. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1056. /// <summary>
  1057. /// 行程单导出
  1058. /// </summary>
  1059. /// <param name="dto"></param>
  1060. /// <returns></returns>
  1061. [HttpPost]
  1062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1063. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1064. {
  1065. try
  1066. {
  1067. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1068. if (groupData.Code != 0)
  1069. {
  1070. return Ok(JsonView(false, groupData.Msg));
  1071. }
  1072. else
  1073. {
  1074. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1075. if (dto.Language == "CN")
  1076. {
  1077. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1078. DocumentBuilder builder = new DocumentBuilder(doc);
  1079. int tableIndex = 0;//表格索引
  1080. //得到文档中的第一个表格
  1081. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1082. foreach (var item in _AirTicketReservations)
  1083. {
  1084. #region 处理固定数据
  1085. string[] FlightsCode = item.FlightsCode.Split('/');
  1086. if (FlightsCode.Length != 0)
  1087. {
  1088. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1089. if (_AirCompany != null)
  1090. {
  1091. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1092. }
  1093. else
  1094. {
  1095. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1096. }
  1097. }
  1098. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1099. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1100. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1101. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1102. string name = "";
  1103. foreach (string clientName in nameArray)
  1104. {
  1105. if (!name.Contains(clientName))
  1106. {
  1107. name += clientName + ",";
  1108. }
  1109. }
  1110. if (!string.IsNullOrWhiteSpace(name))
  1111. {
  1112. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1113. }
  1114. else
  1115. {
  1116. table.Range.Bookmarks["ClientName"].Text = "--";
  1117. }
  1118. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1119. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1120. table.Range.Bookmarks["JointTicket"].Text = "--";
  1121. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1122. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1123. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1124. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1125. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1126. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1127. #endregion
  1128. #region 循环数据处理
  1129. List<AirInfo> airs = new List<AirInfo>();
  1130. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1131. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1132. for (int i = 0; i < FlightsCode.Length; i++)
  1133. {
  1134. AirInfo air = new AirInfo();
  1135. string[] tempstr = DayArray[i]
  1136. .Replace("\r\n", string.Empty)
  1137. .Replace("\\r\\n", string.Empty)
  1138. .TrimStart().TrimEnd()
  1139. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1140. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1141. string starCity = "";
  1142. if (star_Three != null)
  1143. {
  1144. starCity = star_Three.AirPort;
  1145. }
  1146. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1147. string EndCity = "";
  1148. if (End_Three != null)
  1149. {
  1150. EndCity = End_Three.AirPort;
  1151. }
  1152. air.Destination = starCity + "/" + EndCity;
  1153. air.Flight = FlightsCode[i];
  1154. air.SeatingClass = item.CTypeName;
  1155. string dateTime = tempstr[2];
  1156. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1157. air.FlightDate = DateTemp;
  1158. air.DepartureTime = tempstr[5];
  1159. air.LandingTime = tempstr[6];
  1160. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1161. air.TicketStatus = "--";
  1162. air.Luggage = "--";
  1163. air.DepartureTerminal = "--";
  1164. air.LandingTerminal = "--";
  1165. airs.Add(air);
  1166. }
  1167. int row = 13;
  1168. for (int i = 0; i < airs.Count; i++)
  1169. {
  1170. if (airs.Count > 2)
  1171. {
  1172. for (int j = 0; j < airs.Count - 2; j++)
  1173. {
  1174. var CopyRow = table.Rows[12].Clone(true);
  1175. table.Rows.Add(CopyRow);
  1176. }
  1177. }
  1178. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1179. int index = 0;
  1180. foreach (PropertyInfo property in properties)
  1181. {
  1182. string value = property.GetValue(airs[i]).ToString();
  1183. Cell ishcel0 = table.Rows[row].Cells[index];
  1184. Paragraph p = new Paragraph(doc);
  1185. string s = value;
  1186. p.AppendChild(new Run(doc, s));
  1187. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1188. ishcel0.AppendChild(p);
  1189. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1190. index++;
  1191. }
  1192. row++;
  1193. }
  1194. #endregion
  1195. Paragraph lastParagraph = new Paragraph(doc);
  1196. //第一个表格末尾加段落
  1197. table.ParentNode.InsertAfter(lastParagraph, table);
  1198. //复制第一个表格
  1199. Table cloneTable = (Table)table.Clone(true);
  1200. //在文档末尾段落后面加入复制的表格
  1201. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1202. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1203. {
  1204. int rownewsIndex = 13;
  1205. for (int i = 0; i < 2; i++)
  1206. {
  1207. var CopyRow = table.Rows[12].Clone(true);
  1208. table.Rows.RemoveAt(13);
  1209. table.Rows.Add(CopyRow);
  1210. rownewsIndex++;
  1211. }
  1212. }
  1213. else
  1214. {
  1215. table.Rows.RemoveAt(12);
  1216. }
  1217. cloneTable.Rows.RemoveAt(12);
  1218. }
  1219. if (_AirTicketReservations.Count != 0)
  1220. {
  1221. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1222. if (FlightsCode.Length != 0)
  1223. {
  1224. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1225. if (_AirCompany != null)
  1226. {
  1227. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1228. }
  1229. else
  1230. {
  1231. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1232. }
  1233. }
  1234. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1235. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1236. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1237. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1238. string name = "";
  1239. foreach (string clientName in nameArray)
  1240. {
  1241. if (!name.Contains(clientName))
  1242. {
  1243. name += clientName + ",";
  1244. }
  1245. }
  1246. if (!string.IsNullOrWhiteSpace(name))
  1247. {
  1248. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1249. }
  1250. else
  1251. {
  1252. table.Range.Bookmarks["ClientName"].Text = "--";
  1253. }
  1254. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1255. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1256. table.Range.Bookmarks["JointTicket"].Text = "--";
  1257. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1258. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1259. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1260. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1261. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1262. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1263. }
  1264. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1265. //保存合并后的文档
  1266. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1267. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1268. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1269. return Ok(JsonView(true, "成功!", rst));
  1270. }
  1271. else
  1272. {
  1273. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1274. DocumentBuilder builder = new DocumentBuilder(doc);
  1275. int tableIndex = 0;//表格索引
  1276. //得到文档中的第一个表格
  1277. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1278. List<string> texts = new List<string>();
  1279. foreach (var item in _AirTicketReservations)
  1280. {
  1281. string[] FlightsCode = item.FlightsCode.Split('/');
  1282. if (FlightsCode.Length != 0)
  1283. {
  1284. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1285. if (_AirCompany != null)
  1286. {
  1287. if (!transDic.ContainsKey(_AirCompany.CnName))
  1288. {
  1289. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1290. }
  1291. }
  1292. else
  1293. {
  1294. if (!transDic.ContainsKey("--"))
  1295. {
  1296. transDic.Add("--", "--");
  1297. }
  1298. }
  1299. }
  1300. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1301. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1302. string name = "";
  1303. foreach (string clientName in nameArray)
  1304. {
  1305. name += clientName + ",";
  1306. }
  1307. if (!texts.Contains(name))
  1308. {
  1309. texts.Add(name);
  1310. }
  1311. List<AirInfo> airs = new List<AirInfo>();
  1312. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1313. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1314. for (int i = 0; i < FlightsCode.Length; i++)
  1315. {
  1316. AirInfo air = new AirInfo();
  1317. string[] tempstr = DayArray[i]
  1318. .Replace("\r\n", string.Empty)
  1319. .Replace("\\r\\n", string.Empty)
  1320. .TrimStart().TrimEnd()
  1321. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1322. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1323. if (star_Three != null)
  1324. {
  1325. if (!transDic.ContainsKey(star_Three.AirPort))
  1326. {
  1327. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1328. }
  1329. }
  1330. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1331. if (End_Three != null)
  1332. {
  1333. if (!transDic.ContainsKey(End_Three.AirPort))
  1334. {
  1335. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1336. }
  1337. }
  1338. if (!texts.Contains(item.CTypeName))
  1339. {
  1340. texts.Add(item.CTypeName);
  1341. }
  1342. }
  1343. }
  1344. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1345. if (transData.Count > 0)
  1346. {
  1347. foreach (TranslateResult item in transData)
  1348. {
  1349. if (!transDic.ContainsKey(item.Query))
  1350. {
  1351. transDic.Add(item.Query, item.Translation);
  1352. }
  1353. }
  1354. }
  1355. foreach (var item in _AirTicketReservations)
  1356. {
  1357. #region 处理固定数据
  1358. string[] FlightsCode = item.FlightsCode.Split('/');
  1359. if (FlightsCode.Length != 0)
  1360. {
  1361. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1362. if (_AirCompany != null)
  1363. {
  1364. string str = "--";
  1365. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1366. if (!string.IsNullOrEmpty(translateResult))
  1367. {
  1368. str = translateResult;
  1369. str = _airTicketResRep.Processing(str);
  1370. }
  1371. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1372. }
  1373. else
  1374. {
  1375. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1376. }
  1377. }
  1378. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1379. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1380. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1381. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1382. string names = "";
  1383. foreach (string clientName in nameArray)
  1384. {
  1385. names += clientName + ",";
  1386. }
  1387. if (!string.IsNullOrWhiteSpace(names))
  1388. {
  1389. string str = "--";
  1390. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1391. if (!string.IsNullOrEmpty(translateResult))
  1392. {
  1393. str = translateResult;
  1394. str = _airTicketResRep.Processing(str);
  1395. }
  1396. table.Range.Bookmarks["ClientName"].Text = str;
  1397. }
  1398. else
  1399. {
  1400. table.Range.Bookmarks["ClientName"].Text = "--";
  1401. }
  1402. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1403. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1404. table.Range.Bookmarks["JointTicket"].Text = "--";
  1405. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1406. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1407. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1408. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1409. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1410. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1411. #endregion
  1412. #region 循环数据处理
  1413. List<AirInfo> airs = new List<AirInfo>();
  1414. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1415. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1416. for (int i = 0; i < FlightsCode.Length; i++)
  1417. {
  1418. AirInfo air = new AirInfo();
  1419. string[] tempstr = DayArray[i]
  1420. .Replace("\r\n", string.Empty)
  1421. .Replace("\\r\\n", string.Empty)
  1422. .TrimStart().TrimEnd()
  1423. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1424. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1425. string starCity = "";
  1426. if (star_Three != null)
  1427. {
  1428. string str2 = "--";
  1429. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1430. if (!string.IsNullOrEmpty(translateResult2))
  1431. {
  1432. str2 = translateResult2;
  1433. str2 = _airTicketResRep.Processing(str2);
  1434. }
  1435. starCity = str2;
  1436. }
  1437. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1438. string EndCity = "";
  1439. if (End_Three != null)
  1440. {
  1441. string str1 = "--";
  1442. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1443. if (!string.IsNullOrEmpty(translateResult1))
  1444. {
  1445. str1 = translateResult1;
  1446. str1 = _airTicketResRep.Processing(str1);
  1447. }
  1448. EndCity = str1;
  1449. }
  1450. air.Destination = starCity + "/" + EndCity;
  1451. air.Flight = FlightsCode[i];
  1452. string str = "--";
  1453. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1454. if (!string.IsNullOrEmpty(translateResult))
  1455. {
  1456. str = translateResult;
  1457. str = _airTicketResRep.Processing(str);
  1458. }
  1459. air.SeatingClass = str;
  1460. string dateTime = tempstr[2];
  1461. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1462. air.FlightDate = DateTemp;
  1463. air.DepartureTime = tempstr[5];
  1464. air.LandingTime = tempstr[6];
  1465. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1466. air.TicketStatus = "--";
  1467. air.Luggage = "--";
  1468. air.DepartureTerminal = "--";
  1469. air.LandingTerminal = "--";
  1470. airs.Add(air);
  1471. }
  1472. int row = 13;
  1473. for (int i = 0; i < airs.Count; i++)
  1474. {
  1475. if (airs.Count > 2)
  1476. {
  1477. for (int j = 0; j < airs.Count - 2; j++)
  1478. {
  1479. var CopyRow = table.Rows[12].Clone(true);
  1480. table.Rows.Add(CopyRow);
  1481. }
  1482. }
  1483. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1484. int index = 0;
  1485. foreach (PropertyInfo property in properties)
  1486. {
  1487. string value = property.GetValue(airs[i]).ToString();
  1488. Cell ishcel0 = table.Rows[row].Cells[index];
  1489. Paragraph p = new Paragraph(doc);
  1490. string s = value;
  1491. p.AppendChild(new Run(doc, s));
  1492. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1493. ishcel0.AppendChild(p);
  1494. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1495. //ishcel0.CellFormat.VerticalAlignment=
  1496. index++;
  1497. }
  1498. row++;
  1499. }
  1500. #endregion
  1501. Paragraph lastParagraph = new Paragraph(doc);
  1502. //第一个表格末尾加段落
  1503. table.ParentNode.InsertAfter(lastParagraph, table);
  1504. //复制第一个表格
  1505. Table cloneTable = (Table)table.Clone(true);
  1506. //在文档末尾段落后面加入复制的表格
  1507. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1508. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1509. {
  1510. int rownewsIndex = 13;
  1511. for (int i = 0; i < 2; i++)
  1512. {
  1513. var CopyRow = table.Rows[12].Clone(true);
  1514. table.Rows.RemoveAt(13);
  1515. table.Rows.Add(CopyRow);
  1516. rownewsIndex++;
  1517. }
  1518. }
  1519. else
  1520. {
  1521. table.Rows.RemoveAt(12);
  1522. }
  1523. cloneTable.Rows.RemoveAt(12);
  1524. }
  1525. if (_AirTicketReservations.Count != 0)
  1526. {
  1527. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1528. if (FlightsCode.Length != 0)
  1529. {
  1530. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1531. if (_AirCompany != null)
  1532. {
  1533. string str = "--";
  1534. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1535. if (!string.IsNullOrEmpty(translateResult))
  1536. {
  1537. str = translateResult;
  1538. str = _airTicketResRep.Processing(str);
  1539. }
  1540. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1541. }
  1542. else
  1543. {
  1544. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1545. }
  1546. }
  1547. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1548. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1549. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1550. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1551. string names = "";
  1552. foreach (string clientName in nameArray)
  1553. {
  1554. names += clientName + ",";
  1555. }
  1556. if (!string.IsNullOrWhiteSpace(names))
  1557. {
  1558. string str = "--";
  1559. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1560. if (!string.IsNullOrEmpty(translateResult))
  1561. {
  1562. str = translateResult;
  1563. str = _airTicketResRep.Processing(str);
  1564. }
  1565. table.Range.Bookmarks["ClientName"].Text = str;
  1566. }
  1567. else
  1568. {
  1569. table.Range.Bookmarks["ClientName"].Text = "--";
  1570. }
  1571. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1572. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1573. table.Range.Bookmarks["JointTicket"].Text = "--";
  1574. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1575. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1576. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1577. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1578. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1579. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1580. }
  1581. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1582. //保存合并后的文档
  1583. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1584. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1585. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1586. return Ok(JsonView(true, "成功!", rst));
  1587. }
  1588. }
  1589. }
  1590. catch (Exception ex)
  1591. {
  1592. return Ok(JsonView(false, "程序错误!"));
  1593. throw;
  1594. }
  1595. }
  1596. #endregion
  1597. #region 团组增减款项
  1598. /// <summary>
  1599. /// 团组增减款项下拉框绑定
  1600. /// </summary>
  1601. /// <param name="dto"></param>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1606. {
  1607. try
  1608. {
  1609. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1610. if (groupData.Code != 0)
  1611. {
  1612. return Ok(JsonView(false, groupData.Msg));
  1613. }
  1614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1615. }
  1616. catch (Exception ex)
  1617. {
  1618. return Ok(JsonView(false, "程序错误!"));
  1619. throw;
  1620. }
  1621. }
  1622. /// <summary>
  1623. /// 根据团组Id查询团组增减款项
  1624. /// </summary>
  1625. /// <param name="dto"></param>
  1626. /// <returns></returns>
  1627. [HttpPost]
  1628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1629. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1630. {
  1631. try
  1632. {
  1633. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1634. if (groupData.Code != 0)
  1635. {
  1636. return Ok(JsonView(false, groupData.Msg));
  1637. }
  1638. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1639. }
  1640. catch (Exception ex)
  1641. {
  1642. return Ok(JsonView(false, "程序错误!"));
  1643. throw;
  1644. }
  1645. }
  1646. /// <summary>
  1647. /// 团组增减款项操作(Status:1.新增,2.修改)
  1648. /// </summary>
  1649. /// <param name="dto"></param>
  1650. /// <returns></returns>
  1651. [HttpPost]
  1652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1653. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1654. {
  1655. try
  1656. {
  1657. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1658. if (groupData.Code != 0)
  1659. {
  1660. return Ok(JsonView(false, groupData.Msg));
  1661. }
  1662. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1663. }
  1664. catch (Exception ex)
  1665. {
  1666. return Ok(JsonView(false, "程序错误!"));
  1667. throw;
  1668. }
  1669. }
  1670. /// <summary>
  1671. /// 团组增减款项操作 删除
  1672. /// </summary>
  1673. /// <param name="dto"></param>
  1674. /// <returns></returns>
  1675. [HttpPost]
  1676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1677. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1678. {
  1679. try
  1680. {
  1681. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1682. if (!res)
  1683. {
  1684. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1685. {
  1686. IsDel = 1,
  1687. DeleteUserId = dto.DeleteUserId,
  1688. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1689. }).ExecuteCommandAsync();
  1690. return Ok(JsonView(false, "删除失败"));
  1691. }
  1692. return Ok(JsonView(true, "删除成功!"));
  1693. }
  1694. catch (Exception ex)
  1695. {
  1696. return Ok(JsonView(false, "程序错误!"));
  1697. throw;
  1698. }
  1699. }
  1700. /// <summary>
  1701. /// 根据团组增减款项Id查询
  1702. /// </summary>
  1703. /// <param name="dto"></param>
  1704. /// <returns></returns>
  1705. [HttpPost]
  1706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1707. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1708. {
  1709. try
  1710. {
  1711. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1712. if (groupData.Code != 0)
  1713. {
  1714. return Ok(JsonView(false, groupData.Msg));
  1715. }
  1716. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1717. }
  1718. catch (Exception ex)
  1719. {
  1720. return Ok(JsonView(false, "程序错误!"));
  1721. throw;
  1722. }
  1723. }
  1724. #endregion
  1725. #region 文件上传、删除
  1726. /// <summary>
  1727. /// region 文件上传 可以带参数
  1728. /// </summary>
  1729. /// <param name="file"></param>
  1730. /// <returns></returns>
  1731. [HttpPost]
  1732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1733. public async Task<IActionResult> UploadProject(IFormFile file)
  1734. {
  1735. try
  1736. {
  1737. var TypeName = Request.Headers["TypeName"].ToString();
  1738. if (file != null)
  1739. {
  1740. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1741. //文件名称
  1742. string projectFileName = file.FileName;
  1743. //上传的文件的路径
  1744. string filePath = "";
  1745. if (TypeName == "A")//A代表团组增减款项
  1746. {
  1747. if (!Directory.Exists(fileDir))
  1748. {
  1749. Directory.CreateDirectory(fileDir);
  1750. }
  1751. //上传的文件的路径
  1752. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  1753. }
  1754. else if (TypeName == "B")//B代表商邀相关文件
  1755. {
  1756. if (!Directory.Exists(fileDir))
  1757. {
  1758. Directory.CreateDirectory(fileDir);
  1759. }
  1760. //上传的文件的路径
  1761. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1762. }
  1763. using (FileStream fs = System.IO.File.Create(filePath))
  1764. {
  1765. file.CopyTo(fs);
  1766. fs.Flush();
  1767. }
  1768. return Ok(JsonView(true, "上传成功!", projectFileName));
  1769. }
  1770. else
  1771. {
  1772. return Ok(JsonView(false, "上传失败!"));
  1773. }
  1774. }
  1775. catch (Exception ex)
  1776. {
  1777. return Ok(JsonView(false, "程序错误!"));
  1778. throw;
  1779. }
  1780. }
  1781. /// <summary>
  1782. /// 删除指定文件
  1783. /// </summary>
  1784. /// <param name="dto"></param>
  1785. /// <returns></returns>
  1786. [HttpPost]
  1787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1788. public async Task<IActionResult> DelFile(DelFileDto dto)
  1789. {
  1790. try
  1791. {
  1792. var TypeName = Request.Headers["TypeName"].ToString();
  1793. string filePath = "";
  1794. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1795. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  1796. int id = 0;
  1797. if (TypeName == "A")
  1798. {
  1799. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  1800. // 删除该文件
  1801. System.IO.File.Delete(filePath);
  1802. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  1803. }
  1804. else if (TypeName == "B")
  1805. {
  1806. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  1807. // 删除该文件
  1808. System.IO.File.Delete(filePath);
  1809. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  1810. }
  1811. if (id != 0)
  1812. {
  1813. return Ok(JsonView(true, "成功!"));
  1814. }
  1815. else
  1816. {
  1817. return Ok(JsonView(false, "失败!"));
  1818. }
  1819. }
  1820. catch (Exception ex)
  1821. {
  1822. return Ok(JsonView(false, "程序错误!"));
  1823. throw;
  1824. }
  1825. }
  1826. #endregion
  1827. #region 商邀费用录入
  1828. /// <summary>
  1829. /// 根据团组Id查询商邀费用列表
  1830. /// </summary>
  1831. /// <param name="dto"></param>
  1832. /// <returns></returns>
  1833. [HttpPost]
  1834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1835. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  1836. {
  1837. try
  1838. {
  1839. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  1840. if (groupData.Code != 0)
  1841. {
  1842. return Ok(JsonView(false, groupData.Msg));
  1843. }
  1844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1845. }
  1846. catch (Exception ex)
  1847. {
  1848. return Ok(JsonView(false, "程序错误!"));
  1849. throw;
  1850. }
  1851. }
  1852. /// <summary>
  1853. /// 根据商邀费用ID查询C表和商邀费用数据
  1854. /// </summary>
  1855. /// <param name="dto"></param>
  1856. /// <returns></returns>
  1857. [HttpPost]
  1858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1859. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  1860. {
  1861. try
  1862. {
  1863. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  1864. if (groupData.Code != 0)
  1865. {
  1866. return Ok(JsonView(false, groupData.Msg));
  1867. }
  1868. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1869. }
  1870. catch (Exception ex)
  1871. {
  1872. return Ok(JsonView(false, "程序错误!"));
  1873. throw;
  1874. }
  1875. }
  1876. /// <summary>
  1877. /// 商邀费用录入操作(Status:1.新增,2.修改)
  1878. /// </summary>
  1879. /// <param name="dto"></param>
  1880. /// <returns></returns>
  1881. [HttpPost]
  1882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1883. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  1884. {
  1885. try
  1886. {
  1887. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  1888. if (groupData.Code != 0)
  1889. {
  1890. return Ok(JsonView(false, groupData.Msg));
  1891. }
  1892. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1893. }
  1894. catch (Exception ex)
  1895. {
  1896. return Ok(JsonView(false, "程序错误!"));
  1897. throw;
  1898. }
  1899. }
  1900. /// <summary>
  1901. /// 商邀删除
  1902. /// </summary>
  1903. /// <param name="dto"></param>
  1904. /// <returns></returns>
  1905. [HttpPost]
  1906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1907. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  1908. {
  1909. try
  1910. {
  1911. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1912. if (!res)
  1913. {
  1914. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  1915. {
  1916. IsDel = 1,
  1917. DeleteUserId = dto.DeleteUserId,
  1918. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1919. }).ExecuteCommandAsync();
  1920. return Ok(JsonView(false, "删除失败"));
  1921. }
  1922. return Ok(JsonView(true, "删除成功!"));
  1923. }
  1924. catch (Exception ex)
  1925. {
  1926. return Ok(JsonView(false, "程序错误!"));
  1927. throw;
  1928. }
  1929. }
  1930. #endregion
  1931. #region 团组英文资料
  1932. /// <summary>
  1933. /// 查询团组英文所有资料
  1934. /// </summary>
  1935. /// <param name="dto"></param>
  1936. /// <returns></returns>
  1937. [HttpPost]
  1938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1939. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  1940. {
  1941. try
  1942. {
  1943. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  1944. if (groupData.Code != 0)
  1945. {
  1946. return Ok(JsonView(false, groupData.Msg));
  1947. }
  1948. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1949. }
  1950. catch (Exception ex)
  1951. {
  1952. return Ok(JsonView(false, "程序错误!"));
  1953. throw;
  1954. }
  1955. }
  1956. /// <summary>
  1957. /// 团组英文资料操作(Status:1.新增,2.修改)
  1958. /// </summary>
  1959. /// <param name="dto"></param>
  1960. /// <returns></returns>
  1961. [HttpPost]
  1962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1963. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  1964. {
  1965. try
  1966. {
  1967. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  1968. if (groupData.Code != 0)
  1969. {
  1970. return Ok(JsonView(false, groupData.Msg));
  1971. }
  1972. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1973. }
  1974. catch (Exception ex)
  1975. {
  1976. return Ok(JsonView(false, "程序错误!"));
  1977. throw;
  1978. }
  1979. }
  1980. /// <summary>
  1981. /// 团组英文资料Id查询数据
  1982. /// </summary>
  1983. /// <param name="dto"></param>
  1984. /// <returns></returns>
  1985. [HttpPost]
  1986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1987. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  1988. {
  1989. try
  1990. {
  1991. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  1992. if (_DelegationEnData != null)
  1993. {
  1994. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  1995. }
  1996. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  1997. }
  1998. catch (Exception ex)
  1999. {
  2000. return Ok(JsonView(false, "程序错误!"));
  2001. throw;
  2002. }
  2003. }
  2004. /// <summary>
  2005. /// 团组英文资料删除
  2006. /// </summary>
  2007. /// <param name="dto"></param>
  2008. /// <returns></returns>
  2009. [HttpPost]
  2010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2011. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2012. {
  2013. try
  2014. {
  2015. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2016. if (!res)
  2017. {
  2018. return Ok(JsonView(false, "删除失败"));
  2019. }
  2020. return Ok(JsonView(true, "删除成功!"));
  2021. }
  2022. catch (Exception ex)
  2023. {
  2024. return Ok(JsonView(false, "程序错误!"));
  2025. throw;
  2026. }
  2027. }
  2028. #endregion
  2029. #region 导出邀请函
  2030. /// <summary>
  2031. /// 导出邀请函页面初始化
  2032. /// </summary>
  2033. /// <param name="dto"></param>
  2034. /// <returns></returns>
  2035. [HttpPost]
  2036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2037. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2038. {
  2039. try
  2040. {
  2041. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2042. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2043. if (dto.DiId == 0)
  2044. {
  2045. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2046. }
  2047. else
  2048. {
  2049. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2050. }
  2051. return Ok(JsonView(true, "查询成功!", new
  2052. {
  2053. deleClient = crm_Deles,
  2054. delegations = grp_Delegations
  2055. }));
  2056. }
  2057. catch (Exception ex)
  2058. {
  2059. return Ok(JsonView(false, "程序错误!"));
  2060. throw;
  2061. }
  2062. }
  2063. /// <summary>
  2064. /// 导出邀请函
  2065. /// </summary>
  2066. /// <param name="dto"></param>
  2067. /// <returns></returns>
  2068. [HttpPost]
  2069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2070. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2071. {
  2072. try
  2073. {
  2074. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2075. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2076. List<string> texts = new List<string>();
  2077. if (crm_DeleClients.Count != 0)
  2078. {
  2079. foreach (Crm_DeleClient item in crm_DeleClients)
  2080. {
  2081. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2082. {
  2083. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2084. }
  2085. else
  2086. {
  2087. string name = item.LastName + item.FirstName;
  2088. texts.Add(name);
  2089. }
  2090. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2091. {
  2092. if (!transDic.ContainsKey(item.Job))
  2093. {
  2094. texts.Add(item.Job);
  2095. }
  2096. }
  2097. if (item.CrmCompanyId != 0)
  2098. {
  2099. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2100. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2101. {
  2102. texts.Add(crm_Customer.CompanyName);
  2103. }
  2104. }
  2105. }
  2106. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2107. if (transData.Count > 0)
  2108. {
  2109. foreach (TranslateResult item in transData)
  2110. {
  2111. if (!transDic.ContainsKey(item.Query))
  2112. {
  2113. transDic.Add(item.Query, item.Translation);
  2114. }
  2115. }
  2116. }
  2117. List<guestList> list = new List<guestList>();
  2118. foreach (Crm_DeleClient dele in crm_DeleClients)
  2119. {
  2120. guestList guestList = new guestList();
  2121. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2122. {
  2123. guestList.Name = dele.Pinyin;
  2124. }
  2125. else
  2126. {
  2127. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2128. guestList.Name = Name;
  2129. }
  2130. if (dele.Sex == 0)
  2131. {
  2132. guestList.Sex = "Male";
  2133. }
  2134. else if (dele.Sex == 1)
  2135. {
  2136. guestList.Sex = "Female";
  2137. }
  2138. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2139. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2140. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2141. guestList.Job = jobName;
  2142. list.Add(guestList);
  2143. }
  2144. //载入模板
  2145. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2146. DocumentBuilder builder = new DocumentBuilder(doc);
  2147. //获取word里所有表格
  2148. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2149. //获取所填表格的序数
  2150. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2151. var rowStart = tableOne.Rows[0]; //获取第1行
  2152. //循环赋值
  2153. for (int i = 0; i < list.Count; i++)
  2154. {
  2155. builder.MoveToCell(0, i + 1, 0, 0);
  2156. builder.Write(list[i].Name.ToString());
  2157. builder.MoveToCell(0, i + 1, 1, 0);
  2158. builder.Write(list[i].Sex.ToString());
  2159. builder.MoveToCell(0, i + 1, 2, 0);
  2160. builder.Write(list[i].DOB.ToString());
  2161. builder.MoveToCell(0, i + 1, 3, 0);
  2162. builder.Write(list[i].Job.ToString());
  2163. }
  2164. //删除多余行
  2165. while (tableOne.Rows.Count > list.Count + 1)
  2166. {
  2167. tableOne.Rows.RemoveAt(list.Count + 1);
  2168. }
  2169. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2170. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2171. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2172. doc.Save(filePath);
  2173. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2174. return Ok(JsonView(true, "成功!", Url));
  2175. }
  2176. else
  2177. {
  2178. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2179. }
  2180. }
  2181. catch (Exception ex)
  2182. {
  2183. return Ok(JsonView(false, "程序错误!"));
  2184. throw;
  2185. }
  2186. }
  2187. #endregion
  2188. #region 团组经理模块 出入境费用
  2189. ///// <summary>
  2190. ///// 团组模块 - 出入境费用
  2191. ///// </summary>
  2192. ///// <returns></returns>
  2193. //[HttpPost]
  2194. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2195. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2196. //{
  2197. // try
  2198. // {
  2199. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2200. // if (data.Code != 0)
  2201. // {
  2202. // return Ok(JsonView(false, data.Msg));
  2203. // }
  2204. // return Ok(JsonView(true, "查询成功!"));
  2205. // }
  2206. // catch (Exception ex)
  2207. // {
  2208. // return Ok(JsonView(false, ex.Message));
  2209. // throw;
  2210. // }
  2211. //}
  2212. /// <summary>
  2213. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2214. /// </summary>
  2215. /// <returns></returns>
  2216. [HttpPost]
  2217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2218. public async Task<IActionResult> SetDayAndCostAreaChange()
  2219. {
  2220. try
  2221. {
  2222. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2223. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2224. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2225. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2226. foreach (var item in unite) //处理交集数据
  2227. {
  2228. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2229. }
  2230. foreach (var item in merge) //处理差集数据
  2231. {
  2232. int nationalTravelFeeId = 0;
  2233. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2234. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2235. else
  2236. {
  2237. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2238. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2239. }
  2240. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2241. }
  2242. //只更新dayAndCost 的 nationalTravelFeeId;
  2243. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2244. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2245. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2246. }
  2247. catch (Exception ex)
  2248. {
  2249. return Ok(JsonView(false, ex.Message));
  2250. throw;
  2251. }
  2252. }
  2253. /// <summary>
  2254. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2255. /// </summary>
  2256. /// <returns></returns>
  2257. [HttpPost]
  2258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2259. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2260. {
  2261. try
  2262. {
  2263. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2264. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2265. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2266. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2267. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2268. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2269. // Where gntf.Isdel = 0");
  2270. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2271. return Ok(JsonView(true, "查询成功!", new
  2272. {
  2273. GroupNameData = groupNameData.Data,
  2274. CurrencyData = currencyData,
  2275. //NationalTravelFeeData = nationalTravelFeeData
  2276. }));
  2277. }
  2278. catch (Exception ex)
  2279. {
  2280. return Ok(JsonView(false, ex.Message));
  2281. throw;
  2282. }
  2283. }
  2284. /// <summary>
  2285. /// 团组模块 - 出入境费用 - Info
  2286. /// </summary>
  2287. /// <returns></returns>
  2288. [HttpPost]
  2289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2290. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2291. {
  2292. try
  2293. {
  2294. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2295. if (data.Code != 0)
  2296. {
  2297. return Ok(JsonView(false, data.Msg));
  2298. }
  2299. return Ok(JsonView(true, "查询成功!", data.Data));
  2300. }
  2301. catch (Exception ex)
  2302. {
  2303. return Ok(JsonView(false, ex.Message));
  2304. }
  2305. }
  2306. /// <summary>
  2307. /// 团组模块 - 出入境费用 - Add And Update
  2308. /// </summary>
  2309. /// <returns></returns>
  2310. [HttpPost]
  2311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2312. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2313. {
  2314. try
  2315. {
  2316. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2317. if (data.Code != 0)
  2318. {
  2319. return Ok(JsonView(false, data.Msg));
  2320. }
  2321. return Ok(JsonView(true, data.Msg, data.Data));
  2322. }
  2323. catch (Exception ex)
  2324. {
  2325. return Ok(JsonView(false, ex.Message));
  2326. }
  2327. }
  2328. /// <summary>
  2329. /// 团组模块 - 出入境费用 - 子项删除
  2330. /// </summary>
  2331. /// <returns></returns>
  2332. [HttpPost]
  2333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2334. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2335. {
  2336. try
  2337. {
  2338. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2339. if (data.Code != 0)
  2340. {
  2341. return Ok(JsonView(false, data.Msg));
  2342. }
  2343. return Ok(JsonView(true, "操作成功!", data.Data));
  2344. }
  2345. catch (Exception ex)
  2346. {
  2347. return Ok(JsonView(false, ex.Message));
  2348. }
  2349. }
  2350. /// <summary>
  2351. /// 团组模块 - 出入境国家费用标准 List
  2352. /// </summary>
  2353. /// <returns></returns>
  2354. [HttpPost]
  2355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2356. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2357. {
  2358. try
  2359. {
  2360. Stopwatch sw = new Stopwatch();
  2361. sw.Start();
  2362. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2363. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2364. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2365. Where gntf.Isdel = 0");
  2366. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2367. var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2368. List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2369. foreach (var item in nationalTravel)
  2370. {
  2371. var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2372. var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2373. if (otherData != null)
  2374. {
  2375. cityData.Remove(otherData);
  2376. cityData.Add(otherData);
  2377. }
  2378. nationalTravelFeeData1.Add(new
  2379. {
  2380. Country = item.Country,
  2381. CityData = cityData
  2382. });
  2383. }
  2384. sw.Stop();
  2385. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData1));
  2386. }
  2387. catch (Exception ex)
  2388. {
  2389. return Ok(JsonView(false, ex.Message));
  2390. throw;
  2391. }
  2392. }
  2393. /// <summary>
  2394. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2395. /// </summary>
  2396. /// <returns></returns>
  2397. [HttpPost]
  2398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2399. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2400. {
  2401. try
  2402. {
  2403. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2404. if (data.Code != 0)
  2405. {
  2406. return Ok(JsonView(false, data.Msg));
  2407. }
  2408. return Ok(JsonView(true, "操作成功!", data.Data));
  2409. }
  2410. catch (Exception ex)
  2411. {
  2412. return Ok(JsonView(false, ex.Message));
  2413. }
  2414. }
  2415. #endregion
  2416. }
  2417. }