GroupsController.cs 81 KB

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