GroupsController.cs 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647
  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. }
  528. return filename;//返回相对路径
  529. }
  530. #endregion
  531. #region 团组任务分配
  532. /// <summary>
  533. /// 团组任务分配初始化
  534. /// </summary>
  535. /// <param name="dto"></param>
  536. /// <returns></returns>
  537. [HttpPost]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<IActionResult> GetTaskAssignmen()
  540. {
  541. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  542. if (groupData.Code != 0)
  543. {
  544. return Ok(JsonView(false, groupData.Msg));
  545. }
  546. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  547. }
  548. /// <summary>
  549. /// 团组任务分配查询
  550. /// </summary>
  551. /// <param name="dto"></param>
  552. /// <returns></returns>
  553. [HttpPost]
  554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  555. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  556. {
  557. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  558. if (groupData.Code != 0)
  559. {
  560. return Ok(JsonView(false, groupData.Msg));
  561. }
  562. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  563. }
  564. /// <summary>
  565. /// 团组任务分配操作
  566. /// </summary>
  567. /// <param name="dto"></param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  572. {
  573. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  574. if (groupData.Code != 0)
  575. {
  576. return Ok(JsonView(false, groupData.Msg));
  577. }
  578. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  579. }
  580. #endregion
  581. #region 团组费用审核
  582. /// <summary>
  583. /// 获取团组费用审核
  584. /// </summary>
  585. /// <param name="paras">参数Json字符串</param>
  586. /// <returns></returns>
  587. [HttpPost]
  588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  589. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  590. {
  591. if (_dto.DiId < 1)
  592. {
  593. return Ok(JsonView(false, "团组Id为空"));
  594. }
  595. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  596. #region 团组基本信息
  597. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  598. if (_delegation != null)
  599. {
  600. _view.ClientName = _delegation.ClientName;
  601. _view.DiId = _dto.DiId;
  602. _view.TeamName = _delegation.TeamName;
  603. _view.VisitCountry = _delegation.VisitCountry;
  604. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  605. _view.VisitDays = _delegation.VisitDays;
  606. _view.VisitPNumber = _delegation.VisitPNumber;
  607. }
  608. else
  609. {
  610. return Ok(JsonView(false, "团组信息为空"));
  611. }
  612. #endregion
  613. #region 费用清单
  614. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  615. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  616. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  617. List<Grp_CreditCardPayment> entityList = _groupRepository
  618. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  619. .Where(exp.ToExpression())
  620. .ToList();
  621. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  622. decimal CNY = 0;
  623. decimal PayCNY = 0;
  624. decimal BalanceCNY = 0;
  625. decimal YSFYCNY = 0;
  626. decimal USD = 0;
  627. decimal PayUSD = 0;
  628. decimal BalanceUSD = 0;
  629. decimal YSFYUSD = 0;
  630. decimal EUR = 0;
  631. decimal PayEUR = 0;
  632. decimal BalanceEUR = 0;
  633. decimal YSFYEUR = 0;
  634. foreach (var entity in entityList)
  635. {
  636. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  637. _detail.Id = entity.Id;
  638. /*
  639. * Bus名称
  640. */
  641. _detail.BusName = "";
  642. /*
  643. *费用所属
  644. */
  645. switch (entity.CTable)
  646. {
  647. case 85:
  648. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  649. if (jpRes != null)
  650. {
  651. string FlightsDescription = jpRes.FlightsDescription;
  652. string PriceDescription = jpRes.PriceDescription;
  653. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  654. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  655. }
  656. break;
  657. case 79:
  658. _detail.BusName = "待增加";
  659. break;
  660. case 98:
  661. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  662. if (gdpRes != null)
  663. {
  664. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  665. _detail.PriceNameContent = gdpRes.PriceName;
  666. }
  667. break;
  668. default:
  669. break;
  670. }
  671. /*
  672. * 费用模块
  673. */
  674. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  675. if (sdPriceName != null)
  676. {
  677. _detail.PriceName = sdPriceName.Name;
  678. }
  679. /*
  680. * 应付款金额
  681. */
  682. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  683. string PaymentCurrency_WaitPay = "Unknown";
  684. if (sdPaymentCurrency_WaitPay != null)
  685. {
  686. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  687. }
  688. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  689. /*
  690. * 此次付款金额
  691. */
  692. decimal CurrPayStr = 0;
  693. if (entity.PayPercentage == 0)
  694. {
  695. if (entity.PayThenMoney != 0)
  696. CurrPayStr = entity.PayThenMoney * entity.DayRate;
  697. }
  698. else
  699. {
  700. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate);
  701. }
  702. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  703. /*
  704. * 剩余尾款
  705. */
  706. decimal BalanceStr = 0;
  707. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  708. BalanceStr = 0;
  709. else
  710. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate);
  711. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  712. /*
  713. * 申请人
  714. */
  715. string operatorName = "无";
  716. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
  717. if (_opUser != null)
  718. {
  719. operatorName = _opUser.CnName;
  720. }
  721. _detail.OperatorName = operatorName;
  722. /*
  723. * 审核人
  724. */
  725. string auditOperatorName = "Unknown";
  726. if (entity.AuditGMOperate == 0)
  727. auditOperatorName = "无";
  728. else if (entity.AuditGMOperate == 4)
  729. auditOperatorName = "自动审核";
  730. else
  731. {
  732. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
  733. if (_adUser != null)
  734. {
  735. auditOperatorName = _adUser.CnName;
  736. }
  737. }
  738. _detail.AuditOperatorName = auditOperatorName;
  739. /*
  740. *
  741. * *超预算比例
  742. */
  743. string overBudgetStr = "";
  744. if (entity.ExceedBudget == -1)
  745. overBudgetStr = sdPriceName.Name + "尚无预算";
  746. else if (entity.ExceedBudget == 0)
  747. overBudgetStr = "未超预算";
  748. else
  749. overBudgetStr = entity.ExceedBudget.ToString("P");
  750. _detail.OverBudget = overBudgetStr;
  751. /*
  752. * 费用总计
  753. */
  754. if (entity.PaymentCurrency == 48)
  755. {
  756. CNY += entity.PayMoney;
  757. PayCNY += CurrPayStr;
  758. BalanceCNY += BalanceStr;
  759. YSFYCNY += CurrPayStr;
  760. }
  761. if (entity.PaymentCurrency == 49)
  762. {
  763. USD += entity.PayMoney;
  764. PayUSD += CurrPayStr;
  765. BalanceUSD += BalanceStr;
  766. YSFYUSD += CurrPayStr;
  767. }
  768. if (entity.PaymentCurrency == 51)
  769. {
  770. EUR += entity.PayMoney;
  771. PayEUR += CurrPayStr;
  772. BalanceEUR += BalanceStr;
  773. YSFYEUR += CurrPayStr;
  774. }
  775. _detail.IsAuditGM = entity.IsAuditGM;
  776. detailList.Add(_detail);
  777. }
  778. #endregion
  779. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  780. _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  781. _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  782. _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  783. _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  784. return Ok(JsonView(_view));
  785. }
  786. /// <summary>
  787. /// 修改团组费用审核状态
  788. /// </summary>
  789. /// <param name="paras">参数Json字符串</param>
  790. /// <returns></returns>
  791. [HttpPost]
  792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  793. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  794. {
  795. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  796. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  797. DateTime dtNow = DateTime.Now;
  798. _groupRepository.BeginTran();
  799. int rst = 0;
  800. foreach (var item in idList)
  801. {
  802. int CreditId = int.Parse(item);
  803. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  804. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  805. .SetColumns(it => it.AuditGMOperate == _dto.User)
  806. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  807. .Where(s => s.Id == CreditId)
  808. .ExecuteCommandAsync();
  809. if (result < 1)
  810. {
  811. rst = -1;
  812. }
  813. else
  814. {
  815. _groupRepository.RollbackTran();
  816. return Ok(JsonView(false, "保存失败并回滚!"));
  817. }
  818. }
  819. _groupRepository.CommitTran();
  820. if (rst == 0)
  821. {
  822. return Ok(JsonView(true, "保存成功!"));
  823. }
  824. return Ok(JsonView(false, "保存失败!"));
  825. }
  826. #endregion
  827. #region 机票费用录入
  828. /// <summary>
  829. /// 机票录入当前登录人可操作团组
  830. /// </summary>
  831. /// <param name="dto"></param>
  832. /// <returns></returns>
  833. [HttpPost]
  834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  835. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  836. {
  837. try
  838. {
  839. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  840. if (groupData.Code != 0)
  841. {
  842. return Ok(JsonView(false, groupData.Msg));
  843. }
  844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  845. }
  846. catch (Exception ex)
  847. {
  848. return Ok(JsonView(false, "程序错误!"));
  849. throw;
  850. }
  851. }
  852. /// <summary>
  853. /// 机票费用录入列表
  854. /// </summary>
  855. /// <param name="dto"></param>
  856. /// <returns></returns>
  857. [HttpPost]
  858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  859. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  860. {
  861. try
  862. {
  863. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  864. if (groupData.Code != 0)
  865. {
  866. return Ok(JsonView(false, groupData.Msg));
  867. }
  868. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  869. }
  870. catch (Exception ex)
  871. {
  872. return Ok(JsonView(false, "程序错误!"));
  873. throw;
  874. }
  875. }
  876. /// <summary>
  877. /// 根据id查询费用录入信息
  878. /// </summary>
  879. /// <param name="dto"></param>
  880. /// <returns></returns>
  881. [HttpPost]
  882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  883. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  884. {
  885. try
  886. {
  887. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  888. if (groupData.Code != 0)
  889. {
  890. return Ok(JsonView(false, groupData.Msg));
  891. }
  892. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  893. }
  894. catch (Exception ex)
  895. {
  896. return Ok(JsonView(false, "程序错误!"));
  897. throw;
  898. }
  899. }
  900. /// <summary>
  901. /// 机票费用录入操作(Status:1.新增,2.修改)
  902. /// </summary>
  903. /// <param name="dto"></param>
  904. /// <returns></returns>
  905. [HttpPost]
  906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  907. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  908. {
  909. try
  910. {
  911. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  912. if (groupData.Code != 0)
  913. {
  914. return Ok(JsonView(false, groupData.Msg));
  915. }
  916. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  917. }
  918. catch (Exception ex)
  919. {
  920. return Ok(JsonView(false, "程序错误!"));
  921. throw;
  922. }
  923. }
  924. /// <summary>
  925. /// 根据舱位类型查询接团客户名单信息
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  932. {
  933. try
  934. {
  935. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  936. if (crm_Groups.Count != 0)
  937. {
  938. List<dynamic> Customer = new List<dynamic>();
  939. foreach (var item in crm_Groups)
  940. {
  941. var data = new
  942. {
  943. Id = item.Id,
  944. Pinyin = item.Pinyin,
  945. Name = item.LastName + item.FirstName
  946. };
  947. Customer.Add(data);
  948. }
  949. return Ok(JsonView(true, "查询成功!", Customer));
  950. }
  951. return Ok(JsonView(true, "暂无数据", crm_Groups));
  952. }
  953. catch (Exception ex)
  954. {
  955. return Ok(JsonView(false, "程序错误!"));
  956. throw;
  957. }
  958. }
  959. /// <summary>
  960. /// 机票费用录入,删除
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  967. {
  968. try
  969. {
  970. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  971. if (!res)
  972. {
  973. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  974. {
  975. IsDel = 1,
  976. DeleteUserId = dto.DeleteUserId,
  977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  978. }).ExecuteCommandAsync();
  979. return Ok(JsonView(false, "删除失败"));
  980. }
  981. return Ok(JsonView(true, "删除成功!"));
  982. }
  983. catch (Exception ex)
  984. {
  985. return Ok(JsonView(false, "程序错误!"));
  986. throw;
  987. }
  988. }
  989. /// <summary>
  990. /// 导出机票录入报表
  991. /// </summary>
  992. /// <param name="dto"></param>
  993. /// <returns></returns>
  994. [HttpPost]
  995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  996. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  997. {
  998. try
  999. {
  1000. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1001. if (groupData.Code != 0)
  1002. {
  1003. return Ok(JsonView(false, groupData.Msg));
  1004. }
  1005. else
  1006. {
  1007. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1008. if (AirTicketReservations.Count != 0)
  1009. {
  1010. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1011. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1012. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1013. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1014. WorkbookDesigner designer = new WorkbookDesigner();
  1015. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1016. decimal countCost = 0;
  1017. foreach (var item in AirTicketReservations)
  1018. {
  1019. if (item.BankType == "其他")
  1020. {
  1021. item.BankNo = "--";
  1022. }
  1023. else
  1024. {
  1025. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1026. }
  1027. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1028. item.Price = System.Decimal.Round(item.Price, 2);
  1029. countCost += Convert.ToDecimal(item.Price);
  1030. }
  1031. designer.SetDataSource("Export", AirTicketReservations);
  1032. designer.SetDataSource("ExportDiCode", diCode);
  1033. designer.SetDataSource("ExportDiName", diName);
  1034. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1035. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1036. designer.Process();
  1037. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1038. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1039. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1040. return Ok(JsonView(true, "成功", url = rst));
  1041. }
  1042. else
  1043. {
  1044. return Ok(JsonView(false, "暂无数据!"));
  1045. }
  1046. }
  1047. }
  1048. catch (Exception ex)
  1049. {
  1050. return Ok(JsonView(false, "程序错误!"));
  1051. throw;
  1052. }
  1053. }
  1054. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1055. /// <summary>
  1056. /// 行程单导出
  1057. /// </summary>
  1058. /// <param name="dto"></param>
  1059. /// <returns></returns>
  1060. [HttpPost]
  1061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1062. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1063. {
  1064. try
  1065. {
  1066. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1067. if (groupData.Code != 0)
  1068. {
  1069. return Ok(JsonView(false, groupData.Msg));
  1070. }
  1071. else
  1072. {
  1073. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1074. if (dto.Language == "CN")
  1075. {
  1076. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1077. DocumentBuilder builder = new DocumentBuilder(doc);
  1078. int tableIndex = 0;//表格索引
  1079. //得到文档中的第一个表格
  1080. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1081. foreach (var item in _AirTicketReservations)
  1082. {
  1083. #region 处理固定数据
  1084. string[] FlightsCode = item.FlightsCode.Split('/');
  1085. if (FlightsCode.Length != 0)
  1086. {
  1087. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1088. if (_AirCompany != null)
  1089. {
  1090. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1091. }
  1092. else
  1093. {
  1094. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1095. }
  1096. }
  1097. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1098. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1099. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1100. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1101. string name = "";
  1102. foreach (string clientName in nameArray)
  1103. {
  1104. if (!name.Contains(clientName))
  1105. {
  1106. name += clientName + ",";
  1107. }
  1108. }
  1109. if (!string.IsNullOrWhiteSpace(name))
  1110. {
  1111. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1112. }
  1113. else
  1114. {
  1115. table.Range.Bookmarks["ClientName"].Text = "--";
  1116. }
  1117. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1118. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1119. table.Range.Bookmarks["JointTicket"].Text = "--";
  1120. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1121. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1122. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1123. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1124. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1125. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1126. #endregion
  1127. #region 循环数据处理
  1128. List<AirInfo> airs = new List<AirInfo>();
  1129. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1130. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1131. for (int i = 0; i < FlightsCode.Length; i++)
  1132. {
  1133. AirInfo air = new AirInfo();
  1134. string[] tempstr = DayArray[i]
  1135. .Replace("\r\n", string.Empty)
  1136. .Replace("\\r\\n", string.Empty)
  1137. .TrimStart().TrimEnd()
  1138. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1139. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1140. string starCity = "";
  1141. if (star_Three != null)
  1142. {
  1143. starCity = star_Three.AirPort;
  1144. }
  1145. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1146. string EndCity = "";
  1147. if (End_Three != null)
  1148. {
  1149. EndCity = End_Three.AirPort;
  1150. }
  1151. air.Destination = starCity + "/" + EndCity;
  1152. air.Flight = FlightsCode[i];
  1153. air.SeatingClass = item.CTypeName;
  1154. string dateTime = tempstr[2];
  1155. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1156. air.FlightDate = DateTemp;
  1157. air.DepartureTime = tempstr[5];
  1158. air.LandingTime = tempstr[6];
  1159. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1160. air.TicketStatus = "--";
  1161. air.Luggage = "--";
  1162. air.DepartureTerminal = "--";
  1163. air.LandingTerminal = "--";
  1164. airs.Add(air);
  1165. }
  1166. int row = 13;
  1167. for (int i = 0; i < airs.Count; i++)
  1168. {
  1169. if (airs.Count > 2)
  1170. {
  1171. for (int j = 0; j < airs.Count - 2; j++)
  1172. {
  1173. var CopyRow = table.Rows[12].Clone(true);
  1174. table.Rows.Add(CopyRow);
  1175. }
  1176. }
  1177. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1178. int index = 0;
  1179. foreach (PropertyInfo property in properties)
  1180. {
  1181. string value = property.GetValue(airs[i]).ToString();
  1182. Cell ishcel0 = table.Rows[row].Cells[index];
  1183. Paragraph p = new Paragraph(doc);
  1184. string s = value;
  1185. p.AppendChild(new Run(doc, s));
  1186. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1187. ishcel0.AppendChild(p);
  1188. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1189. index++;
  1190. }
  1191. row++;
  1192. }
  1193. #endregion
  1194. Paragraph lastParagraph = new Paragraph(doc);
  1195. //第一个表格末尾加段落
  1196. table.ParentNode.InsertAfter(lastParagraph, table);
  1197. //复制第一个表格
  1198. Table cloneTable = (Table)table.Clone(true);
  1199. //在文档末尾段落后面加入复制的表格
  1200. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1201. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1202. {
  1203. int rownewsIndex = 13;
  1204. for (int i = 0; i < 2; i++)
  1205. {
  1206. var CopyRow = table.Rows[12].Clone(true);
  1207. table.Rows.RemoveAt(13);
  1208. table.Rows.Add(CopyRow);
  1209. rownewsIndex++;
  1210. }
  1211. }
  1212. else
  1213. {
  1214. table.Rows.RemoveAt(12);
  1215. }
  1216. cloneTable.Rows.RemoveAt(12);
  1217. }
  1218. if (_AirTicketReservations.Count != 0)
  1219. {
  1220. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1221. if (FlightsCode.Length != 0)
  1222. {
  1223. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1224. if (_AirCompany != null)
  1225. {
  1226. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1227. }
  1228. else
  1229. {
  1230. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1231. }
  1232. }
  1233. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1234. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1235. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1236. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1237. string name = "";
  1238. foreach (string clientName in nameArray)
  1239. {
  1240. if (!name.Contains(clientName))
  1241. {
  1242. name += clientName + ",";
  1243. }
  1244. }
  1245. if (!string.IsNullOrWhiteSpace(name))
  1246. {
  1247. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1248. }
  1249. else
  1250. {
  1251. table.Range.Bookmarks["ClientName"].Text = "--";
  1252. }
  1253. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1254. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1255. table.Range.Bookmarks["JointTicket"].Text = "--";
  1256. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1257. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1258. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1259. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1260. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1261. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1262. }
  1263. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1264. //保存合并后的文档
  1265. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1266. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1267. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1268. return Ok(JsonView(true, "成功!", rst));
  1269. }
  1270. else
  1271. {
  1272. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1273. DocumentBuilder builder = new DocumentBuilder(doc);
  1274. int tableIndex = 0;//表格索引
  1275. //得到文档中的第一个表格
  1276. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1277. List<string> texts = new List<string>();
  1278. foreach (var item in _AirTicketReservations)
  1279. {
  1280. string[] FlightsCode = item.FlightsCode.Split('/');
  1281. if (FlightsCode.Length != 0)
  1282. {
  1283. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1284. if (_AirCompany != null)
  1285. {
  1286. if (!transDic.ContainsKey(_AirCompany.CnName))
  1287. {
  1288. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1289. }
  1290. }
  1291. else
  1292. {
  1293. if (!transDic.ContainsKey("--"))
  1294. {
  1295. transDic.Add("--", "--");
  1296. }
  1297. }
  1298. }
  1299. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1300. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1301. string name = "";
  1302. foreach (string clientName in nameArray)
  1303. {
  1304. name += clientName + ",";
  1305. }
  1306. if (!texts.Contains(name))
  1307. {
  1308. texts.Add(name);
  1309. }
  1310. List<AirInfo> airs = new List<AirInfo>();
  1311. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1312. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1313. for (int i = 0; i < FlightsCode.Length; i++)
  1314. {
  1315. AirInfo air = new AirInfo();
  1316. string[] tempstr = DayArray[i]
  1317. .Replace("\r\n", string.Empty)
  1318. .Replace("\\r\\n", string.Empty)
  1319. .TrimStart().TrimEnd()
  1320. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1321. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1322. if (star_Three != null)
  1323. {
  1324. if (!transDic.ContainsKey(star_Three.AirPort))
  1325. {
  1326. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1327. }
  1328. }
  1329. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1330. if (End_Three != null)
  1331. {
  1332. if (!transDic.ContainsKey(End_Three.AirPort))
  1333. {
  1334. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1335. }
  1336. }
  1337. if (!texts.Contains(item.CTypeName))
  1338. {
  1339. texts.Add(item.CTypeName);
  1340. }
  1341. }
  1342. }
  1343. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1344. if (transData.Count > 0)
  1345. {
  1346. foreach (TranslateResult item in transData)
  1347. {
  1348. if (!transDic.ContainsKey(item.Query))
  1349. {
  1350. transDic.Add(item.Query, item.Translation);
  1351. }
  1352. }
  1353. }
  1354. foreach (var item in _AirTicketReservations)
  1355. {
  1356. #region 处理固定数据
  1357. string[] FlightsCode = item.FlightsCode.Split('/');
  1358. if (FlightsCode.Length != 0)
  1359. {
  1360. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1361. if (_AirCompany != null)
  1362. {
  1363. string str = "--";
  1364. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1365. if (!string.IsNullOrEmpty(translateResult))
  1366. {
  1367. str = translateResult;
  1368. str = _airTicketResRep.Processing(str);
  1369. }
  1370. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1371. }
  1372. else
  1373. {
  1374. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1375. }
  1376. }
  1377. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1378. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1379. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1380. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1381. string names = "";
  1382. foreach (string clientName in nameArray)
  1383. {
  1384. names += clientName + ",";
  1385. }
  1386. if (!string.IsNullOrWhiteSpace(names))
  1387. {
  1388. string str = "--";
  1389. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1390. if (!string.IsNullOrEmpty(translateResult))
  1391. {
  1392. str = translateResult;
  1393. str = _airTicketResRep.Processing(str);
  1394. }
  1395. table.Range.Bookmarks["ClientName"].Text = str;
  1396. }
  1397. else
  1398. {
  1399. table.Range.Bookmarks["ClientName"].Text = "--";
  1400. }
  1401. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1402. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1403. table.Range.Bookmarks["JointTicket"].Text = "--";
  1404. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1405. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1406. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1407. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1408. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1409. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1410. #endregion
  1411. #region 循环数据处理
  1412. List<AirInfo> airs = new List<AirInfo>();
  1413. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1414. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1415. for (int i = 0; i < FlightsCode.Length; i++)
  1416. {
  1417. AirInfo air = new AirInfo();
  1418. string[] tempstr = DayArray[i]
  1419. .Replace("\r\n", string.Empty)
  1420. .Replace("\\r\\n", string.Empty)
  1421. .TrimStart().TrimEnd()
  1422. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1423. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1424. string starCity = "";
  1425. if (star_Three != null)
  1426. {
  1427. string str2 = "--";
  1428. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1429. if (!string.IsNullOrEmpty(translateResult2))
  1430. {
  1431. str2 = translateResult2;
  1432. str2 = _airTicketResRep.Processing(str2);
  1433. }
  1434. starCity = str2;
  1435. }
  1436. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1437. string EndCity = "";
  1438. if (End_Three != null)
  1439. {
  1440. string str1 = "--";
  1441. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1442. if (!string.IsNullOrEmpty(translateResult1))
  1443. {
  1444. str1 = translateResult1;
  1445. str1 = _airTicketResRep.Processing(str1);
  1446. }
  1447. EndCity = str1;
  1448. }
  1449. air.Destination = starCity + "/" + EndCity;
  1450. air.Flight = FlightsCode[i];
  1451. string str = "--";
  1452. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1453. if (!string.IsNullOrEmpty(translateResult))
  1454. {
  1455. str = translateResult;
  1456. str = _airTicketResRep.Processing(str);
  1457. }
  1458. air.SeatingClass = str;
  1459. string dateTime = tempstr[2];
  1460. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1461. air.FlightDate = DateTemp;
  1462. air.DepartureTime = tempstr[5];
  1463. air.LandingTime = tempstr[6];
  1464. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1465. air.TicketStatus = "--";
  1466. air.Luggage = "--";
  1467. air.DepartureTerminal = "--";
  1468. air.LandingTerminal = "--";
  1469. airs.Add(air);
  1470. }
  1471. int row = 13;
  1472. for (int i = 0; i < airs.Count; i++)
  1473. {
  1474. if (airs.Count > 2)
  1475. {
  1476. for (int j = 0; j < airs.Count - 2; j++)
  1477. {
  1478. var CopyRow = table.Rows[12].Clone(true);
  1479. table.Rows.Add(CopyRow);
  1480. }
  1481. }
  1482. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1483. int index = 0;
  1484. foreach (PropertyInfo property in properties)
  1485. {
  1486. string value = property.GetValue(airs[i]).ToString();
  1487. Cell ishcel0 = table.Rows[row].Cells[index];
  1488. Paragraph p = new Paragraph(doc);
  1489. string s = value;
  1490. p.AppendChild(new Run(doc, s));
  1491. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1492. ishcel0.AppendChild(p);
  1493. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1494. //ishcel0.CellFormat.VerticalAlignment=
  1495. index++;
  1496. }
  1497. row++;
  1498. }
  1499. #endregion
  1500. Paragraph lastParagraph = new Paragraph(doc);
  1501. //第一个表格末尾加段落
  1502. table.ParentNode.InsertAfter(lastParagraph, table);
  1503. //复制第一个表格
  1504. Table cloneTable = (Table)table.Clone(true);
  1505. //在文档末尾段落后面加入复制的表格
  1506. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1507. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1508. {
  1509. int rownewsIndex = 13;
  1510. for (int i = 0; i < 2; i++)
  1511. {
  1512. var CopyRow = table.Rows[12].Clone(true);
  1513. table.Rows.RemoveAt(13);
  1514. table.Rows.Add(CopyRow);
  1515. rownewsIndex++;
  1516. }
  1517. }
  1518. else
  1519. {
  1520. table.Rows.RemoveAt(12);
  1521. }
  1522. cloneTable.Rows.RemoveAt(12);
  1523. }
  1524. if (_AirTicketReservations.Count != 0)
  1525. {
  1526. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1527. if (FlightsCode.Length != 0)
  1528. {
  1529. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1530. if (_AirCompany != null)
  1531. {
  1532. string str = "--";
  1533. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1534. if (!string.IsNullOrEmpty(translateResult))
  1535. {
  1536. str = translateResult;
  1537. str = _airTicketResRep.Processing(str);
  1538. }
  1539. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1540. }
  1541. else
  1542. {
  1543. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1544. }
  1545. }
  1546. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1547. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1548. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1549. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1550. string names = "";
  1551. foreach (string clientName in nameArray)
  1552. {
  1553. names += clientName + ",";
  1554. }
  1555. if (!string.IsNullOrWhiteSpace(names))
  1556. {
  1557. string str = "--";
  1558. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1559. if (!string.IsNullOrEmpty(translateResult))
  1560. {
  1561. str = translateResult;
  1562. str = _airTicketResRep.Processing(str);
  1563. }
  1564. table.Range.Bookmarks["ClientName"].Text = str;
  1565. }
  1566. else
  1567. {
  1568. table.Range.Bookmarks["ClientName"].Text = "--";
  1569. }
  1570. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1571. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1572. table.Range.Bookmarks["JointTicket"].Text = "--";
  1573. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1574. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1575. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1576. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1577. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1578. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1579. }
  1580. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1581. //保存合并后的文档
  1582. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1583. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1584. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1585. return Ok(JsonView(true, "成功!", rst));
  1586. }
  1587. }
  1588. }
  1589. catch (Exception ex)
  1590. {
  1591. return Ok(JsonView(false, "程序错误!"));
  1592. throw;
  1593. }
  1594. }
  1595. #endregion
  1596. #region 团组增减款项
  1597. /// <summary>
  1598. /// 团组增减款项下拉框绑定
  1599. /// </summary>
  1600. /// <param name="dto"></param>
  1601. /// <returns></returns>
  1602. [HttpPost]
  1603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1604. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1605. {
  1606. try
  1607. {
  1608. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1609. if (groupData.Code != 0)
  1610. {
  1611. return Ok(JsonView(false, groupData.Msg));
  1612. }
  1613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1614. }
  1615. catch (Exception ex)
  1616. {
  1617. return Ok(JsonView(false, "程序错误!"));
  1618. throw;
  1619. }
  1620. }
  1621. /// <summary>
  1622. /// 根据团组Id查询团组增减款项
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1629. {
  1630. try
  1631. {
  1632. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1633. if (groupData.Code != 0)
  1634. {
  1635. return Ok(JsonView(false, groupData.Msg));
  1636. }
  1637. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1638. }
  1639. catch (Exception ex)
  1640. {
  1641. return Ok(JsonView(false, "程序错误!"));
  1642. throw;
  1643. }
  1644. }
  1645. /// <summary>
  1646. /// 团组增减款项操作(Status:1.新增,2.修改)
  1647. /// </summary>
  1648. /// <param name="dto"></param>
  1649. /// <returns></returns>
  1650. [HttpPost]
  1651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1652. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1653. {
  1654. try
  1655. {
  1656. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1657. if (groupData.Code != 0)
  1658. {
  1659. return Ok(JsonView(false, groupData.Msg));
  1660. }
  1661. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1662. }
  1663. catch (Exception ex)
  1664. {
  1665. return Ok(JsonView(false, "程序错误!"));
  1666. throw;
  1667. }
  1668. }
  1669. /// <summary>
  1670. /// 团组增减款项操作 删除
  1671. /// </summary>
  1672. /// <param name="dto"></param>
  1673. /// <returns></returns>
  1674. [HttpPost]
  1675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1676. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1677. {
  1678. try
  1679. {
  1680. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1681. if (!res)
  1682. {
  1683. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1684. {
  1685. IsDel = 1,
  1686. DeleteUserId = dto.DeleteUserId,
  1687. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1688. }).ExecuteCommandAsync();
  1689. return Ok(JsonView(false, "删除失败"));
  1690. }
  1691. return Ok(JsonView(true, "删除成功!"));
  1692. }
  1693. catch (Exception ex)
  1694. {
  1695. return Ok(JsonView(false, "程序错误!"));
  1696. throw;
  1697. }
  1698. }
  1699. /// <summary>
  1700. /// 根据团组增减款项Id查询
  1701. /// </summary>
  1702. /// <param name="dto"></param>
  1703. /// <returns></returns>
  1704. [HttpPost]
  1705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1706. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1707. {
  1708. try
  1709. {
  1710. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1711. if (groupData.Code != 0)
  1712. {
  1713. return Ok(JsonView(false, groupData.Msg));
  1714. }
  1715. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1716. }
  1717. catch (Exception ex)
  1718. {
  1719. return Ok(JsonView(false, "程序错误!"));
  1720. throw;
  1721. }
  1722. }
  1723. #endregion
  1724. #region 文件上传、删除
  1725. /// <summary>
  1726. /// region 文件上传 可以带参数
  1727. /// </summary>
  1728. /// <param name="file"></param>
  1729. /// <returns></returns>
  1730. [HttpPost]
  1731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1732. public async Task<IActionResult> UploadProject(IFormFile file)
  1733. {
  1734. try
  1735. {
  1736. var TypeName = Request.Headers["TypeName"].ToString();
  1737. if (file != null)
  1738. {
  1739. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1740. //文件名称
  1741. string projectFileName = file.FileName;
  1742. //上传的文件的路径
  1743. string filePath = "";
  1744. if (TypeName == "A")//A代表团组增减款项
  1745. {
  1746. if (!Directory.Exists(fileDir))
  1747. {
  1748. Directory.CreateDirectory(fileDir);
  1749. }
  1750. //上传的文件的路径
  1751. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  1752. }
  1753. else if (TypeName == "B")//B代表商邀相关文件
  1754. {
  1755. if (!Directory.Exists(fileDir))
  1756. {
  1757. Directory.CreateDirectory(fileDir);
  1758. }
  1759. //上传的文件的路径
  1760. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1761. }
  1762. using (FileStream fs = System.IO.File.Create(filePath))
  1763. {
  1764. file.CopyTo(fs);
  1765. fs.Flush();
  1766. }
  1767. return Ok(JsonView(true, "上传成功!", projectFileName));
  1768. }
  1769. else
  1770. {
  1771. return Ok(JsonView(false, "上传失败!"));
  1772. }
  1773. }
  1774. catch (Exception ex)
  1775. {
  1776. return Ok(JsonView(false, "程序错误!"));
  1777. throw;
  1778. }
  1779. }
  1780. /// <summary>
  1781. /// 删除指定文件
  1782. /// </summary>
  1783. /// <param name="dto"></param>
  1784. /// <returns></returns>
  1785. [HttpPost]
  1786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1787. public async Task<IActionResult> DelFile(DelFileDto dto)
  1788. {
  1789. try
  1790. {
  1791. var TypeName = Request.Headers["TypeName"].ToString();
  1792. string filePath = "";
  1793. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1794. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  1795. int id = 0;
  1796. if (TypeName == "A")
  1797. {
  1798. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  1799. // 删除该文件
  1800. System.IO.File.Delete(filePath);
  1801. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  1802. }
  1803. else if (TypeName == "B")
  1804. {
  1805. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  1806. // 删除该文件
  1807. System.IO.File.Delete(filePath);
  1808. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  1809. }
  1810. if (id != 0)
  1811. {
  1812. return Ok(JsonView(true, "成功!"));
  1813. }
  1814. else
  1815. {
  1816. return Ok(JsonView(false, "失败!"));
  1817. }
  1818. }
  1819. catch (Exception ex)
  1820. {
  1821. return Ok(JsonView(false, "程序错误!"));
  1822. throw;
  1823. }
  1824. }
  1825. #endregion
  1826. #region 商邀费用录入
  1827. /// <summary>
  1828. /// 根据团组Id查询商邀费用列表
  1829. /// </summary>
  1830. /// <param name="dto"></param>
  1831. /// <returns></returns>
  1832. [HttpPost]
  1833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1834. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  1835. {
  1836. try
  1837. {
  1838. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  1839. if (groupData.Code != 0)
  1840. {
  1841. return Ok(JsonView(false, groupData.Msg));
  1842. }
  1843. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1844. }
  1845. catch (Exception ex)
  1846. {
  1847. return Ok(JsonView(false, "程序错误!"));
  1848. throw;
  1849. }
  1850. }
  1851. /// <summary>
  1852. /// 根据商邀费用ID查询C表和商邀费用数据
  1853. /// </summary>
  1854. /// <param name="dto"></param>
  1855. /// <returns></returns>
  1856. [HttpPost]
  1857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1858. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  1859. {
  1860. try
  1861. {
  1862. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  1863. if (groupData.Code != 0)
  1864. {
  1865. return Ok(JsonView(false, groupData.Msg));
  1866. }
  1867. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1868. }
  1869. catch (Exception ex)
  1870. {
  1871. return Ok(JsonView(false, "程序错误!"));
  1872. throw;
  1873. }
  1874. }
  1875. /// <summary>
  1876. /// 商邀费用录入操作(Status:1.新增,2.修改)
  1877. /// </summary>
  1878. /// <param name="dto"></param>
  1879. /// <returns></returns>
  1880. [HttpPost]
  1881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1882. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  1883. {
  1884. try
  1885. {
  1886. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  1887. if (groupData.Code != 0)
  1888. {
  1889. return Ok(JsonView(false, groupData.Msg));
  1890. }
  1891. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1892. }
  1893. catch (Exception ex)
  1894. {
  1895. return Ok(JsonView(false, "程序错误!"));
  1896. throw;
  1897. }
  1898. }
  1899. /// <summary>
  1900. /// 商邀删除
  1901. /// </summary>
  1902. /// <param name="dto"></param>
  1903. /// <returns></returns>
  1904. [HttpPost]
  1905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1906. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  1907. {
  1908. try
  1909. {
  1910. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1911. if (!res)
  1912. {
  1913. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  1914. {
  1915. IsDel = 1,
  1916. DeleteUserId = dto.DeleteUserId,
  1917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1918. }).ExecuteCommandAsync();
  1919. return Ok(JsonView(false, "删除失败"));
  1920. }
  1921. return Ok(JsonView(true, "删除成功!"));
  1922. }
  1923. catch (Exception ex)
  1924. {
  1925. return Ok(JsonView(false, "程序错误!"));
  1926. throw;
  1927. }
  1928. }
  1929. #endregion
  1930. #region 团组英文资料
  1931. /// <summary>
  1932. /// 查询团组英文所有资料
  1933. /// </summary>
  1934. /// <param name="dto"></param>
  1935. /// <returns></returns>
  1936. [HttpPost]
  1937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1938. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  1939. {
  1940. try
  1941. {
  1942. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  1943. if (groupData.Code != 0)
  1944. {
  1945. return Ok(JsonView(false, groupData.Msg));
  1946. }
  1947. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1948. }
  1949. catch (Exception ex)
  1950. {
  1951. return Ok(JsonView(false, "程序错误!"));
  1952. throw;
  1953. }
  1954. }
  1955. /// <summary>
  1956. /// 团组英文资料操作(Status:1.新增,2.修改)
  1957. /// </summary>
  1958. /// <param name="dto"></param>
  1959. /// <returns></returns>
  1960. [HttpPost]
  1961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1962. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  1963. {
  1964. try
  1965. {
  1966. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  1967. if (groupData.Code != 0)
  1968. {
  1969. return Ok(JsonView(false, groupData.Msg));
  1970. }
  1971. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1972. }
  1973. catch (Exception ex)
  1974. {
  1975. return Ok(JsonView(false, "程序错误!"));
  1976. throw;
  1977. }
  1978. }
  1979. /// <summary>
  1980. /// 团组英文资料Id查询数据
  1981. /// </summary>
  1982. /// <param name="dto"></param>
  1983. /// <returns></returns>
  1984. [HttpPost]
  1985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1986. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  1987. {
  1988. try
  1989. {
  1990. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  1991. if (_DelegationEnData != null)
  1992. {
  1993. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  1994. }
  1995. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  1996. }
  1997. catch (Exception ex)
  1998. {
  1999. return Ok(JsonView(false, "程序错误!"));
  2000. throw;
  2001. }
  2002. }
  2003. /// <summary>
  2004. /// 团组英文资料删除
  2005. /// </summary>
  2006. /// <param name="dto"></param>
  2007. /// <returns></returns>
  2008. [HttpPost]
  2009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2010. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2011. {
  2012. try
  2013. {
  2014. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2015. if (!res)
  2016. {
  2017. return Ok(JsonView(false, "删除失败"));
  2018. }
  2019. return Ok(JsonView(true, "删除成功!"));
  2020. }
  2021. catch (Exception ex)
  2022. {
  2023. return Ok(JsonView(false, "程序错误!"));
  2024. throw;
  2025. }
  2026. }
  2027. #endregion
  2028. #region 导出邀请函
  2029. /// <summary>
  2030. /// 导出邀请函页面初始化
  2031. /// </summary>
  2032. /// <param name="dto"></param>
  2033. /// <returns></returns>
  2034. [HttpPost]
  2035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2036. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2037. {
  2038. try
  2039. {
  2040. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2041. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2042. if (dto.DiId == 0)
  2043. {
  2044. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2045. }
  2046. else
  2047. {
  2048. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2049. }
  2050. return Ok(JsonView(true, "查询成功!", new
  2051. {
  2052. deleClient = crm_Deles,
  2053. delegations = grp_Delegations
  2054. }));
  2055. }
  2056. catch (Exception ex)
  2057. {
  2058. return Ok(JsonView(false, "程序错误!"));
  2059. throw;
  2060. }
  2061. }
  2062. /// <summary>
  2063. /// 导出邀请函
  2064. /// </summary>
  2065. /// <param name="dto"></param>
  2066. /// <returns></returns>
  2067. [HttpPost]
  2068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2069. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2070. {
  2071. try
  2072. {
  2073. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2074. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2075. List<string> texts = new List<string>();
  2076. if (crm_DeleClients.Count != 0)
  2077. {
  2078. foreach (Crm_DeleClient item in crm_DeleClients)
  2079. {
  2080. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2081. {
  2082. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2083. }
  2084. else
  2085. {
  2086. string name = item.LastName + item.FirstName;
  2087. texts.Add(name);
  2088. }
  2089. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2090. {
  2091. if (!transDic.ContainsKey(item.Job))
  2092. {
  2093. texts.Add(item.Job);
  2094. }
  2095. }
  2096. if (item.CrmCompanyId != 0)
  2097. {
  2098. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2099. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2100. {
  2101. texts.Add(crm_Customer.CompanyName);
  2102. }
  2103. }
  2104. }
  2105. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2106. if (transData.Count > 0)
  2107. {
  2108. foreach (TranslateResult item in transData)
  2109. {
  2110. if (!transDic.ContainsKey(item.Query))
  2111. {
  2112. transDic.Add(item.Query, item.Translation);
  2113. }
  2114. }
  2115. }
  2116. List<guestList> list = new List<guestList>();
  2117. foreach (Crm_DeleClient dele in crm_DeleClients)
  2118. {
  2119. guestList guestList = new guestList();
  2120. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2121. {
  2122. guestList.Name = dele.Pinyin;
  2123. }
  2124. else
  2125. {
  2126. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2127. guestList.Name = Name;
  2128. }
  2129. if (dele.Sex == 0)
  2130. {
  2131. guestList.Sex = "Male";
  2132. }
  2133. else if (dele.Sex == 1)
  2134. {
  2135. guestList.Sex = "Female";
  2136. }
  2137. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2138. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2139. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2140. guestList.Job = jobName;
  2141. list.Add(guestList);
  2142. }
  2143. //载入模板
  2144. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2145. DocumentBuilder builder = new DocumentBuilder(doc);
  2146. //获取word里所有表格
  2147. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2148. //获取所填表格的序数
  2149. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2150. var rowStart = tableOne.Rows[0]; //获取第1行
  2151. //循环赋值
  2152. for (int i = 0; i < list.Count; i++)
  2153. {
  2154. builder.MoveToCell(0, i + 1, 0, 0);
  2155. builder.Write(list[i].Name.ToString());
  2156. builder.MoveToCell(0, i + 1, 1, 0);
  2157. builder.Write(list[i].Sex.ToString());
  2158. builder.MoveToCell(0, i + 1, 2, 0);
  2159. builder.Write(list[i].DOB.ToString());
  2160. builder.MoveToCell(0, i + 1, 3, 0);
  2161. builder.Write(list[i].Job.ToString());
  2162. }
  2163. //删除多余行
  2164. while (tableOne.Rows.Count > list.Count + 1)
  2165. {
  2166. tableOne.Rows.RemoveAt(list.Count + 1);
  2167. }
  2168. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2169. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2170. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2171. doc.Save(filePath);
  2172. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2173. return Ok(JsonView(true, "成功!", Url));
  2174. }
  2175. else
  2176. {
  2177. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2178. }
  2179. }
  2180. catch (Exception ex)
  2181. {
  2182. return Ok(JsonView(false, "程序错误!"));
  2183. throw;
  2184. }
  2185. }
  2186. #endregion
  2187. #region 团组经理模块 出入境费用
  2188. ///// <summary>
  2189. ///// 团组模块 - 出入境费用
  2190. ///// </summary>
  2191. ///// <returns></returns>
  2192. //[HttpPost]
  2193. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2194. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2195. //{
  2196. // try
  2197. // {
  2198. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2199. // if (data.Code != 0)
  2200. // {
  2201. // return Ok(JsonView(false, data.Msg));
  2202. // }
  2203. // return Ok(JsonView(true, "查询成功!"));
  2204. // }
  2205. // catch (Exception ex)
  2206. // {
  2207. // return Ok(JsonView(false, ex.Message));
  2208. // throw;
  2209. // }
  2210. //}
  2211. /// <summary>
  2212. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2213. /// </summary>
  2214. /// <returns></returns>
  2215. [HttpPost]
  2216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2217. public async Task<IActionResult> SetDayAndCostAreaChange()
  2218. {
  2219. try
  2220. {
  2221. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2222. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2223. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2224. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2225. foreach (var item in unite) //处理交集数据
  2226. {
  2227. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2228. }
  2229. foreach (var item in merge) //处理差集数据
  2230. {
  2231. int nationalTravelFeeId = 0;
  2232. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2233. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2234. else
  2235. {
  2236. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2237. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2238. }
  2239. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2240. }
  2241. //只更新dayAndCost 的 nationalTravelFeeId;
  2242. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2243. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2244. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2245. }
  2246. catch (Exception ex)
  2247. {
  2248. return Ok(JsonView(false, ex.Message));
  2249. throw;
  2250. }
  2251. }
  2252. /// <summary>
  2253. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2254. /// </summary>
  2255. /// <returns></returns>
  2256. [HttpPost]
  2257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2258. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2259. {
  2260. try
  2261. {
  2262. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2263. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2264. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2265. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2266. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2267. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2268. // Where gntf.Isdel = 0");
  2269. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2270. return Ok(JsonView(true, "查询成功!", new
  2271. {
  2272. GroupNameData = groupNameData.Data,
  2273. CurrencyData = currencyData,
  2274. //NationalTravelFeeData = nationalTravelFeeData
  2275. }));
  2276. }
  2277. catch (Exception ex)
  2278. {
  2279. return Ok(JsonView(false, ex.Message));
  2280. throw;
  2281. }
  2282. }
  2283. /// <summary>
  2284. /// 团组模块 - 出入境费用 - Info
  2285. /// </summary>
  2286. /// <returns></returns>
  2287. [HttpPost]
  2288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2289. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2290. {
  2291. try
  2292. {
  2293. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2294. if (data.Code != 0)
  2295. {
  2296. return Ok(JsonView(false, data.Msg));
  2297. }
  2298. return Ok(JsonView(true, "查询成功!", data.Data));
  2299. }
  2300. catch (Exception ex)
  2301. {
  2302. return Ok(JsonView(false, ex.Message));
  2303. }
  2304. }
  2305. /// <summary>
  2306. /// 团组模块 - 出入境费用 - Add And Update
  2307. /// </summary>
  2308. /// <returns></returns>
  2309. [HttpPost]
  2310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2311. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2312. {
  2313. try
  2314. {
  2315. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2316. if (data.Code != 0)
  2317. {
  2318. return Ok(JsonView(false, data.Msg));
  2319. }
  2320. return Ok(JsonView(true, data.Msg, data.Data));
  2321. }
  2322. catch (Exception ex)
  2323. {
  2324. return Ok(JsonView(false, ex.Message));
  2325. }
  2326. }
  2327. /// <summary>
  2328. /// 团组模块 - 出入境费用 - 子项删除
  2329. /// </summary>
  2330. /// <returns></returns>
  2331. [HttpPost]
  2332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2333. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2334. {
  2335. try
  2336. {
  2337. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2338. if (data.Code != 0)
  2339. {
  2340. return Ok(JsonView(false, data.Msg));
  2341. }
  2342. return Ok(JsonView(true, "操作成功!", data.Data));
  2343. }
  2344. catch (Exception ex)
  2345. {
  2346. return Ok(JsonView(false, ex.Message));
  2347. }
  2348. }
  2349. /// <summary>
  2350. /// 团组模块 - 出入境国家费用标准 List
  2351. /// </summary>
  2352. /// <returns></returns>
  2353. [HttpPost]
  2354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2355. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2356. {
  2357. try
  2358. {
  2359. Stopwatch sw = new Stopwatch();
  2360. sw.Start();
  2361. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2362. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2363. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2364. Where gntf.Isdel = 0");
  2365. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2366. var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2367. List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2368. foreach (var item in nationalTravel)
  2369. {
  2370. var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2371. var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2372. if (otherData != null)
  2373. {
  2374. cityData.Remove(otherData);
  2375. cityData.Add(otherData);
  2376. }
  2377. nationalTravelFeeData1.Add(new
  2378. {
  2379. Country = item.Country,
  2380. CityData = cityData
  2381. });
  2382. }
  2383. sw.Stop();
  2384. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData1));
  2385. }
  2386. catch (Exception ex)
  2387. {
  2388. return Ok(JsonView(false, ex.Message));
  2389. throw;
  2390. }
  2391. }
  2392. /// <summary>
  2393. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2394. /// </summary>
  2395. /// <returns></returns>
  2396. [HttpPost]
  2397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2398. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2399. {
  2400. try
  2401. {
  2402. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2403. if (data.Code != 0)
  2404. {
  2405. return Ok(JsonView(false, data.Msg));
  2406. }
  2407. return Ok(JsonView(true, "操作成功!", data.Data));
  2408. }
  2409. catch (Exception ex)
  2410. {
  2411. return Ok(JsonView(false, ex.Message));
  2412. }
  2413. }
  2414. #endregion
  2415. }
  2416. }