ResourceController.cs 114 KB

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