ResourceController.cs 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514
  1. using Aspose.Words;
  2. using NPOI.HPSF;
  3. using NPOI.POIFS.Crypt.Dsig;
  4. using NPOI.SS.Formula.Functions;
  5. using OASystem.API.OAMethodLib;
  6. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  7. using OASystem.Domain.Dtos.Resource;
  8. using OASystem.Domain.Entities.Groups;
  9. using OASystem.Domain.ViewModels.Groups;
  10. using OASystem.Domain.ViewModels.QiYeWeChat;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using Org.BouncyCastle.Asn1.Ocsp;
  13. using Org.BouncyCastle.Utilities;
  14. using Quartz.Util;
  15. using System.Collections.Generic;
  16. using System.Diagnostics;
  17. using System.Net.Http.Headers;
  18. using static QRCoder.PayloadGenerator.SwissQrCode;
  19. namespace OASystem.API.Controllers
  20. {
  21. /// <summary>
  22. /// 资料相关
  23. /// </summary>
  24. //[Authorize]
  25. [Route("api/[controller]/[action]")]
  26. public class ResourceController : ControllerBase
  27. {
  28. private readonly IMapper _mapper;
  29. private readonly SqlSugarClient _sqlSugar;
  30. private readonly IConfiguration _config;
  31. private readonly CarDataRepository _carDataRep;
  32. private readonly LocalGuideDataRepository _localGuideDataRep;
  33. private readonly ThreeCodeRepository _ThreeCodeRep;
  34. private readonly HotelDataRepository _hotelDataRep;
  35. private readonly ResItemInfoRepository _resItemInfoRep;
  36. private readonly SetDataRepository _setDataRepository;
  37. private readonly CountryFeeRepository _countryFeeRep;
  38. private readonly SetDataTypeRepository _setDataTypeRep;
  39. private readonly AirTicketAgentRepository _airTicketAgentRep;
  40. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  41. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  42. private readonly AskDataRepository _askDataRep;
  43. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  44. private readonly TourClientListRepository _tourClientListRep;
  45. private readonly DelegationInfoRepository _delegationInfoRep;
  46. public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep, LocalGuideDataRepository localGuideDataRep,
  47. ThreeCodeRepository threeCodeRep, HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
  48. CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
  49. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep,
  50. TicketBlackCodeRepository ticketBlackCodeRep, TourClientListRepository tourClientListRep, DelegationInfoRepository delegationInfoRep)
  51. {
  52. _mapper = mapper;
  53. _config = config;
  54. _sqlSugar = sqlSugar;
  55. _carDataRep = carDataRep;
  56. _localGuideDataRep = localGuideDataRep;
  57. _ThreeCodeRep = threeCodeRep;
  58. _hotelDataRep = hotelDataRep;
  59. _resItemInfoRep = resItemInfoRep;
  60. _setDataRepository = setDataRepository;
  61. _countryFeeRep = countryFeeRep;
  62. _setDataTypeRep = setDataTypeRep;
  63. _airTicketAgentRep = airTicketAgentRep;
  64. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  65. _officialActivitiesRep = officialActivitiesRep;
  66. _askDataRep = askDataRep;
  67. _ticketBlackCodeRep = ticketBlackCodeRep;
  68. _tourClientListRep = tourClientListRep;
  69. _delegationInfoRep = delegationInfoRep;
  70. }
  71. #region 车公司资料板块
  72. /// <summary>
  73. /// 车公司信息查询
  74. /// </summary>
  75. /// <returns></returns>
  76. [HttpPost]
  77. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  78. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  79. {
  80. try
  81. {
  82. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  83. if (LocalGuide.Code == 0)
  84. {
  85. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  86. }
  87. else
  88. {
  89. return Ok(JsonView(false, LocalGuide.Msg));
  90. }
  91. }
  92. catch (Exception)
  93. {
  94. return Ok(JsonView(false, "程序错误!"));
  95. throw;
  96. }
  97. }
  98. /// <summary>
  99. /// 车公司资料下拉框数据
  100. /// </summary>
  101. /// <returns></returns>
  102. [HttpPost]
  103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  104. public async Task<IActionResult> QueryCarSelect()
  105. {
  106. try
  107. {
  108. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  109. if (CarData.Count == 0)
  110. {
  111. return Ok(JsonView(false, "暂无数据!"));
  112. }
  113. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  114. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  115. CarData = CarData.OrderBy(x => x.Id).ToList();
  116. List<CarDataSelectView> data = new List<CarDataSelectView>();
  117. foreach (CarDataSelectView car in CarData)
  118. {
  119. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  120. {
  121. data.Add(car);
  122. }
  123. }
  124. return Ok(JsonView(true, "查询成功", data));
  125. }
  126. catch (Exception)
  127. {
  128. return Ok(JsonView(false, "程序错误!"));
  129. throw;
  130. }
  131. }
  132. /// <summary>
  133. /// 根据Id查询车公司详细数据
  134. /// </summary>
  135. /// <returns></returns>
  136. [HttpPost]
  137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  138. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  139. {
  140. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  141. CarDataDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  142. if (info == null)
  143. {
  144. return Ok(JsonView(false, "未找到相关数据!"));
  145. }
  146. return Ok(JsonView(true, "查询成功", info));
  147. }
  148. /// <summary>
  149. /// 车公司信息添加
  150. /// </summary>
  151. /// <returns></returns>
  152. [HttpPost]
  153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  154. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  155. {
  156. try
  157. {
  158. if (dto.UnitArea == "")
  159. {
  160. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  161. }
  162. if (dto.UnitName == "")
  163. {
  164. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  165. }
  166. if (dto.Contact == "")
  167. {
  168. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  169. }
  170. if (dto.ContactTel == "")
  171. {
  172. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  173. }
  174. var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea && a.UnitName == dto.UnitName && a.Contact == dto.Contact && a.ContactTel == dto.ContactTel).ToList();
  175. if (carDada.Count != 0)
  176. {
  177. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  178. }
  179. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  180. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  181. if (id == 0)
  182. {
  183. return Ok(JsonView(false, "添加失败!"));
  184. }
  185. return Ok(JsonView(true, "添加成功", new { Id = id }));
  186. }
  187. catch (Exception ex)
  188. {
  189. return Ok(JsonView(false, "程序错误!"));
  190. throw;
  191. }
  192. }
  193. /// <summary>
  194. /// 车公司信息修改
  195. /// </summary>
  196. /// <returns></returns>
  197. [HttpPost]
  198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  199. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  200. {
  201. try
  202. {
  203. if (dto.UnitArea == "")
  204. {
  205. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  206. }
  207. if (dto.UnitName == "")
  208. {
  209. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  210. }
  211. if (dto.Contact == "")
  212. {
  213. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  214. }
  215. if (dto.ContactTel == "")
  216. {
  217. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  218. }
  219. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  220. {
  221. UnitArea = dto.UnitArea,
  222. UnitName = dto.UnitName,
  223. Address = dto.Address,
  224. Contact = dto.Contact,
  225. ContactTel = dto.ContactTel,
  226. ContactEmail = dto.ContactEmail,
  227. ContactFax = dto.ContactFax,
  228. CarDes = dto.CarDes,
  229. CarPicPaths = dto.CarPicPaths,
  230. OtherInfo = dto.OtherInfo,
  231. Score = dto.Score,
  232. QualificationScore = dto.QualificationScore,
  233. CarAgeScore = dto.CarAgeScore,
  234. CleanImgScore = dto.CleanImgScore,
  235. SmellScore = dto.SmellScore,
  236. WaterPaperScore = dto.WaterPaperScore,
  237. HardwareScore = dto.HardwareScore,
  238. TimeScore = dto.TimeScore,
  239. SafetyScore = dto.SafetyScore,
  240. DrivingAgeScore = dto.DrivingAgeScore,
  241. Remark = dto.Remark,
  242. });
  243. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  244. return Ok(JsonView(true, "修改成功"));
  245. }
  246. catch (Exception ex)
  247. {
  248. return Ok(JsonView(false, "程序错误!"));
  249. throw;
  250. }
  251. }
  252. /// <summary>
  253. /// 车公司信息删除
  254. /// </summary>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  259. {
  260. try
  261. {
  262. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  263. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  264. return Ok(JsonView(true, "删除成功"));
  265. }
  266. catch (Exception ex)
  267. {
  268. return Ok(JsonView(false, "程序错误!"));
  269. throw;
  270. }
  271. }
  272. #endregion
  273. #region 导游地接资料板块
  274. /// <summary>
  275. /// 导游地接资料查询
  276. /// </summary>
  277. /// <param name="dto"></param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  281. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  282. {
  283. try
  284. {
  285. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  286. if (LocalGuide.Code == 0)
  287. {
  288. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  289. }
  290. else
  291. {
  292. return Ok(JsonView(false, LocalGuide.Msg));
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. return Ok(JsonView(false, "程序错误!"));
  298. throw;
  299. }
  300. }
  301. /// <summary>
  302. /// 导游地接资料下拉框数据
  303. /// </summary>
  304. /// <returns></returns>
  305. [HttpPost]
  306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  307. public async Task<IActionResult> QueryLocalGuideSelect()
  308. {
  309. try
  310. {
  311. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  312. if (LocalGuide.Count == 0)
  313. {
  314. return Ok(JsonView(false, "暂无数据!"));
  315. }
  316. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  317. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  318. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  319. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  320. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  321. {
  322. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  323. {
  324. data.Add(Local);
  325. }
  326. }
  327. return Ok(JsonView(true, "查询成功", data));
  328. }
  329. catch (Exception)
  330. {
  331. return Ok(JsonView(false, "程序错误!"));
  332. throw;
  333. }
  334. }
  335. /// <summary>
  336. /// 根据Id查询地接详细数据
  337. /// </summary>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  342. {
  343. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  344. LocalGuideDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  345. if(info == null)
  346. {
  347. return Ok(JsonView(false, "未找到相关数据!"));
  348. }
  349. return Ok(JsonView(true, "查询成功", info));
  350. }
  351. /// <summary>
  352. /// 导游地接信息操作(Status:1.新增,2.修改)
  353. /// </summary>
  354. /// <returns></returns>
  355. [HttpPost]
  356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  357. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  358. {
  359. try
  360. {
  361. if (dto.UnitArea == "")
  362. {
  363. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  364. }
  365. if (dto.UnitName == "")
  366. {
  367. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  368. }
  369. if (dto.Contact == "")
  370. {
  371. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  372. }
  373. if (dto.ContactTel == "")
  374. {
  375. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  376. }
  377. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  378. if (result.Code != 0)
  379. {
  380. return Ok(JsonView(false, result.Msg));
  381. }
  382. return Ok(JsonView(true, result.Msg));
  383. }
  384. catch (Exception ex)
  385. {
  386. return Ok(JsonView(false, "程序错误!"));
  387. throw;
  388. }
  389. }
  390. /// <summary>
  391. /// 导游地接信息操作(删除)
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  397. {
  398. try
  399. {
  400. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  401. if (!res)
  402. {
  403. return Ok(JsonView(false, "删除失败"));
  404. }
  405. return Ok(JsonView(true, "删除成功!"));
  406. }
  407. catch (Exception ex)
  408. {
  409. return Ok(JsonView(false, "程序错误!"));
  410. throw;
  411. }
  412. }
  413. #endregion
  414. #region 机场三字码信息
  415. /// <summary>
  416. /// 机场三字码查询
  417. /// </summary>
  418. /// <param name="dto"></param>
  419. /// <returns></returns>
  420. [HttpPost]
  421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  422. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  423. {
  424. try
  425. {
  426. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  427. if (LocalGuide.Code == 0)
  428. {
  429. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  430. }
  431. else
  432. {
  433. return Ok(JsonView(false, LocalGuide.Msg));
  434. }
  435. }
  436. catch (Exception ex)
  437. {
  438. return Ok(JsonView(false, "程序错误!"));
  439. throw;
  440. }
  441. }
  442. /// <summary>
  443. /// 机场三字码数据城市下拉框数据
  444. /// </summary>
  445. /// <returns></returns>
  446. [HttpPost]
  447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  448. public async Task<IActionResult> QueryThreeCodeSelect()
  449. {
  450. try
  451. {
  452. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  453. if (ThreeCode.Count == 0)
  454. {
  455. return Ok(JsonView(false, "暂无数据!"));
  456. }
  457. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  458. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  459. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  460. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  461. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  462. {
  463. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  464. {
  465. data.Add(_ThreeCode);
  466. }
  467. }
  468. return Ok(JsonView(true, "查询成功", data));
  469. }
  470. catch (Exception)
  471. {
  472. return Ok(JsonView(false, "程序错误!"));
  473. throw;
  474. }
  475. }
  476. /// <summary>
  477. /// 机场三字码资料操作(Status:1.新增,2.修改)
  478. /// </summary>
  479. /// <param name="dto"></param>
  480. /// <returns></returns>
  481. [HttpPost]
  482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  483. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  484. {
  485. try
  486. {
  487. if (dto.Three == "")
  488. {
  489. return Ok(JsonView(false, "请检查三字码是否填写!"));
  490. }
  491. if (dto.Country == "")
  492. {
  493. return Ok(JsonView(false, "请检查国家是否填写!"));
  494. }
  495. if (dto.City == "")
  496. {
  497. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  498. }
  499. if (dto.AirPort == "")
  500. {
  501. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  502. }
  503. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  504. if (result.Code != 0)
  505. {
  506. return Ok(JsonView(false, result.Msg));
  507. }
  508. return Ok(JsonView(true, result.Msg));
  509. }
  510. catch (Exception ex)
  511. {
  512. return Ok(JsonView(false, "程序错误!"));
  513. throw;
  514. }
  515. }
  516. /// <summary>
  517. /// 机场三字码资料操作(删除)
  518. /// </summary>
  519. /// <returns></returns>
  520. [HttpPost]
  521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  522. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  523. {
  524. try
  525. {
  526. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  527. if (!res)
  528. {
  529. return Ok(JsonView(false, "删除失败"));
  530. }
  531. return Ok(JsonView(true, "删除成功!"));
  532. }
  533. catch (Exception ex)
  534. {
  535. return Ok(JsonView(false, "程序错误!"));
  536. throw;
  537. }
  538. }
  539. /// <summary>
  540. ///根据ID查询三字码信息
  541. /// </summary>
  542. /// <returns></returns>
  543. [HttpPost]
  544. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  545. {
  546. var jw = JsonView(false);
  547. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  548. if (single != null)
  549. {
  550. jw = JsonView(true, "获取成功!", new
  551. {
  552. single.Three,
  553. Four = single.Four?.Trim(),
  554. single.AirPort,
  555. single.AirPort_En,
  556. single.City, single.Country,
  557. single.Remark
  558. });
  559. }
  560. else
  561. {
  562. jw.Msg = "暂无!";
  563. }
  564. return Ok(jw);
  565. }
  566. #endregion
  567. #region 代理出票合作方资料
  568. /// <summary>
  569. /// 代理出票合作方资料
  570. /// </summary>
  571. /// <param name="dto"></param>
  572. /// <returns></returns>
  573. [HttpPost]
  574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  575. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  576. {
  577. try
  578. {
  579. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  580. if (res_AirTicketAgents.Count != 0)
  581. {
  582. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  583. if (dto.PageSize == 0 && dto.PageIndex == 0)
  584. {
  585. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  586. }
  587. else
  588. {
  589. int count = res_AirTicketAgents.Count;
  590. float totalPage = (float)count / dto.PageSize;//总页数
  591. if (totalPage == 0) totalPage = 1;
  592. else totalPage = (int)Math.Ceiling((double)totalPage);
  593. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  594. for (int i = 0; i < dto.PageSize; i++)
  595. {
  596. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  597. if (RowIndex < res_AirTicketAgents.Count)
  598. {
  599. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  600. }
  601. else
  602. {
  603. break;
  604. }
  605. }
  606. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  607. }
  608. }
  609. else
  610. {
  611. return Ok(JsonView(false, "暂无数据!"));
  612. }
  613. }
  614. catch (Exception ex)
  615. {
  616. return Ok(JsonView(false, "程序错误!"));
  617. throw;
  618. }
  619. }
  620. /// <summary>
  621. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  622. /// </summary>
  623. /// <param name="dto"></param>
  624. /// <returns></returns>
  625. [HttpPost]
  626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  627. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  628. {
  629. try
  630. {
  631. if (dto.Account == "")
  632. {
  633. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  634. }
  635. if (dto.Bank == "")
  636. {
  637. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  638. }
  639. if (dto.Name == "")
  640. {
  641. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  642. }
  643. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  644. if (result.Code != 0)
  645. {
  646. return Ok(JsonView(false, result.Msg));
  647. }
  648. return Ok(JsonView(true, result.Msg));
  649. }
  650. catch (Exception ex)
  651. {
  652. return Ok(JsonView(false, "程序错误!"));
  653. throw;
  654. }
  655. }
  656. /// <summary>
  657. /// 代理出票合作方资料操作(删除)
  658. /// </summary>
  659. /// <returns></returns>
  660. [HttpPost]
  661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  662. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  663. {
  664. try
  665. {
  666. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  667. if (!res)
  668. {
  669. return Ok(JsonView(false, "删除失败"));
  670. }
  671. return Ok(JsonView(true, "删除成功!"));
  672. }
  673. catch (Exception ex)
  674. {
  675. return Ok(JsonView(false, "程序错误!"));
  676. throw;
  677. }
  678. }
  679. #endregion
  680. #region 酒店资料数据
  681. /// <summary>
  682. /// 酒店信息查询 Page
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  689. {
  690. string sqlWhere = string.Empty;
  691. if (!string.IsNullOrWhiteSpace(dto.Name))
  692. {
  693. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", dto.Name);
  694. }
  695. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  696. {
  697. sqlWhere += string.Format(@" And hd.City like '%{0}%'", dto.City);
  698. }
  699. if (!string.IsNullOrWhiteSpace(dto.Contact))
  700. {
  701. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", dto.Contact);
  702. }
  703. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  704. {
  705. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", dto.ContactPhone);
  706. }
  707. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  708. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  709. {
  710. Regex r = new Regex("And");
  711. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  712. }
  713. string sql = string.Format(@"SELECT
  714. *
  715. FROM
  716. (
  717. SELECT
  718. ROW_NUMBER() OVER (
  719. ORDER BY
  720. hd.CreateTime DESC
  721. ) AS Row_Number,
  722. hd.Id,
  723. hd.City,
  724. hd.[Name],
  725. hd.Tel,
  726. hd.Fax,
  727. hd.Contact,
  728. hd.ContactPhone,
  729. u.CnName AS CreateUserName,
  730. hd.CreateTime
  731. FROM
  732. Res_HotelData hd
  733. WITH
  734. (NoLock)
  735. LEFT JOIN Sys_Users u
  736. WITH
  737. (NoLock) ON hd.CreateUserId = u.Id {0}
  738. ) Temp
  739. ", sqlWhere);
  740. if (dto.PortType == 1)
  741. {
  742. List<HotelDataItemView> HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  743. if (HotelDataData.Count == 0)
  744. {
  745. return Ok(JsonView(false, "暂无数据"));
  746. }
  747. return Ok(JsonView(true, "操作成功", HotelDataData));
  748. }
  749. else if (dto.PortType == 2 || dto.PortType == 3)
  750. {
  751. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  752. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  753. return Ok(JsonView(true, "操作成功", data, total));
  754. }
  755. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  756. }
  757. /// <summary>
  758. /// 酒店资料
  759. /// 详情
  760. /// add time:2024-05-14 11:57:10
  761. /// </summary>
  762. /// <returns></returns>
  763. [HttpPost]
  764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  765. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  766. {
  767. var _view = await _hotelDataRep._Info(dto.PortType,dto.Id);
  768. if (_view.Code == 0 )
  769. {
  770. return Ok(JsonView(true, _view.Msg,_view.Data));
  771. }
  772. return Ok(JsonView(false, _view.Msg));
  773. }
  774. /// <summary>
  775. /// 酒店资料下拉框数据
  776. /// </summary>
  777. /// <returns></returns>
  778. [HttpPost]
  779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  780. public async Task<IActionResult> QueryHotelDataSelect()
  781. {
  782. try
  783. {
  784. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  785. if (HotelData.Count == 0)
  786. {
  787. return Ok(JsonView(false, "暂无数据!"));
  788. }
  789. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  790. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  791. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  792. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  793. foreach (QueryHotelDataSelect Hotel in HotelData)
  794. {
  795. if (!string.IsNullOrWhiteSpace(Hotel.City))
  796. {
  797. data.Add(Hotel);
  798. }
  799. }
  800. return Ok(JsonView(true, "查询成功", data));
  801. }
  802. catch (Exception)
  803. {
  804. return Ok(JsonView(false, "程序错误!"));
  805. throw;
  806. }
  807. }
  808. /// <summary>
  809. /// 酒店资料操作(Status:1.新增,2.修改)
  810. /// </summary>
  811. /// <param name="dto"></param>
  812. /// <returns></returns>
  813. [HttpPost]
  814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  815. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  816. {
  817. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  818. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  819. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  820. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  821. Result result = await _hotelDataRep.OperationHotelData(dto);
  822. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  823. return Ok(JsonView(true, result.Msg));
  824. }
  825. /// <summary>
  826. /// 酒店资料操作(删除)
  827. /// </summary>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  832. {
  833. try
  834. {
  835. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  836. if (!res)
  837. {
  838. return Ok(JsonView(false, "删除失败"));
  839. }
  840. return Ok(JsonView(true, "删除成功!"));
  841. }
  842. catch (Exception ex)
  843. {
  844. return Ok(JsonView(false, "程序错误!"));
  845. throw;
  846. }
  847. }
  848. #endregion
  849. #region 签证费用资料
  850. /// <summary>
  851. /// 签证费用资料查询
  852. /// </summary>
  853. /// <param name="dto"></param>
  854. /// <returns></returns>
  855. [HttpPost]
  856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  857. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  858. {
  859. if (dto.PortType == 1)
  860. {
  861. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  862. if (CountryFee.Count == 0)
  863. {
  864. return Ok(JsonView(false, "暂无数据!"));
  865. }
  866. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  867. return Ok(JsonView(true, "查询成功", CountryFee));
  868. }
  869. else if (dto.PortType == 2)
  870. {
  871. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  872. if (CountryFee.Count == 0)
  873. {
  874. return Ok(JsonView(false, "暂无数据!"));
  875. }
  876. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  877. return Ok(JsonView(true, "查询成功", CountryFee));
  878. }
  879. else
  880. {
  881. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  882. }
  883. }
  884. /// <summary>
  885. /// 签证费用资料操作(Status:1.新增,2.修改)
  886. /// </summary>
  887. /// <param name="dto"></param>
  888. /// <returns></returns>
  889. [HttpPost]
  890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  891. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  892. {
  893. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  894. {
  895. return Ok(JsonView(false, "请检查州名是否填写!"));
  896. }
  897. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  898. {
  899. return Ok(JsonView(false, "请检查国家名是否填写!"));
  900. }
  901. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  902. {
  903. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  904. }
  905. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  906. {
  907. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  908. }
  909. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  910. if (result.Code == 0)
  911. {
  912. return Ok(JsonView(true, result.Msg));
  913. }
  914. return Ok(JsonView(false, result.Msg));
  915. }
  916. /// <summary>
  917. /// 签证费用资料操作(删除)
  918. /// </summary>
  919. /// <returns></returns>
  920. [HttpPost]
  921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  922. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  923. {
  924. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  925. if (!res)
  926. {
  927. return Ok(JsonView(false, "删除失败"));
  928. }
  929. return Ok(JsonView(true, "删除成功!"));
  930. }
  931. #endregion
  932. #region 物料信息、供应商维护
  933. #region 供应商
  934. /// <summary>
  935. /// 物料供应商查询
  936. /// </summary>
  937. /// <param name="paras">Json序列化</param>
  938. /// <returns></returns>
  939. [HttpPost]
  940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  941. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  942. {
  943. if (string.IsNullOrEmpty(_jsonDto.Paras))
  944. {
  945. return Ok(JsonView(false, "参数为空"));
  946. }
  947. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  948. if (_ItemVendorDto != null)
  949. {
  950. if (_ItemVendorDto.SearchType == 2) //获取列表
  951. {
  952. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  953. return Ok(rstList);
  954. }
  955. else
  956. {
  957. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  958. return Ok(rstInfo);
  959. }
  960. }
  961. else
  962. {
  963. return Ok(JsonView(false, "参数反序列化失败"));
  964. }
  965. return Ok(JsonView(false));
  966. }
  967. /// <summary>
  968. /// 创建/编辑/删除供应商信息
  969. /// </summary>
  970. /// <param name="_dto"></param>
  971. /// <returns></returns>
  972. [HttpPost]
  973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  974. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  975. {
  976. bool rst = false;
  977. if (_dto.EditType >= 0)
  978. {
  979. if (string.IsNullOrEmpty(_dto.VendorFullName))
  980. {
  981. return Ok(JsonView(false, "全称未填写"));
  982. }
  983. if (string.IsNullOrEmpty(_dto.VendorLinker))
  984. {
  985. return Ok(JsonView(false, "联系人未填写"));
  986. }
  987. if (string.IsNullOrEmpty(_dto.VendorMobile))
  988. {
  989. return Ok(JsonView(false, "联系人手机号未填写"));
  990. }
  991. if (string.IsNullOrEmpty(_dto.BusRange))
  992. {
  993. return Ok(JsonView(false, "经营范围未选择"));
  994. }
  995. if (_dto.EditType == 0)
  996. {
  997. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  998. if (checkEmpty != null)
  999. {
  1000. return Ok(JsonView(false, "已存在同名供应商"));
  1001. }
  1002. rst = await _resItemInfoRep.addVendorInfo(_dto);
  1003. }
  1004. else if (_dto.EditType == 1)
  1005. {
  1006. if (_dto.VendorId > 0)
  1007. {
  1008. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1009. rst = await _resItemInfoRep.updVendorInfo(_entity);
  1010. }
  1011. else
  1012. {
  1013. return Ok(JsonView(false, "供应商不存在"));
  1014. }
  1015. }
  1016. }
  1017. else
  1018. {
  1019. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  1020. {
  1021. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  1022. }
  1023. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1024. rst = await _resItemInfoRep.delVendorInfo(_entity);
  1025. }
  1026. return Ok(JsonView(rst));
  1027. }
  1028. #endregion
  1029. #region 物料信息
  1030. /// <summary>
  1031. /// 物料信息查询
  1032. /// </summary>
  1033. /// <param name="paras">Json序列化</param>
  1034. /// <returns></returns>
  1035. [HttpPost]
  1036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1037. public async Task<IActionResult> PostSearchItemInfo(string paras)
  1038. {
  1039. if (string.IsNullOrEmpty(paras))
  1040. {
  1041. return Ok(JsonView(false, "参数为空"));
  1042. }
  1043. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  1044. if (_ItemInfoDto != null)
  1045. {
  1046. if (_ItemInfoDto.SearchType == 2) //获取列表
  1047. {
  1048. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  1049. return Ok(rstList);
  1050. }
  1051. else
  1052. {
  1053. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  1054. return Ok(rstInfo);
  1055. }
  1056. }
  1057. else
  1058. {
  1059. return Ok(JsonView(false, "参数反序列化失败"));
  1060. }
  1061. return Ok(JsonView(false));
  1062. }
  1063. /// <summary>
  1064. /// 创建/编辑/删除物料信息
  1065. /// </summary>
  1066. ///
  1067. /// <returns></returns>
  1068. [HttpPost]
  1069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1070. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  1071. {
  1072. bool rst = false;
  1073. if (_dto.EditType >= 0)
  1074. {
  1075. if (_dto.VendorId < 1)
  1076. {
  1077. return Ok(JsonView(false, "未选择供应商"));
  1078. }
  1079. if (string.IsNullOrEmpty(_dto.ItemName))
  1080. {
  1081. return Ok(JsonView(false, "物料名称为空"));
  1082. }
  1083. if (_dto.ItemTypeId < 1)
  1084. {
  1085. return Ok(JsonView(false, "未选择物料类型"));
  1086. }
  1087. if (_dto.SysUserId < 1)
  1088. {
  1089. return Ok(JsonView(false, "当前操作用户Id为空"));
  1090. }
  1091. if (_dto.CurrRate <= 0)
  1092. {
  1093. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  1094. }
  1095. if (_dto.EditType == 0)
  1096. {
  1097. //判断物料名称、类型、供应商全部重复
  1098. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1099. if (checkEmpty != null)
  1100. {
  1101. return Ok(JsonView(false, "已存在重复物料信息"));
  1102. }
  1103. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1104. DateTime dtNow = DateTime.Now;
  1105. _entity.CreateUserId = _dto.SysUserId;
  1106. _entity.IsDel = 0;
  1107. _entity.MaxRate = _dto.CurrRate;
  1108. _entity.MaxDt = dtNow;
  1109. _entity.CurrRate = _dto.CurrRate;
  1110. _entity.CurrDt = dtNow;
  1111. _entity.MinRate = _dto.CurrRate;
  1112. _entity.MinDt = dtNow;
  1113. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1114. }
  1115. else if (_dto.EditType == 1)
  1116. {
  1117. if (_dto.ItemId > 0)
  1118. {
  1119. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1120. _entity.Id = _dto.ItemId;
  1121. rst = await _resItemInfoRep.updItemInfo(_entity);
  1122. }
  1123. else
  1124. {
  1125. return Ok(JsonView(false, "供应商不存在"));
  1126. }
  1127. }
  1128. }
  1129. else
  1130. {
  1131. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1132. {
  1133. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1134. }
  1135. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1136. rst = await _resItemInfoRep.delItemInfo(_entity);
  1137. }
  1138. return Ok(JsonView(rst));
  1139. }
  1140. #endregion
  1141. #region 物料类型获取
  1142. #endregion
  1143. #endregion
  1144. #region 备忘录
  1145. /// <summary>
  1146. /// 备忘录查询
  1147. /// </summary>
  1148. /// <param name="paras">Json序列化</param>
  1149. /// <returns></returns>
  1150. [HttpPost]
  1151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1152. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1153. {
  1154. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1155. {
  1156. return Ok(JsonView(false, "参数为空"));
  1157. }
  1158. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1159. if (_memoDto != null)
  1160. {
  1161. if (_memoDto.SearchType == 2)
  1162. {
  1163. //获取列表
  1164. string sqlWhere = string.Format(" Where IsDel=0 ");
  1165. #region SqlWhere
  1166. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1167. {
  1168. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1169. }
  1170. if (!string.IsNullOrEmpty(_memoDto.Title))
  1171. {
  1172. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1173. }
  1174. if (_memoDto.ReadLevel > 0)
  1175. {
  1176. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1177. }
  1178. #endregion
  1179. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1180. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1181. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1182. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1183. m.LastedEditDt,m.LastedEditorId
  1184. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1185. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1186. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1187. Res_MemoListView rst = new Res_MemoListView();
  1188. rst.CurrPageIndex = currPIndex;
  1189. rst.CurrPageSize = currPSize;
  1190. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1191. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1192. foreach (var item in dataSource)
  1193. {
  1194. if (userDic.ContainsKey(item.LastedEditorId))
  1195. {
  1196. item.LastedEditor = userDic[item.LastedEditorId];
  1197. }
  1198. else
  1199. {
  1200. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1201. userDic[item.LastedEditorId] = _sysUser.CnName;
  1202. item.LastedEditor = _sysUser.CnName;
  1203. }
  1204. }
  1205. rst.DataList = new List<Res_MemoView>(dataSource);
  1206. if (rst.DataList.Count > 0)
  1207. {
  1208. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1209. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1210. rst.DataCount = dataCount;
  1211. }
  1212. return Ok(JsonView(rst));
  1213. }
  1214. else
  1215. {
  1216. //获取对象
  1217. string sqlSingle = string.Format(@" Select
  1218. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1219. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1220. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1221. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1222. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1223. if (_result != null)
  1224. {
  1225. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1226. _result.LastedEditor = _sysUser.CnName;
  1227. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1228. return Ok(JsonView(_result));
  1229. }
  1230. }
  1231. }
  1232. else
  1233. {
  1234. return Ok(JsonView(false, "参数反序列化失败"));
  1235. }
  1236. return Ok(JsonView(false));
  1237. }
  1238. /// <summary>
  1239. /// 创建/编辑/删除备忘录信息
  1240. /// </summary>
  1241. /// <param name="_dto"></param>
  1242. /// <returns></returns>
  1243. [HttpPost]
  1244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1245. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1246. {
  1247. bool rst = false;
  1248. if (_dto.SysUserId < 1)
  1249. {
  1250. return Ok(JsonView(false, "操作人失效"));
  1251. }
  1252. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1253. if (_sysUser == null)
  1254. {
  1255. return Ok(JsonView(false, "操作人失效02"));
  1256. }
  1257. if (_dto.EditType >= 0)
  1258. {
  1259. if (_dto.ReadLevel < 1)
  1260. {
  1261. return Ok(JsonView(false, "未知的阅读等级"));
  1262. }
  1263. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1264. {
  1265. return Ok(JsonView(false, "标题不能为空"));
  1266. }
  1267. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1268. {
  1269. return Ok(JsonView(false, "正文内容不能为空"));
  1270. }
  1271. //新增备忘录
  1272. DateTime dtNow = DateTime.Now;
  1273. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1274. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1275. string content = JsonConvert.SerializeObject(_dto.Content);
  1276. if (_dto.EditType == 0)//新增
  1277. {
  1278. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1279. if (savePath.Length > 0)
  1280. {
  1281. Res_MemoInfo _insert = new Res_MemoInfo();
  1282. _insert.Abstracts = _dto.Abstracts;
  1283. _insert.Title = _dto.Title;
  1284. _insert.DepartmentId = _sysUser.DepId;
  1285. _insert.CreateUserId = _sysUser.Id;
  1286. _insert.LastedEditDt = dtNow;
  1287. _insert.LastedEditor = _sysUser.Id;
  1288. _insert.MDFilePath = savePath;
  1289. _insert.ReadLevel = _dto.ReadLevel;
  1290. _insert.Title = _dto.Title;
  1291. int result = await _resItemInfoRep.AddAsync(_insert);
  1292. return Ok(JsonView(result > 0));
  1293. }
  1294. else
  1295. {
  1296. return Ok(JsonView(false, "路径保存失败"));
  1297. }
  1298. }
  1299. else//修改
  1300. {
  1301. if (_dto.MemoId < 1)
  1302. {
  1303. return Ok(JsonView(false, "MemoId不存在"));
  1304. }
  1305. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1306. if (_source == null)
  1307. {
  1308. return Ok(JsonView(false, "MemoInfo不存在"));
  1309. }
  1310. //修改
  1311. string sourcePath = _source.MDFilePath;
  1312. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1313. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1314. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1315. if (savePath.Length > 0)
  1316. {
  1317. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1318. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1319. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1320. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1321. .SetColumns(it => it.MDFilePath == savePath)
  1322. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1323. .SetColumns(it => it.Title == _dto.Title)
  1324. .Where(s => s.Id == _source.Id)
  1325. .ExecuteCommandAsync();
  1326. return Ok(JsonView(result > 0));
  1327. }
  1328. }
  1329. }
  1330. else
  1331. {
  1332. //删除
  1333. if (_dto.MemoId < 1)
  1334. {
  1335. return Ok(JsonView(false, "MemoId不存在"));
  1336. }
  1337. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1338. if (_source == null)
  1339. {
  1340. return Ok(JsonView(false, "MemoInfo不存在"));
  1341. }
  1342. //修改
  1343. string sourcePath = _source.MDFilePath;
  1344. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1345. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1346. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1347. .SetColumns(it => it.IsDel == 1)
  1348. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1349. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1350. .Where(s => s.Id == _source.Id)
  1351. .ExecuteCommandAsync();
  1352. return Ok(JsonView(result > 0));
  1353. }
  1354. return Ok(JsonView(rst));
  1355. }
  1356. #endregion
  1357. #region 商邀资料
  1358. /// <summary>
  1359. /// 商邀资料 基础数据源
  1360. /// </summary>
  1361. /// <param name="dto"></param>
  1362. /// <returns></returns>
  1363. [HttpPost]
  1364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1365. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1366. {
  1367. try
  1368. {
  1369. #region 参数验证
  1370. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1371. #endregion
  1372. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1373. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).ToList();
  1374. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1375. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1376. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1377. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1378. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1379. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1380. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1381. var _data = new {
  1382. CountryData = _countryData,
  1383. InviterData = _inviterData,
  1384. DomainData = _domainData,
  1385. ContactData = _contactData,
  1386. GroupNameData = _groupNameData,
  1387. UserNameData = _userNameData,
  1388. };
  1389. return Ok(JsonView(true, $"查询成功!", _data));
  1390. }
  1391. catch (Exception ex)
  1392. {
  1393. return Ok(JsonView(false, ex.Message));
  1394. }
  1395. }
  1396. /// <summary>
  1397. /// 商邀资料查询
  1398. /// </summary>
  1399. /// <param name="dto"></param>
  1400. /// <returns></returns>
  1401. [HttpPost]
  1402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1403. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1404. {
  1405. try
  1406. {
  1407. #region 参数验证
  1408. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1409. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1410. #endregion
  1411. string sqlWhere = string.Empty;
  1412. if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
  1413. if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
  1414. if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
  1415. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
  1416. if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
  1417. if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
  1418. if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1419. {
  1420. sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
  1421. }
  1422. sqlWhere += string.Format(@"And i.Isdel={0}", 0);
  1423. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  1424. {
  1425. Regex r = new Regex("And");
  1426. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  1427. }
  1428. string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
  1429. i.*,u.CnName As CreateUserName
  1430. From Res_InvitationOfficialActivityData i
  1431. Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
  1432. int totalCount = 0;
  1433. List<InvitationOfficialActivityDataView> _ivitiesViews = _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  1434. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
  1435. foreach (var item in _ivitiesViews)
  1436. {
  1437. string delegationNameList = "";
  1438. if (!string.IsNullOrEmpty(item.Delegation))
  1439. {
  1440. string[] DelegationName = item.Delegation.Split(',');
  1441. for (int i = 0; i < DelegationName.Length; i++)
  1442. {
  1443. string grpId = DelegationName[i];
  1444. if (!string.IsNullOrEmpty(grpId))
  1445. {
  1446. if (grpId.IsNumeric())
  1447. {
  1448. delegationNameList += _DelegationInfos.Find(it => it.Id == int.Parse(grpId))?.TeamName ?? "Unknown" + ",";
  1449. }
  1450. }
  1451. }
  1452. if (!string.IsNullOrWhiteSpace(delegationNameList))
  1453. {
  1454. item.DelegationStr = delegationNameList.Substring(0, delegationNameList.Length - 1);
  1455. }
  1456. }
  1457. }
  1458. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1459. }
  1460. catch (Exception ex)
  1461. {
  1462. return Ok(JsonView(false, ex.Message));
  1463. }
  1464. }
  1465. /// <summary>
  1466. /// 根据商邀资料Id查询信息
  1467. /// </summary>
  1468. /// <param name="dto"></param>
  1469. /// <returns></returns>
  1470. [HttpPost]
  1471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1472. public async Task<IActionResult> QueryInvitationOfficialActivityById(QueryInvitationOfficialActivityByIdDto dto)
  1473. {
  1474. try
  1475. {
  1476. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityById(dto);
  1477. if (groupData.Code != 0)
  1478. {
  1479. return Ok(JsonView(false, groupData.Msg));
  1480. }
  1481. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1482. }
  1483. catch (Exception ex)
  1484. {
  1485. return Ok(JsonView(false, "程序错误!"));
  1486. throw;
  1487. }
  1488. }
  1489. /// <summary>
  1490. /// 商邀资料操作(Status:1.新增,2.修改)
  1491. /// </summary>
  1492. /// <param name="dto"></param>
  1493. /// <returns></returns>
  1494. [HttpPost]
  1495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1496. public async Task<IActionResult> OpInvitationOfficialActivity(OpInvitationOfficialActivityDto dto)
  1497. {
  1498. try
  1499. {
  1500. Result groupData = await _InvitationOfficialActivityDataRep.OpInvitationOfficialActivity(dto);
  1501. if (groupData.Code != 0)
  1502. {
  1503. return Ok(JsonView(false, groupData.Msg));
  1504. }
  1505. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1506. }
  1507. catch (Exception ex)
  1508. {
  1509. return Ok(JsonView(false, "程序错误!"));
  1510. throw;
  1511. }
  1512. }
  1513. /// <summary>
  1514. /// 删除商邀资料信息
  1515. /// </summary>
  1516. /// <param name="dto"></param>
  1517. /// <returns></returns>
  1518. [HttpPost]
  1519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1520. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1521. {
  1522. try
  1523. {
  1524. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1525. if (!res)
  1526. {
  1527. return Ok(JsonView(false, "删除失败"));
  1528. }
  1529. return Ok(JsonView(true, "删除成功!"));
  1530. }
  1531. catch (Exception ex)
  1532. {
  1533. return Ok(JsonView(false, "程序错误!"));
  1534. throw;
  1535. }
  1536. }
  1537. #endregion
  1538. #region 公务出访
  1539. /// <summary>
  1540. /// 获取团组所有信息,绑定下拉框
  1541. /// </summary>
  1542. /// <param name="dto"></param>
  1543. /// <returns></returns>
  1544. [HttpPost]
  1545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1546. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1547. {
  1548. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1549. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1550. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1551. dynamic groupInfos = null;
  1552. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1553. List<Sys_SetData> data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
  1554. List<Grp_DeleFile> _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1555. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile }));
  1556. }
  1557. [HttpPost]
  1558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1559. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1560. {
  1561. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
  1562. if (groupData.Code != 0)
  1563. {
  1564. return Ok(JsonView(false, groupData.Msg));
  1565. }
  1566. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1567. }
  1568. /// <summary>
  1569. /// 根据公务出访数据Id查询数据
  1570. /// </summary>
  1571. /// <param name="dto"></param>
  1572. /// <returns></returns>
  1573. [HttpPost]
  1574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1575. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1576. {
  1577. try
  1578. {
  1579. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1580. if (groupData.Code != 0)
  1581. {
  1582. return Ok(JsonView(false, groupData.Msg));
  1583. }
  1584. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1585. }
  1586. catch (Exception ex)
  1587. {
  1588. return Ok(JsonView(false, "程序错误!"));
  1589. throw;
  1590. }
  1591. }
  1592. /// <summary>
  1593. /// 公务出访操作(Status:1.新增,2.修改)
  1594. /// </summary>
  1595. /// <param name="dto"></param>
  1596. /// <returns></returns>
  1597. [HttpPost]
  1598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1599. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1600. {
  1601. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1602. if (groupData.Code != 0)
  1603. {
  1604. return Ok(JsonView(false, groupData.Msg));
  1605. }
  1606. try
  1607. {
  1608. //公务出访变更发送通知
  1609. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  1610. }
  1611. catch (Exception ex)
  1612. {
  1613. //抄送日志
  1614. }
  1615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1616. }
  1617. /// <summary>
  1618. /// 上传文件
  1619. /// </summary>
  1620. /// <param name="file"></param>
  1621. /// <returns></returns>
  1622. [HttpPost]
  1623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1624. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1625. {
  1626. try
  1627. {
  1628. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1629. int DiId = int.Parse(Request.Headers["DiId"]);
  1630. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  1631. if (file != null)
  1632. {
  1633. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1634. //文件名称
  1635. string projectFileName = file.FileName;
  1636. //上传的文件的路径
  1637. string filePath = "";
  1638. if (!Directory.Exists(fileDir))
  1639. {
  1640. Directory.CreateDirectory(fileDir);
  1641. }
  1642. //上传的文件的路径
  1643. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1644. using (FileStream fs = System.IO.File.Create(filePath))
  1645. {
  1646. file.CopyTo(fs);
  1647. fs.Flush();
  1648. }
  1649. Grp_DeleFile d = new Grp_DeleFile();
  1650. d.Diid = DiId;
  1651. d.Category = 970;
  1652. if (Type == 1) d.Kind = 1;
  1653. else if (Type == 2) d.Kind = 2;
  1654. else if (Type == 3) d.Kind = 3;
  1655. d.FileName = projectFileName;
  1656. d.FilePath = "";
  1657. d.CreateUserId = CreateUserId;
  1658. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1659. return Ok(JsonView(true, "上传成功!", projectFileName));
  1660. }
  1661. else
  1662. {
  1663. return Ok(JsonView(false, "上传失败!"));
  1664. }
  1665. }
  1666. catch (Exception ex)
  1667. {
  1668. return Ok(JsonView(false, "程序错误!"));
  1669. throw;
  1670. }
  1671. }
  1672. /// <summary>
  1673. /// 删除文件
  1674. /// </summary>
  1675. /// <param name="dto"></param>
  1676. /// <returns></returns>
  1677. [HttpPost]
  1678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1679. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  1680. {
  1681. try
  1682. {
  1683. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1684. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  1685. if (_DeleFile != null)
  1686. {
  1687. string fileName = _DeleFile.FileName;
  1688. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  1689. // 删除该文件
  1690. System.IO.File.Delete(filePath);
  1691. int id = await _sqlSugar.Updateable<Grp_DeleFile>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DeleFile { IsDel = 1, DeleteUserId = dto.DeleteUserId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }).ExecuteCommandAsync();
  1692. return Ok(JsonView(true, "取消文件成功!"));
  1693. }
  1694. else
  1695. {
  1696. return Ok(JsonView(false, "取消文件失败!"));
  1697. }
  1698. }
  1699. catch (Exception ex)
  1700. {
  1701. return Ok(JsonView(false, "程序错误!"));
  1702. throw;
  1703. }
  1704. }
  1705. /// <summary>
  1706. /// 删除公务出访信息
  1707. /// </summary>
  1708. /// <param name="dto"></param>
  1709. /// <returns></returns>
  1710. [HttpPost]
  1711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1712. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  1713. {
  1714. try
  1715. {
  1716. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1717. if (!res)
  1718. {
  1719. return Ok(JsonView(false, "删除失败"));
  1720. }
  1721. return Ok(JsonView(true, "删除成功!"));
  1722. }
  1723. catch (Exception ex)
  1724. {
  1725. return Ok(JsonView(false, "程序错误!"));
  1726. throw;
  1727. }
  1728. }
  1729. /// <summary>
  1730. /// 公务出访
  1731. /// 请示范例提示
  1732. /// Add Time:2024-05-13 13:56:44
  1733. /// </summary>
  1734. /// <param name="dto"></param>
  1735. /// <returns></returns>
  1736. [HttpPost]
  1737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1738. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  1739. {
  1740. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area,dto.client);
  1741. if (res.Code == 0)
  1742. {
  1743. return Ok(JsonView(true, "操作成功!", res.Data));
  1744. }
  1745. return Ok(JsonView(false, res.Msg));
  1746. }
  1747. /// <summary>
  1748. /// 公务出访 (省外办,市外办) File Downlaod
  1749. /// </summary>
  1750. /// <param name="dto"></param>
  1751. /// <returns></returns>
  1752. [HttpPost]
  1753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1754. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  1755. {
  1756. #region 参数验证
  1757. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示"));
  1758. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数."));
  1759. #endregion
  1760. //团组基础信息
  1761. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  1762. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在"));
  1763. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  1764. //团组公务信息
  1765. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  1766. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  1767. //团组客户名单
  1768. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  1769. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  1770. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  1771. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  1772. string countryStayStr = ""; // xx、xx、xx
  1773. //出入境费用 住宿类型
  1774. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  1775. if (dayCostDatas.Count > 0)
  1776. {
  1777. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  1778. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  1779. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  1780. foreach (var item in nationalDataGroupByCountry)
  1781. {
  1782. visitCountrys += $"{item.Key}、";
  1783. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  1784. countryStayStr += $"{item.Key}{stayDays}天,";
  1785. }
  1786. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  1787. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  1788. }
  1789. else
  1790. {
  1791. visitCountrys = groupInfo.VisitCountry;
  1792. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  1793. }
  1794. //出访人数
  1795. int visitPeopleNum = groupInfo.VisitPNumber;
  1796. int visitDaysNum = groupInfo.VisitDays;
  1797. //出访单位
  1798. string obInfoStr = "";
  1799. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  1800. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  1801. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  1802. //出访路线
  1803. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  1804. if (dto.FileType == 1)
  1805. {
  1806. //载入模板
  1807. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  1808. var doc = new Document(tempPath);
  1809. DocumentBuilder builder = new DocumentBuilder(doc);
  1810. //键值对存放数据
  1811. Dictionary<string, string> dic = new Dictionary<string, string>();
  1812. //××(组团单位):接团客户信息团组
  1813. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  1814. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  1815. string guestName = "";
  1816. string guestJob = "";
  1817. string guestInfoStr = "";
  1818. var guestFirstInfo = guestInfos.FirstOrDefault();
  1819. if (guestFirstInfo != null)
  1820. {
  1821. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  1822. guestJob = guestFirstInfo.Job.Trim();
  1823. guestInfoStr = $@"{guestJob}、{guestName}";
  1824. }
  1825. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  1826. string askTitle = $@"关于{guestInfoStr }等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  1827. dic.Add("AskTitle", askTitle);
  1828. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  1829. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  1830. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  1831. dic.Add("AskSubTitle", askSubTitle);
  1832. //出访目的
  1833. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  1834. //出访任务
  1835. //(一)××(国家或地区)
  1836. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1837. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1838. string obBackgroundStr = "";//出访背景
  1839. string taskStr = ""; ; //出访任务
  1840. var countrys = obDatas.GroupBy(it => it.Country);
  1841. int countryIndex = 1;
  1842. foreach (var item in countrys)
  1843. {
  1844. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  1845. string taskContent = "";
  1846. string obBackgroundContent = "";
  1847. int obIndex = 1;
  1848. foreach (var obInfo in item.ToList())
  1849. {
  1850. string reqSmaple = "";
  1851. string settingStr = "";
  1852. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  1853. else reqSmaple = "[公务出访请示范例未录入]";
  1854. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  1855. else settingStr = "[公务方背景未录入]";
  1856. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  1857. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  1858. obIndex++;
  1859. }
  1860. taskStr += $"{taskTitle}{taskContent}";
  1861. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  1862. countryIndex++;
  1863. }
  1864. //出访背景
  1865. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  1866. dic.Add("OBSetting", obBackgroundStr);
  1867. //出访任务
  1868. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  1869. dic.Add("TaskContent", taskStr);
  1870. //出访时间
  1871. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  1872. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  1873. //出访时间
  1874. dic.Add("TimeQuantum", visitTimeQuantumStr);
  1875. //出访路线
  1876. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  1877. dic.Add("Line", lineStr);
  1878. //scheduling //行程安排
  1879. string schedulingStr = $"[OP行程单暂未生成]";
  1880. #region op行程 根据黑屏代码录入
  1881. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  1882. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  1883. schedulingStr = "";
  1884. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  1885. travelList = opTripView.Data as List<Grp_TravelList>;
  1886. foreach (var item in travelList)
  1887. {
  1888. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  1889. }
  1890. #endregion
  1891. dic.Add("Scheduling", schedulingStr);
  1892. #region 填充word模板书签内容
  1893. foreach (var key in dic.Keys)
  1894. {
  1895. builder.MoveToBookmark(key);
  1896. builder.Write(dic[key]);
  1897. }
  1898. #endregion
  1899. //获取word里所有表格
  1900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  1901. //获取所填表格的序数
  1902. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  1903. var rowStart = tableOne.Rows[0]; //获取第1行
  1904. //循环赋值
  1905. for (int i = 0; i < guestInfos.Count; i++)
  1906. {
  1907. var guestInfo = guestInfos[i];
  1908. builder.MoveToCell(0, i + 1, 0, 0);
  1909. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  1910. builder.MoveToCell(0, i + 1, 1, 0);
  1911. int sex = guestInfo.Sex;
  1912. string sexStr = string.Empty;
  1913. if (sex == 0) sexStr = "男";
  1914. else if (sex == 1) sexStr = "女";
  1915. else sexStr = "-";
  1916. builder.Write(sexStr);
  1917. builder.MoveToCell(0, i + 1, 2, 0);
  1918. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  1919. builder.MoveToCell(0, i + 1, 3, 0);
  1920. string birthDay = "";
  1921. string birthDayStr = string.Empty;
  1922. if (guestInfo.BirthDay != null)
  1923. {
  1924. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  1925. }
  1926. builder.Write(birthDayStr);
  1927. }
  1928. //删除多余行
  1929. while (tableOne.Rows.Count > guestInfos.Count + 1)
  1930. {
  1931. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  1932. }
  1933. var fileDir = AppSettingsHelper.Get("WordBasePath");
  1934. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  1935. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  1936. doc.Save(filePath);
  1937. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  1938. return Ok(JsonView(true, "操作成功!", Url));
  1939. }
  1940. else if (dto.FileType == 2)
  1941. {
  1942. //载入模板
  1943. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  1944. var doc = new Document(tempPath);
  1945. DocumentBuilder builder = new DocumentBuilder(doc);
  1946. //键值对存放数据
  1947. Dictionary<string, string> dic = new Dictionary<string, string>();
  1948. //××(组团单位):接团客户信息团组
  1949. dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
  1950. dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
  1951. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  1952. string guestName = "";
  1953. string guestJob = "";
  1954. string guestInfoStr = "";
  1955. var guestFirstInfo = guestInfos.FirstOrDefault();
  1956. if (guestFirstInfo != null)
  1957. {
  1958. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  1959. guestJob = guestFirstInfo.Job;
  1960. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  1961. }
  1962. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  1963. dic.Add("ReqTitle", reqTitle);
  1964. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  1965. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  1966. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  1967. dic.Add("ReqSubTitle", reqSubTitle);
  1968. /*
  1969. * 出访任务
  1970. * (一)××(国家或地区)
  1971. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  1972. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  1973. *
  1974. */
  1975. string taskStr = string.Empty ;
  1976. List<string> countrys = obDatas.Select(it => it.Country).ToList();
  1977. int countryIndex = 1;
  1978. foreach (var item in countrys)
  1979. {
  1980. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  1981. string taskContent = "";
  1982. if (!string.IsNullOrEmpty(item))
  1983. {
  1984. var countryObDatas = obDatas.Where(it => it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  1985. int obIndex = 1;
  1986. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  1987. else
  1988. {
  1989. foreach (var obInfo in countryObDatas)
  1990. {
  1991. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  1992. obIndex++;
  1993. }
  1994. }
  1995. }
  1996. taskStr += $"{taskTitle}{taskContent}";
  1997. countryIndex++;
  1998. }
  1999. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  2000. //出访任务
  2001. dic.Add("TaskContent", taskStr);
  2002. //出访目的
  2003. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2004. //出访信息
  2005. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  2006. string tripInfoStr = "";
  2007. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  2008. dic.Add("TripInfo", tripInfoStr);
  2009. #region 填充word模板书签内容
  2010. foreach (var key in dic.Keys)
  2011. {
  2012. builder.MoveToBookmark(key);
  2013. builder.Write(dic[key]);
  2014. }
  2015. #endregion
  2016. //获取word里所有表格
  2017. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2018. //获取所填表格的序数
  2019. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2020. var rowStart = tableOne.Rows[0]; //获取第1行
  2021. //循环赋值
  2022. for (int i = 0; i < guestInfos.Count; i++)
  2023. {
  2024. var guestInfo = guestInfos[i];
  2025. builder.MoveToCell(0, i + 1, 0, 0);
  2026. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2027. builder.MoveToCell(0, i + 1, 1, 0);
  2028. int sex = guestInfo.Sex;
  2029. string sexStr = string.Empty;
  2030. if (sex == 0) sexStr = "男";
  2031. else if (sex == 1) sexStr = "女";
  2032. else sexStr = "未设置";
  2033. builder.Write(sexStr);
  2034. builder.MoveToCell(0, i + 1, 2, 0);
  2035. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2036. builder.MoveToCell(0, i + 1, 3, 0);
  2037. DateTime birthDay = guestInfo.BirthDay;
  2038. string birthDayStr = string.Empty;
  2039. if (birthDay != null)
  2040. {
  2041. birthDayStr = birthDay.ToString("yyyy.MM");
  2042. }
  2043. builder.Write(birthDayStr);
  2044. }
  2045. //删除多余行
  2046. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2047. {
  2048. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2049. }
  2050. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2051. string fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2052. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  2053. doc.Save(filePath);
  2054. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2055. return Ok(JsonView(true, "操作成功!", Url));
  2056. }
  2057. return Ok(JsonView(true, "操作失败!"));
  2058. }
  2059. private string GetToUpperNumber(int num)
  2060. {
  2061. string numStr = "";
  2062. if (num == 1) numStr = "一";
  2063. else if (num == 2) numStr = "二";
  2064. else if (num == 3) numStr = "三";
  2065. else if (num == 4) numStr = "四";
  2066. else if (num == 5) numStr = "五";
  2067. else if (num == 6) numStr = "六";
  2068. else if (num == 7) numStr = "七";
  2069. else if (num == 8) numStr = "八";
  2070. else if (num == 9) numStr = "九";
  2071. else if (num == 10) numStr = "十";
  2072. return numStr;
  2073. }
  2074. #endregion
  2075. #region 请示数据库
  2076. /// <summary>
  2077. /// 查询请示数据库初始化
  2078. /// </summary>
  2079. /// <param name="dto"></param>
  2080. /// <returns></returns>
  2081. [HttpPost]
  2082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2083. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  2084. {
  2085. try
  2086. {
  2087. Result groupData = await _askDataRep.QueryAskData(dto);
  2088. if (groupData.Code != 0)
  2089. {
  2090. return Ok(JsonView(false, groupData.Msg));
  2091. }
  2092. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2093. }
  2094. catch (Exception ex)
  2095. {
  2096. return Ok(JsonView(false, "程序错误!"));
  2097. throw;
  2098. }
  2099. }
  2100. /// <summary>
  2101. /// 根据Id查询请示数据库单挑数据
  2102. /// </summary>
  2103. /// <param name="dto"></param>
  2104. /// <returns></returns>
  2105. [HttpPost]
  2106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2107. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  2108. {
  2109. try
  2110. {
  2111. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  2112. if (_AskData==null)
  2113. {
  2114. return Ok(JsonView(true, "暂无数据!", _AskData));
  2115. }
  2116. return Ok(JsonView(true, "查询成功!", _AskData));
  2117. }
  2118. catch (Exception ex)
  2119. {
  2120. return Ok(JsonView(false, "程序错误!"));
  2121. throw;
  2122. }
  2123. }
  2124. /// <summary>
  2125. /// 请示数据库操作(Status:1.新增,2.修改)
  2126. /// </summary>
  2127. /// <param name="dto"></param>
  2128. /// <returns></returns>
  2129. [HttpPost]
  2130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2131. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  2132. {
  2133. try
  2134. {
  2135. Result groupData = await _askDataRep.OpAskData(dto);
  2136. if (groupData.Code != 0)
  2137. {
  2138. return Ok(JsonView(false, groupData.Msg));
  2139. }
  2140. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2141. }
  2142. catch (Exception ex)
  2143. {
  2144. return Ok(JsonView(false, "程序错误!"));
  2145. throw;
  2146. }
  2147. }
  2148. /// <summary>
  2149. /// 删除请示资料信息
  2150. /// </summary>
  2151. /// <param name="dto"></param>
  2152. /// <returns></returns>
  2153. [HttpPost]
  2154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2155. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  2156. {
  2157. try
  2158. {
  2159. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  2160. if (!res)
  2161. {
  2162. return Ok(JsonView(false, "删除失败"));
  2163. }
  2164. return Ok(JsonView(true, "删除成功!"));
  2165. }
  2166. catch (Exception ex)
  2167. {
  2168. return Ok(JsonView(false, "程序错误!"));
  2169. throw;
  2170. }
  2171. }
  2172. #endregion
  2173. #region 机票黑屏代码
  2174. /// <summary>
  2175. /// 根据团组Id查询黑屏代码列表
  2176. /// </summary>
  2177. /// <param name="dto"></param>
  2178. /// <returns></returns>
  2179. [HttpPost]
  2180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2181. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  2182. {
  2183. try
  2184. {
  2185. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  2186. if (groupData.Code != 0)
  2187. {
  2188. return Ok(JsonView(false, groupData.Msg));
  2189. }
  2190. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2191. }
  2192. catch (Exception ex)
  2193. {
  2194. return Ok(JsonView(false, "程序错误!"));
  2195. throw;
  2196. }
  2197. }
  2198. /// <summary>
  2199. /// 根据黑屏代码数据Id查询信息
  2200. /// </summary>
  2201. /// <param name="dto"></param>
  2202. /// <returns></returns>
  2203. [HttpPost]
  2204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2205. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  2206. {
  2207. try
  2208. {
  2209. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  2210. if (groupData.Code != 0)
  2211. {
  2212. return Ok(JsonView(false, groupData.Msg));
  2213. }
  2214. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2215. }
  2216. catch (Exception ex)
  2217. {
  2218. return Ok(JsonView(false, "程序错误!"));
  2219. throw;
  2220. }
  2221. }
  2222. /// <summary>
  2223. /// 黑屏代码操作(Status:1.新增,2.修改)
  2224. /// </summary>
  2225. /// <param name="dto"></param>
  2226. /// <returns></returns>
  2227. [HttpPost]
  2228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2229. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  2230. {
  2231. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  2232. if (groupData.Code != 0)
  2233. {
  2234. return Ok(JsonView(false, groupData.Msg));
  2235. }
  2236. try
  2237. {
  2238. //行程代码变更通知
  2239. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  2240. }
  2241. catch (Exception ex)
  2242. {
  2243. throw;
  2244. }
  2245. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2246. }
  2247. /// <summary>
  2248. /// 删除黑屏代码
  2249. /// </summary>
  2250. /// <param name="dto"></param>
  2251. /// <returns></returns>
  2252. [HttpPost]
  2253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2254. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  2255. {
  2256. try
  2257. {
  2258. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  2259. if (!res)
  2260. {
  2261. return Ok(JsonView(false, "删除失败"));
  2262. }
  2263. return Ok(JsonView(true, "删除成功!"));
  2264. }
  2265. catch (Exception ex)
  2266. {
  2267. return Ok(JsonView(false, "程序错误!"));
  2268. throw;
  2269. }
  2270. }
  2271. #endregion
  2272. }
  2273. }