ResourceController.cs 202 KB

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