ResourceController.cs 163 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044
  1. using Aspose.Words;
  2. using EyeSoft.Extensions;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.API.OAMethodLib;
  5. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  6. using OASystem.Domain.Dtos.CRM;
  7. using OASystem.Domain.Dtos.Groups;
  8. using OASystem.Domain.Dtos.PersonnelModule;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Domain.ViewModels.QiYeWeChat;
  12. using OASystem.Infrastructure.Repositories.Groups;
  13. using Org.BouncyCastle.Utilities.Encoders;
  14. using System.Data;
  15. using static OASystem.API.OAMethodLib.JWTHelper;
  16. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  17. namespace OASystem.API.Controllers
  18. {
  19. /// <summary>
  20. /// 资料相关
  21. /// </summary>
  22. //[Authorize]
  23. [Route("api/[controller]/[action]")]
  24. public class ResourceController : ControllerBase
  25. {
  26. private readonly IMapper _mapper;
  27. private readonly SqlSugarClient _sqlSugar;
  28. private readonly IConfiguration _config;
  29. private readonly CarDataRepository _carDataRep;
  30. private readonly LocalGuideDataRepository _localGuideDataRep;
  31. private readonly ThreeCodeRepository _ThreeCodeRep;
  32. private readonly HotelDataRepository _hotelDataRep;
  33. private readonly ResItemInfoRepository _resItemInfoRep;
  34. private readonly SetDataRepository _setDataRepository;
  35. private readonly CountryFeeRepository _countryFeeRep;
  36. private readonly SetDataTypeRepository _setDataTypeRep;
  37. private readonly AirTicketAgentRepository _airTicketAgentRep;
  38. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  39. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  40. private readonly AskDataRepository _askDataRep;
  41. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  42. private readonly TourClientListRepository _tourClientListRep;
  43. private readonly DelegationInfoRepository _delegationInfoRep;
  44. private readonly TranslatorLibraryRepository _translatorRep;
  45. public ResourceController(
  46. IMapper mapper,
  47. IConfiguration config,
  48. SqlSugarClient sqlSugar,
  49. CarDataRepository carDataRep,
  50. LocalGuideDataRepository localGuideDataRep,
  51. ThreeCodeRepository threeCodeRep,
  52. HotelDataRepository hotelDataRep,
  53. ResItemInfoRepository resItemInfoRep,
  54. SetDataRepository setDataRepository,
  55. CountryFeeRepository countryFeeRep,
  56. SetDataTypeRepository setDataTypeRep,
  57. AirTicketAgentRepository airTicketAgentRep,
  58. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
  59. OfficialActivitiesRepository officialActivitiesRep,
  60. AskDataRepository askDataRep,
  61. TicketBlackCodeRepository ticketBlackCodeRep,
  62. TourClientListRepository tourClientListRep,
  63. DelegationInfoRepository delegationInfoRep,
  64. TranslatorLibraryRepository translatorRep
  65. )
  66. {
  67. _mapper = mapper;
  68. _config = config;
  69. _sqlSugar = sqlSugar;
  70. _carDataRep = carDataRep;
  71. _localGuideDataRep = localGuideDataRep;
  72. _ThreeCodeRep = threeCodeRep;
  73. _hotelDataRep = hotelDataRep;
  74. _resItemInfoRep = resItemInfoRep;
  75. _setDataRepository = setDataRepository;
  76. _countryFeeRep = countryFeeRep;
  77. _setDataTypeRep = setDataTypeRep;
  78. _airTicketAgentRep = airTicketAgentRep;
  79. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  80. _officialActivitiesRep = officialActivitiesRep;
  81. _askDataRep = askDataRep;
  82. _ticketBlackCodeRep = ticketBlackCodeRep;
  83. _tourClientListRep = tourClientListRep;
  84. _delegationInfoRep = delegationInfoRep;
  85. _translatorRep = translatorRep;
  86. }
  87. #region 车公司资料板块
  88. /// <summary>
  89. /// 车公司信息查询
  90. /// </summary>
  91. /// <returns></returns>
  92. [HttpPost]
  93. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  94. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  95. {
  96. try
  97. {
  98. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  99. if (LocalGuide.Code == 0)
  100. {
  101. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  102. }
  103. else
  104. {
  105. return Ok(JsonView(false, LocalGuide.Msg));
  106. }
  107. }
  108. catch (Exception)
  109. {
  110. return Ok(JsonView(false, "程序错误!"));
  111. throw;
  112. }
  113. }
  114. /// <summary>
  115. /// 车公司资料下拉框数据
  116. /// </summary>
  117. /// <returns></returns>
  118. [HttpPost]
  119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  120. public async Task<IActionResult> QueryCarSelect()
  121. {
  122. try
  123. {
  124. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  125. if (CarData.Count == 0)
  126. {
  127. return Ok(JsonView(false, "暂无数据!"));
  128. }
  129. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  130. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  131. CarData = CarData.OrderBy(x => x.Id).ToList();
  132. List<CarDataSelectView> data = new List<CarDataSelectView>();
  133. foreach (CarDataSelectView car in CarData)
  134. {
  135. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  136. {
  137. data.Add(car);
  138. }
  139. }
  140. return Ok(JsonView(true, "查询成功", data));
  141. }
  142. catch (Exception)
  143. {
  144. return Ok(JsonView(false, "程序错误!"));
  145. throw;
  146. }
  147. }
  148. /// <summary>
  149. /// 根据Id查询车公司详细数据
  150. /// </summary>
  151. /// <returns></returns>
  152. [HttpPost]
  153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  154. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  155. {
  156. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  157. CarDataDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  158. if (info == null)
  159. {
  160. return Ok(JsonView(false, "未找到相关数据!"));
  161. }
  162. return Ok(JsonView(true, "查询成功", info));
  163. }
  164. /// <summary>
  165. /// 车公司信息添加
  166. /// </summary>
  167. /// <returns></returns>
  168. [HttpPost]
  169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  170. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  171. {
  172. try
  173. {
  174. if (dto.UnitArea == "")
  175. {
  176. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  177. }
  178. if (dto.UnitName == "")
  179. {
  180. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  181. }
  182. if (dto.Contact == "")
  183. {
  184. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  185. }
  186. if (dto.ContactTel == "")
  187. {
  188. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  189. }
  190. 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();
  191. if (carDada.Count != 0)
  192. {
  193. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  194. }
  195. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  196. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  197. if (id == 0)
  198. {
  199. return Ok(JsonView(false, "添加失败!"));
  200. }
  201. return Ok(JsonView(true, "添加成功", new { Id = id }));
  202. }
  203. catch (Exception ex)
  204. {
  205. return Ok(JsonView(false, "程序错误!"));
  206. throw;
  207. }
  208. }
  209. /// <summary>
  210. /// 车公司信息修改
  211. /// </summary>
  212. /// <returns></returns>
  213. [HttpPost]
  214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  215. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  216. {
  217. try
  218. {
  219. if (dto.UnitArea == "")
  220. {
  221. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  222. }
  223. if (dto.UnitName == "")
  224. {
  225. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  226. }
  227. if (dto.Contact == "")
  228. {
  229. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  230. }
  231. if (dto.ContactTel == "")
  232. {
  233. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  234. }
  235. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  236. {
  237. UnitArea = dto.UnitArea,
  238. UnitName = dto.UnitName,
  239. Address = dto.Address,
  240. Contact = dto.Contact,
  241. ContactTel = dto.ContactTel,
  242. ContactEmail = dto.ContactEmail,
  243. ContactFax = dto.ContactFax,
  244. CarDes = dto.CarDes,
  245. CarPicPaths = dto.CarPicPaths,
  246. OtherInfo = dto.OtherInfo,
  247. Score = dto.Score,
  248. QualificationScore = dto.QualificationScore,
  249. CarAgeScore = dto.CarAgeScore,
  250. CleanImgScore = dto.CleanImgScore,
  251. SmellScore = dto.SmellScore,
  252. WaterPaperScore = dto.WaterPaperScore,
  253. HardwareScore = dto.HardwareScore,
  254. TimeScore = dto.TimeScore,
  255. SafetyScore = dto.SafetyScore,
  256. DrivingAgeScore = dto.DrivingAgeScore,
  257. Remark = dto.Remark,
  258. });
  259. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  260. return Ok(JsonView(true, "修改成功"));
  261. }
  262. catch (Exception ex)
  263. {
  264. return Ok(JsonView(false, "程序错误!"));
  265. throw;
  266. }
  267. }
  268. /// <summary>
  269. /// 车公司信息删除
  270. /// </summary>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  275. {
  276. try
  277. {
  278. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  279. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  280. return Ok(JsonView(true, "删除成功"));
  281. }
  282. catch (Exception ex)
  283. {
  284. return Ok(JsonView(false, "程序错误!"));
  285. throw;
  286. }
  287. }
  288. #endregion
  289. #region 导游地接资料板块
  290. /// <summary>
  291. /// 导游地接资料查询
  292. /// </summary>
  293. /// <param name="dto"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  298. {
  299. try
  300. {
  301. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  302. if (LocalGuide.Code == 0)
  303. {
  304. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  305. }
  306. else
  307. {
  308. return Ok(JsonView(false, LocalGuide.Msg));
  309. }
  310. }
  311. catch (Exception ex)
  312. {
  313. return Ok(JsonView(false, "程序错误!"));
  314. throw;
  315. }
  316. }
  317. /// <summary>
  318. /// 导游地接资料下拉框数据
  319. /// </summary>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<IActionResult> QueryLocalGuideSelect()
  324. {
  325. try
  326. {
  327. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  328. if (LocalGuide.Count == 0)
  329. {
  330. return Ok(JsonView(false, "暂无数据!"));
  331. }
  332. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  333. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  334. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  335. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  336. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  337. {
  338. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  339. {
  340. data.Add(Local);
  341. }
  342. }
  343. return Ok(JsonView(true, "查询成功", data));
  344. }
  345. catch (Exception)
  346. {
  347. return Ok(JsonView(false, "程序错误!"));
  348. throw;
  349. }
  350. }
  351. /// <summary>
  352. /// 根据Id查询地接详细数据
  353. /// </summary>
  354. /// <returns></returns>
  355. [HttpPost]
  356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  357. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  358. {
  359. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  360. LocalGuideDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  361. if (info == null)
  362. {
  363. return Ok(JsonView(false, "未找到相关数据!"));
  364. }
  365. return Ok(JsonView(true, "查询成功", info));
  366. }
  367. /// <summary>
  368. /// 导游地接信息操作(Status:1.新增,2.修改)
  369. /// </summary>
  370. /// <returns></returns>
  371. [HttpPost]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  374. {
  375. try
  376. {
  377. if (dto.UnitArea == "")
  378. {
  379. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  380. }
  381. if (dto.UnitName == "")
  382. {
  383. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  384. }
  385. if (dto.Contact == "")
  386. {
  387. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  388. }
  389. if (dto.ContactTel == "")
  390. {
  391. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  392. }
  393. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  394. if (result.Code != 0)
  395. {
  396. return Ok(JsonView(false, result.Msg));
  397. }
  398. return Ok(JsonView(true, result.Msg));
  399. }
  400. catch (Exception ex)
  401. {
  402. return Ok(JsonView(false, "程序错误!"));
  403. throw;
  404. }
  405. }
  406. /// <summary>
  407. /// 导游地接信息操作(删除)
  408. /// </summary>
  409. /// <returns></returns>
  410. [HttpPost]
  411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  412. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  413. {
  414. try
  415. {
  416. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  417. if (!res)
  418. {
  419. return Ok(JsonView(false, "删除失败"));
  420. }
  421. return Ok(JsonView(true, "删除成功!"));
  422. }
  423. catch (Exception ex)
  424. {
  425. return Ok(JsonView(false, "程序错误!"));
  426. throw;
  427. }
  428. }
  429. #endregion
  430. #region 机场三字码信息
  431. /// <summary>
  432. /// 机场三字码查询
  433. /// </summary>
  434. /// <param name="dto"></param>
  435. /// <returns></returns>
  436. [HttpPost]
  437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  438. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  439. {
  440. try
  441. {
  442. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  443. if (LocalGuide.Code == 0)
  444. {
  445. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  446. }
  447. else
  448. {
  449. return Ok(JsonView(false, LocalGuide.Msg));
  450. }
  451. }
  452. catch (Exception ex)
  453. {
  454. return Ok(JsonView(false, "程序错误!"));
  455. throw;
  456. }
  457. }
  458. /// <summary>
  459. /// 机场三字码数据城市下拉框数据
  460. /// </summary>
  461. /// <returns></returns>
  462. [HttpPost]
  463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  464. public async Task<IActionResult> QueryThreeCodeSelect()
  465. {
  466. try
  467. {
  468. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  469. if (ThreeCode.Count == 0)
  470. {
  471. return Ok(JsonView(false, "暂无数据!"));
  472. }
  473. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  474. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  475. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  476. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  477. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  478. {
  479. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  480. {
  481. data.Add(_ThreeCode);
  482. }
  483. }
  484. return Ok(JsonView(true, "查询成功", data));
  485. }
  486. catch (Exception)
  487. {
  488. return Ok(JsonView(false, "程序错误!"));
  489. throw;
  490. }
  491. }
  492. /// <summary>
  493. /// 机场三字码资料操作(Status:1.新增,2.修改)
  494. /// </summary>
  495. /// <param name="dto"></param>
  496. /// <returns></returns>
  497. [HttpPost]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  500. {
  501. try
  502. {
  503. if (dto.Three == "")
  504. {
  505. return Ok(JsonView(false, "请检查三字码是否填写!"));
  506. }
  507. if (dto.Country == "")
  508. {
  509. return Ok(JsonView(false, "请检查国家是否填写!"));
  510. }
  511. if (dto.City == "")
  512. {
  513. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  514. }
  515. if (dto.AirPort == "")
  516. {
  517. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  518. }
  519. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  520. if (result.Code != 0)
  521. {
  522. return Ok(JsonView(false, result.Msg));
  523. }
  524. return Ok(JsonView(true, result.Msg));
  525. }
  526. catch (Exception ex)
  527. {
  528. return Ok(JsonView(false, "程序错误!"));
  529. throw;
  530. }
  531. }
  532. /// <summary>
  533. /// 机场三字码资料操作(删除)
  534. /// </summary>
  535. /// <returns></returns>
  536. [HttpPost]
  537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  538. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  539. {
  540. try
  541. {
  542. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  543. if (!res)
  544. {
  545. return Ok(JsonView(false, "删除失败"));
  546. }
  547. return Ok(JsonView(true, "删除成功!"));
  548. }
  549. catch (Exception ex)
  550. {
  551. return Ok(JsonView(false, "程序错误!"));
  552. throw;
  553. }
  554. }
  555. /// <summary>
  556. ///根据ID查询三字码信息
  557. /// </summary>
  558. /// <returns></returns>
  559. [HttpPost]
  560. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  561. {
  562. var jw = JsonView(false);
  563. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  564. if (single != null)
  565. {
  566. jw = JsonView(true, "获取成功!", new
  567. {
  568. single.Three,
  569. Four = single.Four?.Trim(),
  570. single.AirPort,
  571. single.AirPort_En,
  572. single.City,
  573. single.Country,
  574. single.Remark
  575. });
  576. }
  577. else
  578. {
  579. jw.Msg = "暂无!";
  580. }
  581. return Ok(jw);
  582. }
  583. #endregion
  584. #region 代理出票合作方资料
  585. /// <summary>
  586. /// 代理出票合作方资料
  587. /// </summary>
  588. /// <param name="dto"></param>
  589. /// <returns></returns>
  590. [HttpPost]
  591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  592. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  593. {
  594. try
  595. {
  596. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  597. if (res_AirTicketAgents.Count != 0)
  598. {
  599. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  600. if (dto.PageSize == 0 && dto.PageIndex == 0)
  601. {
  602. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  603. }
  604. else
  605. {
  606. int count = res_AirTicketAgents.Count;
  607. float totalPage = (float)count / dto.PageSize;//总页数
  608. if (totalPage == 0) totalPage = 1;
  609. else totalPage = (int)Math.Ceiling((double)totalPage);
  610. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  611. for (int i = 0; i < dto.PageSize; i++)
  612. {
  613. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  614. if (RowIndex < res_AirTicketAgents.Count)
  615. {
  616. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  617. }
  618. else
  619. {
  620. break;
  621. }
  622. }
  623. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  624. }
  625. }
  626. else
  627. {
  628. return Ok(JsonView(false, "暂无数据!"));
  629. }
  630. }
  631. catch (Exception ex)
  632. {
  633. return Ok(JsonView(false, "程序错误!"));
  634. throw;
  635. }
  636. }
  637. /// <summary>
  638. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  639. /// </summary>
  640. /// <param name="dto"></param>
  641. /// <returns></returns>
  642. [HttpPost]
  643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  644. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  645. {
  646. try
  647. {
  648. if (dto.Account == "")
  649. {
  650. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  651. }
  652. if (dto.Bank == "")
  653. {
  654. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  655. }
  656. if (dto.Name == "")
  657. {
  658. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  659. }
  660. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  661. if (result.Code != 0)
  662. {
  663. return Ok(JsonView(false, result.Msg));
  664. }
  665. return Ok(JsonView(true, result.Msg));
  666. }
  667. catch (Exception ex)
  668. {
  669. return Ok(JsonView(false, "程序错误!"));
  670. throw;
  671. }
  672. }
  673. /// <summary>
  674. /// 代理出票合作方资料操作(删除)
  675. /// </summary>
  676. /// <returns></returns>
  677. [HttpPost]
  678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  679. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  680. {
  681. try
  682. {
  683. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  684. if (!res)
  685. {
  686. return Ok(JsonView(false, "删除失败"));
  687. }
  688. return Ok(JsonView(true, "删除成功!"));
  689. }
  690. catch (Exception ex)
  691. {
  692. return Ok(JsonView(false, "程序错误!"));
  693. throw;
  694. }
  695. }
  696. #endregion
  697. #region 酒店资料数据
  698. /// <summary>
  699. /// 酒店信息查询 Page
  700. /// </summary>
  701. /// <param name="dto"></param>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  706. {
  707. string sqlWhere = string.Empty;
  708. if (!string.IsNullOrWhiteSpace(dto.Name))
  709. {
  710. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", dto.Name);
  711. }
  712. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  713. {
  714. sqlWhere += string.Format(@" And hd.City like '%{0}%'", dto.City);
  715. }
  716. if (!string.IsNullOrWhiteSpace(dto.Contact))
  717. {
  718. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", dto.Contact);
  719. }
  720. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  721. {
  722. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", dto.ContactPhone);
  723. }
  724. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  725. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  726. {
  727. Regex r = new Regex("And");
  728. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  729. }
  730. string sql = string.Format(@"SELECT
  731. *
  732. FROM
  733. (
  734. SELECT
  735. ROW_NUMBER() OVER (
  736. ORDER BY
  737. hd.CreateTime DESC
  738. ) AS Row_Number,
  739. hd.Id,
  740. hd.City,
  741. hd.[Name],
  742. hd.Tel,
  743. hd.Fax,
  744. hd.Contact,
  745. hd.ContactPhone,
  746. u.CnName AS CreateUserName,
  747. hd.CreateTime
  748. FROM
  749. Res_HotelData hd
  750. WITH
  751. (NoLock)
  752. LEFT JOIN Sys_Users u
  753. WITH
  754. (NoLock) ON hd.CreateUserId = u.Id {0}
  755. ) Temp
  756. ", sqlWhere);
  757. if (dto.PortType == 1)
  758. {
  759. List<HotelDataItemView> HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  760. if (HotelDataData.Count == 0)
  761. {
  762. return Ok(JsonView(false, "暂无数据"));
  763. }
  764. return Ok(JsonView(true, "操作成功", HotelDataData));
  765. }
  766. else if (dto.PortType == 2 || dto.PortType == 3)
  767. {
  768. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  769. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  770. return Ok(JsonView(true, "操作成功", data, total));
  771. }
  772. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  773. }
  774. /// <summary>
  775. /// 酒店资料
  776. /// 详情
  777. /// add time:2024-05-14 11:57:10
  778. /// </summary>
  779. /// <returns></returns>
  780. [HttpPost]
  781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  782. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  783. {
  784. var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
  785. if (_view.Code == 0)
  786. {
  787. return Ok(JsonView(true, _view.Msg, _view.Data));
  788. }
  789. return Ok(JsonView(false, _view.Msg));
  790. }
  791. /// <summary>
  792. /// 酒店资料下拉框数据
  793. /// </summary>
  794. /// <returns></returns>
  795. [HttpPost]
  796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  797. public async Task<IActionResult> QueryHotelDataSelect()
  798. {
  799. try
  800. {
  801. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  802. if (HotelData.Count == 0)
  803. {
  804. return Ok(JsonView(false, "暂无数据!"));
  805. }
  806. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  807. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  808. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  809. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  810. foreach (QueryHotelDataSelect Hotel in HotelData)
  811. {
  812. if (!string.IsNullOrWhiteSpace(Hotel.City))
  813. {
  814. data.Add(Hotel);
  815. }
  816. }
  817. return Ok(JsonView(true, "查询成功", data));
  818. }
  819. catch (Exception)
  820. {
  821. return Ok(JsonView(false, "程序错误!"));
  822. throw;
  823. }
  824. }
  825. /// <summary>
  826. /// 酒店资料操作(Status:1.新增,2.修改)
  827. /// </summary>
  828. /// <param name="dto"></param>
  829. /// <returns></returns>
  830. [HttpPost]
  831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  832. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  833. {
  834. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  835. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  836. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  837. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  838. Result result = await _hotelDataRep.OperationHotelData(dto);
  839. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  840. return Ok(JsonView(true, result.Msg));
  841. }
  842. /// <summary>
  843. /// 酒店资料操作(删除)
  844. /// </summary>
  845. /// <returns></returns>
  846. [HttpPost]
  847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  848. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  849. {
  850. try
  851. {
  852. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  853. if (!res)
  854. {
  855. return Ok(JsonView(false, "删除失败"));
  856. }
  857. return Ok(JsonView(true, "删除成功!"));
  858. }
  859. catch (Exception ex)
  860. {
  861. return Ok(JsonView(false, "程序错误!"));
  862. throw;
  863. }
  864. }
  865. #endregion
  866. #region 签证费用资料
  867. /// <summary>
  868. /// 签证费用资料查询
  869. /// </summary>
  870. /// <param name="dto"></param>
  871. /// <returns></returns>
  872. [HttpPost]
  873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  874. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  875. {
  876. if (dto.PortType == 1)
  877. {
  878. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  879. if (CountryFee.Count == 0)
  880. {
  881. return Ok(JsonView(false, "暂无数据!"));
  882. }
  883. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  884. return Ok(JsonView(true, "查询成功", CountryFee));
  885. }
  886. else if (dto.PortType == 2)
  887. {
  888. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  889. if (CountryFee.Count == 0)
  890. {
  891. return Ok(JsonView(false, "暂无数据!"));
  892. }
  893. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  894. return Ok(JsonView(true, "查询成功", CountryFee));
  895. }
  896. else
  897. {
  898. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  899. }
  900. }
  901. /// <summary>
  902. /// 签证费用资料操作(Status:1.新增,2.修改)
  903. /// </summary>
  904. /// <param name="dto"></param>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  909. {
  910. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  911. {
  912. return Ok(JsonView(false, "请检查州名是否填写!"));
  913. }
  914. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  915. {
  916. return Ok(JsonView(false, "请检查国家名是否填写!"));
  917. }
  918. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  919. {
  920. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  921. }
  922. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  923. {
  924. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  925. }
  926. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  927. if (result.Code == 0)
  928. {
  929. return Ok(JsonView(true, result.Msg));
  930. }
  931. return Ok(JsonView(false, result.Msg));
  932. }
  933. /// <summary>
  934. /// 签证费用资料操作(删除)
  935. /// </summary>
  936. /// <returns></returns>
  937. [HttpPost]
  938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  939. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  940. {
  941. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  942. if (!res)
  943. {
  944. return Ok(JsonView(false, "删除失败"));
  945. }
  946. return Ok(JsonView(true, "删除成功!"));
  947. }
  948. #endregion
  949. #region 物料信息、供应商维护
  950. #region 供应商
  951. /// <summary>
  952. /// 物料供应商查询
  953. /// </summary>
  954. /// <param name="paras">Json序列化</param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  959. {
  960. if (string.IsNullOrEmpty(_jsonDto.Paras))
  961. {
  962. return Ok(JsonView(false, "参数为空"));
  963. }
  964. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  965. if (_ItemVendorDto != null)
  966. {
  967. if (_ItemVendorDto.SearchType == 2) //获取列表
  968. {
  969. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  970. return Ok(rstList);
  971. }
  972. else
  973. {
  974. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  975. return Ok(rstInfo);
  976. }
  977. }
  978. else
  979. {
  980. return Ok(JsonView(false, "参数反序列化失败"));
  981. }
  982. return Ok(JsonView(false));
  983. }
  984. /// <summary>
  985. /// 创建/编辑/删除供应商信息
  986. /// </summary>
  987. /// <param name="_dto"></param>
  988. /// <returns></returns>
  989. [HttpPost]
  990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  991. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  992. {
  993. bool rst = false;
  994. if (_dto.EditType >= 0)
  995. {
  996. if (string.IsNullOrEmpty(_dto.VendorFullName))
  997. {
  998. return Ok(JsonView(false, "全称未填写"));
  999. }
  1000. if (string.IsNullOrEmpty(_dto.VendorLinker))
  1001. {
  1002. return Ok(JsonView(false, "联系人未填写"));
  1003. }
  1004. if (string.IsNullOrEmpty(_dto.VendorMobile))
  1005. {
  1006. return Ok(JsonView(false, "联系人手机号未填写"));
  1007. }
  1008. if (string.IsNullOrEmpty(_dto.BusRange))
  1009. {
  1010. return Ok(JsonView(false, "经营范围未选择"));
  1011. }
  1012. if (_dto.EditType == 0)
  1013. {
  1014. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  1015. if (checkEmpty != null)
  1016. {
  1017. return Ok(JsonView(false, "已存在同名供应商"));
  1018. }
  1019. rst = await _resItemInfoRep.addVendorInfo(_dto);
  1020. }
  1021. else if (_dto.EditType == 1)
  1022. {
  1023. if (_dto.VendorId > 0)
  1024. {
  1025. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1026. rst = await _resItemInfoRep.updVendorInfo(_entity);
  1027. }
  1028. else
  1029. {
  1030. return Ok(JsonView(false, "供应商不存在"));
  1031. }
  1032. }
  1033. }
  1034. else
  1035. {
  1036. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  1037. {
  1038. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  1039. }
  1040. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1041. rst = await _resItemInfoRep.delVendorInfo(_entity);
  1042. }
  1043. return Ok(JsonView(rst));
  1044. }
  1045. #endregion
  1046. #region 物料信息
  1047. /// <summary>
  1048. /// 物料信息查询
  1049. /// </summary>
  1050. /// <param name="paras">Json序列化</param>
  1051. /// <returns></returns>
  1052. [HttpPost]
  1053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1054. public async Task<IActionResult> PostSearchItemInfo(string paras)
  1055. {
  1056. if (string.IsNullOrEmpty(paras))
  1057. {
  1058. return Ok(JsonView(false, "参数为空"));
  1059. }
  1060. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  1061. if (_ItemInfoDto != null)
  1062. {
  1063. if (_ItemInfoDto.SearchType == 2) //获取列表
  1064. {
  1065. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  1066. return Ok(rstList);
  1067. }
  1068. else
  1069. {
  1070. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  1071. return Ok(rstInfo);
  1072. }
  1073. }
  1074. else
  1075. {
  1076. return Ok(JsonView(false, "参数反序列化失败"));
  1077. }
  1078. return Ok(JsonView(false));
  1079. }
  1080. /// <summary>
  1081. /// 创建/编辑/删除物料信息
  1082. /// </summary>
  1083. ///
  1084. /// <returns></returns>
  1085. [HttpPost]
  1086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1087. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  1088. {
  1089. bool rst = false;
  1090. if (_dto.EditType >= 0)
  1091. {
  1092. if (_dto.VendorId < 1)
  1093. {
  1094. return Ok(JsonView(false, "未选择供应商"));
  1095. }
  1096. if (string.IsNullOrEmpty(_dto.ItemName))
  1097. {
  1098. return Ok(JsonView(false, "物料名称为空"));
  1099. }
  1100. if (_dto.ItemTypeId < 1)
  1101. {
  1102. return Ok(JsonView(false, "未选择物料类型"));
  1103. }
  1104. if (_dto.SysUserId < 1)
  1105. {
  1106. return Ok(JsonView(false, "当前操作用户Id为空"));
  1107. }
  1108. if (_dto.CurrRate <= 0)
  1109. {
  1110. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  1111. }
  1112. if (_dto.EditType == 0)
  1113. {
  1114. //判断物料名称、类型、供应商全部重复
  1115. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1116. if (checkEmpty != null)
  1117. {
  1118. return Ok(JsonView(false, "已存在重复物料信息"));
  1119. }
  1120. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1121. DateTime dtNow = DateTime.Now;
  1122. _entity.CreateUserId = _dto.SysUserId;
  1123. _entity.IsDel = 0;
  1124. _entity.MaxRate = _dto.CurrRate;
  1125. _entity.MaxDt = dtNow;
  1126. _entity.CurrRate = _dto.CurrRate;
  1127. _entity.CurrDt = dtNow;
  1128. _entity.MinRate = _dto.CurrRate;
  1129. _entity.MinDt = dtNow;
  1130. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1131. }
  1132. else if (_dto.EditType == 1)
  1133. {
  1134. if (_dto.ItemId > 0)
  1135. {
  1136. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1137. _entity.Id = _dto.ItemId;
  1138. rst = await _resItemInfoRep.updItemInfo(_entity);
  1139. }
  1140. else
  1141. {
  1142. return Ok(JsonView(false, "供应商不存在"));
  1143. }
  1144. }
  1145. }
  1146. else
  1147. {
  1148. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1149. {
  1150. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1151. }
  1152. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1153. rst = await _resItemInfoRep.delItemInfo(_entity);
  1154. }
  1155. return Ok(JsonView(rst));
  1156. }
  1157. #endregion
  1158. #region 物料类型获取
  1159. #endregion
  1160. #endregion
  1161. #region 备忘录
  1162. /// <summary>
  1163. /// 备忘录查询
  1164. /// </summary>
  1165. /// <param name="paras">Json序列化</param>
  1166. /// <returns></returns>
  1167. [HttpPost]
  1168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1169. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1170. {
  1171. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1172. {
  1173. return Ok(JsonView(false, "参数为空"));
  1174. }
  1175. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1176. if (_memoDto != null)
  1177. {
  1178. if (_memoDto.SearchType == 2)
  1179. {
  1180. //获取列表
  1181. string sqlWhere = string.Format(" Where IsDel=0 ");
  1182. #region SqlWhere
  1183. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1184. {
  1185. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1186. }
  1187. if (!string.IsNullOrEmpty(_memoDto.Title))
  1188. {
  1189. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1190. }
  1191. if (_memoDto.ReadLevel > 0)
  1192. {
  1193. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1194. }
  1195. #endregion
  1196. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1197. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1198. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1199. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1200. m.LastedEditDt,m.LastedEditorId
  1201. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1202. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1203. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1204. Res_MemoListView rst = new Res_MemoListView();
  1205. rst.CurrPageIndex = currPIndex;
  1206. rst.CurrPageSize = currPSize;
  1207. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1208. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1209. foreach (var item in dataSource)
  1210. {
  1211. if (userDic.ContainsKey(item.LastedEditorId))
  1212. {
  1213. item.LastedEditor = userDic[item.LastedEditorId];
  1214. }
  1215. else
  1216. {
  1217. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1218. userDic[item.LastedEditorId] = _sysUser.CnName;
  1219. item.LastedEditor = _sysUser.CnName;
  1220. }
  1221. }
  1222. rst.DataList = new List<Res_MemoView>(dataSource);
  1223. if (rst.DataList.Count > 0)
  1224. {
  1225. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1226. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1227. rst.DataCount = dataCount;
  1228. }
  1229. return Ok(JsonView(rst));
  1230. }
  1231. else
  1232. {
  1233. //获取对象
  1234. string sqlSingle = string.Format(@" Select
  1235. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1236. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1237. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1238. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1239. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1240. if (_result != null)
  1241. {
  1242. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1243. _result.LastedEditor = _sysUser.CnName;
  1244. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1245. return Ok(JsonView(_result));
  1246. }
  1247. }
  1248. }
  1249. else
  1250. {
  1251. return Ok(JsonView(false, "参数反序列化失败"));
  1252. }
  1253. return Ok(JsonView(false));
  1254. }
  1255. /// <summary>
  1256. /// 创建/编辑/删除备忘录信息
  1257. /// </summary>
  1258. /// <param name="_dto"></param>
  1259. /// <returns></returns>
  1260. [HttpPost]
  1261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1262. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1263. {
  1264. bool rst = false;
  1265. if (_dto.SysUserId < 1)
  1266. {
  1267. return Ok(JsonView(false, "操作人失效"));
  1268. }
  1269. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1270. if (_sysUser == null)
  1271. {
  1272. return Ok(JsonView(false, "操作人失效02"));
  1273. }
  1274. if (_dto.EditType >= 0)
  1275. {
  1276. if (_dto.ReadLevel < 1)
  1277. {
  1278. return Ok(JsonView(false, "未知的阅读等级"));
  1279. }
  1280. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1281. {
  1282. return Ok(JsonView(false, "标题不能为空"));
  1283. }
  1284. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1285. {
  1286. return Ok(JsonView(false, "正文内容不能为空"));
  1287. }
  1288. //新增备忘录
  1289. DateTime dtNow = DateTime.Now;
  1290. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1291. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1292. string content = JsonConvert.SerializeObject(_dto.Content);
  1293. if (_dto.EditType == 0)//新增
  1294. {
  1295. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1296. if (savePath.Length > 0)
  1297. {
  1298. Res_MemoInfo _insert = new Res_MemoInfo();
  1299. _insert.Abstracts = _dto.Abstracts;
  1300. _insert.Title = _dto.Title;
  1301. _insert.DepartmentId = _sysUser.DepId;
  1302. _insert.CreateUserId = _sysUser.Id;
  1303. _insert.LastedEditDt = dtNow;
  1304. _insert.LastedEditor = _sysUser.Id;
  1305. _insert.MDFilePath = savePath;
  1306. _insert.ReadLevel = _dto.ReadLevel;
  1307. _insert.Title = _dto.Title;
  1308. int result = await _resItemInfoRep.AddAsync(_insert);
  1309. return Ok(JsonView(result > 0));
  1310. }
  1311. else
  1312. {
  1313. return Ok(JsonView(false, "路径保存失败"));
  1314. }
  1315. }
  1316. else//修改
  1317. {
  1318. if (_dto.MemoId < 1)
  1319. {
  1320. return Ok(JsonView(false, "MemoId不存在"));
  1321. }
  1322. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1323. if (_source == null)
  1324. {
  1325. return Ok(JsonView(false, "MemoInfo不存在"));
  1326. }
  1327. //修改
  1328. string sourcePath = _source.MDFilePath;
  1329. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1330. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1331. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1332. if (savePath.Length > 0)
  1333. {
  1334. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1335. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1336. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1337. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1338. .SetColumns(it => it.MDFilePath == savePath)
  1339. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1340. .SetColumns(it => it.Title == _dto.Title)
  1341. .Where(s => s.Id == _source.Id)
  1342. .ExecuteCommandAsync();
  1343. return Ok(JsonView(result > 0));
  1344. }
  1345. }
  1346. }
  1347. else
  1348. {
  1349. //删除
  1350. if (_dto.MemoId < 1)
  1351. {
  1352. return Ok(JsonView(false, "MemoId不存在"));
  1353. }
  1354. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1355. if (_source == null)
  1356. {
  1357. return Ok(JsonView(false, "MemoInfo不存在"));
  1358. }
  1359. //修改
  1360. string sourcePath = _source.MDFilePath;
  1361. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1362. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1363. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1364. .SetColumns(it => it.IsDel == 1)
  1365. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1366. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1367. .Where(s => s.Id == _source.Id)
  1368. .ExecuteCommandAsync();
  1369. return Ok(JsonView(result > 0));
  1370. }
  1371. return Ok(JsonView(rst));
  1372. }
  1373. #endregion
  1374. #region 商邀资料
  1375. /// <summary>
  1376. /// 商邀资料 基础数据源
  1377. /// </summary>
  1378. /// <param name="dto"></param>
  1379. /// <returns></returns>
  1380. [HttpPost]
  1381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1382. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1383. {
  1384. try
  1385. {
  1386. #region 参数验证
  1387. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1388. #endregion
  1389. var ExcludedKeyStr = new string[] { "快递费" };
  1390. var ClientKeyStr = new string[] { "邀请函翻译" };
  1391. var expable = Expressionable.Create<Res_InvitationOfficialActivityData>();
  1392. foreach (var key in ClientKeyStr)
  1393. {
  1394. expable = expable.And(it => !it.Contact.Contains(key));
  1395. }
  1396. foreach (var item in ExcludedKeyStr)
  1397. {
  1398. expable = expable.And(it => !it.UnitName.Contains(item));
  1399. }
  1400. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1401. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).Where(expable.ToExpression()).ToList();
  1402. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1403. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1404. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1405. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1406. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1407. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1408. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1409. var _data = new
  1410. {
  1411. CountryData = _countryData,
  1412. InviterData = _inviterData,
  1413. DomainData = _domainData,
  1414. ContactData = _contactData,
  1415. GroupNameData = _groupNameData,
  1416. UserNameData = _userNameData,
  1417. };
  1418. return Ok(JsonView(true, $"查询成功!", _data));
  1419. }
  1420. catch (Exception ex)
  1421. {
  1422. return Ok(JsonView(false, ex.Message));
  1423. }
  1424. }
  1425. /// <summary>
  1426. /// 商邀资料查询
  1427. /// </summary>
  1428. /// <param name="dto"></param>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1433. {
  1434. var ExcludedKeyStr = new string[] { "快递费" };
  1435. var ClientKeyStr = new string[] { "邀请函翻译" };
  1436. try
  1437. {
  1438. #region 参数验证
  1439. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1440. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1441. #endregion
  1442. string sqlWhere = string.Empty;
  1443. if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
  1444. if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
  1445. if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
  1446. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
  1447. if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
  1448. if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
  1449. if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1450. {
  1451. sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
  1452. }
  1453. sqlWhere += string.Format(@"And i.Isdel={0}", 0);
  1454. foreach (var item in ExcludedKeyStr)
  1455. {
  1456. sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1457. }
  1458. foreach (var item in ClientKeyStr)
  1459. {
  1460. sqlWhere += $" And i.Contact not like '%{item}%' ";
  1461. }
  1462. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  1463. {
  1464. Regex r = new Regex("And");
  1465. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  1466. }
  1467. string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
  1468. i.*,u.CnName As CreateUserName
  1469. From Res_InvitationOfficialActivityData i
  1470. Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
  1471. RefAsync<int> totalCount = 0;
  1472. var _ivitiesViews = await _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
  1473. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
  1474. foreach (var item in _ivitiesViews)
  1475. {
  1476. string groupNameStr = "";
  1477. if (!string.IsNullOrEmpty(item.Delegation))
  1478. {
  1479. int[] groupIds = item.Delegation.Split(',').Select(x =>
  1480. {
  1481. int id;
  1482. if (int.TryParse(x, out id)) return id;
  1483. else return id;
  1484. }).ToArray();
  1485. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id) && x.IsDel == 0).ToList();
  1486. foreach (var group in _DelegationInfos)
  1487. {
  1488. groupNameStr += $"{group.TeamName},";
  1489. }
  1490. if (groupNameStr.Length > 1)
  1491. {
  1492. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1493. }
  1494. }
  1495. item.DelegationStr = groupNameStr;
  1496. }
  1497. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1498. }
  1499. catch (Exception ex)
  1500. {
  1501. return Ok(JsonView(false, ex.Message));
  1502. }
  1503. }
  1504. /// <summary>
  1505. /// 根据商邀资料Id查询信息
  1506. /// </summary>
  1507. /// <param name="id"></param>
  1508. /// <returns></returns>
  1509. [HttpGet("{id}")]
  1510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1511. public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
  1512. {
  1513. if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
  1514. return Ok(await _InvitationOfficialActivityDataRep.Info(id));
  1515. }
  1516. /// <summary>
  1517. /// 商邀资料操作(Status:1.新增,2.修改)
  1518. /// </summary>
  1519. /// <param name="dto"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
  1524. {
  1525. return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
  1526. }
  1527. /// <summary>
  1528. /// 商邀资料 删除文件
  1529. /// </summary>
  1530. /// <param name="id"></param>
  1531. /// <param name="fileName"></param>
  1532. /// <returns></returns>
  1533. [HttpDelete("{id}")]
  1534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1535. public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
  1536. {
  1537. if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
  1538. if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
  1539. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
  1540. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1541. var files = new List<string>();
  1542. try
  1543. {
  1544. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1545. }
  1546. catch (Exception) { }
  1547. if (files != null && files.Count > 0 && files.Contains(fileName))
  1548. {
  1549. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1550. if (System.IO.File.Exists(filePath))
  1551. {
  1552. System.IO.File.Delete(filePath);
  1553. }
  1554. //更改文件值
  1555. files.Remove(fileName);
  1556. var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  1557. .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
  1558. .Where(x => x.Id == id)
  1559. .ExecuteCommandAsync();
  1560. if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
  1561. }
  1562. return Ok(JsonView(false, "操作失败!"));
  1563. }
  1564. /// <summary>
  1565. /// 删除商邀资料信息
  1566. /// </summary>
  1567. /// <param name="dto"></param>
  1568. /// <returns></returns>
  1569. [HttpPost]
  1570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1571. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1572. {
  1573. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1574. if (!res) return Ok(JsonView(false, "删除失败"));
  1575. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
  1576. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1577. var files = new List<string>();
  1578. try
  1579. {
  1580. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1581. }
  1582. catch (Exception) { }
  1583. if (files != null && files.Count > 0)
  1584. {
  1585. foreach (var fileName in files)
  1586. {
  1587. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1588. if (System.IO.File.Exists(filePath))
  1589. {
  1590. System.IO.File.Delete(filePath);
  1591. }
  1592. }
  1593. }
  1594. return Ok(JsonView(true, "删除成功!"));
  1595. }
  1596. #endregion
  1597. #region 公务出访
  1598. /// <summary>
  1599. /// 获取团组所有信息,绑定下拉框
  1600. /// </summary>
  1601. /// <param name="dto"></param>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1606. {
  1607. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1608. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1609. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1610. dynamic groupInfos = null;
  1611. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1612. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
  1613. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1614. var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).Select(x => new { x.Id, x.Name }).ToList();
  1615. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile , TranslatorData = translatorData }));
  1616. }
  1617. /// <summary>
  1618. /// 公务List
  1619. /// </summary>
  1620. /// <param name="dto"></param>
  1621. /// <returns></returns>
  1622. [HttpPost]
  1623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1624. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1625. {
  1626. return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
  1627. }
  1628. /// <summary>
  1629. /// 根据公务出访数据Id查询数据
  1630. /// </summary>
  1631. /// <param name="dto"></param>
  1632. /// <returns></returns>
  1633. [HttpPost]
  1634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1635. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1636. {
  1637. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1638. if (groupData.Code != 0)
  1639. {
  1640. return Ok(JsonView(false, groupData.Msg));
  1641. }
  1642. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1643. }
  1644. /// <summary>
  1645. /// 公务出访操作(Status:1.新增,2.修改)
  1646. /// </summary>
  1647. /// <param name="dto"></param>
  1648. /// <returns></returns>
  1649. [HttpPost]
  1650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1651. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1652. {
  1653. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1654. if (groupData.Code != 0)
  1655. {
  1656. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
  1657. }
  1658. try
  1659. {
  1660. //公务出访变更发送通知
  1661. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  1662. }
  1663. catch (Exception ex)
  1664. {
  1665. //抄送日志
  1666. }
  1667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1668. }
  1669. /// <summary>
  1670. /// 上传文件(邮件截图)
  1671. /// </summary>
  1672. /// <param name="file"></param>
  1673. /// <returns></returns>
  1674. [HttpPost]
  1675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1676. public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
  1677. {
  1678. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1679. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1680. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1681. if (dto.diId < 1 || dto.currUserId < 1)
  1682. {
  1683. return Ok(JsonView(false, "参数有误,上传失败!"));
  1684. }
  1685. if (dto.files == null || dto.files.Count < 1)
  1686. {
  1687. return Ok(JsonView(false, "文件为空,上传失败!"));
  1688. }
  1689. string localFileDir = $"{localPath}{ptfPath}";
  1690. List<string> fileUrls = new List<string>();
  1691. string[] failFiles = new string[] { };
  1692. foreach (var file in dto.files)
  1693. {
  1694. //文件名称
  1695. string[] fileNameArray = file.FileName.Split(".");
  1696. string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
  1697. //上传的文件的路径
  1698. string filePath = $@"{localPath}公务相关文件";
  1699. if (!Directory.Exists(filePath))
  1700. {
  1701. Directory.CreateDirectory(filePath);
  1702. }
  1703. var path = Path.Combine(filePath, projectFileName);
  1704. //using var stream = new FileStream(path, FileMode.Create);
  1705. //await file.CopyToAsync(stream);
  1706. try
  1707. {
  1708. using (FileStream fs = System.IO.File.Create(path))
  1709. {
  1710. file.CopyTo(fs);
  1711. fs.Flush();
  1712. }
  1713. fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
  1714. }
  1715. catch (Exception ex)
  1716. {
  1717. failFiles.Append(file.FileName);
  1718. }
  1719. }
  1720. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
  1721. List<string> files = new List<string>();
  1722. var status = false;
  1723. var _oaInfo = new Res_OfficialActivities()
  1724. {
  1725. DiId = dto.diId,
  1726. ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
  1727. IsDel = 0,
  1728. CreateUserId = dto.currUserId,
  1729. CreateTime = DateTime.Now
  1730. };
  1731. if (oaInfo == null)
  1732. {
  1733. var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
  1734. .ExecuteReturnIdentityAsync();
  1735. if (id > 0)
  1736. {
  1737. status = true;
  1738. dto.id = id;
  1739. }
  1740. }
  1741. else
  1742. {
  1743. var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
  1744. ? new List<string>()
  1745. : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
  1746. if (oldFiles.Count > 0)
  1747. {
  1748. fileUrls.AddRange(oldFiles);
  1749. }
  1750. fileUrls = fileUrls.Distinct().ToList();
  1751. if (fileUrls.Count() > 0)
  1752. {
  1753. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1754. .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
  1755. .Where(x => x.Id == dto.id)
  1756. .ExecuteCommandAsync();
  1757. if (upd > 0) status = true;
  1758. }
  1759. }
  1760. List<string> returnFileUrls = new List<string>();
  1761. fileUrls.ForEach(x =>
  1762. {
  1763. returnFileUrls.Add($"{networkPath}{x}");
  1764. });
  1765. if (status)
  1766. {
  1767. string msg = "操作成功!";
  1768. if (failFiles.Length > 1)
  1769. {
  1770. foreach (var item in failFiles)
  1771. {
  1772. msg += $"{failFiles}、";
  1773. }
  1774. msg = msg.Substring(0, msg.Length - 1);
  1775. msg += "等文件保存失败!";
  1776. }
  1777. return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
  1778. }
  1779. return Ok(JsonView(false, "操作失败!"));
  1780. }
  1781. /// <summary>
  1782. /// 删除文件(邮件截图)
  1783. /// </summary>
  1784. /// <param name="file"></param>
  1785. /// <returns></returns>
  1786. [HttpPost]
  1787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1788. public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
  1789. {
  1790. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1791. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1792. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1793. if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
  1794. {
  1795. return Ok(JsonView(false, "参数有误,上传失败!"));
  1796. }
  1797. string localFileDir = $"{localPath}{ptfPath}";
  1798. List<string> fileUrls = new List<string>();
  1799. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
  1800. if (oaInfo != null)
  1801. {
  1802. string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
  1803. if (!string.IsNullOrEmpty(urlJson))
  1804. {
  1805. List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
  1806. var filePath = urls.Find(x => x.Contains(dto.FileName));
  1807. if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
  1808. var updFile = urls.Remove(filePath);
  1809. if (updFile)
  1810. {
  1811. //删除文件
  1812. string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
  1813. if (System.IO.File.Exists(fileUrl))
  1814. {
  1815. System.IO.File.Delete(fileUrl);
  1816. }
  1817. string urlJsonstr = JsonConvert.SerializeObject(urls);
  1818. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1819. .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
  1820. .Where(x => x.Id == dto.Id)
  1821. .ExecuteCommandAsync();
  1822. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1823. }
  1824. }
  1825. }
  1826. return Ok(JsonView(false, "操作失败!"));
  1827. }
  1828. /// <summary>
  1829. /// 公务出访 确认、取消邀请
  1830. /// </summary>
  1831. /// <param name="file"></param>
  1832. /// <returns></returns>
  1833. [HttpPost]
  1834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1835. public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
  1836. {
  1837. if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
  1838. if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
  1839. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1840. .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
  1841. .Where(x => x.Id == dto.Id)
  1842. .ExecuteCommandAsync();
  1843. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1844. return Ok(JsonView(false, "操作失败!"));
  1845. }
  1846. /// <summary>
  1847. /// 上传文件
  1848. /// </summary>
  1849. /// <param name="file"></param>
  1850. /// <returns></returns>
  1851. [HttpPost]
  1852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1853. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1854. {
  1855. try
  1856. {
  1857. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1858. int DiId = int.Parse(Request.Headers["DiId"]);
  1859. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  1860. if (file != null)
  1861. {
  1862. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1863. //文件名称
  1864. string projectFileName = file.FileName;
  1865. //上传的文件的路径
  1866. string filePath = "";
  1867. if (!Directory.Exists(fileDir))
  1868. {
  1869. Directory.CreateDirectory(fileDir);
  1870. }
  1871. //上传的文件的路径
  1872. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1873. using (FileStream fs = System.IO.File.Create(filePath))
  1874. {
  1875. file.CopyTo(fs);
  1876. fs.Flush();
  1877. }
  1878. Grp_DeleFile d = new Grp_DeleFile();
  1879. d.Diid = DiId;
  1880. d.Category = 970;
  1881. if (Type == 1) d.Kind = 1;
  1882. else if (Type == 2) d.Kind = 2;
  1883. else if (Type == 3) d.Kind = 3;
  1884. d.FileName = projectFileName;
  1885. d.FilePath = "";
  1886. d.CreateUserId = CreateUserId;
  1887. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1888. return Ok(JsonView(true, "上传成功!", projectFileName));
  1889. }
  1890. else
  1891. {
  1892. return Ok(JsonView(false, "上传失败!"));
  1893. }
  1894. }
  1895. catch (Exception ex)
  1896. {
  1897. return Ok(JsonView(false, "程序错误!"));
  1898. throw;
  1899. }
  1900. }
  1901. /// <summary>
  1902. /// 删除文件
  1903. /// </summary>
  1904. /// <param name="dto"></param>
  1905. /// <returns></returns>
  1906. [HttpPost]
  1907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1908. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  1909. {
  1910. try
  1911. {
  1912. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1913. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  1914. if (_DeleFile != null)
  1915. {
  1916. string fileName = _DeleFile.FileName;
  1917. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  1918. // 删除该文件
  1919. System.IO.File.Delete(filePath);
  1920. 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();
  1921. return Ok(JsonView(true, "取消文件成功!"));
  1922. }
  1923. else
  1924. {
  1925. return Ok(JsonView(false, "取消文件失败!"));
  1926. }
  1927. }
  1928. catch (Exception ex)
  1929. {
  1930. return Ok(JsonView(false, "程序错误!"));
  1931. throw;
  1932. }
  1933. }
  1934. /// <summary>
  1935. /// 删除公务出访信息
  1936. /// </summary>
  1937. /// <param name="dto"></param>
  1938. /// <returns></returns>
  1939. [HttpPost]
  1940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1941. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  1942. {
  1943. _sqlSugar.BeginTran();
  1944. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1945. if (!res)
  1946. {
  1947. _sqlSugar.RollbackTran();
  1948. return Ok(JsonView(false, "删除失败"));
  1949. }
  1950. #region 删除公务出访
  1951. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  1952. .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
  1953. {
  1954. DeleteUserId = dto.DeleteUserId,
  1955. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  1956. IsDel = 1,
  1957. Remark = $"公务出访-->删除"
  1958. })
  1959. .Where(x => x.OfficialDutyId == dto.Id)
  1960. .ExecuteCommandAsync();
  1961. #endregion
  1962. _sqlSugar.CommitTran();
  1963. return Ok(JsonView(true, "删除成功!"));
  1964. }
  1965. /// <summary>
  1966. /// 公务出访
  1967. /// 请示范例提示
  1968. /// Add Time:2024-05-13 13:56:44
  1969. /// </summary>
  1970. /// <param name="dto"></param>
  1971. /// <returns></returns>
  1972. [HttpPost]
  1973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1974. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  1975. {
  1976. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
  1977. if (res.Code == 0)
  1978. {
  1979. return Ok(JsonView(true, "操作成功!", res.Data));
  1980. }
  1981. return Ok(JsonView(false, res.Msg));
  1982. }
  1983. /// <summary>
  1984. /// 公务出访 (省外办,市外办) File Downlaod
  1985. /// </summary>
  1986. /// <param name="dto"></param>
  1987. /// <returns></returns>
  1988. [HttpPost]
  1989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1990. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  1991. {
  1992. #region 参数验证
  1993. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
  1994. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
  1995. #endregion
  1996. //团组基础信息
  1997. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  1998. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
  1999. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  2000. //团组公务信息
  2001. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  2002. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  2003. //团组客户名单
  2004. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  2005. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  2006. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  2007. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  2008. string countryStayStr = ""; // xx、xx、xx
  2009. //出入境费用 住宿类型
  2010. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  2011. if (dayCostDatas.Count > 0)
  2012. {
  2013. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  2014. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  2015. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  2016. foreach (var item in nationalDataGroupByCountry)
  2017. {
  2018. visitCountrys += $"{item.Key}、";
  2019. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  2020. countryStayStr += $"{item.Key}{stayDays}天,";
  2021. }
  2022. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  2023. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  2024. }
  2025. else
  2026. {
  2027. visitCountrys = groupInfo.VisitCountry;
  2028. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  2029. }
  2030. //出访人数
  2031. int visitPeopleNum = groupInfo.VisitPNumber;
  2032. int visitDaysNum = groupInfo.VisitDays;
  2033. //出访单位
  2034. string obInfoStr = "";
  2035. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  2036. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  2037. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  2038. //出访路线
  2039. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  2040. if (dto.FileType == 1)
  2041. {
  2042. //载入模板
  2043. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  2044. var doc = new Document(tempPath);
  2045. DocumentBuilder builder = new DocumentBuilder(doc);
  2046. //键值对存放数据
  2047. Dictionary<string, string> dic = new Dictionary<string, string>();
  2048. //××(组团单位):接团客户信息团组
  2049. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  2050. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2051. string guestName = "";
  2052. string guestJob = "";
  2053. string guestInfoStr = "";
  2054. var guestFirstInfo = guestInfos.FirstOrDefault();
  2055. if (guestFirstInfo != null)
  2056. {
  2057. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2058. guestJob = guestFirstInfo.Job.Trim();
  2059. guestInfoStr = $@"{guestJob}、{guestName}";
  2060. }
  2061. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  2062. string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2063. dic.Add("AskTitle", askTitle);
  2064. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  2065. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2066. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  2067. dic.Add("AskSubTitle", askSubTitle);
  2068. //出访目的
  2069. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2070. //出访任务
  2071. //(一)××(国家或地区)
  2072. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2073. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2074. string obBackgroundStr = "";//出访背景
  2075. string taskStr = ""; ; //出访任务
  2076. var countrys = obDatas.GroupBy(it => it.Country);
  2077. int countryIndex = 1;
  2078. foreach (var item in countrys)
  2079. {
  2080. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  2081. string taskContent = "";
  2082. string obBackgroundContent = "";
  2083. int obIndex = 1;
  2084. foreach (var obInfo in item.ToList())
  2085. {
  2086. string reqSmaple = "";
  2087. string settingStr = "";
  2088. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  2089. else reqSmaple = "[公务出访请示范例未录入]";
  2090. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  2091. else settingStr = "[公务方背景未录入]";
  2092. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  2093. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  2094. obIndex++;
  2095. }
  2096. taskStr += $"{taskTitle}{taskContent}";
  2097. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  2098. countryIndex++;
  2099. }
  2100. //出访背景
  2101. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  2102. dic.Add("OBSetting", obBackgroundStr);
  2103. //出访任务
  2104. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  2105. dic.Add("TaskContent", taskStr);
  2106. //出访时间
  2107. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  2108. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  2109. //出访时间
  2110. dic.Add("TimeQuantum", visitTimeQuantumStr);
  2111. //出访路线
  2112. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  2113. dic.Add("Line", lineStr);
  2114. //scheduling //行程安排
  2115. string schedulingStr = $"[OP行程单暂未生成]";
  2116. #region op行程 根据黑屏代码录入
  2117. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  2118. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  2119. schedulingStr = "";
  2120. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  2121. travelList = opTripView.Data as List<Grp_TravelList>;
  2122. if (travelList != null)
  2123. {
  2124. foreach (var item in travelList)
  2125. {
  2126. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  2127. }
  2128. }
  2129. #endregion
  2130. dic.Add("Scheduling", schedulingStr);
  2131. #region 填充word模板书签内容
  2132. foreach (var key in dic.Keys)
  2133. {
  2134. builder.MoveToBookmark(key);
  2135. builder.Write(dic[key]);
  2136. }
  2137. #endregion
  2138. //获取word里所有表格
  2139. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2140. //获取所填表格的序数
  2141. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2142. var rowStart = tableOne.Rows[0]; //获取第1行
  2143. //循环赋值
  2144. for (int i = 0; i < guestInfos.Count; i++)
  2145. {
  2146. var guestInfo = guestInfos[i];
  2147. builder.MoveToCell(0, i + 1, 0, 0);
  2148. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2149. builder.MoveToCell(0, i + 1, 1, 0);
  2150. int sex = guestInfo.Sex;
  2151. string sexStr = string.Empty;
  2152. if (sex == 0) sexStr = "男";
  2153. else if (sex == 1) sexStr = "女";
  2154. else sexStr = "-";
  2155. builder.Write(sexStr);
  2156. builder.MoveToCell(0, i + 1, 2, 0);
  2157. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2158. builder.MoveToCell(0, i + 1, 3, 0);
  2159. string birthDay = "";
  2160. string birthDayStr = string.Empty;
  2161. if (guestInfo.BirthDay != null)
  2162. {
  2163. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  2164. }
  2165. builder.Write(birthDayStr);
  2166. }
  2167. //删除多余行
  2168. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2169. {
  2170. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2171. }
  2172. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2173. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2174. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  2175. doc.Save(filePath);
  2176. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2177. return Ok(JsonView(true, "操作成功!", Url));
  2178. }
  2179. else if (dto.FileType == 2)
  2180. {
  2181. //载入模板
  2182. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  2183. var doc = new Document(tempPath);
  2184. DocumentBuilder builder = new DocumentBuilder(doc);
  2185. //键值对存放数据
  2186. Dictionary<string, string> dic = new Dictionary<string, string>();
  2187. //××(组团单位):接团客户信息团组
  2188. dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
  2189. dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
  2190. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2191. string guestName = "";
  2192. string guestJob = "";
  2193. string guestInfoStr = "";
  2194. var guestFirstInfo = guestInfos.FirstOrDefault();
  2195. if (guestFirstInfo != null)
  2196. {
  2197. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2198. guestJob = guestFirstInfo.Job;
  2199. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  2200. }
  2201. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2202. dic.Add("ReqTitle", reqTitle);
  2203. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  2204. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2205. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  2206. dic.Add("ReqSubTitle", reqSubTitle);
  2207. /*
  2208. * 出访任务
  2209. * (一)××(国家或地区)
  2210. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  2211. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  2212. *
  2213. */
  2214. string taskStr = string.Empty;
  2215. List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
  2216. int countryIndex = 1;
  2217. foreach (var item in countrys)
  2218. {
  2219. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  2220. string taskContent = "";
  2221. if (!string.IsNullOrEmpty(item))
  2222. {
  2223. var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  2224. int obIndex = 1;
  2225. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  2226. else
  2227. {
  2228. foreach (var obInfo in countryObDatas)
  2229. {
  2230. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  2231. obIndex++;
  2232. }
  2233. }
  2234. }
  2235. taskStr += $"{taskTitle}{taskContent}";
  2236. countryIndex++;
  2237. }
  2238. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  2239. //出访任务
  2240. dic.Add("TaskContent", taskStr);
  2241. //出访目的
  2242. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2243. //出访信息
  2244. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  2245. string tripInfoStr = "";
  2246. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  2247. dic.Add("TripInfo", tripInfoStr);
  2248. #region 填充word模板书签内容
  2249. foreach (var key in dic.Keys)
  2250. {
  2251. builder.MoveToBookmark(key);
  2252. builder.Write(dic[key]);
  2253. }
  2254. #endregion
  2255. //获取word里所有表格
  2256. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2257. //获取所填表格的序数
  2258. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2259. var rowStart = tableOne.Rows[0]; //获取第1行
  2260. //循环赋值
  2261. for (int i = 0; i < guestInfos.Count; i++)
  2262. {
  2263. var guestInfo = guestInfos[i];
  2264. builder.MoveToCell(0, i + 1, 0, 0);
  2265. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2266. builder.MoveToCell(0, i + 1, 1, 0);
  2267. int sex = guestInfo.Sex;
  2268. string sexStr = string.Empty;
  2269. if (sex == 0) sexStr = "男";
  2270. else if (sex == 1) sexStr = "女";
  2271. else sexStr = "未设置";
  2272. builder.Write(sexStr);
  2273. builder.MoveToCell(0, i + 1, 2, 0);
  2274. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2275. builder.MoveToCell(0, i + 1, 3, 0);
  2276. DateTime birthDay = guestInfo.BirthDay;
  2277. string birthDayStr = string.Empty;
  2278. if (birthDay != null)
  2279. {
  2280. birthDayStr = birthDay.ToString("yyyy.MM");
  2281. }
  2282. builder.Write(birthDayStr);
  2283. }
  2284. //删除多余行
  2285. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2286. {
  2287. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2288. }
  2289. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2290. var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2291. var filePath = fileDir + $@"OfficialActivities/{fileName}";
  2292. doc.Save(filePath);
  2293. var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2294. return Ok(JsonView(true, "操作成功!", url));
  2295. }
  2296. return Ok(JsonView(true, "操作失败!", ""));
  2297. }
  2298. private string GetToUpperNumber(int num)
  2299. {
  2300. string numStr = "";
  2301. if (num == 1) numStr = "一";
  2302. else if (num == 2) numStr = "二";
  2303. else if (num == 3) numStr = "三";
  2304. else if (num == 4) numStr = "四";
  2305. else if (num == 5) numStr = "五";
  2306. else if (num == 6) numStr = "六";
  2307. else if (num == 7) numStr = "七";
  2308. else if (num == 8) numStr = "八";
  2309. else if (num == 9) numStr = "九";
  2310. else if (num == 10) numStr = "十";
  2311. return numStr;
  2312. }
  2313. #endregion
  2314. #region 请示数据库
  2315. /// <summary>
  2316. /// 查询请示数据库初始化
  2317. /// </summary>
  2318. /// <param name="dto"></param>
  2319. /// <returns></returns>
  2320. [HttpPost]
  2321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2322. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  2323. {
  2324. Result groupData = await _askDataRep.QueryAskData(dto);
  2325. if (groupData.Code != 0)
  2326. {
  2327. return Ok(JsonView(false, groupData.Msg));
  2328. }
  2329. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2330. }
  2331. /// <summary>
  2332. /// 根据Id查询请示数据库单条数据
  2333. /// </summary>
  2334. /// <param name="dto"></param>
  2335. /// <returns></returns>
  2336. [HttpPost]
  2337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2338. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  2339. {
  2340. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  2341. if (_AskData == null)
  2342. {
  2343. return Ok(JsonView(true, "暂无数据!", _AskData));
  2344. }
  2345. return Ok(JsonView(true, "查询成功!", _AskData));
  2346. }
  2347. /// <summary>
  2348. /// 请示数据库操作(Status:1.新增,2.修改)
  2349. /// </summary>
  2350. /// <param name="dto"></param>
  2351. /// <returns></returns>
  2352. [HttpPost]
  2353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2354. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  2355. {
  2356. Result groupData = await _askDataRep.OpAskData(dto);
  2357. if (groupData.Code != 0)
  2358. {
  2359. return Ok(JsonView(false, groupData.Msg));
  2360. }
  2361. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2362. }
  2363. /// <summary>
  2364. /// 删除请示资料信息
  2365. /// </summary>
  2366. /// <param name="dto"></param>
  2367. /// <returns></returns>
  2368. [HttpPost]
  2369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2370. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  2371. {
  2372. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  2373. if (!res)
  2374. {
  2375. return Ok(JsonView(false, "删除失败"));
  2376. }
  2377. return Ok(JsonView(true, "删除成功!"));
  2378. }
  2379. /// <summary>
  2380. /// 请示资料信息
  2381. /// 省外办下载
  2382. /// </summary>
  2383. /// <param name="dto"></param>
  2384. /// <returns></returns>
  2385. [HttpPost]
  2386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2387. public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
  2388. {
  2389. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
  2390. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  2391. //大写数字序号
  2392. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  2393. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  2394. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  2395. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  2396. //数据源
  2397. var idItem = dto.DataIdItem.OrderBy(x => x);
  2398. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  2399. //书签名
  2400. string Area = "",
  2401. Official = "";
  2402. //表格数据源
  2403. DataTable dt = new DataTable();
  2404. dt.Columns.Add("Country", typeof(string));
  2405. dt.Columns.Add("TalkCase", typeof(string));
  2406. int id = 0;
  2407. int TalkcaseOrder = 0;
  2408. int RowOrder = 0;
  2409. //填充数据
  2410. for (int i = 0; i < askDatas.Count; i++)
  2411. {
  2412. var ad = askDatas[i];
  2413. Area = Area + ad.Country + ad.Area + "、";
  2414. Official = Official + ad.UnitName + "、";
  2415. //填充表格数据源
  2416. DataRow dr = dt.NewRow();
  2417. if (i > 0)
  2418. {
  2419. var adtemp = askDatas[i - 1];
  2420. if (ad.Country == adtemp.Country)
  2421. {
  2422. TalkcaseOrder++;
  2423. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  2424. }
  2425. else
  2426. {
  2427. RowOrder++;
  2428. dr = dt.NewRow();
  2429. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  2430. dr["TalkCase"] = "1、" + ad.TalkCase;
  2431. dt.Rows.Add(dr);
  2432. TalkcaseOrder = 0;
  2433. }
  2434. }
  2435. else
  2436. {
  2437. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  2438. dr["TalkCase"] = "1、" + ad.TalkCase;
  2439. dt.Rows.Add(dr);
  2440. }
  2441. id = ad.Id;
  2442. }
  2443. //模板路径
  2444. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
  2445. //载入模板
  2446. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  2447. #region 填充word内容
  2448. #region 填充请示内容
  2449. //利用DocumentBuilder处理表格或是书签
  2450. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  2451. string bookmark = "";
  2452. try
  2453. {
  2454. for (int i = 0; i < dt.Rows.Count; i++)
  2455. {
  2456. bookmark = bookmark
  2457. + dt.Rows[i]["Country"].ToString() + "\r\n"
  2458. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  2459. }
  2460. }
  2461. catch
  2462. {
  2463. }
  2464. #endregion
  2465. #region 填充word模板书签内容
  2466. //团组信息
  2467. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  2468. //接团客户名单实例
  2469. string client_sql = string.Format(@"
  2470. SELECT
  2471. tcl.Id,
  2472. tcl.DiId,
  2473. tcl.IsAccompany,
  2474. temp.*,
  2475. u.CnName AS Operator,
  2476. tcl.CreateTime AS OperatingTime
  2477. FROM
  2478. Grp_TourClientList tcl
  2479. LEFT JOIN (
  2480. SELECT
  2481. dc.Id AS DcId,
  2482. dc.LastName,
  2483. dc.FirstName,
  2484. ccom.CompanyFullName,
  2485. dc.Job,
  2486. cc.CertNo AS IDCardNo,
  2487. dc.Sex,
  2488. dc.BirthDay
  2489. FROM
  2490. Crm_DeleClient dc
  2491. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  2492. AND ccom.IsDel = 0
  2493. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  2494. AND cc.SdId = 773
  2495. AND cc.IsDel = 0
  2496. WHERE
  2497. dc.IsDel = 0
  2498. ) temp ON temp.DcId = tcl.ClientId
  2499. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  2500. WHERE
  2501. tcl.IsDel = 0
  2502. AND tcl.DiId = {0}", dto.DiId);
  2503. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  2504. //机票代码实例
  2505. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  2506. //三字码
  2507. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
  2508. //团名
  2509. if (doc.Range.Bookmarks["TeamName"] != null)
  2510. {
  2511. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  2512. mark.Text = di.TeamName;
  2513. }
  2514. //团长名
  2515. if (doc.Range.Bookmarks["ClientName2"] != null)
  2516. {
  2517. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  2518. if (clientList == null || clientList.Count == 0)
  2519. {
  2520. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2521. }
  2522. else
  2523. {
  2524. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2525. }
  2526. }
  2527. if (doc.Range.Bookmarks["ClientName"] != null)
  2528. {
  2529. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  2530. if (clientList == null || clientList.Count == 0)
  2531. {
  2532. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2533. }
  2534. else
  2535. {
  2536. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2537. }
  2538. }
  2539. //跟团人数
  2540. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  2541. {
  2542. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  2543. mark.Text = di.VisitPNumber.ToString();
  2544. }
  2545. if (doc.Range.Bookmarks["ClientNumber"] != null)
  2546. {
  2547. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  2548. mark.Text = di.VisitPNumber.ToString();
  2549. }
  2550. //地区
  2551. if (doc.Range.Bookmarks["Area"] != null)
  2552. {
  2553. Bookmark mark = doc.Range.Bookmarks["Area"];
  2554. mark.Text = Area.TrimEnd('、');
  2555. }
  2556. if (doc.Range.Bookmarks["Area2"] != null)
  2557. {
  2558. Bookmark mark = doc.Range.Bookmarks["Area2"];
  2559. mark.Text = Area.TrimEnd('、');
  2560. }
  2561. //出访目的
  2562. if (doc.Range.Bookmarks["Destination2"] != null)
  2563. {
  2564. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  2565. mark.Text = di.VisitPurpose;
  2566. }
  2567. if (doc.Range.Bookmarks["Destination"] != null)
  2568. {
  2569. Bookmark mark = doc.Range.Bookmarks["Destination"];
  2570. mark.Text = di.VisitPurpose;
  2571. }
  2572. //邀请方
  2573. if (doc.Range.Bookmarks["Official"] != null)
  2574. {
  2575. Bookmark mark = doc.Range.Bookmarks["Official"];
  2576. mark.Text = Official.TrimEnd('、');
  2577. }
  2578. //出访日期
  2579. if (doc.Range.Bookmarks["VisitDate"] != null)
  2580. {
  2581. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  2582. mark.Text = di.VisitStartDate.Year + "年"
  2583. + di.VisitStartDate.Month + "月"
  2584. + di.VisitStartDate.Day + "日"
  2585. + "至"
  2586. + di.VisitEndDate.Month + "月"
  2587. + di.VisitEndDate.Day + "日";
  2588. }
  2589. //请示范例
  2590. if (doc.Range.Bookmarks["Temp"] != null)
  2591. {
  2592. Bookmark mark = doc.Range.Bookmarks["Temp"];
  2593. mark.Text = bookmark;
  2594. }
  2595. //出访起止日期
  2596. if (doc.Range.Bookmarks["Duration"] != null)
  2597. {
  2598. Bookmark mark = doc.Range.Bookmarks["Duration"];
  2599. mark.Text = di.VisitStartDate.Year + "年"
  2600. + di.VisitStartDate.Month + "月"
  2601. + di.VisitStartDate.Day + "日"
  2602. + "至"
  2603. + di.VisitEndDate.Month + "月"
  2604. + di.VisitEndDate.Day + "日";
  2605. }
  2606. //出访天数
  2607. if (doc.Range.Bookmarks["Durationdays"] != null)
  2608. {
  2609. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  2610. mark.Text = di.VisitDays.ToString();
  2611. }
  2612. if (doc.Range.Bookmarks["Durationdays2"] != null)
  2613. {
  2614. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  2615. mark.Text = di.VisitDays.ToString();
  2616. }
  2617. #region 根据黑屏代码获取国家呆的天数;获取路线
  2618. string result_CountryAndDay = "", result_Air = "";
  2619. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  2620. {
  2621. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  2622. result_Air = result_CountryAndDay;
  2623. }
  2624. else
  2625. {
  2626. string place_start, place_end;
  2627. DateTime time_start, time_end;
  2628. Res_ThreeCode three = null;
  2629. for (int i = 0; i < airTable.Rows.Count; i++)
  2630. {
  2631. //三字码实例
  2632. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  2633. if (three == null)
  2634. {
  2635. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2636. }
  2637. else
  2638. {
  2639. if (string.IsNullOrEmpty(three.Country))
  2640. {
  2641. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2642. }
  2643. else
  2644. {
  2645. place_start = three.City;
  2646. }
  2647. }
  2648. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  2649. if (three == null)
  2650. {
  2651. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2652. }
  2653. else
  2654. {
  2655. if (string.IsNullOrEmpty(three.Country))
  2656. {
  2657. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2658. }
  2659. else
  2660. {
  2661. place_end = three.City;
  2662. }
  2663. }
  2664. result_Air += place_start + "一" + place_end + "一";
  2665. //获取国家和呆的天数
  2666. if (i > 0 && i < airTable.Rows.Count - 1)
  2667. {
  2668. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  2669. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  2670. TimeSpan daycount = time_end.Subtract(time_start);
  2671. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  2672. }
  2673. }
  2674. }
  2675. #endregion
  2676. //每个国家呆的天数
  2677. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  2678. {
  2679. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  2680. mark.Text = result_CountryAndDay.TrimEnd(',');
  2681. }
  2682. #region 出访路线城市字符串去重
  2683. result_Air = result_Air.TrimEnd('一');
  2684. string[] airTemp = result_Air.Split('一');
  2685. airTemp = airTemp.Distinct().ToArray();
  2686. result_Air = "";
  2687. foreach (string str in airTemp)
  2688. {
  2689. result_Air += str + "一";
  2690. }
  2691. result_Air = result_Air + airTemp[0];
  2692. #endregion
  2693. //出访路线
  2694. if (doc.Range.Bookmarks["Air"] != null)
  2695. {
  2696. Bookmark mark = doc.Range.Bookmarks["Air"];
  2697. mark.Text = result_Air;
  2698. }
  2699. #endregion
  2700. #region 客户名单
  2701. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2702. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  2703. if (clientList == null || clientList.Count == 0)
  2704. {
  2705. builder.MoveToCell(0, 1, 0, 0);
  2706. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  2707. }
  2708. else
  2709. {
  2710. for (int i = 0; i < clientList.Count(); i++)
  2711. {
  2712. builder.MoveToCell(0, i + 1, 0, 0);
  2713. builder.Write((i + 1).ToString());
  2714. builder.MoveToCell(0, i + 1, 1, 0);
  2715. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  2716. builder.MoveToCell(0, i + 1, 2, 0);
  2717. builder.Write(clientList[i].Sex.ToString());
  2718. builder.MoveToCell(0, i + 1, 3, 0);
  2719. builder.Write(clientList[i].BirthDay);
  2720. builder.MoveToCell(0, i + 1, 4, 0);
  2721. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  2722. }
  2723. }
  2724. while (tableClient.Rows.Count > clientList.Count + 1)
  2725. {
  2726. tableClient.Rows.RemoveAt(clientList.Count + 1);
  2727. }
  2728. #endregion
  2729. #region 商邀行程
  2730. string content = "", temp1 = "", temp2 = "";
  2731. //获取数据,放到datatable
  2732. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  2733. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  2734. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  2735. .Select((at, atd) => new
  2736. {
  2737. at.Id,
  2738. at.Date,
  2739. atd.Time,
  2740. atd.Details
  2741. })
  2742. .ToListAsync();
  2743. if (listapt == null || listapt.Count == 0)
  2744. {
  2745. content = "尚未生成商邀行程";
  2746. }
  2747. else
  2748. {
  2749. for (int i = 0; i < listapt.Count; i++)
  2750. {
  2751. content = content + " " + listapt[i].Date + "\r\n";
  2752. temp1 = listapt[i].Time;
  2753. temp2 = listapt[i].Details;
  2754. if (!string.IsNullOrEmpty(temp1))
  2755. {
  2756. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2757. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2758. for (int j = 0; j < str.Count(); j++)
  2759. {
  2760. content = content + " " + str[j] + str2[j] + "\r\n";
  2761. }
  2762. }
  2763. }
  2764. }
  2765. if (doc.Range.Bookmarks["Content"] != null)
  2766. {
  2767. Bookmark mark = doc.Range.Bookmarks["Content"];
  2768. mark.Text = content;
  2769. }
  2770. while (tableClient.Rows.Count > 1 + clientList.Count)
  2771. {
  2772. tableClient.Rows.RemoveAt(1 + clientList.Count);
  2773. }
  2774. #endregion
  2775. #endregion
  2776. string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
  2777. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  2778. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  2779. return Ok(JsonView(true,"操作成功!",new { url = url }));
  2780. }
  2781. /// <summary>
  2782. /// 请示资料信息
  2783. /// 市外办下载
  2784. /// </summary>
  2785. /// <param name="dto"></param>
  2786. /// <returns></returns>
  2787. [HttpPost]
  2788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2789. public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
  2790. {
  2791. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
  2792. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  2793. //大写数字序号
  2794. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  2795. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  2796. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  2797. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  2798. //数据源
  2799. var idItem = dto.DataIdItem.OrderBy(x => x);
  2800. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  2801. //书签名
  2802. string Area = "",
  2803. Official = "";
  2804. //表格数据源
  2805. DataTable dt = new DataTable();
  2806. dt.Columns.Add("Country", typeof(string));
  2807. dt.Columns.Add("TalkCase", typeof(string));
  2808. int id = 0;
  2809. int TalkcaseOrder = 0;
  2810. int RowOrder = 0;
  2811. //填充数据
  2812. for (int i = 0; i < askDatas.Count; i++)
  2813. {
  2814. var ad = askDatas[i];
  2815. Area = Area + ad.Country + ad.Area + "、";
  2816. Official = Official + ad.UnitName + "、";
  2817. //填充表格数据源
  2818. DataRow dr = dt.NewRow();
  2819. if (i > 0)
  2820. {
  2821. var adtemp = askDatas[i - 1];
  2822. if (ad.Country == adtemp.Country)
  2823. {
  2824. TalkcaseOrder++;
  2825. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  2826. }
  2827. else
  2828. {
  2829. RowOrder++;
  2830. dr = dt.NewRow();
  2831. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  2832. dr["TalkCase"] = "1、" + ad.TalkCase;
  2833. dt.Rows.Add(dr);
  2834. TalkcaseOrder = 0;
  2835. }
  2836. }
  2837. else
  2838. {
  2839. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  2840. dr["TalkCase"] = "1、" + ad.TalkCase;
  2841. dt.Rows.Add(dr);
  2842. }
  2843. id = ad.Id;
  2844. }
  2845. //模板路径
  2846. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
  2847. //载入模板
  2848. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  2849. #region 填充word内容
  2850. #region 填充请示内容
  2851. //利用DocumentBuilder处理表格或是书签
  2852. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  2853. string bookmark = "";
  2854. try
  2855. {
  2856. for (int i = 0; i < dt.Rows.Count; i++)
  2857. {
  2858. bookmark = bookmark
  2859. + dt.Rows[i]["Country"].ToString() + "\r\n"
  2860. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  2861. }
  2862. }
  2863. catch
  2864. {
  2865. }
  2866. #endregion
  2867. #region 填充word模板书签内容
  2868. //团组信息
  2869. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  2870. //接团客户名单实例
  2871. string client_sql = string.Format(@"
  2872. SELECT
  2873. tcl.Id,
  2874. tcl.DiId,
  2875. tcl.IsAccompany,
  2876. temp.*,
  2877. u.CnName AS Operator,
  2878. tcl.CreateTime AS OperatingTime
  2879. FROM
  2880. Grp_TourClientList tcl
  2881. LEFT JOIN (
  2882. SELECT
  2883. dc.Id AS DcId,
  2884. dc.LastName,
  2885. dc.FirstName,
  2886. ccom.CompanyFullName,
  2887. dc.Job,
  2888. cc.CertNo AS IDCardNo,
  2889. dc.Sex,
  2890. dc.BirthDay
  2891. FROM
  2892. Crm_DeleClient dc
  2893. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  2894. AND ccom.IsDel = 0
  2895. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  2896. AND cc.SdId = 773
  2897. AND cc.IsDel = 0
  2898. WHERE
  2899. dc.IsDel = 0
  2900. ) temp ON temp.DcId = tcl.ClientId
  2901. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  2902. WHERE
  2903. tcl.IsDel = 0
  2904. AND tcl.DiId = {0}", dto.DiId);
  2905. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  2906. //机票代码实例
  2907. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  2908. //三字码
  2909. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
  2910. //团名
  2911. if (doc.Range.Bookmarks["TeamName"] != null)
  2912. {
  2913. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  2914. mark.Text = di.TeamName;
  2915. }
  2916. //团长名
  2917. if (doc.Range.Bookmarks["ClientName2"] != null)
  2918. {
  2919. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  2920. if (clientList == null || clientList.Count == 0)
  2921. {
  2922. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2923. }
  2924. else
  2925. {
  2926. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2927. }
  2928. }
  2929. if (doc.Range.Bookmarks["ClientName"] != null)
  2930. {
  2931. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  2932. if (clientList == null || clientList.Count == 0)
  2933. {
  2934. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2935. }
  2936. else
  2937. {
  2938. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2939. }
  2940. }
  2941. //跟团人数
  2942. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  2943. {
  2944. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  2945. mark.Text = di.VisitPNumber.ToString();
  2946. }
  2947. if (doc.Range.Bookmarks["ClientNumber"] != null)
  2948. {
  2949. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  2950. mark.Text = di.VisitPNumber.ToString();
  2951. }
  2952. //地区
  2953. if (doc.Range.Bookmarks["Area"] != null)
  2954. {
  2955. Bookmark mark = doc.Range.Bookmarks["Area"];
  2956. mark.Text = Area.TrimEnd('、');
  2957. }
  2958. if (doc.Range.Bookmarks["Area2"] != null)
  2959. {
  2960. Bookmark mark = doc.Range.Bookmarks["Area2"];
  2961. mark.Text = Area.TrimEnd('、');
  2962. }
  2963. //出访目的
  2964. if (doc.Range.Bookmarks["Destination2"] != null)
  2965. {
  2966. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  2967. mark.Text = di.VisitPurpose;
  2968. }
  2969. if (doc.Range.Bookmarks["Destination"] != null)
  2970. {
  2971. Bookmark mark = doc.Range.Bookmarks["Destination"];
  2972. mark.Text = di.VisitPurpose;
  2973. }
  2974. //邀请方
  2975. if (doc.Range.Bookmarks["Official"] != null)
  2976. {
  2977. Bookmark mark = doc.Range.Bookmarks["Official"];
  2978. mark.Text = Official.TrimEnd('、');
  2979. }
  2980. //出访日期
  2981. if (doc.Range.Bookmarks["VisitDate"] != null)
  2982. {
  2983. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  2984. mark.Text = di.VisitStartDate.Year + "年"
  2985. + di.VisitStartDate.Month + "月"
  2986. + di.VisitStartDate.Day + "日"
  2987. + "至"
  2988. + di.VisitEndDate.Month + "月"
  2989. + di.VisitEndDate.Day + "日";
  2990. }
  2991. //请示范例
  2992. if (doc.Range.Bookmarks["Temp"] != null)
  2993. {
  2994. Bookmark mark = doc.Range.Bookmarks["Temp"];
  2995. mark.Text = bookmark;
  2996. }
  2997. //出访起止日期
  2998. if (doc.Range.Bookmarks["Duration"] != null)
  2999. {
  3000. Bookmark mark = doc.Range.Bookmarks["Duration"];
  3001. mark.Text = di.VisitStartDate.Year + "年"
  3002. + di.VisitStartDate.Month + "月"
  3003. + di.VisitStartDate.Day + "日"
  3004. + "至"
  3005. + di.VisitEndDate.Month + "月"
  3006. + di.VisitEndDate.Day + "日";
  3007. }
  3008. //出访天数
  3009. if (doc.Range.Bookmarks["Durationdays"] != null)
  3010. {
  3011. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  3012. mark.Text = di.VisitDays.ToString();
  3013. }
  3014. if (doc.Range.Bookmarks["Durationdays2"] != null)
  3015. {
  3016. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  3017. mark.Text = di.VisitDays.ToString();
  3018. }
  3019. #region 根据黑屏代码获取国家呆的天数;获取路线
  3020. string result_CountryAndDay = "", result_Air = "";
  3021. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  3022. {
  3023. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  3024. result_Air = result_CountryAndDay;
  3025. }
  3026. else
  3027. {
  3028. string place_start, place_end;
  3029. DateTime time_start, time_end;
  3030. Res_ThreeCode three = null;
  3031. for (int i = 0; i < airTable.Rows.Count; i++)
  3032. {
  3033. //三字码实例
  3034. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  3035. if (three == null)
  3036. {
  3037. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3038. }
  3039. else
  3040. {
  3041. if (string.IsNullOrEmpty(three.Country))
  3042. {
  3043. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3044. }
  3045. else
  3046. {
  3047. place_start = three.City;
  3048. }
  3049. }
  3050. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  3051. if (three == null)
  3052. {
  3053. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3054. }
  3055. else
  3056. {
  3057. if (string.IsNullOrEmpty(three.Country))
  3058. {
  3059. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3060. }
  3061. else
  3062. {
  3063. place_end = three.City;
  3064. }
  3065. }
  3066. result_Air += place_start + "一" + place_end + "一";
  3067. //获取国家和呆的天数
  3068. if (i > 0 && i < airTable.Rows.Count - 1)
  3069. {
  3070. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  3071. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  3072. TimeSpan daycount = time_end.Subtract(time_start);
  3073. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  3074. }
  3075. }
  3076. }
  3077. #endregion
  3078. //每个国家呆的天数
  3079. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  3080. {
  3081. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  3082. mark.Text = result_CountryAndDay.TrimEnd(',');
  3083. }
  3084. #region 出访路线城市字符串去重
  3085. result_Air = result_Air.TrimEnd('一');
  3086. string[] airTemp = result_Air.Split('一');
  3087. airTemp = airTemp.Distinct().ToArray();
  3088. result_Air = "";
  3089. foreach (string str in airTemp)
  3090. {
  3091. result_Air += str + "一";
  3092. }
  3093. result_Air = result_Air + airTemp[0];
  3094. #endregion
  3095. //出访路线
  3096. if (doc.Range.Bookmarks["Air"] != null)
  3097. {
  3098. Bookmark mark = doc.Range.Bookmarks["Air"];
  3099. mark.Text = result_Air;
  3100. }
  3101. #endregion
  3102. #region 客户名单
  3103. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3104. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  3105. if (clientList == null || clientList.Count == 0)
  3106. {
  3107. builder.MoveToCell(0, 1, 0, 0);
  3108. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  3109. }
  3110. else
  3111. {
  3112. for (int i = 0; i < clientList.Count(); i++)
  3113. {
  3114. builder.MoveToCell(0, i + 1, 0, 0);
  3115. builder.Write((i + 1).ToString());
  3116. builder.MoveToCell(0, i + 1, 1, 0);
  3117. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  3118. builder.MoveToCell(0, i + 1, 2, 0);
  3119. builder.Write(clientList[i].Sex.ToString());
  3120. builder.MoveToCell(0, i + 1, 3, 0);
  3121. builder.Write(clientList[i].BirthDay);
  3122. builder.MoveToCell(0, i + 1, 4, 0);
  3123. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  3124. }
  3125. }
  3126. while (tableClient.Rows.Count > clientList.Count + 1)
  3127. {
  3128. tableClient.Rows.RemoveAt(clientList.Count + 1);
  3129. }
  3130. #endregion
  3131. #region 商邀行程
  3132. string content = "", temp1 = "", temp2 = "";
  3133. //获取数据,放到datatable
  3134. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  3135. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  3136. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  3137. .Select((at, atd) => new
  3138. {
  3139. at.Id,
  3140. at.Date,
  3141. atd.Time,
  3142. atd.Details
  3143. })
  3144. .ToListAsync();
  3145. if (listapt == null || listapt.Count == 0)
  3146. {
  3147. content = "尚未生成商邀行程";
  3148. }
  3149. else
  3150. {
  3151. for (int i = 0; i < listapt.Count; i++)
  3152. {
  3153. content = content + " " + listapt[i].Date + "\r\n";
  3154. temp1 = listapt[i].Time;
  3155. temp2 = listapt[i].Details;
  3156. if (!string.IsNullOrEmpty(temp1))
  3157. {
  3158. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3159. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3160. for (int j = 0; j < str.Count(); j++)
  3161. {
  3162. content = content + " " + str[j] + str2[j] + "\r\n";
  3163. }
  3164. }
  3165. }
  3166. }
  3167. if (doc.Range.Bookmarks["Content"] != null)
  3168. {
  3169. Bookmark mark = doc.Range.Bookmarks["Content"];
  3170. mark.Text = content;
  3171. }
  3172. while (tableClient.Rows.Count > 1 + clientList.Count)
  3173. {
  3174. tableClient.Rows.RemoveAt(1 + clientList.Count);
  3175. }
  3176. #endregion
  3177. #endregion
  3178. string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
  3179. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3180. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3181. return Ok(JsonView(true, "操作成功!", new { url = url }));
  3182. }
  3183. #endregion
  3184. #region 机票黑屏代码
  3185. /// <summary>
  3186. /// 根据团组Id查询黑屏代码列表
  3187. /// </summary>
  3188. /// <param name="dto"></param>
  3189. /// <returns></returns>
  3190. [HttpPost]
  3191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3192. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  3193. {
  3194. try
  3195. {
  3196. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  3197. if (groupData.Code != 0)
  3198. {
  3199. return Ok(JsonView(false, groupData.Msg));
  3200. }
  3201. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3202. }
  3203. catch (Exception ex)
  3204. {
  3205. return Ok(JsonView(false, "程序错误!"));
  3206. throw;
  3207. }
  3208. }
  3209. /// <summary>
  3210. /// 根据黑屏代码数据Id查询信息
  3211. /// </summary>
  3212. /// <param name="dto"></param>
  3213. /// <returns></returns>
  3214. [HttpPost]
  3215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3216. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  3217. {
  3218. try
  3219. {
  3220. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  3221. if (groupData.Code != 0)
  3222. {
  3223. return Ok(JsonView(false, groupData.Msg));
  3224. }
  3225. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3226. }
  3227. catch (Exception ex)
  3228. {
  3229. return Ok(JsonView(false, "程序错误!"));
  3230. throw;
  3231. }
  3232. }
  3233. /// <summary>
  3234. /// 黑屏代码操作(Status:1.新增,2.修改)
  3235. /// </summary>
  3236. /// <param name="dto"></param>
  3237. /// <returns></returns>
  3238. [HttpPost]
  3239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3240. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  3241. {
  3242. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  3243. if (groupData.Code != 0)
  3244. {
  3245. return Ok(JsonView(false, groupData.Msg));
  3246. }
  3247. try
  3248. {
  3249. var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
  3250. if (tongzhi.Code == 0)
  3251. {
  3252. var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
  3253. var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
  3254. if (data != null)
  3255. await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
  3256. }
  3257. //行程代码变更通知
  3258. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  3259. }
  3260. catch (Exception ex)
  3261. {
  3262. throw;
  3263. }
  3264. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3265. }
  3266. /// <summary>
  3267. /// 删除黑屏代码
  3268. /// </summary>
  3269. /// <param name="dto"></param>
  3270. /// <returns></returns>
  3271. [HttpPost]
  3272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3273. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  3274. {
  3275. try
  3276. {
  3277. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  3278. if (!res)
  3279. {
  3280. return Ok(JsonView(false, "删除失败"));
  3281. }
  3282. return Ok(JsonView(true, "删除成功!"));
  3283. }
  3284. catch (Exception ex)
  3285. {
  3286. return Ok(JsonView(false, "程序错误!"));
  3287. throw;
  3288. }
  3289. }
  3290. #endregion
  3291. #region 翻译人员
  3292. /// <summary>
  3293. /// 翻译人员库
  3294. /// Init
  3295. /// </summary>
  3296. /// <param name="id"></param>
  3297. /// <returns></returns>
  3298. [HttpGet()]
  3299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3300. public async Task<IActionResult> TranslatorLibraryInit()
  3301. {
  3302. var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
  3303. .Where(x => x.IsDel == 0 && x.STid == 66)
  3304. .Select(x => new {
  3305. x.Id,
  3306. x.Name,
  3307. })
  3308. .ToListAsync();
  3309. var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
  3310. .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  3311. .Where((oa, di) => oa.IsDel == 0)
  3312. .Select((oa, di) => new
  3313. {
  3314. oa.Id,
  3315. oa.Client,
  3316. oa.DiId,
  3317. di.TeamName
  3318. })
  3319. .ToListAsync();
  3320. var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
  3321. .Select(g => new {
  3322. id = g.Key,
  3323. label = g.FirstOrDefault()?.TeamName ?? "-",
  3324. children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
  3325. })
  3326. .ToList();
  3327. var view = new {
  3328. currencyData = currencyData,
  3329. officialDutyData = officialDutyData1
  3330. };
  3331. return Ok(JsonView(view));
  3332. }
  3333. /// <summary>
  3334. /// 翻译人员库
  3335. /// 详情
  3336. /// </summary>
  3337. /// <param name="id"></param>
  3338. /// <returns></returns>
  3339. [HttpGet("id")]
  3340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3341. public async Task<IActionResult> TranslatorLibraryInfo(int id)
  3342. {
  3343. if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
  3344. var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
  3345. var view = _mapper.Map<TranslatorLibraryInfoView>(info);
  3346. //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
  3347. view.OfficialDutyIdItem = await _sqlSugar
  3348. .Queryable<Grp_OfficialDutyLinkTranslator>()
  3349. .Where(x => x.IsDel == 0 && x.TranslatorId == id)
  3350. .Select(x => x.OfficialDutyId)
  3351. .ToArrayAsync();
  3352. return Ok(JsonView(view));
  3353. }
  3354. /// <summary>
  3355. /// 翻译人员库
  3356. /// Item
  3357. /// </summary>
  3358. /// <param name="dto"></param>
  3359. /// <returns></returns>
  3360. [HttpPost]
  3361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3362. public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
  3363. {
  3364. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3365. RefAsync<int> total = 0;
  3366. var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  3367. .Where(x => x.IsDel == 0)
  3368. .WhereIF(!string.IsNullOrEmpty(dto.Name), x => x.Name.Contains(dto.Name))
  3369. .Select(x => new
  3370. {
  3371. x.Id,
  3372. x.Area,
  3373. x.Name,
  3374. Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
  3375. x.Tel,
  3376. x.Email,
  3377. x.WechatNo,
  3378. x.Language,
  3379. x.Price,
  3380. //x.Currency,
  3381. Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
  3382. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
  3383. x.CreateTime,
  3384. x.Remark
  3385. })
  3386. .OrderByDescending(x => x.CreateTime)
  3387. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  3388. return Ok(JsonView(view, total));
  3389. }
  3390. /// <summary>
  3391. /// 翻译人员库
  3392. /// OP
  3393. /// </summary>
  3394. /// <param name="dto"></param>
  3395. /// <returns></returns>
  3396. [HttpPost]
  3397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3398. public async Task<IActionResult> TranslatorLibraryOp([FromForm]TranslatorLibraryOpDto dto)
  3399. {
  3400. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3401. if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
  3402. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3403. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3404. var fileNames = new List<string>();
  3405. //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
  3406. var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
  3407. #region 保存文件
  3408. if (dto.Files != null)
  3409. {
  3410. if (!System.IO.Directory.Exists(fileBasePath))
  3411. {
  3412. System.IO.Directory.CreateDirectory(fileBasePath);
  3413. }
  3414. foreach (var item in dto.Files)
  3415. {
  3416. if (item.Length < 1) continue;
  3417. var file = item;
  3418. // 将文件保存到指定位置
  3419. var filePath = Path.Combine(fileBasePath, file.FileName);
  3420. using (var stream = new FileStream(filePath, FileMode.Create))
  3421. {
  3422. await file.CopyToAsync(stream);
  3423. }
  3424. //验证文件是否上传成功
  3425. if (!System.IO.File.Exists(filePath))
  3426. {
  3427. foreach (var filePathStr in fileNames)
  3428. {
  3429. System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
  3430. }
  3431. return Ok(JsonView(false, "文件上传失败!"));
  3432. }
  3433. fileNames.Add(file.FileName);
  3434. }
  3435. }
  3436. #endregion
  3437. #region 参数处理
  3438. var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
  3439. #endregion
  3440. _sqlSugar.BeginTran();
  3441. if (dto.Status == 1)
  3442. {
  3443. //验证重复
  3444. var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
  3445. if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
  3446. translatorInfo.CreateUserId = currUserInfo.UserId;
  3447. if (fileNames.Count > 0)
  3448. {
  3449. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  3450. }
  3451. var id = await _translatorRep.AddAsync(translatorInfo);
  3452. if (id > 0) {
  3453. #region 新增(公务信息关联翻译人员) 关联信息
  3454. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3455. {
  3456. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3457. foreach (var officialDutyId in dto.officialDutyIdItem)
  3458. {
  3459. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3460. {
  3461. TranslatorId = id,
  3462. OfficialDutyId = officialDutyId,
  3463. CreateUserId = currUserInfo.UserId,
  3464. Remark = $"翻译人员库-->添加"
  3465. });
  3466. }
  3467. if (officialDutyLinkTranslators.Count > 0)
  3468. {
  3469. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3470. }
  3471. }
  3472. #endregion
  3473. _sqlSugar.CommitTran();
  3474. return Ok(JsonView(true));
  3475. }
  3476. }
  3477. else if (dto.Status == 2)
  3478. {
  3479. var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
  3480. if (info != null)
  3481. {
  3482. if (!string.IsNullOrEmpty(info.Files))
  3483. {
  3484. try
  3485. {
  3486. var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
  3487. fileNames.AddRange(selectFiles);
  3488. }
  3489. catch (Exception)
  3490. {
  3491. }
  3492. }
  3493. }
  3494. if (fileNames.Count > 0)
  3495. {
  3496. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  3497. }
  3498. var upd = await _translatorRep
  3499. .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
  3500. {
  3501. Area = translatorInfo.Area,
  3502. Name = translatorInfo.Name,
  3503. Sex = translatorInfo.Sex,
  3504. Photo = translatorInfo.Photo,
  3505. Tel = translatorInfo.Tel,
  3506. Email = translatorInfo.Email,
  3507. WechatNo = translatorInfo.WechatNo,
  3508. OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
  3509. Language = translatorInfo.Language,
  3510. Price = translatorInfo.Price,
  3511. Currency = translatorInfo.Currency,
  3512. Remark = translatorInfo.Remark,
  3513. Files = translatorInfo.Files,
  3514. });
  3515. if (upd) {
  3516. #region 更新(公务信息关联翻译人员) 关联信息
  3517. var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
  3518. .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
  3519. .ToListAsync();
  3520. //删除
  3521. var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
  3522. if (officialDutyLinkTranslatorIds.Count > 0)
  3523. {
  3524. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3525. .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
  3526. {
  3527. DeleteUserId = currUserInfo.UserId,
  3528. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3529. IsDel = 1,
  3530. Remark = $"翻译人员库-->删除"
  3531. })
  3532. .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
  3533. .ExecuteCommandAsync();
  3534. }
  3535. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3536. {
  3537. //添加
  3538. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3539. foreach (var officialDutyId in dto.officialDutyIdItem)
  3540. {
  3541. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3542. {
  3543. TranslatorId = dto.Id,
  3544. OfficialDutyId = officialDutyId,
  3545. CreateUserId = currUserInfo.UserId,
  3546. Remark = $"翻译人员库-->更新"
  3547. });
  3548. }
  3549. if (officialDutyLinkTranslators.Count > 0)
  3550. {
  3551. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3552. }
  3553. }
  3554. #endregion
  3555. _sqlSugar.CommitTran();
  3556. return Ok(JsonView(true));
  3557. }
  3558. }
  3559. _sqlSugar.RollbackTran();
  3560. return Ok(JsonView(false));
  3561. }
  3562. /// <summary>
  3563. /// 翻译人员库
  3564. /// Del
  3565. /// </summary>
  3566. /// <param name="id"></param>
  3567. /// <returns></returns>
  3568. [HttpDelete("id")]
  3569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3570. public async Task<IActionResult> TranslatorLibraryDel(int id)
  3571. {
  3572. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3573. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3574. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3575. _sqlSugar.BeginTran();
  3576. var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
  3577. if (!upd) {
  3578. _sqlSugar.RollbackTran();
  3579. return Ok(JsonView(false));
  3580. }
  3581. #region 删除公务出访
  3582. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3583. .SetColumns(x => new Grp_OfficialDutyLinkTranslator() {
  3584. DeleteUserId = currUserInfo.UserId,
  3585. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3586. IsDel = 1,
  3587. Remark = $"翻译人员库-->删除"
  3588. })
  3589. .Where(x => x.TranslatorId == id)
  3590. .ExecuteCommandAsync();
  3591. #endregion
  3592. _sqlSugar.CommitTran();
  3593. return Ok(JsonView(true));
  3594. }
  3595. #endregion
  3596. }
  3597. }