12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637 |
- using Aspose.Cells;
- using Aspose.Words;
- using EyeSoft.Extensions;
- using EyeSoft.Reflection;
- using NPOI.SS.Formula.Functions;
- using OASystem.API.OAMethodLib;
- using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
- using OASystem.Domain.AesEncryption;
- using OASystem.Domain.Dtos.CRM;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Dtos.PersonnelModule;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Domain.ViewModels.JuHeExchangeRate;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- using OASystem.Infrastructure.Repositories.Groups;
- using Org.BouncyCastle.Asn1.X509;
- using Org.BouncyCastle.Utilities.Encoders;
- using System.Data;
- using System.Diagnostics;
- using System.IO;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- using static QRCoder.PayloadGenerator.SwissQrCode;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 资料相关
- /// </summary>
- //[Authorize]
- [Route("api/[controller]/[action]")]
- public class ResourceController : ControllerBase
- {
- private readonly IMapper _mapper;
- private readonly SqlSugarClient _sqlSugar;
- private readonly IConfiguration _config;
- private readonly CarDataRepository _carDataRep;
- private readonly LocalGuideDataRepository _localGuideDataRep;
- private readonly ThreeCodeRepository _ThreeCodeRep;
- private readonly HotelDataRepository _hotelDataRep;
- private readonly ResItemInfoRepository _resItemInfoRep;
- private readonly SetDataRepository _setDataRepository;
- private readonly CountryFeeRepository _countryFeeRep;
- private readonly SetDataTypeRepository _setDataTypeRep;
- private readonly AirTicketAgentRepository _airTicketAgentRep;
- private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
- private readonly OfficialActivitiesRepository _officialActivitiesRep;
- private readonly AskDataRepository _askDataRep;
- private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
- private readonly TourClientListRepository _tourClientListRep;
- private readonly DelegationInfoRepository _delegationInfoRep;
- private readonly TranslatorLibraryRepository _translatorRep;
- private readonly MediaSuppliersRepository _mediaSupplierRep;
- private readonly List<int> _portIds;
- private readonly BasicInsuranceCostRepository _insuranceCostRep;
- public ResourceController(
- IMapper mapper,
- IConfiguration config,
- SqlSugarClient sqlSugar,
- CarDataRepository carDataRep,
- LocalGuideDataRepository localGuideDataRep,
- ThreeCodeRepository threeCodeRep,
- HotelDataRepository hotelDataRep,
- ResItemInfoRepository resItemInfoRep,
- SetDataRepository setDataRepository,
- CountryFeeRepository countryFeeRep,
- SetDataTypeRepository setDataTypeRep,
- AirTicketAgentRepository airTicketAgentRep,
- InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
- OfficialActivitiesRepository officialActivitiesRep,
- AskDataRepository askDataRep,
- TicketBlackCodeRepository ticketBlackCodeRep,
- TourClientListRepository tourClientListRep,
- DelegationInfoRepository delegationInfoRep,
- TranslatorLibraryRepository translatorRep,
- MediaSuppliersRepository mediaSupplierRep,
- BasicInsuranceCostRepository insuranceCostRep
- )
- {
- _mapper = mapper;
- _config = config;
- _sqlSugar = sqlSugar;
- _carDataRep = carDataRep;
- _localGuideDataRep = localGuideDataRep;
- _ThreeCodeRep = threeCodeRep;
- _hotelDataRep = hotelDataRep;
- _resItemInfoRep = resItemInfoRep;
- _setDataRepository = setDataRepository;
- _countryFeeRep = countryFeeRep;
- _setDataTypeRep = setDataTypeRep;
- _airTicketAgentRep = airTicketAgentRep;
- _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
- _officialActivitiesRep = officialActivitiesRep;
- _askDataRep = askDataRep;
- _ticketBlackCodeRep = ticketBlackCodeRep;
- _tourClientListRep = tourClientListRep;
- _delegationInfoRep = delegationInfoRep;
- _translatorRep = translatorRep;
- _mediaSupplierRep = mediaSupplierRep;
- _portIds = new List<int> { 1, 2, 3 };
- _insuranceCostRep = insuranceCostRep;
- }
- #region 车公司资料板块
- /// <summary>
- /// 车公司信息查询
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
- {
- Result LocalGuide = await _carDataRep.QueryCarData(dto);
- if (LocalGuide.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", LocalGuide.Data));
- }
- else
- {
- return Ok(JsonView(false, LocalGuide.Msg));
- }
- }
- /// <summary>
- /// 车公司资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarSelect()
- {
- var carData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
- if (carData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- foreach (var item in carData) EncryptionProcessor.DecryptProperties(item);
- carData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
- carData = carData.Where((x, i) => carData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
- carData = carData.OrderBy(x => x.Id).ToList();
- var data = new List<CarDataSelectView>();
- foreach (CarDataSelectView car in carData)
- {
- if (!string.IsNullOrWhiteSpace(car.UnitArea))
- {
- data.Add(car);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- /// <summary>
- /// 根据Id查询车公司详细数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
- {
- string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
- var info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
- if (info == null)
- {
- return Ok(JsonView(false, "未找到相关数据!"));
- }
- EncryptionProcessor.DecryptProperties(info);
- return Ok(JsonView(true, "查询成功", info));
- }
- /// <summary>
- /// 车公司信息添加
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AddCarData(AddCarDataDto dto)
- {
- if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
- if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
- if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- var carDadaInfo = _carDataRep
- .QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea &&
- a.UnitName == dto.UnitName &&
- a.Contact == dto.Contact &&
- a.ContactTel == dto.ContactTel
- )
- .First();
- if (carDadaInfo != null) return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
- var carData = _mapper.Map<Res_CarData>(dto);
- EncryptionProcessor.EncryptProperties(carData);
- int id = await _carDataRep.AddAsyncReturnId(carData);
- if (id < 1) return Ok(JsonView(false, "添加失败!"));
- return Ok(JsonView(true, "添加成功", new { Id = id }));
- }
- /// <summary>
- /// 车公司信息修改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UpCarData(UpCarDataDto dto)
- {
- if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
- if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
- if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- var carData = _mapper.Map<Res_CarData>(dto);
- EncryptionProcessor.EncryptProperties(carData);
- var res = await _sqlSugar.Updateable(carData)
- .IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.DeleteTime, x.DeleteUserId, x.IsDel })
- .ExecuteCommandAsync();
- if (res < 1) { return Ok(JsonView(false, "修改失败!")); }
- return Ok(JsonView(true, "修改成功"));
- }
- /// <summary>
- /// 车公司信息删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCarData(DelCarDataDto dto)
- {
- bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res) { return Ok(JsonView(false, "删除失败!")); }
- return Ok(JsonView(true, "删除成功"));
- }
- #endregion
- #region 导游地接资料板块
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> LocalGuideBatchEncryption()
- {
- var infos = await _sqlSugar.Queryable<Res_LocalGuideData>().ToListAsync();
- foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
- var updTotal = await _sqlSugar.Updateable(infos).ExecuteCommandAsync();
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 导游地接资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
- {
- Stopwatch stopwatch = Stopwatch.StartNew();
- Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
- if (LocalGuide.Code == 0)
- {
- stopwatch.Stop();
- return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.ElapsedMilliseconds} 毫秒", LocalGuide.Data));
- }
- stopwatch.Stop();
- return Ok(JsonView(false, LocalGuide.Msg + $" 耗时:{stopwatch.ElapsedMilliseconds} 毫秒"));
- }
- /// <summary>
- /// 导游地接资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuideSelect()
- {
- var localGuides = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
- if (localGuides.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- foreach (var item in localGuides) EncryptionProcessor.DecryptProperties(item);
- localGuides.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
- localGuides = localGuides.Where((x, i) => localGuides.FindIndex(z => z.UnitArea == x.UnitArea && !string.IsNullOrEmpty(z.UnitArea)) == i).ToList();
- localGuides = localGuides.OrderBy(x => x.Id).ToList();
- var data = new List<QueryLocalGuideSelectView>();
- foreach (QueryLocalGuideSelectView Local in localGuides)
- {
- if (!string.IsNullOrWhiteSpace(Local.UnitArea))
- {
- data.Add(Local);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- /// <summary>
- /// 根据Id查询地接详细数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
- {
- string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
- var info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
- if (info == null)
- {
- return Ok(JsonView(false, "未找到相关数据!"));
- }
- EncryptionProcessor.DecryptProperties(info);
- return Ok(JsonView(true, "查询成功", info));
- }
- /// <summary>
- /// 导游地接信息操作(Status:1.新增,2.修改)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
- {
- if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
- if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
- if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
- if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
- Result result = await _localGuideDataRep.LocalGuideOperation(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- /// <summary>
- /// 导游地接信息操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
- {
- var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 机场三字码信息
- /// <summary>
- /// 机场三字码查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
- {
- try
- {
- Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
- if (LocalGuide.Code == 0)
- {
- return Ok(JsonView(true, "查询成功", LocalGuide.Data));
- }
- else
- {
- return Ok(JsonView(false, LocalGuide.Msg));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码数据城市下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryThreeCodeSelect()
- {
- try
- {
- var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
- if (ThreeCode.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
- ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
- ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
- List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
- foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
- {
- if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
- {
- data.Add(_ThreeCode);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
- {
- try
- {
- if (dto.Three == "")
- {
- return Ok(JsonView(false, "请检查三字码是否填写!"));
- }
- if (dto.Country == "")
- {
- return Ok(JsonView(false, "请检查国家是否填写!"));
- }
- if (dto.City == "")
- {
- return Ok(JsonView(false, "请检查城市是否填写正确!"));
- }
- if (dto.AirPort == "")
- {
- return Ok(JsonView(false, "请检查机场是否填写正确!"));
- }
- Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机场三字码资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
- {
- try
- {
- var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- ///根据ID查询三字码信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
- {
- var jw = JsonView(false);
- var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
- if (single != null)
- {
- jw = JsonView(true, "获取成功!", new
- {
- single.Three,
- Four = single.Four?.Trim(),
- single.AirPort,
- single.AirPort_En,
- single.City,
- single.Country,
- single.Remark
- });
- }
- else
- {
- jw.Msg = "暂无!";
- }
- return Ok(jw);
- }
- #endregion
- #region 代理出票合作方资料
- /// <summary>
- /// 代理出票合作方资料
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
- {
- var res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
- if (res_AirTicketAgents.Count > 1)
- {
- res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
- if (dto.PageSize == 0 && dto.PageIndex == 0)
- {
- foreach (var item in res_AirTicketAgents) EncryptionProcessor.DecryptProperties(item);
- return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
- }
- else
- {
- int count = res_AirTicketAgents.Count;
- float totalPage = (float)count / dto.PageSize;//总页数
- if (totalPage == 0) totalPage = 1;
- else totalPage = (int)Math.Ceiling((double)totalPage);
- var _AirTicketAgent = new List<Res_AirTicketAgent>();
- for (int i = 0; i < dto.PageSize; i++)
- {
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
- if (RowIndex < res_AirTicketAgents.Count)
- {
- EncryptionProcessor.DecryptProperties(res_AirTicketAgents[RowIndex]);
- _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
- }
- else break;
- }
- return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
- }
- }
- return Ok(JsonView(false, "暂无数据!"));
- }
- /// <summary>
- /// 代理出票合作方资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
- {
- if (string.IsNullOrEmpty(dto.Account)) return Ok(JsonView(false, "请检查代理商账户是否填写!"));
- if (string.IsNullOrEmpty(dto.Bank)) return Ok(JsonView(false, "请检查代理商银行是否填写!"));
- if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
- Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
- if (result.Code != 0) return Ok(JsonView(false, result.Msg));
- return Ok(JsonView(true, result.Msg));
- }
- /// <summary>
- /// 代理出票合作方资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
- {
- var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res) return Ok(JsonView(false, "删除失败"));
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 酒店资料数据
- /// <summary>
- /// 酒店信息查询 Page
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
- {
- string sqlWhere = string.Empty;
- if (!string.IsNullOrWhiteSpace(dto.Name))
- {
- sqlWhere += string.Format(@" And hd.Name like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Name));
- }
- if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
- {
- sqlWhere += string.Format(@" And hd.City like '%{0}%'", AesEncryptionHelper.Encrypt(dto.City));
- }
- if (!string.IsNullOrWhiteSpace(dto.Contact))
- {
- sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Contact));
- }
- if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
- {
- sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", AesEncryptionHelper.Encrypt(dto.ContactPhone));
- }
- sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- string sql = string.Format(@"SELECT
- *
- FROM
- (
- SELECT
- ROW_NUMBER() OVER (
- ORDER BY
- hd.CreateTime DESC
- ) AS Row_Number,
- hd.Id,
- hd.City,
- hd.[Name],
- hd.Tel,
- hd.Fax,
- hd.Contact,
- hd.ContactPhone,
- u.CnName AS CreateUserName,
- hd.CreateTime
- FROM
- Res_HotelData hd
- WITH
- (NoLock)
- LEFT JOIN Sys_Users u
- WITH
- (NoLock) ON hd.CreateUserId = u.Id {0}
- ) Temp
- ", sqlWhere);
- if (dto.PortType == 1)
- {
- var HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
- if (HotelDataData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据"));
- }
- foreach (var item in HotelDataData)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- return Ok(JsonView(true, "操作成功", HotelDataData));
- }
- else if (dto.PortType == 2 || dto.PortType == 3)
- {
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
- foreach (var item in data) EncryptionProcessor.DecryptProperties(item);
- return Ok(JsonView(true, "操作成功", data, total));
- }
- else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
- }
- /// <summary>
- /// 酒店资料
- /// 详情
- /// add time:2024-05-14 11:57:10
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
- {
- var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, _view.Msg, _view.Data));
- }
- return Ok(JsonView(false, _view.Msg));
- }
- /// <summary>
- /// 酒店资料下拉框数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryHotelDataSelect()
- {
- try
- {
- var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
- if (HotelData.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- //解密
- foreach (var item in HotelData)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
- HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
- HotelData = HotelData.OrderBy(x => x.Id).ToList();
- var data = new List<QueryHotelDataSelect>();
- foreach (var Hotel in HotelData)
- {
- if (!string.IsNullOrWhiteSpace(Hotel.City))
- {
- data.Add(Hotel);
- }
- }
- return Ok(JsonView(true, "查询成功", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 酒店资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
- {
- if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
- if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
- if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
- if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
- Result result = await _hotelDataRep.OperationHotelData(dto);
- if (result.Code != 0) return Ok(JsonView(false, result.Msg));
- return Ok(JsonView(true, result.Msg));
- }
- /// <summary>
- /// 酒店资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
- {
- try
- {
- var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 签证费用资料
- /// <summary>
- /// 签证费用资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
- {
- if (dto.PortType == 1)
- {
- var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
- if (CountryFee.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
- return Ok(JsonView(true, "查询成功", CountryFee));
- }
- else if (dto.PortType == 2)
- {
- var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
- if (CountryFee.Count == 0)
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
- return Ok(JsonView(true, "查询成功", CountryFee));
- }
- else
- {
- return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
- }
- }
- /// <summary>
- /// 签证费用资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
- {
- if (string.IsNullOrWhiteSpace(dto.VisaContinent))
- {
- return Ok(JsonView(false, "请检查州名是否填写!"));
- }
- if (string.IsNullOrWhiteSpace(dto.VisaCountry))
- {
- return Ok(JsonView(false, "请检查国家名是否填写!"));
- }
- if (string.IsNullOrWhiteSpace(dto.VisaTime))
- {
- return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
- }
- if (string.IsNullOrWhiteSpace(dto.UrgentTime))
- {
- return Ok(JsonView(false, "请检加急时间是否填写正确!"));
- }
- Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
- if (result.Code == 0)
- {
- return Ok(JsonView(true, result.Msg));
- }
- return Ok(JsonView(false, result.Msg));
- }
- /// <summary>
- /// 签证费用资料操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
- {
- var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- #endregion
- #region 物料信息、供应商维护
- #region 供应商
- /// <summary>
- /// 物料供应商查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
- if (_ItemVendorDto != null)
- {
- if (_ItemVendorDto.SearchType == 2) //获取列表
- {
- Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
- return Ok(rstList);
- }
- else
- {
- Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
- return Ok(rstInfo);
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除供应商信息
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
- {
- bool rst = false;
- if (_dto.EditType >= 0)
- {
- if (string.IsNullOrEmpty(_dto.VendorFullName))
- {
- return Ok(JsonView(false, "全称未填写"));
- }
- if (string.IsNullOrEmpty(_dto.VendorLinker))
- {
- return Ok(JsonView(false, "联系人未填写"));
- }
- if (string.IsNullOrEmpty(_dto.VendorMobile))
- {
- return Ok(JsonView(false, "联系人手机号未填写"));
- }
- if (string.IsNullOrEmpty(_dto.BusRange))
- {
- return Ok(JsonView(false, "经营范围未选择"));
- }
- if (_dto.EditType == 0)
- {
- var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
- if (checkEmpty != null)
- {
- return Ok(JsonView(false, "已存在同名供应商"));
- }
- rst = await _resItemInfoRep.addVendorInfo(_dto);
- }
- else if (_dto.EditType == 1)
- {
- if (_dto.VendorId > 0)
- {
- Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
- rst = await _resItemInfoRep.updVendorInfo(_entity);
- }
- else
- {
- return Ok(JsonView(false, "供应商不存在"));
- }
- }
- }
- else
- {
- if (_dto.VendorId < 1 || _dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "用户Id或供应商Id不存在"));
- }
- Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
- rst = await _resItemInfoRep.delVendorInfo(_entity);
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 物料信息
- /// <summary>
- /// 物料信息查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchItemInfo(string paras)
- {
- if (string.IsNullOrEmpty(paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
- if (_ItemInfoDto != null)
- {
- if (_ItemInfoDto.SearchType == 2) //获取列表
- {
- Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
- return Ok(rstList);
- }
- else
- {
- Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
- return Ok(rstInfo);
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除物料信息
- /// </summary>
- ///
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
- {
- bool rst = false;
- if (_dto.EditType >= 0)
- {
- if (_dto.VendorId < 1)
- {
- return Ok(JsonView(false, "未选择供应商"));
- }
- if (string.IsNullOrEmpty(_dto.ItemName))
- {
- return Ok(JsonView(false, "物料名称为空"));
- }
- if (_dto.ItemTypeId < 1)
- {
- return Ok(JsonView(false, "未选择物料类型"));
- }
- if (_dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "当前操作用户Id为空"));
- }
- if (_dto.CurrRate <= 0)
- {
- return Ok(JsonView(false, "物料录入价格不能小于等于0"));
- }
- if (_dto.EditType == 0)
- {
- //判断物料名称、类型、供应商全部重复
- var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
- if (checkEmpty != null)
- {
- return Ok(JsonView(false, "已存在重复物料信息"));
- }
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- DateTime dtNow = DateTime.Now;
- _entity.CreateUserId = _dto.SysUserId;
- _entity.IsDel = 0;
- _entity.MaxRate = _dto.CurrRate;
- _entity.MaxDt = dtNow;
- _entity.CurrRate = _dto.CurrRate;
- _entity.CurrDt = dtNow;
- _entity.MinRate = _dto.CurrRate;
- _entity.MinDt = dtNow;
- rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
- }
- else if (_dto.EditType == 1)
- {
- if (_dto.ItemId > 0)
- {
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- _entity.Id = _dto.ItemId;
- rst = await _resItemInfoRep.updItemInfo(_entity);
- }
- else
- {
- return Ok(JsonView(false, "供应商不存在"));
- }
- }
- }
- else
- {
- if (_dto.ItemId < 1 || _dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
- }
- Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
- rst = await _resItemInfoRep.delItemInfo(_entity);
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 物料类型获取
- #endregion
- #endregion
- #region 备忘录
- /// <summary>
- /// 备忘录查询
- /// </summary>
- /// <param name="paras">Json序列化</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
- if (_memoDto != null)
- {
- if (_memoDto.SearchType == 2)
- {
- //获取列表
- string sqlWhere = string.Format(" Where IsDel=0 ");
- #region SqlWhere
- if (!string.IsNullOrEmpty(_memoDto.Abstracts))
- {
- sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
- }
- if (!string.IsNullOrEmpty(_memoDto.Title))
- {
- sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
- }
- if (_memoDto.ReadLevel > 0)
- {
- sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
- }
- #endregion
- int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
- int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
- string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
- m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
- m.LastedEditDt,m.LastedEditorId
- From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
- Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
- ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
- Res_MemoListView rst = new Res_MemoListView();
- rst.CurrPageIndex = currPIndex;
- rst.CurrPageSize = currPSize;
- List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
- Dictionary<int, string> userDic = new Dictionary<int, string>();
- foreach (var item in dataSource)
- {
- if (userDic.ContainsKey(item.LastedEditorId))
- {
- item.LastedEditor = userDic[item.LastedEditorId];
- }
- else
- {
- var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
- userDic[item.LastedEditorId] = _sysUser.CnName;
- item.LastedEditor = _sysUser.CnName;
- }
- }
- rst.DataList = new List<Res_MemoView>(dataSource);
- if (rst.DataList.Count > 0)
- {
- string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
- int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
- rst.DataCount = dataCount;
- }
- return Ok(JsonView(rst));
- }
- else
- {
- //获取对象
- string sqlSingle = string.Format(@" Select
- m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
- m.LastedEditDt,m.LastedEditor,m.MDFilePath
- From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
- Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
- Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
- if (_result != null)
- {
- var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
- _result.LastedEditor = _sysUser.CnName;
- _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
- return Ok(JsonView(_result));
- }
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 创建/编辑/删除备忘录信息
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
- {
- bool rst = false;
- if (_dto.SysUserId < 1)
- {
- return Ok(JsonView(false, "操作人失效"));
- }
- var _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
- if (_sysUser == null)
- {
- return Ok(JsonView(false, "操作人失效02"));
- }
- if (_dto.EditType >= 0)
- {
- if (_dto.ReadLevel < 1)
- {
- return Ok(JsonView(false, "未知的阅读等级"));
- }
- if (string.IsNullOrEmpty(_dto.Title.Trim()))
- {
- return Ok(JsonView(false, "标题不能为空"));
- }
- if (string.IsNullOrEmpty(_dto.Content.Trim()))
- {
- return Ok(JsonView(false, "正文内容不能为空"));
- }
- //新增备忘录
- DateTime dtNow = DateTime.Now;
- string dir = AppSettingsHelper.Get("MemoCurrPath");
- string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
- string content = JsonConvert.SerializeObject(_dto.Content);
- if (_dto.EditType == 0)//新增
- {
- string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
- if (savePath.Length > 0)
- {
- Res_MemoInfo _insert = new Res_MemoInfo();
- _insert.Abstracts = _dto.Abstracts;
- _insert.Title = _dto.Title;
- _insert.DepartmentId = _sysUser.DepId;
- _insert.CreateUserId = _sysUser.Id;
- _insert.LastedEditDt = dtNow;
- _insert.LastedEditor = _sysUser.Id;
- _insert.MDFilePath = savePath;
- _insert.ReadLevel = _dto.ReadLevel;
- _insert.Title = _dto.Title;
- int result = await _resItemInfoRep.AddAsync(_insert);
- return Ok(JsonView(result > 0));
- }
- else
- {
- return Ok(JsonView(false, "路径保存失败"));
- }
- }
- else//修改
- {
- if (_dto.MemoId < 1)
- {
- return Ok(JsonView(false, "MemoId不存在"));
- }
- Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
- if (_source == null)
- {
- return Ok(JsonView(false, "MemoInfo不存在"));
- }
- //修改
- string sourcePath = _source.MDFilePath;
- string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
- new IOOperatorHelper().MoveFile(sourcePath, recycDir);
- string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
- if (savePath.Length > 0)
- {
- var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
- .SetColumns(it => it.LastedEditDt == DateTime.Now)
- .SetColumns(it => it.LastedEditor == _sysUser.Id)
- .SetColumns(it => it.Abstracts == _dto.Abstracts)
- .SetColumns(it => it.MDFilePath == savePath)
- .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
- .SetColumns(it => it.Title == _dto.Title)
- .Where(s => s.Id == _source.Id)
- .ExecuteCommandAsync();
- return Ok(JsonView(result > 0));
- }
- }
- }
- else
- {
- //删除
- if (_dto.MemoId < 1)
- {
- return Ok(JsonView(false, "MemoId不存在"));
- }
- Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
- if (_source == null)
- {
- return Ok(JsonView(false, "MemoInfo不存在"));
- }
- //修改
- string sourcePath = _source.MDFilePath;
- string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
- new IOOperatorHelper().MoveFile(sourcePath, recycDir);
- var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
- .SetColumns(it => it.IsDel == 1)
- .SetColumns(it => it.DeleteUserId == _sysUser.Id)
- .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
- .Where(s => s.Id == _source.Id)
- .ExecuteCommandAsync();
- return Ok(JsonView(result > 0));
- }
- return Ok(JsonView(rst));
- }
- #endregion
- #region 商邀资料
- /// <summary>
- /// 商邀资料 基础数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
- {
- #region 参数验证
- if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
- #endregion
- var ExcludedKeyStr = new string[] { "快递费" };
- var ClientKeyStr = new string[] { "邀请函翻译" };
- List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
- List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .Where(it => it.IsDel == 0)
- .Select(x => new Res_InvitationOfficialActivityData
- {
- Country = x.Country,
- UnitName = x.UnitName,
- Contact = x.Contact,
- Field = x.Field,
- })
- .ToList();
- foreach (var item in _ioaDatas)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- foreach (var item in ExcludedKeyStr)
- {
- _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
- }
- foreach (var item in ClientKeyStr)
- {
- _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
- }
- List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
- var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
- var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
- var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
- var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
- var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
- var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
- var _data = new
- {
- CountryData = _countryData,
- InviterData = _inviterData,
- DomainData = _domainData,
- ContactData = _contactData,
- GroupNameData = _groupNameData,
- UserNameData = _userNameData,
- };
- return Ok(JsonView(true, $"查询成功!", _data));
- }
- /// <summary>
- /// 商邀资料查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
- {
- var ExcludedKeyStr = new string[] { "快递费" };
- var ClientKeyStr = new string[] { "邀请函翻译" };
- var columns = "Id,UnitName,Contact";
- try
- {
- #region 参数验证
- if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
- if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
- #endregion
- //string sqlWhere = string.Empty;
- if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
- //if (!string.IsNullOrWhiteSpace(dto.UnitName)) { columns += ",UnitName"; }
- //if (!string.IsNullOrWhiteSpace(dto.Contact)) { columns += ",Contact"; }
- if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
- if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
- //if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { columns += ",CreateUserId"; }
- //if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
- //{
- // columns += ",CreateUserId";
- //}
- DateTime endTime = new DateTime();
- var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .Where(x => x.IsDel == 0)
- .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
- .WhereIF(DateTime.TryParse(dto.StartCreateTime , out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime )
- .Select(columns)
- .ToList();
- foreach (var item in InvitationOfficialActivityDataList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => !string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
- .ToList();
- foreach (var item in ExcludedKeyStr)
- {
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
- //sqlWhere += $" And i.UnitName not like '%{item}%' ";
- }
- foreach (var item in ClientKeyStr)
- {
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
- //sqlWhere += $" And i.Contact not like '%{item}%' ";
- }
- var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
- RefAsync<int> totalCount = 0;
- var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
- .Where((a, b) => ids.Contains(a.Id))
- .OrderByDescending((a, b) => a.CreateTime)
- .Select((a, b) => new InvitationOfficialActivityDataView
- {
- FaceBook = a.FaceBook,
- Id = a.Id,
- CreateUserId = a.CreateUserId,
- IsDel = 0,
- Address = a.Address,
- Background = a.Background,
- City = a.City,
- Contact = a.Contact,
- Country = a.Country,
- CreateTime = a.CreateTime,
- CreateUserName = b.CnName,
- Delegation = a.Delegation,
- Email = a.Email,
- Fax = a.Fax,
- Field = a.Field,
- FilePath = a.FilePath,
- Ins = a.Ins,
- WeChat = a.WeChat,
- UnitWeb = a.UnitWeb,
- UnitName = a.UnitName,
- UnitInfo = a.UnitInfo,
- Tel = a.Tel,
- SndFilePath = a.SndFilePath,
- SndFileName = a.SndFileName,
- Remark = a.Remark,
- OtherInfo = a.OtherInfo,
- Job = a.Job
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
- var allGroupIds = new HashSet<int>();
- foreach (var item in _ivitiesViews)
- {
- EncryptionProcessor.DecryptProperties(item);
- if (!string.IsNullOrEmpty(item.Delegation))
- {
- allGroupIds.UnionWith(item.Delegation.Split(',').Select(x =>
- {
- int id;
- if (int.TryParse(x, out id)) return id;
- return 0;
- }).Where(id => id != 0));
- }
- }
- var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
- .ToList()
- .GroupBy(x => x.Id)
- .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
- foreach (var item in _ivitiesViews)
- {
- string groupNameStr = "";
- if (!string.IsNullOrEmpty(item.Delegation))
- {
- var groupIds = item.Delegation.Split(',').Select(x =>
- {
- int id;
- if (int.TryParse(x, out id)) return id;
- return 0;
- })
- .Where(id => id != 0)
- .ToArray();
- foreach (var id in groupIds)
- {
- if (_DelegationInfos.ContainsKey(id))
- {
- groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
- }
- }
- if (groupNameStr.Length > 1)
- {
- groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
- }
- }
- item.DelegationStr = groupNameStr;
- }
- return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- //[HttpPost]
- //public IActionResult EncipherInvitationOfficialActivityData()
- //{
- // var jw = JsonView(false);
- // var List_DB = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().ToList();
- // try
- // {
- // //foreach (var item in List_DB)
- // //{
- // // EncryptionProcessor.DecryptProperties(item);
- // //}
- // _sqlSugar.BeginTran();
- // foreach (var item in List_DB)
- // {
- // EncryptionProcessor.EncryptProperties(item);
- // }
- // var updateRow = _sqlSugar.Updateable<Res_InvitationOfficialActivityData>(List_DB).ExecuteCommand();
- // jw = JsonView(true, "success", "修改行数:" + updateRow);
- // _sqlSugar.CommitTran();
- // }
- // catch (Exception ex)
- // {
- // _sqlSugar.RollbackTran();
- // jw.Msg = ex.Message;
- // }
- // return Ok(jw);
- //}
- /// <summary>
- /// 根据商邀资料Id查询信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
- {
- if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
- return Ok(await _InvitationOfficialActivityDataRep.Info(id));
- }
- /// <summary>
- /// 商邀资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
- {
- return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
- }
- /// <summary>
- /// 商邀资料 删除文件
- /// </summary>
- /// <param name="id"></param>
- /// <param name="fileName"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
- {
- if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
- if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
- var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
- if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
- var files = new List<string>();
- try
- {
- files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
- }
- catch (Exception) { }
- if (files != null && files.Count > 0 && files.Contains(fileName))
- {
- var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
- if (System.IO.File.Exists(filePath))
- {
- System.IO.File.Delete(filePath);
- }
- //更改文件值
- files.Remove(fileName);
- var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
- .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 删除商邀资料信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
- {
- var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res) return Ok(JsonView(false, "删除失败"));
- var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
- if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
- var files = new List<string>();
- try
- {
- files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
- }
- catch (Exception) { }
- if (files != null && files.Count > 0)
- {
- foreach (var fileName in files)
- {
- var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
- if (System.IO.File.Exists(filePath))
- {
- System.IO.File.Delete(filePath);
- }
- }
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 商邀资料 ExcelExport
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityExcelExport(QueryInvitationOfficialActivityDataDto dto)
- {
- var ExcludedKeyStr = new string[] { "快递费" };
- var ClientKeyStr = new string[] { "邀请函翻译" };
- var columns = "Id,UnitName,Contact";
- #region 参数验证
- if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
- if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
- #endregion
- if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
- if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
- if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
- DateTime endTime = new DateTime();
- var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .Where(x => x.IsDel == 0)
- .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
- .WhereIF(DateTime.TryParse(dto.StartCreateTime, out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime)
- .Select(columns)
- .ToList();
- foreach (var item in InvitationOfficialActivityDataList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => !string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
- .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
- .ToList();
- foreach (var item in ExcludedKeyStr)
- {
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
- //sqlWhere += $" And i.UnitName not like '%{item}%' ";
- }
- foreach (var item in ClientKeyStr)
- {
- InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
- //sqlWhere += $" And i.Contact not like '%{item}%' ";
- }
- var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
- var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
- .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
- .Where((a, b) => ids.Contains(a.Id))
- .OrderByDescending((a, b) => a.CreateTime)
- .Select((a, b) => new IOAInfoView
- {
- FaceBook = a.FaceBook,
- Id = a.Id,
- Address = a.Address,
- Background = a.Background,
- City = a.City,
- Contact = a.Contact,
- Country = a.Country,
- Delegation = a.Delegation,
- Email = a.Email,
- Fax = a.Fax,
- Field = a.Field,
- Ins = a.Ins,
- WeChat = a.WeChat,
- UnitWeb = a.UnitWeb,
- UnitName = a.UnitName,
- UnitInfo = a.UnitInfo,
- Tel = a.Tel,
- SndFileName = a.SndFileName,
- Remark = a.Remark,
- OtherInfo = a.OtherInfo,
- Job = a.Job
- })
- .ToListAsync();
- if (!_ivitiesViews.Any()) return Ok(JsonView(false, $"您查询的数据暂无内容,不可导出!"));
- var allGroupIds = new HashSet<int>();
- foreach (var item in _ivitiesViews)
- {
- EncryptionProcessor.DecryptProperties(item);
- if (!string.IsNullOrEmpty(item.Delegation))
- {
- allGroupIds.UnionWith(
- item.Delegation.Split(',')
- .Select(x =>
- {
- int id;
- if (int.TryParse(x, out id)) return id;
- return 0;
- })
- .Where(id => id != 0)
- );
- }
- }
- var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
- .ToList()
- .GroupBy(x => x.Id)
- .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
- foreach (var item in _ivitiesViews)
- {
- string groupNameStr = "";
- if (!string.IsNullOrEmpty(item.Delegation))
- {
- var groupIds = item.Delegation.Split(',').Select(x =>
- {
- int id;
- if (int.TryParse(x, out id)) return id;
- return 0;
- })
- .Where(id => id != 0)
- .ToArray();
- foreach (var id in groupIds)
- {
- if (_DelegationInfos.ContainsKey(id))
- {
- groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
- }
- }
- if (groupNameStr.Length > 1)
- {
- groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
- }
- }
- item.DelegationStr = groupNameStr;
- }
- //获取模板
- string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/商邀资料模板.xls");
- var designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- var dt = CommonFun.ToDataTableArray(_ivitiesViews);
- dt.TableName = $"OADataView";
- designer.SetDataSource(dt);
- designer.Process();
- //文件名
- string fileName = $"商邀资料{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "InvitationOfficialActivityExport/" + fileName);
- string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/InvitationOfficialActivityExport/" + fileName;
- return Ok(JsonView(true, "成功", url));
- }
- /// <summary>
- /// 商邀资料 导入文件(Excel)模板下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityExcelTemplateExport()
- {
- //获取模板
- string fileName = $"商邀资料上传文件模板.xls";
- string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/Template/" + fileName;
- return Ok(JsonView(true, "成功", url));
- }
- /// <summary>
- /// 商邀资料 上传Excel文件添加
- /// </summary>
- /// <param name="file"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityExcelUpload(IFormFile file,int currUserId)
- {
- var fileName = file.FileName;
- var filePostfix = fileName.Split(".")[1].ToUpper();
- if (!filePostfix.Contains("XLS")) return Ok(JsonView(false, $"请传入Excel文件"));
- if (file.Length < 1) return Ok(JsonView(false, $"请传入有效的文件"));
- if (currUserId < 1) return Ok(JsonView(false, $"请传入有效的UserId"));
- //保存文件
- string fileDirPath = string.Format(@"{0}InvitationOfficialActivityExcelUpload/", AppSettingsHelper.Get("ExcelBasePath"));
- if (!Directory.Exists(fileDirPath))
- {
- Directory.CreateDirectory(fileDirPath);
- }
- var filePath = Path.Combine(fileDirPath, fileName);
- await using var stream = new FileStream(filePath, FileMode.Create);
- await file.CopyToAsync(stream);
- //读取保存的文件
- Workbook workbook = new Workbook(filePath);
- if (workbook == null) return Ok(JsonView(false, $"Excel文件不存在!"));
- Worksheet worksheet = workbook.Worksheets[0];
- if (worksheet == null) return Ok(JsonView(false, $"Excel文件工作簿不存在!"));
- var infos = new List<Res_InvitationOfficialActivityData>();
- var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName)).Select(x => new { x.Id, x.TeamName }).ToListAsync();
- for (int row = 1; row < worksheet.Cells.MaxDataRow + 1; row++)
- {
- var groupIdsLabel = string.Empty;
- var groupNames1 = worksheet.Cells[row, 14].StringValue ?? "-";
- if (!string.IsNullOrEmpty(groupNames1))
- {
- if (groupNames1.Contains(";"))
- {
- var groupNameArray = groupNames1.Split(";").Where(x => !string.IsNullOrEmpty(x)).ToList();
- var groupIds = groupNames.Where(x => groupNameArray.Contains(x.TeamName)).Select(x => x.Id).ToList();
- if (groupIds.Any()) groupIdsLabel = string.Join(',', groupIds);
- }
- else groupIdsLabel = groupNames.Where(x => groupNames1.Equals(x.TeamName)).FirstOrDefault()?.Id.ToString() ?? string.Empty;
- }
-
- infos.Add(new Res_InvitationOfficialActivityData() {
- Country = worksheet.Cells[row, 0].StringValue ?? "-",
- City = worksheet.Cells[row, 1].StringValue ?? "-",
- UnitName = worksheet.Cells[row, 2].StringValue ?? "-",
- Field = worksheet.Cells[row, 3].StringValue ?? "-",
- Address = worksheet.Cells[row, 4].StringValue ?? "-",
- UnitInfo = worksheet.Cells[row, 5].StringValue ?? "-",
- Contact = worksheet.Cells[row, 6].StringValue ?? "-",
- Job = worksheet.Cells[row, 7].StringValue ?? "-",
- Tel = worksheet.Cells[row, 8].StringValue ?? "-",
- Email = worksheet.Cells[row, 9].StringValue ?? "-",
- WeChat = worksheet.Cells[row, 10].StringValue ?? "-",
- FaceBook = worksheet.Cells[row, 11].StringValue ?? "-",
- Ins = worksheet.Cells[row, 12].StringValue ?? "-",
- Fax = worksheet.Cells[row, 13].StringValue ?? "-",
- Delegation = groupIdsLabel,
- SndFilePath = worksheet.Cells[row, 15].StringValue ?? "-",
- OtherInfo = worksheet.Cells[row, 16].StringValue ?? "-",
- Remark = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}] Excel上传文件添加! 文件存储地址[{filePath}]",
- CreateUserId = currUserId,
- IsDel = 0
- });
- }
- //加密
- foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
- var addCount = await _sqlSugar.Insertable(infos).ExecuteCommandAsync();
- if (addCount < 1) return Ok(JsonView(false, "文件上传添加失败!"));
- return Ok(JsonView(true, $"上传文件添加成功!共添加{addCount}条!"));
- }
- #endregion
- #region 公务出访
- /// <summary>
- /// 获取团组所有信息,绑定下拉框
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
- {
- //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
- //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
- var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
- dynamic groupInfos = null;
- if (_groupData.Code == 0) groupInfos = _groupData.Data;
- var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
- var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
- var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).Select(x => new TranslatorLibraryNameView() { Id = x.Id, Name = x.Name }).ToList();
- foreach (var item in translatorData) EncryptionProcessor.DecryptProperties(item);
- return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile , TranslatorData = translatorData }));
- }
- /// <summary>
- /// 公务List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
- {
- return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
- }
- /// <summary>
- /// 根据公务出访数据Id查询数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
- {
- Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 公务出访操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
- {
- Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
- }
- try
- {
- //公务出访变更发送通知
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
- }
- catch (Exception ex)
- {
- //抄送日志
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 上传文件(邮件截图)
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
- {
- string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
- string localPath = AppSettingsHelper.Get("GrpFileBasePath");
- string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
- if (dto.diId < 1 || dto.currUserId < 1)
- {
- return Ok(JsonView(false, "参数有误,上传失败!"));
- }
- if (dto.files == null || dto.files.Count < 1)
- {
- return Ok(JsonView(false, "文件为空,上传失败!"));
- }
- string localFileDir = $"{localPath}{ptfPath}";
- List<string> fileUrls = new List<string>();
- string[] failFiles = new string[] { };
- foreach (var file in dto.files)
- {
- //文件名称
- string[] fileNameArray = file.FileName.Split(".");
- string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
- //上传的文件的路径
- string filePath = $@"{localPath}公务相关文件";
- if (!Directory.Exists(filePath))
- {
- Directory.CreateDirectory(filePath);
- }
- var path = Path.Combine(filePath, projectFileName);
- //using var stream = new FileStream(path, FileMode.Create);
- //await file.CopyToAsync(stream);
- try
- {
- using (FileStream fs = System.IO.File.Create(path))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
- }
- catch (Exception ex)
- {
- failFiles.Append(file.FileName);
- }
- }
- var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
- List<string> files = new List<string>();
- var status = false;
- var _oaInfo = new Res_OfficialActivities()
- {
- DiId = dto.diId,
- ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
- IsDel = 0,
- CreateUserId = dto.currUserId,
- CreateTime = DateTime.Now
- };
- if (oaInfo == null)
- {
- var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
- .ExecuteReturnIdentityAsync();
- if (id > 0)
- {
- status = true;
- dto.id = id;
- }
- }
- else
- {
- var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
- ? new List<string>()
- : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
- if (oldFiles.Count > 0)
- {
- fileUrls.AddRange(oldFiles);
- }
- fileUrls = fileUrls.Distinct().ToList();
- if (fileUrls.Count() > 0)
- {
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
- .Where(x => x.Id == dto.id)
- .ExecuteCommandAsync();
- if (upd > 0) status = true;
- }
- }
- List<string> returnFileUrls = new List<string>();
- fileUrls.ForEach(x =>
- {
- returnFileUrls.Add($"{networkPath}{x}");
- });
- if (status)
- {
- string msg = "操作成功!";
- if (failFiles.Length > 1)
- {
- foreach (var item in failFiles)
- {
- msg += $"{failFiles}、";
- }
- msg = msg.Substring(0, msg.Length - 1);
- msg += "等文件保存失败!";
- }
- return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 删除文件(邮件截图)
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
- {
- string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
- string localPath = AppSettingsHelper.Get("GrpFileBasePath");
- string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
- if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
- {
- return Ok(JsonView(false, "参数有误,上传失败!"));
- }
- string localFileDir = $"{localPath}{ptfPath}";
- List<string> fileUrls = new List<string>();
- var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
- if (oaInfo != null)
- {
- string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
- if (!string.IsNullOrEmpty(urlJson))
- {
- List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
- var filePath = urls.Find(x => x.Contains(dto.FileName));
- if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
- var updFile = urls.Remove(filePath);
- if (updFile)
- {
- //删除文件
- string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
- if (System.IO.File.Exists(fileUrl))
- {
- System.IO.File.Delete(fileUrl);
- }
- string urlJsonstr = JsonConvert.SerializeObject(urls);
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
- .Where(x => x.Id == dto.Id)
- .ExecuteCommandAsync();
- if (upd > 0) return Ok(JsonView(true, "操作成功!"));
- }
- }
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 公务出访 确认、取消邀请
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
- if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
- var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
- .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
- .Where(x => x.Id == dto.Id)
- .ExecuteCommandAsync();
- if (upd > 0) return Ok(JsonView(true, "操作成功!"));
- return Ok(JsonView(false, "操作失败!"));
- }
- /// <summary>
- /// 上传文件
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
- {
- try
- {
- int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
- int DiId = int.Parse(Request.Headers["DiId"]);
- int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- Grp_DeleFile d = new Grp_DeleFile();
- d.Diid = DiId;
- d.Category = 970;
- if (Type == 1) d.Kind = 1;
- else if (Type == 2) d.Kind = 2;
- else if (Type == 3) d.Kind = 3;
- d.FileName = projectFileName;
- d.FilePath = "";
- d.CreateUserId = CreateUserId;
- int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
- {
- try
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
- if (_DeleFile != null)
- {
- string fileName = _DeleFile.FileName;
- string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- 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();
- return Ok(JsonView(true, "取消文件成功!"));
- }
- else
- {
- return Ok(JsonView(false, "取消文件失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除公务出访信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
- {
- _sqlSugar.BeginTran();
- var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- #region 删除公务出访
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
- {
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"公务出访-->删除"
- })
- .Where(x => x.OfficialDutyId == dto.Id)
- .ExecuteCommandAsync();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 公务出访
- /// 请示范例提示
- /// Add Time:2024-05-13 13:56:44
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
- {
- var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
- if (res.Code == 0)
- {
- return Ok(JsonView(true, "操作成功!", res.Data));
- }
- return Ok(JsonView(false, res.Msg));
- }
- /// <summary>
- /// 公务出访 (省外办,市外办) File Downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
- {
- #region 参数验证
- if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
- #endregion
- //团组基础信息
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
- if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
- groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
- //团组公务信息
- var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
- //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
- //团组客户名单
- var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
- List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
- if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
- string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
- string countryStayStr = ""; // xx、xx、xx
- //出入境费用 住宿类型
- var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
- if (dayCostDatas.Count > 0)
- {
- List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
- var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
- var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
- foreach (var item in nationalDataGroupByCountry)
- {
- visitCountrys += $"{item.Key}、";
- int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
- countryStayStr += $"{item.Key}{stayDays}天,";
- }
- if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
- if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
- }
- else
- {
- visitCountrys = groupInfo.VisitCountry;
- countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
- }
- //出访人数
- int visitPeopleNum = groupInfo.VisitPNumber;
- int visitDaysNum = groupInfo.VisitDays;
- //出访单位
- string obInfoStr = "";
- foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
- if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
- obInfoStr = obInfoStr ?? "[公务出访未录入]";
- //出访路线
- string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
- if (dto.FileType == 1)
- {
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //××(组团单位):接团客户信息团组
- dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
- //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
- string guestName = "";
- string guestJob = "";
- string guestInfoStr = "";
- var guestFirstInfo = guestInfos.FirstOrDefault();
- if (guestFirstInfo != null)
- {
- guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
- guestJob = guestFirstInfo.Job.Trim();
- guestInfoStr = $@"{guestJob}、{guestName}";
- }
- guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
- string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
- dic.Add("AskTitle", askTitle);
- //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
- string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
- string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
- dic.Add("AskSubTitle", askSubTitle);
- //出访目的
- dic.Add("VisitPurpose", groupInfo.VisitPurpose);
- //出访任务
- //(一)××(国家或地区)
- //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
- //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
- string obBackgroundStr = "";//出访背景
- string taskStr = ""; ; //出访任务
- var countrys = obDatas.GroupBy(it => it.Country);
- int countryIndex = 1;
- foreach (var item in countrys)
- {
- string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
- string taskContent = "";
- string obBackgroundContent = "";
- int obIndex = 1;
- foreach (var obInfo in item.ToList())
- {
- string reqSmaple = "";
- string settingStr = "";
- if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
- else reqSmaple = "[公务出访请示范例未录入]";
- if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
- else settingStr = "[公务方背景未录入]";
- taskContent += $"{obIndex}. {reqSmaple}\r\n";
- obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
- obIndex++;
- }
- taskStr += $"{taskTitle}{taskContent}";
- obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
- countryIndex++;
- }
- //出访背景
- if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
- dic.Add("OBSetting", obBackgroundStr);
- //出访任务
- if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
- dic.Add("TaskContent", taskStr);
- //出访时间
- //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
- string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
- //出访时间
- dic.Add("TimeQuantum", visitTimeQuantumStr);
- //出访路线
- //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
- dic.Add("Line", lineStr);
- //scheduling //行程安排
- string schedulingStr = $"[OP行程单暂未生成]";
- #region op行程 根据黑屏代码录入
- var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
- if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
- schedulingStr = "";
- List<Grp_TravelList> travelList = new List<Grp_TravelList>();
- travelList = opTripView.Data as List<Grp_TravelList>;
- if (travelList != null)
- {
- foreach (var item in travelList)
- {
- schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
- }
- }
- #endregion
- dic.Add("Scheduling", schedulingStr);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < guestInfos.Count; i++)
- {
- var guestInfo = guestInfos[i];
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(guestInfo.LastName + guestInfo.FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = guestInfo.Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "-";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
- builder.MoveToCell(0, i + 1, 3, 0);
- string birthDay = "";
- string birthDayStr = string.Empty;
- if (guestInfo.BirthDay != null)
- {
- birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
- }
- builder.Write(birthDayStr);
- }
- //删除多余行
- while (tableOne.Rows.Count > guestInfos.Count + 1)
- {
- tableOne.Rows.RemoveAt(guestInfos.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
- string filePath = fileDir + $@"OfficialActivities/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else if (dto.FileType == 2)
- {
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //××(组团单位):接团客户信息团组
- dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
- dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
- //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
- string guestName = "";
- string guestJob = "";
- string guestInfoStr = "";
- var guestFirstInfo = guestInfos.FirstOrDefault();
- if (guestFirstInfo != null)
- {
- guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
- guestJob = guestFirstInfo.Job;
- guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
- }
- string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
- dic.Add("ReqTitle", reqTitle);
- //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
- string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
- string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
- dic.Add("ReqSubTitle", reqSubTitle);
- /*
- * 出访任务
- * (一)××(国家或地区)
- * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
- * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
- *
- */
- string taskStr = string.Empty;
- List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
- int countryIndex = 1;
- foreach (var item in countrys)
- {
- string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
- string taskContent = "";
- if (!string.IsNullOrEmpty(item))
- {
- var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
- int obIndex = 1;
- if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
- else
- {
- foreach (var obInfo in countryObDatas)
- {
- taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
- obIndex++;
- }
- }
- }
- taskStr += $"{taskTitle}{taskContent}";
- countryIndex++;
- }
- if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
- //出访任务
- dic.Add("TaskContent", taskStr);
- //出访目的
- dic.Add("VisitPurpose", groupInfo.VisitPurpose);
- //出访信息
- //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
- string tripInfoStr = "";
- tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
- dic.Add("TripInfo", tripInfoStr);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < guestInfos.Count; i++)
- {
- var guestInfo = guestInfos[i];
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(guestInfo.LastName + guestInfo.FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = guestInfo.Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "未设置";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
- builder.MoveToCell(0, i + 1, 3, 0);
- DateTime birthDay = guestInfo.BirthDay;
- string birthDayStr = string.Empty;
- if (birthDay != null)
- {
- birthDayStr = birthDay.ToString("yyyy.MM");
- }
- builder.Write(birthDayStr);
- }
- //删除多余行
- while (tableOne.Rows.Count > guestInfos.Count + 1)
- {
- tableOne.Rows.RemoveAt(guestInfos.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
- var filePath = fileDir + $@"OfficialActivities/{fileName}";
- doc.Save(filePath);
- var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
- return Ok(JsonView(true, "操作成功!", url));
- }
- return Ok(JsonView(true, "操作失败!", ""));
- }
- private string GetToUpperNumber(int num)
- {
- string numStr = "";
- if (num == 1) numStr = "一";
- else if (num == 2) numStr = "二";
- else if (num == 3) numStr = "三";
- else if (num == 4) numStr = "四";
- else if (num == 5) numStr = "五";
- else if (num == 6) numStr = "六";
- else if (num == 7) numStr = "七";
- else if (num == 8) numStr = "八";
- else if (num == 9) numStr = "九";
- else if (num == 10) numStr = "十";
- return numStr;
- }
- [HttpPost]
- public IActionResult ExportOfficialActivitiesInfo(ExportOfficialActivitiesInfoDto dto)
- {
- var jw = JsonView(false);
- if (!ModelState.IsValid)
- {
- jw.Data = ModelState;
- return Ok(jw);
- }
- var startTime_bool = DateTime.TryParse(dto.StartTime, out DateTime startTime_parse);
- var endTime_bool = DateTime.TryParse(dto.EndTime, out DateTime endTime_parse);
- if(startTime_parse > endTime_parse)
- {
- jw.Msg = "开始实际不能大于结束时间!";
- return Ok(jw);
- }
- if (startTime_bool && endTime_bool)
- {
- //处理时间模板
- var Query_DB = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .LeftJoin<Res_OfficialActivities>((a, b) => a.Id == b.DiId && b.IsDel == 0)
- .LeftJoin<Sys_Users>((a, b, c) => b.CreateUserId == c.Id && c.IsDel == 0)
- .Where((a, b, c) => a.IsDel == 0 && a.VisitDate >= startTime_parse && a.VisitDate <= endTime_parse)
- .WhereIF(dto.State != -1, (a, b, c) => b.ConfirmTheInvitation == dto.State)
- .Select((a, b, c) => new
- {
- a.TeamName,
- b.Client,
- b.ConfirmTheInvitation,
- b.Contact,
- ConfirmTheInvitationStr = b.ConfirmTheInvitation == 1 ? "是" : "否",
- b.Date,
- b.Nature,
- c.CnName,
- b.Address,
- b.CreateTime
- })
- .ToList()
- .Where(x=>!x.Client.IsNullOrWhiteSpace())
- .ToList();
- if (Query_DB.Count > 0)
- {
- //打开excel
- var ftpPath = AppSettingsHelper.Get("ExcelFtpPath");
- var fileBasePath = AppSettingsHelper.Get("ExcelBasePath");
- var fileName = "公务出访信息.docx";
- //创建数据源Table
- DataTable dtSource = new DataTable();
- dtSource.TableName = "TB";
- var firstElem = Query_DB.First();
- //遍历firstElem所有属性
- foreach (var item in firstElem.GetType().GetProperties())
- {
- dtSource.Columns.Add(item.Name, item.PropertyType);
- }
- foreach (var item in Query_DB)
- {
- DataRow dr = dtSource.NewRow();
- //遍历dtSource所有列头
- foreach (DataColumn column in dtSource.Columns)
- {
- dr[column.ColumnName] = item.GetType().GetProperty(column.ColumnName)?.GetValue(item)?.ToString();
- }
- dtSource.Rows.Add(dr);
- }
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(fileBasePath + ("Template/公务出访信息.xlsx"));
- var title = startTime_parse.ToString("yyyy年MM月dd日") + " - " + endTime_parse.ToString("yyyy年MM月dd日") + " 公务出访信息";
- designer.SetDataSource("title", title);
- designer.SetDataSource(dtSource);
- designer.Process();
-
- var exportSerevePath = fileBasePath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
- var exportFtpPaht = ftpPath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
- //保存文件
- designer.Workbook.Save(exportSerevePath);
- jw.Data = AppSettingsHelper.Get("ExcelBaseUrl") + exportFtpPaht;
- jw.Code = 200;
- jw.Msg = "获取成功!";
- }
- else
- {
- jw.Data = "无公务信息!";
- }
- }
- else
- {
- jw.Data = "时间格式错误!";
- }
- return Ok(jw);
- }
- #endregion
- #region 请示数据库
- /// <summary>
- /// 查询请示数据库初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
- {
- Result groupData = await _askDataRep.QueryAskData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据Id查询请示数据库单条数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
- {
- Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
- if (_AskData == null)
- {
- return Ok(JsonView(true, "暂无数据!", _AskData));
- }
- return Ok(JsonView(true, "查询成功!", _AskData));
- }
- /// <summary>
- /// 请示数据库操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAskData(OpAskDataDto dto)
- {
- Result groupData = await _askDataRep.OpAskData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 删除请示资料信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAskData(DelBaseDto dto)
- {
- var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 请示资料信息
- /// 省外办下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
- {
- if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
- if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
- //大写数字序号
- string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
- "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
- "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
- "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
- //数据源
- var idItem = dto.DataIdItem.OrderBy(x => x);
- var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
- //书签名
- string Area = "",
- Official = "";
- //表格数据源
- DataTable dt = new DataTable();
- dt.Columns.Add("Country", typeof(string));
- dt.Columns.Add("TalkCase", typeof(string));
- int id = 0;
- int TalkcaseOrder = 0;
- int RowOrder = 0;
- //填充数据
- for (int i = 0; i < askDatas.Count; i++)
- {
- var ad = askDatas[i];
- Area = Area + ad.Country + ad.Area + "、";
- Official = Official + ad.UnitName + "、";
- //填充表格数据源
- DataRow dr = dt.NewRow();
- if (i > 0)
- {
- var adtemp = askDatas[i - 1];
- if (ad.Country == adtemp.Country)
- {
- TalkcaseOrder++;
- dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
- }
- else
- {
- RowOrder++;
- dr = dt.NewRow();
- dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- TalkcaseOrder = 0;
- }
- }
- else
- {
- dr["Country"] = "(" + num[i] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- }
- id = ad.Id;
- }
- //模板路径
- var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- #region 填充word内容
- #region 填充请示内容
- //利用DocumentBuilder处理表格或是书签
- Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
- string bookmark = "";
- try
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- bookmark = bookmark
- + dt.Rows[i]["Country"].ToString() + "\r\n"
- + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
- }
- }
- catch
- {
- }
- #endregion
- #region 填充word模板书签内容
- //团组信息
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
- //接团客户名单实例
- string client_sql = string.Format(@"
- SELECT
- tcl.Id,
- tcl.DiId,
- tcl.IsAccompany,
- temp.*,
- u.CnName AS Operator,
- tcl.CreateTime AS OperatingTime
- FROM
- Grp_TourClientList tcl
- LEFT JOIN (
- SELECT
- dc.Id AS DcId,
- dc.LastName,
- dc.FirstName,
- ccom.CompanyFullName,
- dc.Job,
- cc.CertNo AS IDCardNo,
- dc.Sex,
- dc.BirthDay
- FROM
- Crm_DeleClient dc
- LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
- AND ccom.IsDel = 0
- LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
- AND cc.SdId = 773
- AND cc.IsDel = 0
- WHERE
- dc.IsDel = 0
- ) temp ON temp.DcId = tcl.ClientId
- LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
- WHERE
- tcl.IsDel = 0
- AND tcl.DiId = {0}", dto.DiId);
- var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
- //机票代码实例
- DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
- //三字码
- var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
- //团名
- if (doc.Range.Bookmarks["TeamName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TeamName"];
- mark.Text = di.TeamName;
- }
- //团长名
- if (doc.Range.Bookmarks["ClientName2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName2"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- if (doc.Range.Bookmarks["ClientName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- //跟团人数
- if (doc.Range.Bookmarks["ClientNumber2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
- mark.Text = di.VisitPNumber.ToString();
- }
- if (doc.Range.Bookmarks["ClientNumber"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
- mark.Text = di.VisitPNumber.ToString();
- }
- //地区
- if (doc.Range.Bookmarks["Area"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area"];
- mark.Text = Area.TrimEnd('、');
- }
- if (doc.Range.Bookmarks["Area2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area2"];
- mark.Text = Area.TrimEnd('、');
- }
- //出访目的
- if (doc.Range.Bookmarks["Destination2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination2"];
- mark.Text = di.VisitPurpose;
- }
- if (doc.Range.Bookmarks["Destination"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination"];
- mark.Text = di.VisitPurpose;
- }
- //邀请方
- if (doc.Range.Bookmarks["Official"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Official"];
- mark.Text = Official.TrimEnd('、');
- }
- //出访日期
- if (doc.Range.Bookmarks["VisitDate"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VisitDate"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //请示范例
- if (doc.Range.Bookmarks["Temp"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Temp"];
- mark.Text = bookmark;
- }
- //出访起止日期
- if (doc.Range.Bookmarks["Duration"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Duration"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //出访天数
- if (doc.Range.Bookmarks["Durationdays"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays"];
- mark.Text = di.VisitDays.ToString();
- }
- if (doc.Range.Bookmarks["Durationdays2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
- mark.Text = di.VisitDays.ToString();
- }
- #region 根据黑屏代码获取国家呆的天数;获取路线
- string result_CountryAndDay = "", result_Air = "";
- if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
- {
- result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
- result_Air = result_CountryAndDay;
- }
- else
- {
- string place_start, place_end;
- DateTime time_start, time_end;
- Res_ThreeCode three = null;
- for (int i = 0; i < airTable.Rows.Count; i++)
- {
- //三字码实例
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
- if (three == null)
- {
- place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_start = three.City;
- }
- }
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
- if (three == null)
- {
- place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_end = three.City;
- }
- }
- result_Air += place_start + "一" + place_end + "一";
- //获取国家和呆的天数
- if (i > 0 && i < airTable.Rows.Count - 1)
- {
- time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
- time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
- TimeSpan daycount = time_end.Subtract(time_start);
- result_CountryAndDay += place_start + daycount.Days + "天" + ",";
- }
- }
- }
- #endregion
- //每个国家呆的天数
- if (doc.Range.Bookmarks["CountryAndDay"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
- mark.Text = result_CountryAndDay.TrimEnd(',');
- }
- #region 出访路线城市字符串去重
- result_Air = result_Air.TrimEnd('一');
- string[] airTemp = result_Air.Split('一');
- airTemp = airTemp.Distinct().ToArray();
- result_Air = "";
- foreach (string str in airTemp)
- {
- result_Air += str + "一";
- }
- result_Air = result_Air + airTemp[0];
- #endregion
- //出访路线
- if (doc.Range.Bookmarks["Air"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Air"];
- mark.Text = result_Air;
- }
- #endregion
- #region 客户名单
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
- if (clientList == null || clientList.Count == 0)
- {
- builder.MoveToCell(0, 1, 0, 0);
- builder.Write("【本团尚未录入客户名单,请联系主管!】");
- }
- else
- {
- for (int i = 0; i < clientList.Count(); i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write((i + 1).ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(clientList[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(clientList[i].BirthDay);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
- }
- }
- while (tableClient.Rows.Count > clientList.Count + 1)
- {
- tableClient.Rows.RemoveAt(clientList.Count + 1);
- }
- #endregion
- #region 商邀行程
- string content = "", temp1 = "", temp2 = "";
- //获取数据,放到datatable
- var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
- .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
- .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
- .Select((at, atd) => new
- {
- at.Id,
- at.Date,
- atd.Time,
- atd.Details
- })
- .ToListAsync();
- if (listapt == null || listapt.Count == 0)
- {
- content = "尚未生成商邀行程";
- }
- else
- {
- for (int i = 0; i < listapt.Count; i++)
- {
- content = content + " " + listapt[i].Date + "\r\n";
- temp1 = listapt[i].Time;
- temp2 = listapt[i].Details;
- if (!string.IsNullOrEmpty(temp1))
- {
- string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int j = 0; j < str.Count(); j++)
- {
- content = content + " " + str[j] + str2[j] + "\r\n";
- }
- }
- }
- }
- if (doc.Range.Bookmarks["Content"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Content"];
- mark.Text = content;
- }
- while (tableClient.Rows.Count > 1 + clientList.Count)
- {
- tableClient.Rows.RemoveAt(1 + clientList.Count);
- }
- #endregion
- #endregion
- string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- return Ok(JsonView(true,"操作成功!",new { url = url }));
- }
- /// <summary>
- /// 请示资料信息
- /// 市外办下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
- {
- if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
- if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
- //大写数字序号
- string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
- "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
- "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
- "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
- //数据源
- var idItem = dto.DataIdItem.OrderBy(x => x);
- var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
- //书签名
- string Area = "",
- Official = "";
- //表格数据源
- DataTable dt = new DataTable();
- dt.Columns.Add("Country", typeof(string));
- dt.Columns.Add("TalkCase", typeof(string));
- int id = 0;
- int TalkcaseOrder = 0;
- int RowOrder = 0;
- //填充数据
- for (int i = 0; i < askDatas.Count; i++)
- {
- var ad = askDatas[i];
- Area = Area + ad.Country + ad.Area + "、";
- Official = Official + ad.UnitName + "、";
- //填充表格数据源
- DataRow dr = dt.NewRow();
- if (i > 0)
- {
- var adtemp = askDatas[i - 1];
- if (ad.Country == adtemp.Country)
- {
- TalkcaseOrder++;
- dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
- }
- else
- {
- RowOrder++;
- dr = dt.NewRow();
- dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- TalkcaseOrder = 0;
- }
- }
- else
- {
- dr["Country"] = "(" + num[i] + ")" + ad.Country;
- dr["TalkCase"] = "1、" + ad.TalkCase;
- dt.Rows.Add(dr);
- }
- id = ad.Id;
- }
- //模板路径
- var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- #region 填充word内容
- #region 填充请示内容
- //利用DocumentBuilder处理表格或是书签
- Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
- string bookmark = "";
- try
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- bookmark = bookmark
- + dt.Rows[i]["Country"].ToString() + "\r\n"
- + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
- }
- }
- catch
- {
- }
- #endregion
- #region 填充word模板书签内容
- //团组信息
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
- //接团客户名单实例
- string client_sql = string.Format(@"
- SELECT
- tcl.Id,
- tcl.DiId,
- tcl.IsAccompany,
- temp.*,
- u.CnName AS Operator,
- tcl.CreateTime AS OperatingTime
- FROM
- Grp_TourClientList tcl
- LEFT JOIN (
- SELECT
- dc.Id AS DcId,
- dc.LastName,
- dc.FirstName,
- ccom.CompanyFullName,
- dc.Job,
- cc.CertNo AS IDCardNo,
- dc.Sex,
- dc.BirthDay
- FROM
- Crm_DeleClient dc
- LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
- AND ccom.IsDel = 0
- LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
- AND cc.SdId = 773
- AND cc.IsDel = 0
- WHERE
- dc.IsDel = 0
- ) temp ON temp.DcId = tcl.ClientId
- LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
- WHERE
- tcl.IsDel = 0
- AND tcl.DiId = {0}", dto.DiId);
- var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
- //机票代码实例
- DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
- //三字码
- var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
- //团名
- if (doc.Range.Bookmarks["TeamName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TeamName"];
- mark.Text = di.TeamName;
- }
- //团长名
- if (doc.Range.Bookmarks["ClientName2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName2"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- if (doc.Range.Bookmarks["ClientName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientName"];
- if (clientList == null || clientList.Count == 0)
- {
- mark.Text = "【本团尚未录入客户名单,请联系主管!】";
- }
- else
- {
- mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
- }
- }
- //跟团人数
- if (doc.Range.Bookmarks["ClientNumber2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
- mark.Text = di.VisitPNumber.ToString();
- }
- if (doc.Range.Bookmarks["ClientNumber"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
- mark.Text = di.VisitPNumber.ToString();
- }
- //地区
- if (doc.Range.Bookmarks["Area"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area"];
- mark.Text = Area.TrimEnd('、');
- }
- if (doc.Range.Bookmarks["Area2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Area2"];
- mark.Text = Area.TrimEnd('、');
- }
- //出访目的
- if (doc.Range.Bookmarks["Destination2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination2"];
- mark.Text = di.VisitPurpose;
- }
- if (doc.Range.Bookmarks["Destination"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Destination"];
- mark.Text = di.VisitPurpose;
- }
- //邀请方
- if (doc.Range.Bookmarks["Official"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Official"];
- mark.Text = Official.TrimEnd('、');
- }
- //出访日期
- if (doc.Range.Bookmarks["VisitDate"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VisitDate"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //请示范例
- if (doc.Range.Bookmarks["Temp"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Temp"];
- mark.Text = bookmark;
- }
- //出访起止日期
- if (doc.Range.Bookmarks["Duration"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Duration"];
- mark.Text = di.VisitStartDate.Year + "年"
- + di.VisitStartDate.Month + "月"
- + di.VisitStartDate.Day + "日"
- + "至"
- + di.VisitEndDate.Month + "月"
- + di.VisitEndDate.Day + "日";
- }
- //出访天数
- if (doc.Range.Bookmarks["Durationdays"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays"];
- mark.Text = di.VisitDays.ToString();
- }
- if (doc.Range.Bookmarks["Durationdays2"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
- mark.Text = di.VisitDays.ToString();
- }
- #region 根据黑屏代码获取国家呆的天数;获取路线
- string result_CountryAndDay = "", result_Air = "";
- if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
- {
- result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
- result_Air = result_CountryAndDay;
- }
- else
- {
- string place_start, place_end;
- DateTime time_start, time_end;
- Res_ThreeCode three = null;
- for (int i = 0; i < airTable.Rows.Count; i++)
- {
- //三字码实例
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
- if (three == null)
- {
- place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_start = three.City;
- }
- }
- three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
- if (three == null)
- {
- place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
- }
- else
- {
- if (string.IsNullOrEmpty(three.Country))
- {
- place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
- }
- else
- {
- place_end = three.City;
- }
- }
- result_Air += place_start + "一" + place_end + "一";
- //获取国家和呆的天数
- if (i > 0 && i < airTable.Rows.Count - 1)
- {
- time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
- time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
- TimeSpan daycount = time_end.Subtract(time_start);
- result_CountryAndDay += place_start + daycount.Days + "天" + ",";
- }
- }
- }
- #endregion
- //每个国家呆的天数
- if (doc.Range.Bookmarks["CountryAndDay"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
- mark.Text = result_CountryAndDay.TrimEnd(',');
- }
- #region 出访路线城市字符串去重
- result_Air = result_Air.TrimEnd('一');
- string[] airTemp = result_Air.Split('一');
- airTemp = airTemp.Distinct().ToArray();
- result_Air = "";
- foreach (string str in airTemp)
- {
- result_Air += str + "一";
- }
- result_Air = result_Air + airTemp[0];
- #endregion
- //出访路线
- if (doc.Range.Bookmarks["Air"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Air"];
- mark.Text = result_Air;
- }
- #endregion
- #region 客户名单
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
- if (clientList == null || clientList.Count == 0)
- {
- builder.MoveToCell(0, 1, 0, 0);
- builder.Write("【本团尚未录入客户名单,请联系主管!】");
- }
- else
- {
- for (int i = 0; i < clientList.Count(); i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write((i + 1).ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(clientList[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(clientList[i].BirthDay);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
- }
- }
- while (tableClient.Rows.Count > clientList.Count + 1)
- {
- tableClient.Rows.RemoveAt(clientList.Count + 1);
- }
- #endregion
- #region 商邀行程
- string content = "", temp1 = "", temp2 = "";
- //获取数据,放到datatable
- var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
- .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
- .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
- .Select((at, atd) => new
- {
- at.Id,
- at.Date,
- atd.Time,
- atd.Details
- })
- .ToListAsync();
- if (listapt == null || listapt.Count == 0)
- {
- content = "尚未生成商邀行程";
- }
- else
- {
- for (int i = 0; i < listapt.Count; i++)
- {
- content = content + " " + listapt[i].Date + "\r\n";
- temp1 = listapt[i].Time;
- temp2 = listapt[i].Details;
- if (!string.IsNullOrEmpty(temp1))
- {
- string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int j = 0; j < str.Count(); j++)
- {
- content = content + " " + str[j] + str2[j] + "\r\n";
- }
- }
- }
- }
- if (doc.Range.Bookmarks["Content"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Content"];
- mark.Text = content;
- }
- while (tableClient.Rows.Count > 1 + clientList.Count)
- {
- tableClient.Rows.RemoveAt(1 + clientList.Count);
- }
- #endregion
- #endregion
- string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- return Ok(JsonView(true, "操作成功!", new { url = url }));
- }
- #endregion
- #region 机票黑屏代码
- /// <summary>
- /// 根据团组Id查询黑屏代码列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
- {
- try
- {
- Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据黑屏代码数据Id查询信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
- {
- try
- {
- Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 黑屏代码操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
- {
- Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- try
- {
- var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
- if (tongzhi.Code == 0)
- {
- var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
- var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
- if (data != null)
- await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
- }
- //行程代码变更通知
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
- }
- catch (Exception ex)
- {
- throw;
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 删除黑屏代码
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
- {
- try
- {
- var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 翻译人员
- /// <summary>
- /// 翻译人员库
- /// Init
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet()]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryInit()
- {
- var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 66)
- .Select(x => new {
- x.Id,
- x.Name,
- })
- .ToListAsync();
- var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
- .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
- .Where((oa, di) => oa.IsDel == 0)
- .Select((oa, di) => new
- {
- oa.Id,
- oa.Client,
- oa.DiId,
- di.TeamName
- })
- .ToListAsync();
- var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
- .Select(g => new {
- id = g.Key,
- label = g.FirstOrDefault()?.TeamName ?? "-",
- children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
- })
- .ToList();
- var view = new {
- currencyData = currencyData,
- officialDutyData = officialDutyData1
- };
- return Ok(JsonView(view));
- }
- /// <summary>
- /// 翻译人员库
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("id")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryInfo(int id)
- {
- if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
- var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
- EncryptionProcessor.DecryptProperties(info);
- var view = _mapper.Map<TranslatorLibraryInfoView>(info);
- //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
- view.OfficialDutyIdItem = await _sqlSugar
- .Queryable<Grp_OfficialDutyLinkTranslator>()
- .Where(x => x.IsDel == 0 && x.TranslatorId == id)
- .Select(x => x.OfficialDutyId)
- .ToArrayAsync();
- return Ok(JsonView(view));
- }
- /// <summary>
- /// 翻译人员库
- /// Item
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- var name = AesEncryptionHelper.Encrypt(dto.Name);
- RefAsync<int> total = 0;
- var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
- .Where(x => x.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(name), x => x.Name.Contains(name))
- .Select(x => new TranslatorLibraryItemView()
- {
- Id = x.Id,
- Area = x.Area,
- Name = x.Name,
- Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
- Tel = x.Tel,
- Email = x.Email,
- WechatNo = x.WechatNo,
- Language = x.Language,
- Price = x.Price,
- Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
- CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
- CreateTime = x.CreateTime,
- Remark = x.Remark
- })
- .OrderByDescending(x => x.CreateTime)
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- foreach (var item in view) EncryptionProcessor.DecryptProperties(item);
- return Ok(JsonView(view, total));
- }
- /// <summary>
- /// 翻译人员库
- /// OP
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryOp([FromForm]TranslatorLibraryOpDto dto)
- {
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- var fileNames = new List<string>();
- //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
- var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
- #region 保存文件
- if (dto.Files != null)
- {
- if (!System.IO.Directory.Exists(fileBasePath))
- {
- System.IO.Directory.CreateDirectory(fileBasePath);
- }
- foreach (var item in dto.Files)
- {
- if (item.Length < 1) continue;
- var file = item;
- // 将文件保存到指定位置
- var filePath = Path.Combine(fileBasePath, file.FileName);
- using (var stream = new FileStream(filePath, FileMode.Create))
- {
- await file.CopyToAsync(stream);
- }
- //验证文件是否上传成功
- if (!System.IO.File.Exists(filePath))
- {
- foreach (var filePathStr in fileNames)
- {
- System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
- }
- return Ok(JsonView(false, "文件上传失败!"));
- }
- fileNames.Add(file.FileName);
- }
- }
- #endregion
- #region 参数处理
- EncryptionProcessor.EncryptProperties(dto);
- var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
- #endregion
- _sqlSugar.BeginTran();
- if (dto.Status == 1)
- {
- //验证重复
- var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
- if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
- translatorInfo.CreateUserId = currUserInfo.UserId;
- if (fileNames.Count > 0)
- {
- translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
- }
- var id = await _translatorRep.AddAsync(translatorInfo);
- if (id > 0) {
- #region 新增(公务信息关联翻译人员) 关联信息
- if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
- {
- var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
- foreach (var officialDutyId in dto.officialDutyIdItem)
- {
- officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
- {
- TranslatorId = id,
- OfficialDutyId = officialDutyId,
- CreateUserId = currUserInfo.UserId,
- Remark = $"翻译人员库-->添加"
- });
- }
- if (officialDutyLinkTranslators.Count > 0)
- {
- await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
- }
- }
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- }
- else if (dto.Status == 2)
- {
- var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
- if (info != null)
- {
- if (!string.IsNullOrEmpty(info.Files))
- {
- try
- {
- var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
- fileNames.AddRange(selectFiles);
- }
- catch (Exception)
- {
- }
- }
- }
- if (fileNames.Count > 0)
- {
- translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
- }
- var upd = await _translatorRep
- .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
- {
- Area = translatorInfo.Area,
- Name = translatorInfo.Name,
- Sex = translatorInfo.Sex,
- Photo = translatorInfo.Photo,
- Tel = translatorInfo.Tel,
- Email = translatorInfo.Email,
- WechatNo = translatorInfo.WechatNo,
- OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
- Language = translatorInfo.Language,
- Price = translatorInfo.Price,
- Currency = translatorInfo.Currency,
- Remark = translatorInfo.Remark,
- Files = translatorInfo.Files,
- });
- if (upd) {
- #region 更新(公务信息关联翻译人员) 关联信息
- var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
- .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
- .ToListAsync();
- //删除
- var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
- if (officialDutyLinkTranslatorIds.Count > 0)
- {
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
- {
- DeleteUserId = currUserInfo.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"翻译人员库-->删除"
- })
- .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
- .ExecuteCommandAsync();
- }
- if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
- {
- //添加
- var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
- foreach (var officialDutyId in dto.officialDutyIdItem)
- {
- officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
- {
- TranslatorId = dto.Id,
- OfficialDutyId = officialDutyId,
- CreateUserId = currUserInfo.UserId,
- Remark = $"翻译人员库-->更新"
- });
- }
- if (officialDutyLinkTranslators.Count > 0)
- {
- await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
- }
- }
-
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- }
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 翻译人员库
- /// Del
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("id")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TranslatorLibraryDel(int id)
- {
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- _sqlSugar.BeginTran();
- var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
- if (!upd) {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- #region 删除公务出访
- await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
- .SetColumns(x => new Grp_OfficialDutyLinkTranslator() {
- DeleteUserId = currUserInfo.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- IsDel = 1,
- Remark = $"翻译人员库-->删除"
- })
- .Where(x => x.TranslatorId == id)
- .ExecuteCommandAsync();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- #endregion
- #region 策划部供应商资料
- /// <summary>
- /// 策划部供应商资料
- /// Init
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> MediaSupplierInit()
- {
- return Ok(await _mediaSupplierRep.Init());
- }
- /// <summary>
- /// 策划部供应商资料
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> MediaSupplierInfo(MediaSupplierInfoDto dto)
- {
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
- return Ok(await _mediaSupplierRep.Info(dto));
- }
- /// <summary>
- /// 策划部供应商资料
- /// 分页查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> MediaSupplierPageItem(MediaSupplierPageItemDto dto)
- {
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- return Ok(await _mediaSupplierRep.PageItem(dto));
- }
- /// <summary>
- /// 策划部供应商资料
- /// 操作(添加 Or 编辑)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> MediaSupplierOp(MediaSupplierAddOrEditDto dto)
- {
- var result = new JsonView() { Code = 400, Msg = "操作失败" };
- var userId = dto.CurrUserId;
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- return Ok(await _mediaSupplierRep.AddOrEdit(dto));
- }
- /// <summary>
- /// 策划部供应商资料
- /// 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> MediaSupplierSoftDel(MediaSupplierSoftDelDto dto)
- {
- var result = new JsonView() { Code = 400, Msg = "操作失败" };
- int userId = dto.CurrUserId, id = dto.Id;
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- return Ok(await _mediaSupplierRep.SoftDel(dto));
- }
- #endregion
- #region 保险国家基础费用
- /// <summary>
- /// 保险国家基础费用
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InsuranceCostInfo(InsuranceCostInfoDto dto)
- {
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
- var id = dto.Id;
- var info = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
- .Where(x => x.Id == id && x.IsDel == 0)
- .Select(x => new {
- x.Id,
- x.IsSchengen,
- x.CountryName,
- x.Cost,
- x.Remark,
- CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(s => s.Id == x.CreateUserId).Select(s => s.CnName),
- x.CreateTime
- })
- .FirstAsync();
- return Ok(JsonView(info));
- }
- /// <summary>
- /// 保险国家基础费用
- /// 分页查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InsuranceCostPageItem(InsuranceCostPageItemDto dto)
- {
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
- .LeftJoin<Sys_Users>((bic,u) => bic.CreateUserId == u.Id)
- .Where((bic, u) => bic.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (bic, u) => bic.CountryName.Contains(dto.Search))
- .OrderByDescending((bic, u) => bic.Id)
- .Select((bic, u) => new {
- bic.Id,
- bic.IsSchengen,
- bic.CountryName,
- bic.Cost,
- bic.Remark,
- CreateUserName = u.CnName,
- bic.CreateTime
- })
- .ToPageListAsync(dto.PageIndex,dto.PageSize,total);
- return Ok(JsonView(data,total));
- }
- /// <summary>
- /// 保险国家基础费用
- /// 操作(添加 Or 编辑)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InsuranceCostOp(InsuranceCostOpDto dto)
- {
- var result = new JsonView() { Code = 400, Msg = "操作失败" };
- var userId = dto.CurrUserId;
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var countryName = dto.CountryName.Trim();
- if (string.IsNullOrEmpty(countryName)) return Ok(JsonView(false,$"国家名称不能为空!"));
- var info = _mapper.Map<Res_BasicInsuranceCost>(dto);
- info.CreateUserId = dto.CurrUserId;
- info.CountryName = countryName;
- if (dto.Id < 1) //添加
- {
- var addInfo = await _insuranceCostRep.Query(x => x.CountryName.Equals(countryName)).FirstAsync();
- if (addInfo != null) return Ok(JsonView(false, $"该国家信息已存在,不可添加!"));
- var add = await _insuranceCostRep.AddAsync(info);
- if (add < 1) return Ok(JsonView(false, "添加失败!"));
- }
- else //修改
- {
- var upd = await _insuranceCostRep.UpdateAsync(x => x.Id == dto.Id, x => new Res_BasicInsuranceCost
- {
- IsSchengen = dto.IsSchengen,
- CountryName = dto.CountryName,
- Cost = dto.Cost,
- Remark = dto.Remark
- });
- if (!upd) return Ok(JsonView(false, "修改失败!"));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 保险国家基础费用
- /// 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InsuranceCostSoftDel(InsuranceCostSoftDelDto dto)
- {
- int userId = dto.CurrUserId, id = dto.Id;
- if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- var del = await _insuranceCostRep.SoftDeleteAsync(x => x.Id == id, userId);
- if (!del) return Ok(JsonView(false));
- return Ok(JsonView(true));
- }
- #endregion
- }
- }
|