GroupsController.cs 75 KB

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