12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182 |
- using Aspose.Cells;
- using Aspose.Words;
- using Aspose.Words.Drawing;
- using Aspose.Words.Tables;
- using DiffMatchPatch;
- using Microsoft.AspNetCore.SignalR;
- using Microsoft.EntityFrameworkCore.Query.Internal;
- using NPOI.HSSF.UserModel;
- using NPOI.SS.UserModel;
- using NPOI.SS.Util;
- using NPOI.XSSF.UserModel;
- using OASystem.API.Middlewares;
- using OASystem.API.OAMethodLib;
- using OASystem.API.OAMethodLib.APNs;
- using OASystem.API.OAMethodLib.File;
- using OASystem.API.OAMethodLib.Hub.HubClients;
- using OASystem.API.OAMethodLib.Hub.Hubs;
- using OASystem.API.OAMethodLib.JuHeAPI;
- using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
- using OASystem.Domain.AesEncryption;
- using OASystem.Domain.Dtos.CRM;
- using OASystem.Domain.Dtos.FileDto;
- using OASystem.Domain.Dtos.Financial;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Customer;
- using OASystem.Domain.Entities.Financial;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Financial;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Infrastructure.Repositories.CRM;
- using OASystem.Infrastructure.Repositories.Financial;
- using OASystem.Infrastructure.Repositories.Groups;
- using OfficeOpenXml;
- using Org.BouncyCastle.Asn1.Ocsp;
- using Org.BouncyCastle.Utilities.Encoders;
- using Quartz.Util;
- using SqlSugar.Extensions;
- using System.Collections;
- using System.Data;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO.Compression;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
- using Bookmark = Aspose.Words.Bookmark;
- using Cell = Aspose.Words.Tables.Cell;
- using Table = Aspose.Words.Tables.Table;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 团组相关
- /// </summary>
- //[Authorize]
- [Route("api/[controller]/[action]")]
- public class GroupsController : ControllerBase
- {
- private readonly ILogger<GroupsController> _logger;
- private readonly GrpScheduleRepository _grpScheduleRep;
- private readonly IMapper _mapper;
- private readonly DelegationInfoRepository _groupRepository;
- private readonly TaskAssignmentRepository _taskAssignmentRep;
- private readonly AirTicketResRepository _airTicketResRep;
- private readonly DecreasePaymentsRepository _decreasePaymentsRep;
- private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
- private readonly DelegationEnDataRepository _delegationEnDataRep;
- private readonly DelegationVisaRepository _delegationVisaRep;
- private readonly VisaPriceRepository _visaPriceRep;
- private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
- private readonly HotelPriceRepository _hotelPriceRep;
- private readonly CustomersRepository _customersRep;
- private readonly MessageRepository _message;
- private readonly SqlSugarClient _sqlSugar;
- private readonly TourClientListRepository _tourClientListRep;
- private readonly TeamRateRepository _teamRateRep;
- #region 成本相关
- private readonly CheckBoxsRepository _checkBoxs;
- private readonly GroupCostRepository _GroupCostRepository;
- private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
- private readonly GroupCostParameterRepository _GroupCostParameterRepository;
- #endregion
- private readonly SetDataRepository _setDataRep;
- private string url;
- private string path;
- private readonly EnterExitCostRepository _enterExitCostRep;
- private readonly IHubContext<ChatHub, IChatClient> _hubContext;
- private readonly UsersRepository _usersRep;
- private readonly IJuHeApiService _juHeApi;
- private readonly InvertedListRepository _invertedListRep;
- private readonly VisaFeeInfoRepository _visaFeeInfoRep;
- private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
- private readonly ThreeCodeRepository _threeCodeRepository;
- private readonly HotelInquiryRepository _hotelInquiryRep;
- private readonly FeeAuditRepository _feeAuditRep;
- private readonly VisaCommissionRepository _visaCommissionRep;
- private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
- private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
- private readonly List<CurrencyInfo> _currencyInit;
- private readonly List<int> _portTypeData;
- private readonly TableOperationRecordRepository _tableorRep;
- private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
- private readonly RestaurantRepository _restaurantRep;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="logger"></param>
- /// <param name="mapper"></param>
- /// <param name="hubContext"></param>
- /// <param name="sqlSugar"></param>
- /// <param name="grpScheduleRep"></param>
- /// <param name="groupRepository"></param>
- /// <param name="taskAssignmentRep"></param>
- /// <param name="airTicketResRep"></param>
- /// <param name="decreasePaymentsRep"></param>
- /// <param name="InvitationOfficialActivitiesRep"></param>
- /// <param name="delegationEnDataRep"></param>
- /// <param name="enterExitCostRep"></param>
- /// <param name="delegationVisaRep"></param>
- /// <param name="message"></param>
- /// <param name="visaPriceRep"></param>
- /// <param name="carTouristGuideGroundRep"></param>
- /// <param name="checkBoxs"></param>
- /// <param name="GroupCostRepository"></param>
- /// <param name="CostTypeHotelNumberRepository"></param>
- /// <param name="GroupCostParameterRepository"></param>
- /// <param name="hotelPriceRep"></param>
- /// <param name="customersRep"></param>
- /// <param name="setDataRep"></param>
- /// <param name="tourClientListRep"></param>
- /// <param name="teamRateRep"></param>
- /// <param name="usersRep"></param>
- /// <param name="juHeApi"></param>
- /// <param name="invertedListRep"></param>
- /// <param name="visaFeeInfoRep"></param>
- /// <param name="ticketBlackCodeRep"></param>
- /// <param name="hotelInquiryRep"></param>
- /// <param name="threeCodeRepository"></param>
- /// <param name="feeAuditRep"></param>
- /// <param name="visaCommissionRep"></param>
- /// <param name="ffrRep"></param>
- /// <param name="opinionaireRep"></param>
- /// <param name="tableorRep"></param>
- /// <param name="enterExitCostDraftRep"></param>
- /// <param name="restaurantRep"></param>
- public GroupsController(
- ILogger<GroupsController> logger,
- IMapper mapper,
- IHubContext<ChatHub, IChatClient> hubContext,
- SqlSugarClient sqlSugar,
- GrpScheduleRepository grpScheduleRep,
- DelegationInfoRepository groupRepository,
- TaskAssignmentRepository taskAssignmentRep,
- AirTicketResRepository airTicketResRep,
- DecreasePaymentsRepository decreasePaymentsRep,
- InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
- DelegationEnDataRepository delegationEnDataRep,
- EnterExitCostRepository enterExitCostRep,
- DelegationVisaRepository delegationVisaRep,
- MessageRepository message,
- VisaPriceRepository visaPriceRep,
- CarTouristGuideGroundRepository carTouristGuideGroundRep,
- CheckBoxsRepository checkBoxs,
- GroupCostRepository GroupCostRepository,
- CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
- GroupCostParameterRepository GroupCostParameterRepository,
- HotelPriceRepository hotelPriceRep,
- CustomersRepository customersRep,
- SetDataRepository setDataRep,
- TourClientListRepository tourClientListRep,
- TeamRateRepository teamRateRep,
- UsersRepository usersRep, IJuHeApiService juHeApi,
- InvertedListRepository invertedListRep,
- VisaFeeInfoRepository visaFeeInfoRep,
- TicketBlackCodeRepository ticketBlackCodeRep,
- HotelInquiryRepository hotelInquiryRep,
- ThreeCodeRepository threeCodeRepository,
- FeeAuditRepository feeAuditRep,
- VisaCommissionRepository visaCommissionRep,
- ForeignReceivablesRepository ffrRep,
- OpinionaireRepository opinionaireRep,
- TableOperationRecordRepository tableorRep,
- EnterExitCostDraftRepository enterExitCostDraftRep,
- RestaurantRepository restaurantRep
- )
- {
- _logger = logger;
- _mapper = mapper;
- _grpScheduleRep = grpScheduleRep;
- _groupRepository = groupRepository;
- _taskAssignmentRep = taskAssignmentRep;
- _airTicketResRep = airTicketResRep;
- _sqlSugar = sqlSugar;
- url = AppSettingsHelper.Get("ExcelBaseUrl");
- path = AppSettingsHelper.Get("ExcelBasePath");
- if (!System.IO.Directory.Exists(path))
- {
- System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
- }
- _decreasePaymentsRep = decreasePaymentsRep;
- _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
- _delegationEnDataRep = delegationEnDataRep;
- _enterExitCostRep = enterExitCostRep;
- _delegationVisaRep = delegationVisaRep;
- _message = message;
- _visaPriceRep = visaPriceRep;
- _carTouristGuideGroundRep = carTouristGuideGroundRep;
- _checkBoxs = checkBoxs;
- _GroupCostRepository = GroupCostRepository;
- _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
- _GroupCostParameterRepository = GroupCostParameterRepository;
- _hotelPriceRep = hotelPriceRep;
- _customersRep = customersRep;
- _setDataRep = setDataRep;
- _tourClientListRep = tourClientListRep;
- _teamRateRep = teamRateRep;
- _hubContext = hubContext;
- _usersRep = usersRep;
- _juHeApi = juHeApi;
- _invertedListRep = invertedListRep;
- _visaFeeInfoRep = visaFeeInfoRep;
- _ticketBlackCodeRep = ticketBlackCodeRep;
- _hotelInquiryRep = hotelInquiryRep;
- _threeCodeRepository = threeCodeRepository;
- _feeAuditRep = feeAuditRep;
- _visaCommissionRep = visaCommissionRep;
- _ffrRep = ffrRep;
- _opinionaireRep = opinionaireRep;
- _currencyInit = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- _portTypeData = new List<int>() { 2, 3 };
- _tableorRep = tableorRep;
- _enterExitCostDraftRep = enterExitCostDraftRep;
- _restaurantRep = restaurantRep;
- }
- #region 流程管控
- /// <summary>
- /// 获取团组流程管控信息
- /// </summary>
- /// <param name="paras">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
- if (_ScheduleDto != null)
- {
- if (_ScheduleDto.SearchType == 2)//获取列表
- {
- List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
- return Ok(JsonView(_grpScheduleViewList));
- }
- else//获取对象
- {
- Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
- if (_grpScheduleView != null)
- {
- return Ok(JsonView(_grpScheduleView));
- }
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false, "暂无数据!"));
- }
- /// <summary>
- /// 修改团组流程管控详细表数据
- /// </summary>
- /// <param name="paras"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.Duty == _detail.Duty)
- .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
- .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
- .SetColumns(it => it.JobContent == _detail.JobContent)
- .SetColumns(it => it.Remark == _detail.Remark)
- .SetColumns(it => it.StepStatus == _detail.StepStatus)
- .Where(s => s.Id == dto.Id)
- //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "保存成功!"));
- }
- return Ok(JsonView(false, "保存失败!"));
- }
- /// <summary>
- /// 删除团组流程管控详细表数据,删除人Id请放在Duty
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- _detail.IsDel = 1;
- _detail.DeleteUserId = dto.Duty;
- _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.IsDel == _detail.IsDel)
- .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
- .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
- .Where(it => it.Id == dto.Id)
- //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
- //.WhereColumns(s => s.Id == dto.Id)
- .ExecuteCommandAsync();
- if (result > 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<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- if (DateTime.Now < _detail.ExpectBeginDt)
- {
- _detail.StepStatus = 0;
- }
- else
- {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
- _detail.StepStatus = 1;
- }
- var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
- if (result > 0)
- {
- Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
- return Ok(JsonView(true, "添加成功!", _result));
- }
- return Ok(JsonView(false, "添加失败!"));
- }
- #endregion
- #region 团组基本信息
- /// <summary>
- /// 接团信息列表
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupList(GroupListDto dto)
- {
- var groupData = await _groupRepository.GetGroupList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 分页查询团组列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
- .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
- .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
- .Distinct()
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
- }
- /// <summary>
- /// 接团信息列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime,IsBid
- From (
- Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToList();
- foreach (var item in _DelegationList)
- {
- item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #endregion
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType != 1 && dto.PortType != 2)
- {
- return Ok(JsonView(false, "查询失败!"));
- }
- string orderbyStr = "order by gdi.CreateTime Desc";
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- //团组类型
- if (dto.TeamDid > 0)
- {
- sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
- }
- //团组名称
- if (!string.IsNullOrEmpty(dto.TeamName))
- {
- sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
- }
- //客户名称
- if (!string.IsNullOrEmpty(dto.ClientName))
- {
- sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
- }
- //客户单位
- if (!string.IsNullOrEmpty(dto.ClientUnit))
- {
- sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
- }
- //出访时间
- if (!string.IsNullOrEmpty(dto.visitDataTime))
- {
- sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
- orderbyStr = "order by gdi.VisitDate";
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over({0}) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {1}
- ) temp ", orderbyStr, sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToList();
- foreach (var item in _DelegationList)
- {
- item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #endregion
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- /// <summary>
- /// 接团信息详情
- /// </summary>
- /// <param name="dto">团组info请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
- {
- var groupData = await _groupRepository.GetGroupInfo(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息 编辑添加
- /// 基础信息数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
- {
- var groupData = await _groupRepository.GroupEditBasicSource(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息 操作(增改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
- {
- // 创建 Stopwatch 实例
- Stopwatch stopwatch = Stopwatch.StartNew();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var groupData = await _groupRepository.GroupOperation(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- int diId = 0;
- try
- {
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- var _managerIds = new List<int>() { 22, 32, 21 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- else if (dto.Status == 2)
- {
- diId = dto.Id;
- }
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- #endregion
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- // 停止计时
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
- }
- catch (Exception ex)
- {
- // 停止计时
- stopwatch.Stop();
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
- }
- // 停止计时
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
- //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
- #endregion
- #endregion
- try
- {
- //_sqlSugar.BeginTran();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var _dto = new GroupOperationDto();
- _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
- var groupData = await _groupRepository.GroupOperation(_dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
- }
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- List<int> _managerIds = new List<int>() { 21, 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
- }
- }
- catch (Exception ex)
- {
- }
- #endregion
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- if (dto.Status == 2)
- {
- diId = dto.Id;
- if (diId == 0)
- {
- //_sqlSugar.RollbackTran();
- return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
- }
- }
- var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
- if (viewData.Code != 0)
- {
- //_sqlSugar.RollbackTran();
- return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
- }
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- #endregion
- //_sqlSugar.CommitTran();
- return Ok(JsonView(true, "添加成功"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
- //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
- #endregion
- #endregion
- _sqlSugar.BeginTran();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var _dto = new GroupOperationDto();
- _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
- var groupData = await _groupRepository.GroupOperation(_dto);
- if (groupData.Code != 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
- }
- try
- {
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- List<int> _managerIds = new List<int>() { 21, 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
- }
- #endregion
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- else if (dto.Status == 2)
- {
- diId = dto.Id;
- if (diId == 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
- }
- }
- var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
- if (viewData.Code != 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
- }
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团信息 操作(删除)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupDel(GroupDelDto dto)
- {
- var diId = dto.Id;
- if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
- #region 删除 验证 (费用录入、出入境费用、收款账单)
- //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
- //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
- //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
- //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
- #endregion
- var groupData = await _groupRepository.GroupDel(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 获取团组销售报价号
- /// 团组添加时 使用
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupSalesQuoteNo()
- {
- var groupData = await _groupRepository.GetGroupSalesQuoteNo();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- object salesQuoteNo = new
- {
- SalesQuoteNo = groupData.Data
- };
- return Ok(JsonView(salesQuoteNo));
- }
- /// <summary>
- /// 设置确认出团
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
- {
- var groupData = await _groupRepository.ConfirmationGroup(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
- #region OA消息推送
- try
- {
- string groupName = groupInfo.TeamName;
- var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
- string title = $"系统通知";
- string content = $"团组[{groupName}]已确认出团!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
- }
- }
- catch (Exception ex)
- {
- }
- #endregion
- GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
- return Ok(JsonView(true, "操作成功!", groupData.Data));
- }
- /// <summary>
- /// 获取团组名称data And 签证国别Data
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
- {
- var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
- {
- try
- {
- Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(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>
- /// 团组清单 Excel
- /// </summary>
- /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
- /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
- {
- DateTime _beginDt, _endDt;
- bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
- endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
- if (!beginBool && !endBool)
- {
- return Ok(JsonView(false, "开始或结束时间不正确!"));
- }
- string sql = string.Format(@"
- SELECT
- ROW_NUMBER,
- Id,
- SalesQuoteNo,
- TourCode,
- TeamTypeId,
- TeamType,
- TeamLevId,
- TeamLev,
- TeamName,
- ClientName,
- ClientUnit,
- VisitDate,
- VisitDays,
- VisitPNumber,
- JietuanOperatorId,
- JietuanOperator,
- IsSure,
- CreateUserName,
- IsBid
- FROM
- (
- SELECT
- ROW_NUMBER() OVER(
- ORDER BY
- gdi.CreateTime Desc
- ) AS ROW_NUMBER,
- gdi.Id,
- SalesQuoteNo,
- TourCode,
- ssd.Id TeamTypeId,
- ssd.Name TeamType,
- ssd1.Id TeamLevId,
- ssd1.Name TeamLev,
- TeamName,
- ClientName,
- ClientUnit,
- VisitDate,
- VisitDays,
- VisitPNumber,
- JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,
- IsSure,
- gdi.CreateTime,
- su1.CnName As CreateUserName,
- gdi.IsBid
- FROM
- Grp_DelegationInfo gdi
- LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
- LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
- LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
- LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
- WHERE
- gdi.IsDel = 0
- AND gdi.IsBid = 0
- AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
- ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
- var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToListAsync();
- var droupIds = groupList.Select(it => it.Id).ToList();
- var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
- .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
- .Select((tcl, dc, cc) => new ClientInfoInfo_Group
- {
- DiId = tcl.DiId,
- LastName = dc.LastName,
- FirstName = dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job,
- CreateTime = tcl.CreateTime,
- })
- .ToList();
- foreach (var item in groupList)
- {
- item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- string groupFirstName = "";
- var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
- if (currDatas.Any())
- {
- groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
- }
- item.GroupFirst = groupFirstName;
- }
- #endregion
- #region Excel
- var tempPath = AppSettingsHelper.Get("ExcelTempPath");
- var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
- var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
- var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
- var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
- designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
- DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
- dt.TableName = "GroupList";
- designer.SetDataSource(dt);
- designer.Process();
- if (!Directory.Exists(savePath))
- {
- Directory.CreateDirectory(savePath);
- }
- string serverPath = $"{savePath}{fileName}";
- designer.Workbook.Save(serverPath);
- string rst = $"{servicePath}{ftpPath}{fileName}";
- #endregion
- return Ok(JsonView(true, "操作成功!", rst));
- }
- #endregion
- #region 团组&签证
- /// <summary>
- /// 根据团组Id获取签证客户信息List
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
- {
- var groupData = await _groupRepository.GetCrmByGroupId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度01(团组列表)
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "参数为空"));
- }
- DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
- return Ok(JsonView(visaList));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度03(相册)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
- string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
- list.ForEach(s => s.url = url);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度04(图片上传)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
- {
- //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
- //if (!string.IsNullOrEmpty(result))
- //{
- //}
- //else {
- // return Ok(JsonView(false, "上传失败"));
- //}
- DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
- int sucNum = 0;
- try
- {
- foreach (var item in dto.base64DataList)
- {
- string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
- string result = decodeBase64ToImage(item, imageName);
- if (!string.IsNullOrEmpty(result))
- {
- Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
- pic.CreateUserId = dto.CreateUserId;
- pic.PicName = imageName;
- pic.PicPath = result;
- pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
- int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
- if (insertResult > 0)
- {
- sucNum++;
- }
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- string msg = string.Format(@"成功上传{0}张", sucNum);
- return Ok(JsonView(true, msg));
- }
- private string decodeBase64ToImage(string base64DataURL, string imgName)
- {
- string filename = "";//声明一个string类型的相对路径
- String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
- System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
- try//会有异常抛出,try,catch一下
- {
- byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
- System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
- bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
- var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
- //文件名称
- filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + filename;
- //string url = HttpRuntime.AppDomainAppPath.ToString();
- //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
- //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
- bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
- //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
- //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
- //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
- ms.Close();//关闭当前流,并释放所有与之关联的资源
- bitmap.Dispose();
- }
- catch (Exception e)
- {
- string massage = e.Message;
- Logs("IOS图片上传Error:" + massage);
- //filename = e.Message;
- }
- return filename;//返回相对路径
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- string msg = "参数错误";
- if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
- {
- try
- {
- //_delegationVisaRep.BeginTran();
- var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
- .SetColumns(it => it.WorkStatus == dto.visaStatus)
- .Where(s => s.Id == dto.visaProgressCustomerId)
- .ExecuteCommandAsync();
- if (updCount > 0 && dto.publishCode == 1)
- {
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
- string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
- OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
- //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
- //var groupData = await _groupRepository.GetGroupInfo(grpDto);
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
- if (groupData == null)
- {
- _delegationVisaRep.RollbackTran();
- }
- string title = string.Format(@"[签证进度更新]");
- string content = string.Format(@"测试文本");
- bool rst = await _message.AddMsg(new MessageDto()
- {
- Type = MessageTypeEnum.GroupVisaProgressUpdate,
- IssuerId = dto.publisher,
- Title = title,
- Content = content,
- ReleaseTime = DateTime.Now,
- UIdList = new List<int> {
- 234
- }
- });
- if (rst)
- {
- return Ok(JsonView(true, "发送通知成功"));
- }
- }
- //_delegationVisaRep.CommitTran();
- }
- catch (Exception)
- {
- //_delegationVisaRep.RollbackTran();
- }
- }
- return Ok(JsonView(true, msg));
- }
- #endregion
- #region 团组任务分配
- /// <summary>
- /// 团组任务分配初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetTaskAssignmen()
- {
- var groupData = await _taskAssignmentRep.GetTaskAssignmen();
- 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> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
- {
- var groupData = await _taskAssignmentRep.TaskAssignmenQuery(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> GetTaskAssignmenOp(TaskAssignmenDto dto)
- {
- Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(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> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
- {
- //参数验证
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
- return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
- return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
- }
- /// <summary>
- /// 团组任务分配
- /// 批量分配
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
- {
- //参数验证
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
- if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
- if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
- return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
- }
- #endregion
- #region 团组费用审核
- /// <summary>
- /// 费用审核
- /// 团组列表 Page
- /// </summary>
- /// <param name="_dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
- {
- string sqlWhere = string.Empty;
- if (_dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (_dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(_dto.SearchCriteria))
- {
- string tj = _dto.SearchCriteria;
- sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
- VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
- ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
- VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 获取团组费用审核
- /// </summary>
- /// <param name="paras">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 页面操作权限验证
- var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- var _view = new Grp_CreditCardPaymentView();
- var clientNameList = getSimplClientList(_dto.DiId);
- #region 费用清单
- var exp = Expressionable.Create<Grp_CreditCardPayment>();
- exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
- exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
- var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
- var detailList = new List<Grp_CreditCardPaymentDetailView>();
- var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
- /*
- * 76://酒店预订
- */
- var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 79://车/导游地接
- */
- var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 80: //签证
- */
- var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- *81: //邀请/公务活动
- */
- var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 82: //团组客户保险
- */
- var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * Lable = 85 机票预订
- */
- var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 85 机票预定
- */
- var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 98 其他款项
- */
- var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 285:收款退还
- */
- var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 1015: //超支费用
- */
- var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
- /*
- * 币种信息
- */
- var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
- var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
- /*
- * 用户信息
- */
- var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
- /*
- * 费用模块
- */
- var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
- string priceModule = string.Empty;
- if (sdPriceName != null)
- {
- priceModule = sdPriceName.Name;
- }
- /*
- * 成本信息
- */
- var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
- decimal _groupRate = 0.0000M;
- string _groupCurrencyCode = "-";
- if (groupCost != null)
- {
- _groupRate = groupCost.Rate;
- if (int.TryParse(groupCost.Currency, out int _currency))
- {
- _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
- }
- else _groupCurrencyCode = groupCost.Currency;
- }
- string costContentSql = $"Select * From Grp_GroupCost";
- var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
- //处理日期为空的天数
- for (int i = 0; i < groupCostDetails.Count; i++)
- if (i != 0)
- if (string.IsNullOrEmpty(groupCostDetails[i].Date))
- groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
- /*
- * 处理详情数据
- */
- foreach (var entity in entityList)
- {
- var _detail = new Grp_CreditCardPaymentDetailView();
- _detail.Id = entity.Id;
- _detail.PriceName = priceModule;
- _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
- if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
- else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
- //处理金额
- if (entity.CTable == 1015)
- {
- var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
- if (czInfo != null)
- {
- entity.PayMoney = czInfo.Price * czInfo.PriceCount;
- entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
- }
- }
- /*
- * 应付款金额
- */
- var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
- string PaymentCurrency_WaitPay = "Unknown";
- string hotelCurrncyCode = "Unknown";
- string hotelCurrncyName = "Unknown";
- if (sdPaymentCurrency_WaitPay != null)
- {
- PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
- if (hotelCurrncyCode.Equals("CNY"))
- {
- entity.DayRate = 1.0000M;
- }
- }
- _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * 此次付款金额
- */
- decimal CurrPayStr = 0.00M,
- OriginalCurrPay = 0.00M;
- if (entity.PayPercentage == 0)
- {
- if (entity.PayThenMoney != 0)
- CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
- }
- else
- {
- if (entity.PayMoney != 0)
- {
- CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
- }
- }
- //if (_dto.Label == 79)
- //{
- // string original = string.Empty;
- // if (hotelCurrncyCode.Equals("CNY"))
- // {
- // OriginalCurrPay = CurrPayStr;
- // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- // }
- // else
- // {
- // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
- // //760 EUR(7600.00 CNY)
- // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
- // }
- //}
- //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- string original = string.Empty;
- if (hotelCurrncyCode.Equals("CNY"))
- {
- OriginalCurrPay = CurrPayStr;
- _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- }
- else
- {
- OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
- //760 EUR(7600.00 CNY)
- _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
- }
- /*
- * 剩余尾款
- */
- decimal BalanceStr = 0;
- if (CurrPayStr != 0)
- {
- if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
- BalanceStr = 0;
- else
- BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
- }
- _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * Bus名称
- */
- _detail.BusName = "待增加";
- /*
- *费用所属
- */
- switch (entity.CTable)
- {
- case 76://酒店预订
- Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (hotelReservations != null)
- {
- DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
- checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
- int hotel_days = (int)(checkOut - checkIn).TotalDays;
- string roomFeeStr = "", roomFeestr1 = "";
- //是否比较房型价格
- bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
- //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
- roomFeeStr += $"<br/>";
- var roomTotal = 0.00M;
- if (hotelReservations.SingleRoomPrice > 0)
- {
- var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- __isSingle = true;
- roomTotal += fee;
- }
- if (hotelReservations.DoubleRoomPrice > 0)
- {
- var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- __isDouble = true;
- roomTotal += fee;
- }
- if (hotelReservations.SuiteRoomPrice > 0)
- {
- var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- __isSuite = true;
- roomTotal += fee;
- }
- if (hotelReservations.OtherRoomPrice > 0)
- {
- var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- __isOther = true;
- roomTotal += fee;
- }
- if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
- else roomFeeStr += " 0.00 * 0";
- decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
- string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
- string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
- var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
- /*
- * 费用类型
- * 1:房费
- * 2:早餐
- * 3:地税
- * 4:城市税
- * </summary>
- */
- //地税
- var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
- if (governmentRentData != null)
- {
- governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
- governmentRentFee = governmentRentData.Price;
- var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
- if (governmentRentCurrData != null)
- {
- governmentRentCode = governmentRentCurrData.Name;
- governmentRentName = $"({governmentRentCurrData.Remark})";
- }
- }
- //城市税
- var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
- if (cityTaxData != null)
- {
- cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
- cityTaxFee = cityTaxData.Price;
- var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
- if (cityTaxCurrData != null)
- {
- cityTaxCode = cityTaxCurrData.Name;
- cityTaxName = $"({cityTaxCurrData.Remark})";
- }
- }
- //酒店早餐
- var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
- if (breakfastData != null)
- {
- breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
- breakfastFee = breakfastData.Price;
- var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
- if (breakfastCurrData != null)
- {
- breakfastCode = breakfastCurrData.Name;
- breakfastName = $"({breakfastCurrData.Remark})";
- }
- }
- //房间费用
- var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
- if (roomData != null)
- {
- _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
- if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
- else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
- roomBool = roomData.IsOppay == 1 ? "是" : "否";
- roomFee = roomData.Price;
- var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
- if (roomCurrData != null)
- {
- roomCode = roomCurrData.Name;
- roomName = $"({roomCurrData.Remark})";
- }
- }
- string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
- string hotelCostStr = "";
- decimal hotelCsotTotal = 0.00M;
- if (groupCost != null)
- {
- if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
- hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
- }
- if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
- var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
- string hotelCost_day = "";
- var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
- foreach (var item in hotelCostDetails1)
- {
- hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
- hotelCost_day += @$"{item.First()?.Date ?? "-"}";
- if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
- //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
- if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
- //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
- if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
- //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
- if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
- //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
- hotelCost_day += @$"<br/>";
- }
- string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
- if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
- if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
- if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
- string hotelCostTotalStr = "";// $" 成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
- _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
- $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
- $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
- $"房间说明: {hotelReservations.Remark} <br/>" +
- $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
- $"{hotelBreakfastStr}" +
- $"{hotelGovernmentRentStr}" +
- $"{hotelCityTaxStr}";
- _detail.PriceNameContent = hotelReservations.HotelName;
- }
- break;
- case 79://车/导游地接
- Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (touristGuideGroundReservations != null)
- {
- if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
- {
- _detail.BusName = touristGuideGroundReservations.BusName;
- }
- _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
- //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
- //if (isInt)
- //{
- // var cityInfo = cityData.Find(it => it.Id == cityId);
- // if (cityInfo != null)
- // {
- // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
- // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
- // if (carFeeItem != null)
- // {
- // nameContent += $@"({carFeeItem.Name})";
- // }
- // _detail.PriceNameContent = nameContent;
- // }
- //}
- //else
- //{
- // _detail.PriceNameContent = touristGuideGroundReservations.Area;
- //}
- var touristGuideGroundReservationsContents =
- _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
- string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
- foreach (var item in touristGuideGroundReservationsContents)
- {
- string typeName = "Unknown";
- string carCurrencyCode = "Unknown";
- string carCurrencyName = "Unknown";
- var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
- if (carTypeData != null) typeName = carTypeData.Name;
- var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
- if (currencyData != null)
- {
- carCurrencyCode = currencyData.Name;
- carCurrencyName = currencyData.Remark;
- }
- //op、成本 币种是否一致
- bool IsCurrencyAgreement = false;
- if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
- string opCostStr = string.Empty;
- decimal opCostTypePrice = 0.00M;
- #region 处理成本各项费用
- var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
- var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
- if (opCost.Count > 0)
- {
- switch (item.SId)
- {
- case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
- //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
- case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
- case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
- case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
- case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
- case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
- case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
- //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
- //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
- case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
- case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
- case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
- case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
- case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
- case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
- case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
- case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
- case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
- case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
- }
- opCostStr = $" / 成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
- if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
- }
- #endregion
- string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
- if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
- priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
- $"{opTypeStr} {opCostStr}<br/>" +
- $"明细:{item.PriceContent ?? "-"}<br/>" +
- $"备注:{item.Remark ?? "-"}<br/><br/>";
- }
- _detail.PriceMsgContent = priceMsg;
- }
- break;
- case 80: //签证
- Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (visaInfo != null)
- {
- string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
- _detail.PriceNameContent = visaInfo.VisaDescription;
- _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
- }
- break;
- case 81: //邀请/公务活动
- Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (_ioa != null)
- {
- string inviteCurrName = "Unknown", //邀请费用币种 Name
- inviteCurrCode = "Unknown", //邀请费用币种 Code
- sendCurrName = "Unknown", //快递费用币种 Name
- sendCurrCode = "Unknown", //快递费用币种 Code
- eventsCurrName = "Unknown", //公务活动费币种 Name
- eventsCurrCode = "Unknown", //公务活动费币种 Code
- translateCurrName = "Unknown", //公务翻译费 Name
- translateCurrCode = "Unknown"; //公务翻译费 Code
- #region 处理费用币种
- var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
- if (inviteCurrData != null)
- {
- inviteCurrName = inviteCurrData.Remark;
- inviteCurrCode = inviteCurrData.Name;
- }
- var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
- if (sendCurrData != null)
- {
- sendCurrName = sendCurrData.Remark;
- sendCurrCode = sendCurrData.Name;
- }
- var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
- if (eventsCurrData != null)
- {
- eventsCurrName = eventsCurrData.Remark;
- eventsCurrCode = eventsCurrData.Name;
- }
- var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
- if (translateCurrData != null)
- {
- translateCurrName = translateCurrData.Remark;
- translateCurrCode = translateCurrData.Name;
- }
- #endregion
- _detail.PriceNameContent = _ioa.InviterArea;
- _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
- $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
- $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
- $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
- $@"备注:" + _ioa.Remark + "<br/>";
- }
- break;
- case 82: //团组客户保险
- Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
- if (customers != null)
- {
- _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
- _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
- }
- break;
- case 85: //机票预订
- Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (jpRes != null)
- {
- string FlightsDescription = jpRes.FlightsDescription;
- string PriceDescription = jpRes.PriceDescription;
- _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
- _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
- }
- break;
- case 98://其他款项
- Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (gdpRes != null)
- {
- _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
- _detail.PriceNameContent = gdpRes.PriceName;
- }
- break;
- case 285://收款退还
- Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (refundAndOtherMoney != null)
- {
- _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
- _detail.PriceNameContent = refundAndOtherMoney.PriceName;
- }
- break;
- case 751://酒店早餐
- break;
- case 1015://超支费用
- Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (groupExtraCost != null)
- {
- _detail.PriceNameContent = groupExtraCost.PriceName;
- _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
- }
- break;
- default:
- break;
- }
- /*
- * 申请人
- */
- string operatorName = " - ";
- var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
- if (_opUser != null)
- {
- operatorName = _opUser.CnName;
- }
- _detail.OperatorName = operatorName;
- /*
- * 审核人
- */
- string auditOperatorName = "Unknown";
- if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
- else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
- else
- {
- var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
- if (_adUser != null)
- {
- auditOperatorName = _adUser.CnName;
- }
- }
- _detail.AuditOperatorName = auditOperatorName;
- /*
- * 超预算比例
- */
- string overBudgetStr = "";
- if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
- else if (entity.ExceedBudget == 0)
- {
- if (entity.CTable == 76 || entity.CTable == 79)
- {
- if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
- else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
- }
- else
- {
- overBudgetStr = "未超预算";
- }
- }
- else overBudgetStr = entity.ExceedBudget.ToString("P");
- _detail.OverBudget = overBudgetStr;
- decimal auditFee = 0.00M; //已审核金额 人名币
- decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
- decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
- decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
- if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
- {
- auditedFeeOriginal = entity.PayMoney;
- auditFee = CurrPayStr;
- }
- else if (entity.IsAuditGM == 0)
- {
- unAuditFeeCNY = CurrPayStr;
- unAuditFeeOriginal = OriginalCurrPay;
- OriginalCurrPay = 0.00M;
- }
- /*
- * 费用总计
- */
- ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
- {
- CurrencyId = entity.PaymentCurrency,
- CurrencyName = PaymentCurrency_WaitPay,
- AmountPayable = entity.PayMoney,
- ThisPayment = OriginalCurrPay,
- BalancePayment = BalanceStr,
- AuditedFunds = auditFee,
- AuditedFundsOriginal = auditedFeeOriginal,
- UnAuditFundsCNY = unAuditFeeCNY,
- UnAuditFundsOriginal = unAuditFeeOriginal
- });
- _detail.IsAuditGM = entity.IsAuditGM;
- detailList.Add(_detail);
- }
- #endregion
- _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
- /*
- * 下方描述处理
- */
- var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
- var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
- if (ccpCurrencyPrice != null)
- {
- int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
- nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
- }
- else
- {
- nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
- }
- string amountPayableStr = string.Format(@"应付款总金额: ");
- string thisPaymentStr = string.Format(@"此次付款总金额: ");
- string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
- string auditedFundsStr = string.Format(@"已审费用总额: ");
- string unAuditedFundsStr = string.Format(@"未审费用总额: ");
- foreach (var item in nonDuplicat)
- {
- var currencyName = item.CurrencyName;
- var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
- if (strs.Count > 0)
- {
- decimal amountPayable = strs.Sum(it => it.AmountPayable);
- decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
- decimal balancePayment = strs.Sum(it => it.BalancePayment);
- amountPayableStr += string.Format(@"{0}{1} |", amountPayable.ToString("#0.00"), currencyName);
- //单独处理此次付款金额
- thisPaymentStr += string.Format(@"{0}{1} |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
- balancePaymentStr += string.Format(@"{0}{1} |", balancePayment.ToString("#0.00"), currencyName);
- //单独处理已审核费用
- //if (item.CurrencyId == 836) //人民币
- //{
- // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
- // auditedFundsStr += string.Format(@"{0}{1} |", auditedFunds.ToString("#0.00"), currencyName);
- //}
- //else
- //{
- // auditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.AmountPayable), currencyName);
- //}
- if (currencyName.Equals("CNY"))
- {
- //已审核费用
- auditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
- //未审核费用
- unAuditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
- }
- else
- {
- //已审核费用
- auditedFundsStr += string.Format(@"{0}{1}({2}CNY) |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
- //未审核费用
- unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY) |", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
- }
- }
- }
- _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
- _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
- _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
- _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
- //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
- var _view1 = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _view
- };
- return Ok(JsonView(_view1));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 费用审核
- /// 修改团组费用审核状态
- /// </summary>
- /// <param name="_dto">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- #endregion
- #region 页面操作权限验证
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
- #endregion
- List<string> idList = _dto.CreditIdStr.Split(',').ToList();
- Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
- DateTime dtNow = DateTime.Now;
- _groupRepository.BeginTran();
- int rst = 0;
- var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
- var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
- var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
- List<dynamic> msgDatas = new List<dynamic>();
- Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
- foreach (var item in idList)
- {
- int CreditId = int.Parse(item);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
- .SetColumns(it => it.AuditGMOperate == _dto.UserId)
- .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
- .Where(s => s.Id == CreditId)
- .ExecuteCommandAsync();
- if (result < 1)
- {
- rst = -1;
- _groupRepository.RollbackTran();
- return Ok(JsonView(false, "操作失败并回滚!"));
- }
- var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
- if (creditData != null)
- {
- #region 应用通知配置
- try
- {
- dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
- string groupNameStr = string.Empty;
- var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
- if (groupData != null) groupNameStr = groupData.TeamName;
- string creditTypeStr = string.Empty;
- var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
- if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
- string creditCurrency = string.Empty;
- var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
- if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
- if (creditCurrency.Equals("CNY"))
- {
- creditData.DayRate = 1.0000M;
- }
- if (creditData.PayPercentage == 0.00M)
- {
- creditData.PayPercentage = 100M;
- }
- decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
- string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
- string msgContent = "";
- if (creditCurrency.Equals("CNY"))
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
- }
- else
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
- }
- msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
- }
- }
- if (rst == 0)
- {
- _groupRepository.CommitTran();
- foreach (var item in msgDatas)
- {
- //发送消息
- GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
- }
- #region 应用推送
- try
- {
- foreach (var ccpId in dic_ccp_user.Keys)
- {
- List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
- }
- }
- catch (Exception)
- {
- }
- #endregion
- return Ok(JsonView(true, "操作成功!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 机票费用录入
- /// <summary>
- /// 机票录入当前登录人可操作团组
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResSelect(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>
- /// 机票费用录入列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResList(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, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 根据id查询费用录入信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
- {
- Result groupData = await _airTicketResRep.AirTicketResById(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> OpAirTicketRes(AirTicketResOpDto dto)
- {
- Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.AirTicketResOpData.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- 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> tankType(AirTicketResByIdDto dto)
- {
- try
- {
- List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
- if (crm_Groups.Count != 0)
- {
- List<dynamic> Customer = new List<dynamic>();
- foreach (var item in crm_Groups)
- {
- var data = new
- {
- Id = item.Id,
- Pinyin = item.Pinyin,
- Name = item.LastName + item.FirstName
- };
- Customer.Add(data);
- }
- return Ok(JsonView(true, "查询成功!", Customer));
- }
- return Ok(JsonView(true, "暂无数据", crm_Groups));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据团号获取客户信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
- {
- var jw = JsonView(false);
- if (dto.DIID < 1)
- {
- jw.Msg += "请输入正确的diid";
- return Ok(jw);
- }
- var arr = getSimplClientList(dto.DIID);
- jw = JsonView(true, "获取成功!", arr);
- return Ok(jw);
- }
- private List<SimplClientInfo> getSimplClientList(int diId)
- {
- string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
- List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
- foreach (var item in arr)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- return arr;
- }
- private string getClientNameStr(List<SimplClientInfo> list, string origin)
- {
- string result = origin;
- if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
- {
- string[] temparr = origin.Split(',');
- string fistrStr = temparr[0];
- int count = temparr.Count();
- int tempId;
- bool success = int.TryParse(fistrStr, out tempId);
- if (success)
- {
- SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
- if (tempInfo != null)
- {
- if (count > 1)
- {
- result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
- }
- else
- {
- result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
- }
- }
- }
- }
- return result;
- }
- private string getClientNameStr1(List<SimplClientInfo> list, string origin)
- {
- string result = origin;
- if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
- {
- string[] temparr = origin.Split(',');
- result = "";
- foreach (var item in temparr)
- {
- int tempId;
- bool success = int.TryParse(item, out tempId);
- if (success)
- {
- SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
- if (tempInfo != null)
- {
- result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
- }
- }
- }
- }
- if (result.Length > 0) result = result.Substring(0, result.Length - 1);
- return result;
- }
- /// <summary>
- /// 机票费用录入,删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
- {
- try
- {
- var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (res)
- {
- var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- 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> DeriveAirTicketRes(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
- }
- else
- {
- List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
- if (AirTicketReservations.Count != 0)
- {
- Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
- Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
- string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
- string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
- decimal countCost = 0;
- foreach (var item in AirTicketReservations)
- {
- #region 处理客人姓名
- string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
- item.ClientName = clientNames;
- #endregion
- if (item.BankType == "其他")
- {
- item.BankNo = "--";
- }
- else
- {
- if (!string.IsNullOrEmpty(item.BankType))
- {
- item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
- }
- }
- item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
- item.Price = System.Decimal.Round(item.Price, 2);
- countCost += Convert.ToDecimal(item.Price);
- }
- designer.SetDataSource("Export", AirTicketReservations);
- designer.SetDataSource("ExportDiCode", diCode);
- designer.SetDataSource("ExportDiName", diName);
- designer.SetDataSource("ExportOpUserName", _Users.CnName);
- designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
- designer.Process();
- string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- return Ok(JsonView(true, "成功", url = rst));
- }
- else
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
- throw;
- }
- }
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- /// <summary>
- /// 行程单导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
- }
- else
- {
- List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
- if (dto.Language == "CN")
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- starCity = star_Three.AirPort;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- EndCity = End_Three.AirPort;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- air.SeatingClass = item.CTypeName;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- else
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- List<string> texts = new List<string>();
- foreach (var item in _AirTicketReservations)
- {
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- if (!transDic.ContainsKey(_AirCompany.CnName))
- {
- transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
- }
- }
- else
- {
- if (!transDic.ContainsKey("--"))
- {
- transDic.Add("--", "--");
- }
- }
- }
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- name += clientName + ",";
- }
- if (!texts.Contains(name))
- {
- texts.Add(name);
- }
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- if (star_Three != null)
- {
- if (!transDic.ContainsKey(star_Three.AirPort))
- {
- transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
- }
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- if (End_Three != null)
- {
- if (!transDic.ContainsKey(End_Three.AirPort))
- {
- transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
- }
- }
- if (!texts.Contains(item.CTypeName))
- {
- texts.Add(item.CTypeName);
- }
- }
- }
- List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- string str2 = "--";
- string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult2))
- {
- str2 = translateResult2;
- str2 = _airTicketResRep.Processing(str2);
- }
- starCity = str2;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- string str1 = "--";
- string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult1))
- {
- str1 = translateResult1;
- str1 = _airTicketResRep.Processing(str1);
- }
- EndCity = str1;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- air.SeatingClass = str;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- //ishcel0.CellFormat.VerticalAlignment=
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
- throw;
- }
- }
- #endregion
- #region 团组增减款项 --> 其他款项
- /// <summary>
- /// 团组增减款项下拉框绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
- #endregion
- return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
- }
- /// <summary>
- /// 根据团组Id查询团组增减款项
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
- }
- /// <summary>
- /// 团组增减款项操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
- {
- JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
- if (groupData.Code != 200)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
- int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- //自动审核
- var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
- #endregion
- 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> DelDecreasePayments(DelBaseDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
- var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
- if (res.Code == 0)
- {
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- /// <summary>
- /// 根据团组增减款项Id查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
- return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
- }
- /// <summary>
- /// 查询供应商名称
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
- {
- var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
- .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
- ?? new List<Grp_DecreasePayments>();
- dbResult = dbResult.Distinct(new
- ProductComparer()).ToList();
- var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
- {
- x.Id,
- x.SupplierAddress,
- x.SupplierArea,
- x.SupplierContact,
- x.SupplierContactNumber,
- x.SupplierEmail,
- x.SupplierName,
- x.SupplierSocialAccount,
- x.SupplierTypeId,
- }).ToList());
- return Ok(jw);
- }
- /// <summary>
- /// 团组增减款项 OTA匹配
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
- {
- if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
- string fileName = file.FileName;
- if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
- {
- return Ok(JsonView(false, "请上传Excel文件!"));
- }
- //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
- var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- var filePath = @$"{path}/{fileName}";
- //保存文件
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
- //读取ExcelFile
- DataTable dt = ConvertExcelToDataTable(filePath);
- if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
- dt.TableName = "TB";
- //修改table列名
- dt.Columns[0].ColumnName = "OrderNo"; // 订单号
- dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
- dt.Columns[2].ColumnName = "PackageName"; // 套餐名
- dt.Columns[3].ColumnName = "IsPay"; // 是否支付
- dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
- dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
- dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
- dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
- dt.Columns[8].ColumnName = "UseTime"; // 使用时间
- dt.Columns[9].ColumnName = "Quantity"; // 台数
- dt.Columns[10].ColumnName = "Days"; // 租赁天数
- dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
- dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
- dt.Columns[13].ColumnName = "GroupName"; // 团组名称
- dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
- var otaOrderNos = new List<string>();
- foreach (DataRow item in dt.Rows)
- {
- otaOrderNos.Add(item["OTAOrderNo"].ToString());
- }
- var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
- .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
- .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
- .Select((dp, di) => new
- {
- dp.PriceName,
- dp.OTAOrderNo,
- dp.FeeTotal,
- di.TeamName,
- })
- .ToListAsync();
- foreach (DataRow item in dt.Rows)
- {
- var otaOrderNo = item["OTAOrderNo"].ToString();
- var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
- if (oaData == null) continue;
- item["GroupName"] = oaData.TeamName;
- item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
- }
- string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- Dictionary<string, object> pairs = new Dictionary<string, object>();
- List<DataTable> datas = new List<DataTable>();
- datas.Add(dt);
- url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
- return Ok(JsonView(true, "操作成功", new { url = url }));
- }
- #region
- private DataTable ConvertExcelToDataTable(string excelFilePath)
- {
- // 创建Workbook对象
- Workbook workbook = new Workbook(excelFilePath);
- // 获取第一个工作表
- Worksheet worksheet = workbook.Worksheets[0];
- // 将工作表转换为DataTable
- DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
- return dataTable;
- }
- #endregion
- #endregion
- #region 文件上传、删除
- /// <summary>
- /// region 文件上传 可以带参数
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadProject(IFormFile file)
- {
- //var TypeName = Request.Headers["TypeName"].ToString();
- //if (file == null) return Ok(JsonView(false, "文件不存在!"));
- //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- ////文件名称
- //string projectFileName = file.FileName;
- ////上传的文件的路径
- //string filePath = $"{fileDir}/{projectFileName}";
- //if (TypeName == "A")//A代表团组增减款项
- //{
- // filePath = fileDir + $@"\团组增减款项相关文件";
- // if (!Directory.Exists(filePath))
- // {
- // Directory.CreateDirectory(filePath);
- // }
- // //上传的文件的路径
- // filePath += $@"\{projectFileName}";
- //}
- //else if (TypeName == "B")//B代表商邀相关文件
- //{
- // //上传的文件的路径
- // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- // if (!Directory.Exists(filePath))
- // {
- // Directory.CreateDirectory(filePath);
- // }
- // //上传的文件的路径
- // filePath = $@"\{projectFileName}";
- //}
- //try
- //{
- // using (FileStream fs = System.IO.File.Create(filePath))
- // {
- // file.CopyTo(fs);
- // fs.Flush();
- // }
- //}
- //catch (Exception ex)
- //{
- // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
- //}
- //return Ok(JsonView(true, "上传成功!", projectFileName));
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = $"{fileDir}/{projectFileName}";
- if (TypeName == "A")//A代表团组增减款项
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
- }
- else if (TypeName == "B")//B代表商邀相关文件
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- }
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// 删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFile(DelFileDto dto)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- int id = 0;
- if (TypeName == "A")
- {
- filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
- .Where(a => a.Id == dto.Id)
- .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
- .ExecuteCommandAsync();
- }
- else if (TypeName == "B")
- {
- filePath = fileDir + "/商邀相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
- if (info != null)
- {
- string[] files = new string[] { };
- if (!string.IsNullOrEmpty(info.Attachment))
- {
- try
- {
- files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
- }
- catch (Exception)
- {
- files = new List<string>() { info.Attachment }.ToArray();
- }
- }
- if (files.Length > 0)
- {
- var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
- string filePath2 = string.Empty;
- if (files1.Length > 0)
- {
- filePath2 = JsonConvert.SerializeObject(files1);
- }
- id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
- .Where(a => a.Id == dto.Id)
- .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
- .ExecuteCommandAsync();
- }
- }
- }
- if (id != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 文件上传多个文件 可以带参数
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadProjects(IFormFile[] files)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
- if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- var filePahts = new List<string>();
- foreach (var file in files)
- {
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = $"{fileDir}/{projectFileName}";
- if (TypeName == "A")//A代表团组增减款项
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
- }
- else if (TypeName == "B")//B代表商邀相关文件
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- }
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- filePahts.Add(projectFileName);
- }
- return Ok(JsonView(true, "上传成功!", filePahts));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- #endregion
- #region 商邀费用录入
- /// <summary>
- /// 根据团组Id查询商邀费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(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>
- [HttpGet("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
- {
- if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
- var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
- if (info == null) return Ok(JsonView(false, "数据不存在!"));
- if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
- var filePaths = new List<string>();
- var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
- try
- {
- filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
- }
- catch (Exception ex)
- {
- filePaths.Add(info.Attachment);
- }
- if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
- for (int i = 0; i < filePaths.Count; i++)
- {
- filePaths[i] = $"{filePathBase}{filePaths[i]}";
- }
- var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
- var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
- using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
- {
- using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
- {
- foreach (string filePath in filePaths)
- {
- if (System.IO.File.Exists(filePath))
- {
- // 获取文件名
- string fileName = Path.GetFileName(filePath);
- // 将文件添加到ZIP归档中
- zipArchive.CreateEntryFromFile(filePath, fileName);
- }
- }
- }
- }
- return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
- }
- /// <summary>
- /// 商邀费用 Info Page 基础数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, "操作成功", groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 根据商邀费用ID查询C表和商邀费用数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(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, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 商邀费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
- {
- Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- 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> DelInvitationOfficialActivities(DelBaseDto dto)
- {
- try
- {
- _sqlSugar.BeginTran();
- var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
- .SetColumns(it => new Grp_InvitationOfficialActivities()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(it => it.Id == dto.Id)
- .ExecuteCommand();
- if (res1 > 0)
- {
- int _diId = 0;
- var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
- if (_ioaInfo != null)
- {
- _diId = _ioaInfo.DiId;
- }
- var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
- .ExecuteCommand();
- if (res2 > 0)
- {
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- }
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块文件上传
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
- {
- var jw = JsonView(false);
- long M = 1024 * 1024;
- if (dto.Files == null || dto.Files.Count == 0)
- {
- jw.Msg = "无文件信息!";
- return Ok(jw);
- }
- if (dto.Files.Sum(x => x.Length) > 20 * M)
- {
- jw.Msg = "文件大小超过20M!";
- return Ok(jw);
- }
- //var nameSp = dto.File.FileName.Split(".");
- //if (nameSp.Length < 2)
- //{
- // jw.Msg = "拓展名称有误!";
- // return Ok(jw);
- //}
- //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
- //if (!existsName.Contains(nameSp[1].ToUpper()))
- //{
- // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
- // return Ok(jw);
- //}
- var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
- if (Ctable == null)
- {
- jw.Msg = "Ctable指向有误!";
- return Ok(jw);
- }
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
- var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
- try
- {
- if (!Directory.Exists(fileBase))
- {
- Directory.CreateDirectory(fileBase);
- }
- List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
- foreach (var fileStream in dto.Files)
- {
- var saveFilePath = fileBase + "\\" + fileStream.FileName;
- Grp_GroupModelFile file = new Grp_GroupModelFile()
- {
- Cid = dto.Cid,
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- Ctable = dto.Ctable,
- Diid = dto.Diid,
- IsDel = 0,
- FilePath = saveFilePath,
- FileName = fileStream.FileName
- };
- using (FileStream fs = System.IO.File.Create(saveFilePath))
- {
- fileStream.CopyTo(fs);
- fs.Flush();
- }
- saveArr.Add(file);
- }
- var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
- //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
- jw = JsonView(true, "保存成功!", new
- {
- count = addResult,
- filesName = saveArr.Select(x => x.FileName)
- });
- }
- catch (Exception ex)
- {
- jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
- {
- count = 0,
- filesName = new string[0],
- });
- }
- return Ok(jw);
- }
- /// <summary>
- /// 查询各模块已保存文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
- {
- var expression = Expressionable.Create<Grp_GroupModelFile>()
- .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
- var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
- if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
- {
- expression = Expressionable.Create<Grp_GroupModelFile>()
- .And(x => visaIds.Contains(x.CreateUserId));
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
- .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
- .Where(expression.ToExpression())
- .ToList();
- //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
- return Ok(JsonView(true, "success", dbQuery.Select(x => new
- {
- x.FileName,
- x.Id,
- Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
- CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
- })));
- }
- /// <summary>
- /// 下载该团组下的所有文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportGroupZip(ExportGroupZipDto dto)
- {
- var jw = JsonView(false);
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
- var isModule = Convert.ToBoolean(dto.isModule);
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- IOOperatorHelper io = new IOOperatorHelper();
- if (isModule)
- {
- var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
- foreach (var moduleArr in moduleGroup)
- {
- var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
- key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
- foreach (var item in moduleArr)
- {
- if (System.IO.File.Exists(item.FilePath))
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- chiZips.Add(item.FileName, stream);
- }
- }
- }
- if (chiZips.Count > 0)
- {
- var byts = io.ConvertZipStream(chiZips);
- Stream stream = new MemoryStream(byts);
- Zips.Add(key.Name + "_.zip", stream);
- }
- }
- }
- else
- {
- foreach (var item in dbQuery)
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- while (Zips.Keys.Contains(item.FileName))
- {
- item.FileName = new Random().Next(100) + "_" + item.FileName;
- }
- Zips.Add(item.FileName, stream);
- }
- }
- }
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- if (Zips.Count > 0)
- {
- var byts = io.ConvertZipStream(Zips);
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
- io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 下载该团组下此模块的所有文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
- {
- var jw = JsonView(false);
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
- var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
- && x.IsDel == 0);
- if (key == null)
- {
- jw.Msg = "Ctable指向错误!";
- return Ok(jw);
- }
- key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- IOOperatorHelper io = new IOOperatorHelper();
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- foreach (var item in dbQuery)
- {
- if (System.IO.File.Exists(item.FilePath))
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- while (Zips.Keys.Contains(item.FileName))
- {
- item.FileName = new Random().Next(100) + "_" + item.FileName;
- }
- Zips.Add(item.FileName, stream);
- }
- }
- }
- if (Zips.Count > 0)
- {
- var byts = io.ConvertZipStream(Zips);
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
- io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 删除该团组下的指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
- {
- var jw = JsonView(false);
- var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
- if (sing == null)
- {
- jw.Msg = "暂无";
- return Ok(jw);
- }
- if (System.IO.File.Exists(sing.FilePath))
- {
- try
- {
- System.IO.File.Delete(sing.FilePath);
- }
- catch (Exception ex)
- {
- jw.Msg = "删除失败!" + ex.Message;
- return Ok(jw);
- }
- }
- sing.IsDel = 1;
- sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- sing.DeleteUserId = dto.UserId;
- _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
- jw = JsonView(true, "删除成功!");
- return Ok(jw);
- }
- #endregion
- #region 团组英文资料
- /// <summary>
- /// 查询团组英文所有资料
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.QueryDelegationEnData(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> OpDelegationEnData(OpDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.OpDelegationEnData(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> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
- {
- try
- {
- Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
- if (_DelegationEnData != null)
- {
- return Ok(JsonView(true, "查询成功!", _DelegationEnData));
- }
- return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
- }
- 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> DelDelegationEnData(DelBaseDto dto)
- {
- try
- {
- var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(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> QueryinvitationLetter(DecreasePaymentsListDto dto)
- {
- try
- {
- List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
- List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
- if (dto.DiId == 0)
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
- }
- else
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
- }
- return Ok(JsonView(true, "查询成功!", new
- {
- deleClient = crm_Deles,
- delegations = grp_Delegations
- }));
- }
- 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> invitationLetter(DecreasePaymentsListDto dto)
- {
- #region 参数验证
- //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- try
- {
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
- var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
- List<string> texts = new List<string>();
- if (datas.Count != 0)
- {
- foreach (TourClientListDetailsView item in datas)
- {
- if (!string.IsNullOrWhiteSpace(item.Pinyin))
- {
- transDic.Add(item.LastName + item.FirstName, item.Pinyin);
- }
- else
- {
- string name = item.LastName + item.FirstName;
- texts.Add(name);
- }
- if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
- {
- if (!transDic.ContainsKey(item.Job))
- {
- texts.Add(item.Job);
- }
- }
- if (!string.IsNullOrEmpty(item.CompanyFullName))
- {
- texts.Add(item.CompanyFullName);
- }
- }
- List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- List<GuestList> list = new List<GuestList>();
- foreach (TourClientListDetailsView dele in datas)
- {
- GuestList guestList = new GuestList();
- if (!string.IsNullOrWhiteSpace(dele.Pinyin))
- {
- guestList.Name = dele.Pinyin;
- }
- else
- {
- string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
- guestList.Name = Name;
- }
- if (dele.Sex == 0)
- {
- guestList.Sex = "Male";
- }
- else if (dele.Sex == 1)
- {
- guestList.Sex = "Female";
- }
- guestList.DOB = dele.BirthDay.Replace('-', '.');
- if (!string.IsNullOrEmpty(dele.Job))
- {
- guestList.Job = dele.Job;
- }
- list.Add(guestList);
- }
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取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 < list.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(list[i].Name.ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(list[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(list[i].DOB.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(list[i].Job.ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > list.Count + 1)
- {
- tableOne.Rows.RemoveAt(list.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
- string filePath = fileDir + $@"商邀相关文件/{fileName}";
- doc.Save(filePath);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "该团组客户名单暂未录入!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- #endregion
- #region 团组经理模块 出入境费用
-
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetDayAndCostAreaChange()
- {
- try
- {
- var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
- var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
- var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
- var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
- foreach (var item in unite) //处理交集数据
- {
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
- }
- foreach (var item in merge) //处理差集数据
- {
- int nationalTravelFeeId = 0;
- var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
- if (cityData != null) nationalTravelFeeId = cityData.Id;
- else
- {
- var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
- if (countryData != null) nationalTravelFeeId = countryData.Id;
- }
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
- }
- //只更新dayAndCost 的 nationalTravelFeeId;
- var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
- if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
- else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
- {
- var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
- List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
- var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
- List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
- //默认币种显示
- List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
- rate1 *= 1.035M;
- item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- }
- }
- }
- var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- GroupNameData = groupNameData.Data,
- CurrencyData = _CurrencyData,
- WordTypeData = _WordTypeData,
- ExcelTypeData = _ExcelTypeData,
- CurrencyInit = _currencyInfos,
- ViewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用
- /// 实时汇率 tips
- /// 签证费用 tips
- /// 机票费用 tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
- //默认币种显示
- var _currencyInfos = _currencyInit;
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- List<dynamic> reteInfos = new List<dynamic>();
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
- decimal rate1 = item.Rate;
- rate1 *= 1.03M;
- decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- reteInfos.Add(new
- {
- currCode = item.CurrencyCode,
- currName = item.CurrencyName,
- rate = rate2,
- lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
- });
- }
- }
- }
- var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
- var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
- return Ok(JsonView(true, "查询成功!", new
- {
- //GroupNameData = groupNameData.Data,
- visaData = visaData.Data,
- airData = airData.Data,
- reteInfos = reteInfos
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
- {
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- var permissions = new List<Grp_EnterExitCostPermission>();
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- _sqlSugar.BeginTran();
- try
- {
- await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- if (dto.DayOtherPriceData.Any())
- {
- var inserList = dto.DayOtherPriceData
- .Where(x => x.Id == 0)
- .Select(x => new Grp_DayOtherPrice
- {
- Cost = x.Cost,
- Id = x.Id,
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Currency = x.Currency,
- Diid = x.DiId,
- Index = x.Index,
- IsDel = 0,
- SetDataId = x.SetDataId,
- SubTotal = x.SubTotal,
- Remark = x.Remark
- })
- .ToList();
- var updateList = dto.DayOtherPriceData
- .Where(x => x.Id != 0)
- .Select(x => new Grp_DayOtherPrice
- {
- Cost = x.Cost,
- Id = x.Id,
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Currency = x.Currency,
- Diid = x.DiId,
- Index = x.Index,
- IsDel = 0,
- SetDataId = x.SetDataId,
- SubTotal = x.SubTotal,
- Remark = x.Remark
- })
- .ToList();
- //添加
- _sqlSugar.BeginTran();
- if (inserList.Any())
- {
- var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
- }
- if (updateList.Any())
- {
- var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
- }
- _sqlSugar.CommitTran();
- }
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- //生成默认文件pdf并且通知人员
- var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- {
- DiId = dto.DiId,
- ExportType = 1,
- SubTypeId = 1005
- }, "pdf");
- //发送通知
- string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
- string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
- string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Confirm 费用
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
- {
- //TODO:测试完毕需把对应的用户ID更改
- //1、数据表添加字段
- //2、更改字段接口()
- var _view = await _enterExitCostRep.ConfirmCost(dto);
- //3、确认成功 给财务发送消息
- if (_view.Code == 200)
- {
- if (dto.Type == 1)
- {
- int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
- }
- }
- return Ok(_view);
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - File downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
- {
- try
- {
- if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
- if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
- if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
- 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
- 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
- 3 团组成员名单 1 团组成员名单", ""));
- var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
- //数据源
- var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
- var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
- .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
- .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
- .Select((x, a, b) => new
- {
- x.Index,
- itemName = a.Name,
- CurrencyStr = b.Name,
- x.Cost,
- x.SubTotal,
- x.Remark
- })
- .OrderBy((x) => x.Index)
- .ToList(); //其他款项费用
- var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
- var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
- .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
- .Select((tcl, dc, cc) => new ClientInfo
- {
- LastName = dc.LastName,
- FirstName = dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job
- })
- .ToList();
- foreach (var item in DeleClientList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
- var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
- var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
- var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
- _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
- if (dto.ExportType == 1) //明细表
- {
- if (dto.SubTypeId == 1005) //1005(默认明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
- decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
- decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
- decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
- decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
- decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
- //境内费用(其他费用)
- if (_EnterExitCosts.ChoiceOne == 1)
- {
- string row1_1 = "";
- if (_EnterExitCosts.Visa > 0)
- {
- //insidePayTotal += _EnterExitCosts.Visa;
- row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
- if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
- {
- row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
- }
- }
- string row1_2 = "";
- if (_EnterExitCosts.YiMiao > 0)
- {
- //insidePayTotal += _EnterExitCosts.YiMiao;
- row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.HeSuan > 0)
- {
- //insidePayTotal += _EnterExitCosts.HeSuan;
- row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Service > 0)
- {
- //insidePayTotal += _EnterExitCosts.Service;
- row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
- }
- string row1_3 = "";
- if (_EnterExitCosts.Safe > 0)
- {
- //insidePayTotal += _EnterExitCosts.Safe;
- row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Ticket > 0)
- {
- //insidePayTotal += _EnterExitCosts.Ticket;
- row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
- }
- string row1 = "";
- if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
- if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
- if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
- row1 += $"备注:{_EnterExitCosts.Remark}";
- dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
- dic.Add("Row1Str", row1);
- }
- string airTotalStr = string.Empty,
- airPriceStr = string.Empty;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
- airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
- airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
- airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
- }
- string twoItemRemark = "备注:";
- if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
- {
- twoItemRemark = _EnterExitCosts.TwoItemRemark;
- }
- dic.Add("AirTotalStr", airTotalStr);
- dic.Add("AirPriceStr", airPriceStr);
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("TwoItemRemark", twoItemRemark);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int table1Row = 0,
- table2Row = 0,
- table3Row = 0,
- table4Row = 0,
- table5Row = 0;
- //住宿费
- if (_EnterExitCosts.ChoiceThree == 1)
- {
- dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
- table1Row = dac1.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac1.Count; i++)
- {
- Grp_DayAndCost dac = dac1[i];
- if (dac == null) continue;
- builder.MoveToCell(0, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "晚:");
- builder.MoveToCell(0, i, 1, 0);
- //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- //builder.Write(dac.Place == null ? "" : dac.Place);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(0, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubZS", "0.00");
- //删除多余行
- while (table1.Rows.Count > table1Row)
- {
- table1.Rows.RemoveAt(table1Row);
- }
- //伙食费
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFour == 1)
- {
- dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
- table2Row = dac2.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac2.Count; i++)
- {
- Grp_DayAndCost dac = dac2[i];
- if (dac == null) continue;
- builder.MoveToCell(1, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(1, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(1, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(1, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(1, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(1, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubHS", "0.00");
- //删除多余行
- while (table2.Rows.Count > table2Row)
- {
- table2.Rows.RemoveAt(table2Row);
- }
- //公杂费
- Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFive == 1)
- {
- dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
- table3Row = dac3.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac3.Count; i++)
- {
- Grp_DayAndCost dac = dac3[i];
- if (dac == null) continue;
- builder.MoveToCell(2, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(2, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(2, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(2, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(2, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(2, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- #endregion
- }
- else dic.Add("SubGZF", "0.00");
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- //培训费
- Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceSix == 1)
- {
- string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
- dic.Add("SubPX", pxStr);
- table4Row = dac4.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac4.Count; i++)
- {
- Grp_DayAndCost dac = dac4[i];
- if (dac == null) continue;
- builder.MoveToCell(3, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(3, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(3, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(3, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(3, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(3, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
- //删除多余行
- while (table4.Rows.Count > table4Row)
- {
- table4.Rows.RemoveAt(table4Row);
- }
- //其他费用
- Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.OtherExpenses_Checked == 1)
- {
- string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
- dic.Add("titleQi", qtStr);
- table5Row = dac5.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac5.Count; i++)
- {
- var dac = dac5[i];
- if (dac == null) continue;
- builder.MoveToCell(4, i, 0, 0);
- builder.Write("第" + dac.Index.ToString() + "项:");
- builder.MoveToCell(4, i, 1, 0);
- builder.Write(dac.itemName);
- builder.MoveToCell(4, i, 2, 0);
- builder.Write("费用标准:");
- builder.MoveToCell(4, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
- builder.MoveToCell(4, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(4, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- builder.MoveToCell(4, i, 6, 0);
- builder.Write("备注:");
- builder.MoveToCell(4, i, 7, 0);
- builder.Write(dac.Remark);
- }
- #endregion
- }
- else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
- //删除多余行
- while (table5.Rows.Count > table5Row)
- {
- table5.Rows.RemoveAt(table5Row);
- }
- //加上其他费用
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
- //公务舱
- if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
- //头等舱
- if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
- dic.Add("SubJJC", subJJC.ToString("#0.00"));
- dic.Add("SubGWC", subGWC.ToString("#0.00"));
- dic.Add("SubTDC", subTDC.ToString("#0.00"));
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- #endregion
- //文件名
- string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
- AsposeHelper.removewatermark_v2180();
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- //dic.Add("Names", Names);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- int accommodationStartIndex = 6, foodandotherStartIndex = 22;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0.00M)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- foodandotherStartIndex--;
- }
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- }
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- //总计
- decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
- //国际旅费
- string outsideAir = string.Empty;
- string allPriceAir = string.Empty;
- if (_EnterExitCosts.SumJJC == 1)
- {
- outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
- allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1)
- {
- outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
- allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumTDC == 1)
- {
- outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
- allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
- }
- dic.Add("InTravelPrice", $"({outsideAir})");
- dic.Add("FinalSumPrice", $"({allPriceAir})");
- //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
- //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
- //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
- designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
- designer.SetDataSource("Group", _DelegationInfo.TeamName);
- designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
- designer.SetDataSource("Name", Names);
- designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
- designer.SetDataSource("Day", dic["Day"] + "天");
- designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
- designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
- int startIndex = 10;
- const int startIndexcopy = 10;
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- DataTable dtdac1 = new DataTable();
- List<string> place = new List<string>();
- dtdac1.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
- });
- DataTable dtdac2 = new DataTable();
- dtdac2.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
- });
- dtdac1.TableName = "tb1";
- dtdac2.TableName = "tb2";
- decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
- foreach (var item in dac1)
- {
- item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac1.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["costRMB"] = rbmPrice;
- dtdac1.Rows.Add(row);
- place.Add(item.Place);
- }
- place = new List<string>();
- foreach (var item in dac2)
- {
- item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac2.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["cost"] = item.SubTotal;
- //row["costRMB"] = rbmPrice;
- dtdac2.Rows.Add(row);
- place.Add(item.Place);
- //dac2totalPrice += rbmPrice;
- }
- dac1totalPrice = dac1.Sum(it => it.SubTotal);
- dac2totalPrice = dac2.Sum(it => it.SubTotal);
- designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- designer.SetDataSource("dac2totalPrice", dac2totalPrice);
- designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
- designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
- string cell4Str1 = string.Empty;
- if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
- string cell4Str = $" 4.国际旅费:{cell4Str1}";
- string cellStr = $" 5.其他费用(";
- if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
- if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
- if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
- if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
- if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
- if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
- #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
- var otherPriceTotal = dac5.Sum(x => x.SubTotal);
- foreach (var otherInfo in dac5)
- {
- cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (cellStr.Length > 8)
- {
- cellStr = cellStr.Substring(0, cellStr.Length - 1);
- }
- cellStr += ")";
- decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
- decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
- decimal pxFee = dac4.Sum(it => it.Cost);
- decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
- string celllastStr1 = "";
- if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
- if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
- if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
- celllastStr1 += $",国际旅费 元";
- if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
- string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
- designer.SetDataSource("cell4Str", cell4Str);
- designer.SetDataSource("cellStr", cellStr);
- designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
- designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- designer.SetDataSource("celllastStr", celllastStr);
- Workbook wb = designer.Workbook;
- var sheet = wb.Worksheets[0];
- //绑定datatable数据集
- designer.SetDataSource(dtdac1);
- designer.SetDataSource(dtdac2);
- designer.Process();
- var rowStart = dtdac1.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
- startIndex += 1; //总计行
- rowStart = dtdac2.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
- wb.CalculateFormula(true);
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("GroupName", _DelegationInfo.TeamName);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- string missionLeader = ""; //团负责人默认接团客户名单第一个人
- string missionLeaderJob = "";//负责人job
- int groupNumber = 0; //团人数
- if (DeleClientList.Count > 0)
- {
- missionLeader = DeleClientList[0]?.Name ?? "";
- missionLeaderJob = DeleClientList[0]?.Job ?? "";
- }
- dic.Add("MissionLeader", missionLeader); //团负责人
- dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
- dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
- #region MyRegion
- //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- //{
- // List<string> list = new List<string>();
- // try
- // {
- // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- // foreach (var item in spilitArr)
- // {
- // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- // var depCode = spDotandEmpty[2].Substring(0, 3);
- // var arrCode = spDotandEmpty[2].Substring(3, 3);
- // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
- // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
- // list.Add(depName);
- // list.Add(arrName);
- // }
- // list = list.Distinct().ToList();
- // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- // }
- // catch (Exception)
- // {
- // dic.Add("ReturnCode", "行程录入不正确!");
- // }
- //}
- //else
- //{
- // dic.Add("ReturnCode", "未录入行程!");
- //}
- List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
- dic.Add("ReturnCode", string.Join("、", countrys));
- #endregion
- //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- //{
- // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- // dic.Add("Day", sp.Days.ToString());
- //}
- dic.Add("Day", _DelegationInfo.VisitDays.ToString());
- dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
- // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- //培训人员名单
- int cultivateRowIndex = 7;
- foreach (var item in DeleClientList)
- {
- builder.MoveToCell(0, cultivateRowIndex, 0, 0);
- builder.Write(item.Name);
- builder.MoveToCell(0, cultivateRowIndex, 1, 0);
- builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
- builder.MoveToCell(0, cultivateRowIndex, 2, 0);
- string birthDay = "";
- if (item.Birthday != null)
- {
- DateTime dt = Convert.ToDateTime(item.Birthday);
- birthDay = $"{dt.Year}.{dt.Month}";
- }
- builder.Write(birthDay);
- builder.MoveToCell(0, cultivateRowIndex, 3, 0);
- builder.Write(item.Company);
- builder.MoveToCell(0, cultivateRowIndex, 4, 0);
- builder.Write(item.Job);
- cultivateRowIndex++;
- }
- //删除多余行
- //cultivateRowIndex -= 2;
- int delRows = 10 + 7 - cultivateRowIndex;
- if (delRows > 0)
- {
- for (int i = 0; i < delRows; i++)
- {
- table1.Rows.RemoveAt(cultivateRowIndex);
- //cultivateRowIndex++;
- }
- }
- decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
- dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
- decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
- dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
- decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
- dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
- decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
- dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
- decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
- dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
- //其他费用
- decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
- dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
- //其他费用合计
- decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
- decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
- decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
- //公务舱合计
- //国际旅费
- string outsideJJ = "";
- string allPriceJJ = "";
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
- dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
- dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
- {
- string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
- dic.Add("AirFeeTotal", airFeeTotalStr);
- string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
- dic.Add("FeeTotal", feeTotalStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 2) //表格
- {
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- dic.Add("TeamName", _DelegationInfo.TeamName);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- //dic.Add("TellPhone", _DelegationInfo.TellPhone);
- string missionLeaderName = "",
- missionLeaderJob = "";
- if (DeleClientList.Count > 0)
- {
- missionLeaderName = DeleClientList[0].Name;
- missionLeaderJob = DeleClientList[0].Job;
- }
- dic.Add("MissionLeaderName", missionLeaderName);
- dic.Add("MissionLeaderJob", missionLeaderJob);
- dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
- dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int rowCount = 10;//总人数行
- int startRowIndex = 7; //起始行
- for (int i = 0; i < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, startRowIndex, 0, 0);
- builder.Write(DeleClientList[i].Name); //出国人员姓名
- builder.MoveToCell(0, startRowIndex, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);//性别
- builder.MoveToCell(0, startRowIndex, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
- builder.MoveToCell(0, startRowIndex, 3, 0);
- builder.Write(DeleClientList[i].Company);//工作单位
- builder.MoveToCell(0, startRowIndex, 4, 0);
- builder.Write(DeleClientList[i].Job);//职务及级别
- builder.MoveToCell(0, startRowIndex, 5, 0);
- builder.Write("");//人员属性
- builder.MoveToCell(0, startRowIndex, 6, 0);
- builder.Write("");//上次出国时间
- startRowIndex++;
- }
- int nullRow = rowCount - DeleClientList.Count;//空行
- for (int i = 0; i < nullRow; i++)
- {
- table1.Rows.Remove(table1.Rows[startRowIndex]);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- dic.Add("GroupClient", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
- dic.Add("Names", Names);
- int accommodationRows = 12, foodandotherRows = 12;
- var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int accommodationStartIndex = 6;
- decimal dac1totalPrice = 0.00M;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += rbmPrice;
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write("小计");
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- builder.Write(dac1totalPrice.ToString("#0.00"));
- accommodationStartIndex++;
- int nullRow = accommodationRows - dac1.Count;
- //删除空行
- //if (nullRow > 0)
- //{
- // int rowIndex = accommodationStartIndex;
- // for (int i = 0; i < nullRow; i++)
- // {
- // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
- // row.Remove();
- // rowIndex++;
- // }
- //}
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- int foodandotherStartIndex = 19;//
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- //foodandotherStartIndex = 12;
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += rbmPrice;
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- //删除空行
- //if (dac2.Count < foodandotherRows)
- //{
- // while (table2.Rows.Count > dac2.Count)
- // {
- // table2.Rows.RemoveAt(dac2.Count);
- // }
- //}
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
- if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
- if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
- if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 3)
- {
- if (dto.SubTypeId == 1) //团组成员名单
- {
- if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取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 < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DeleClientList[i].Name);
- builder.MoveToCell(0, i + 1, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(DeleClientList[i].Company);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DeleClientList[i].Job);
- }
- //删除多余行
- while (tableOne.Rows.Count > DeleClientList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
- }
- string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
- //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
- //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- return Ok(JsonView(400, "操作失败!", ""));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(400, ex.Message, ""));
- }
- }
- /// <summary>
- /// 获取三公费用标准city
- /// </summary>
- /// <param name="placeData"></param>
- /// <param name="nationalTravelFeeId"></param>
- /// <returns></returns>
- private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
- {
- string _city = string.Empty;
- if (placeData.Count < 1) return _city;
- var data = placeData.Find(it => it.Id == nationalTravelFeeId);
- if (data == null) return _city;
- string country = data.Country;
- string city = data.City;
- if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
- else _city = city;
- return _city;
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 明细表导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 一键清空
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
- {
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
- var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
- await _sqlSugar.Updateable<Grp_DayOtherPrice>()
- .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
- .SetColumns(x => new Grp_DayOtherPrice
- {
- IsDel = 1,
- DeleteUserId = dto.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .ExecuteCommandAsync();
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, "操作成功"));
- }
- return Ok(JsonView(false, "操作失败"));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 删除三公其他费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
- {
- var jw = JsonView(false,"删除失败!");
- var data = new Grp_DayOtherPrice()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0)
- {
- jw.Code = 200;
- jw.Msg = "删除成功!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
- {
- try
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0");
- var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
- //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
- //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
- //foreach (var item in nationalTravel)
- //{
- // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
- // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
- // if (otherData != null)
- // {
- // cityData.Remove(otherData);
- // cityData.Add(otherData);
- // }
- // nationalTravelFeeData1.Add(new
- // {
- // Country = item.Country,
- // CityData = cityData
- // });
- //}
- sw.Stop();
- return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List Data Source
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeePageDataSource()
- {
- string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
- List<string> countryData = new List<string>();
- countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
- countryData = countryData.Distinct().ToList();
- List<dynamic> dataSource = new List<dynamic>();
- foreach (var item in countryData)
- {
- List<string> cityData1 = new List<string>();
- cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
- var countryData2 = new
- {
- CountryName = item,
- CityData = cityData1
- };
- dataSource.Add(countryData2);
- }
- return Ok(JsonView(true, "查询成功!", dataSource));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
- {
- int portId = dto.PortType;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
- if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
- }
- string pageSql = string.Format(@"Select * From (
- Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
- ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
- From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0 {0} ) temp ", whereSql);
- RefAsync<int> total = 0;
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 根据城市查询
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请传入参数!"));
- int portId = dto.PortType;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql = string.Format(@"And City = '{0}' ", dto.City);
- }
- string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
- ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
- gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
- From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0 {0} ", whereSql);
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Add Or Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
- {
- var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Del
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
- {
- Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
- {
- Id = dto.Id,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
- IsDel = 1
- };
- var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
- .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (delStatus <= 0)
- {
- return Ok(JsonView(false, "删除失败!"));
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
- /// 注:Get 请求Headers 加 Token
- /// </summary>
- /// <param name="groupId"></param>
- /// <returns></returns>
- [HttpGet("{groupId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
- {
- var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
- data.ForEach(x =>
- {
- x.CreateUserId = _currUserInfo.UserId;
- });
- if (data.Any())
- {
- var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
- if (add > 0)
- {
- return Ok(JsonView(true, "操作成功!"));
- }
- }
- return Ok(JsonView(false, "未操作!"));
- }
- #endregion
- #region 团组经理模块 出入境费用-草稿
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
- {
- var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
- .Where(x => x.IsDel == 0)
- .OrderByDescending(x => x.CreateTime)
- .Select(x => new { x.Id, x.DraftName })
- .ToListAsync();
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
- var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
- var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
- var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
- //默认币种显示
- List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
- rate1 *= 1.035M;
- item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- }
- }
- }
- var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- DraftNameDatas = draftNameDatas,
- CurrencyData = _CurrencyData,
- WordTypeData = _WordTypeData,
- ExcelTypeData = _ExcelTypeData,
- CurrencyInit = _currencyInfos,
- ViewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿
- /// 实时汇率 tips
- /// 签证费用 tips
- /// 机票费用 tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
- {
- //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
- //默认币种显示
- var _currencyInfos = _currencyInit;
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- List<dynamic> reteInfos = new List<dynamic>();
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
- decimal rate1 = item.Rate;
- rate1 *= 1.03M;
- decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- reteInfos.Add(new
- {
- currCode = item.CurrencyCode,
- currName = item.CurrencyName,
- rate = rate2,
- lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
- });
- }
- }
- }
- //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
- //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
- return Ok(JsonView(true, "查询成功!", new
- {
- //GroupNameData = groupNameData.Data,
- //visaData = visaData.Data,
- //airData = airData.Data,
- reteInfos = reteInfos
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
- {
- return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- var permissions = new List<Grp_EnterExitCostDraftPermission>();
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- _sqlSugar.BeginTran();
- try
- {
- await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
- {
- var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - File downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
- {
- try
- {
- var id = dto.Id;
- if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
- if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
- if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
- 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
- 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
- 3 团组成员名单 1 团组成员名单", ""));
- var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
- if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
- var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
- var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
- //数据源
- var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
- var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
- .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
- .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
- .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
- .Select((x, a, b) => new
- {
- x.Index,
- itemName = a.Name,
- CurrencyStr = b.Name,
- x.Cost,
- x.SubTotal,
- x.Remark
- })
- .OrderBy((x) => x.Index)
- .ToList(); //其他款项费用
- var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
-
- var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
- var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
- var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
- if (dto.ExportType == 1) //明细表
- {
- if (dto.SubTypeId == 1005) //1005(默认明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
- decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
- decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
- decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
- decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
- decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
- //境内费用(其他费用)
- if (_EnterExitCosts.ChoiceOne == 1)
- {
- string row1_1 = "";
- if (_EnterExitCosts.Visa > 0)
- {
- //insidePayTotal += _EnterExitCosts.Visa;
- row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
- if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
- {
- row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
- }
- }
- string row1_2 = "";
- if (_EnterExitCosts.YiMiao > 0)
- {
- //insidePayTotal += _EnterExitCosts.YiMiao;
- row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.HeSuan > 0)
- {
- //insidePayTotal += _EnterExitCosts.HeSuan;
- row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Service > 0)
- {
- //insidePayTotal += _EnterExitCosts.Service;
- row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
- }
- string row1_3 = "";
- if (_EnterExitCosts.Safe > 0)
- {
- //insidePayTotal += _EnterExitCosts.Safe;
- row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Ticket > 0)
- {
- //insidePayTotal += _EnterExitCosts.Ticket;
- row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
- }
- string row1 = "";
- if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
- if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
- if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
- row1 += $"备注:{_EnterExitCosts.Remark}";
- dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
- dic.Add("Row1Str", row1);
- }
- string airTotalStr = string.Empty,
- airPriceStr = string.Empty;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
- airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
- airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
- airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
- }
- string twoItemRemark = "备注:";
- if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
- {
- twoItemRemark = _EnterExitCosts.TwoItemRemark;
- }
- dic.Add("AirTotalStr", airTotalStr);
- dic.Add("AirPriceStr", airPriceStr);
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("TwoItemRemark", twoItemRemark);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int table1Row = 0,
- table2Row = 0,
- table3Row = 0,
- table4Row = 0,
- table5Row = 0;
- //住宿费
- if (_EnterExitCosts.ChoiceThree == 1)
- {
- dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
- table1Row = dac1.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac1.Count; i++)
- {
- var dac = dac1[i];
- if (dac == null) continue;
- builder.MoveToCell(0, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "晚:");
- builder.MoveToCell(0, i, 1, 0);
- //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- //builder.Write(dac.Place == null ? "" : dac.Place);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(0, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubZS", "0.00");
- //删除多余行
- while (table1.Rows.Count > table1Row)
- {
- table1.Rows.RemoveAt(table1Row);
- }
- //伙食费
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFour == 1)
- {
- dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
- table2Row = dac2.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac2.Count; i++)
- {
- var dac = dac2[i];
- if (dac == null) continue;
- builder.MoveToCell(1, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(1, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(1, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(1, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(1, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(1, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubHS", "0.00");
- //删除多余行
- while (table2.Rows.Count > table2Row)
- {
- table2.Rows.RemoveAt(table2Row);
- }
- //公杂费
- Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFive == 1)
- {
- dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
- table3Row = dac3.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac3.Count; i++)
- {
- var dac = dac3[i];
- if (dac == null) continue;
- builder.MoveToCell(2, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(2, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(2, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(2, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(2, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(2, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- #endregion
- }
- else dic.Add("SubGZF", "0.00");
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- //培训费
- Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceSix == 1)
- {
- string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
- dic.Add("SubPX", pxStr);
- table4Row = dac4.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac4.Count; i++)
- {
- var dac = dac4[i];
- if (dac == null) continue;
- builder.MoveToCell(3, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(3, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(3, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(3, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(3, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(3, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
- //删除多余行
- while (table4.Rows.Count > table4Row)
- {
- table4.Rows.RemoveAt(table4Row);
- }
- //其他费用
- Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.OtherExpenses_Checked == 1)
- {
- string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
- dic.Add("titleQi", qtStr);
- table5Row = dac5.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac5.Count; i++)
- {
- var dac = dac5[i];
- if (dac == null) continue;
- builder.MoveToCell(4, i, 0, 0);
- builder.Write("第" + dac.Index.ToString() + "项:");
- builder.MoveToCell(4, i, 1, 0);
- builder.Write(dac.itemName);
- builder.MoveToCell(4, i, 2, 0);
- builder.Write("费用标准:");
- builder.MoveToCell(4, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
- builder.MoveToCell(4, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(4, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- builder.MoveToCell(4, i, 6, 0);
- builder.Write("备注:");
- builder.MoveToCell(4, i, 7, 0);
- builder.Write(dac.Remark);
- }
- #endregion
- }
- else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
- //删除多余行
- while (table5.Rows.Count > table5Row)
- {
- table5.Rows.RemoveAt(table5Row);
- }
- //加上其他费用
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
- //公务舱
- if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
- //头等舱
- if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
- dic.Add("SubJJC", subJJC.ToString("#0.00"));
- dic.Add("SubGWC", subGWC.ToString("#0.00"));
- dic.Add("SubTDC", subTDC.ToString("#0.00"));
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- #endregion
- //文件名
- string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- AsposeHelper.removewatermark_v2180();
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- string returnCodeLabel = string.Empty;
- if (nationalTravelFeeData.Any())
- {
- List<string> list = new List<string>();
- foreach (var item in nationalTravelFeeData)
- {
- list.Add($"{item.Country}({item.City})");
- }
- list = list.Distinct().ToList();
- returnCodeLabel = string.Join("-", list).TrimEnd('-');
- }
- var countryLabel = string.Empty;
- var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
- if (countryData.Any())
- {
- countryLabel = string.Join("、", countryData);
- }
- dic.Add("ReturnCodeAir", returnCodeLabel);
- dic.Add("VisitStartDate", "-");
- dic.Add("VisitEndDate", "-");
- dic.Add("Day", "-");
- dic.Add("VisitCountry", countryLabel);
- dic.Add("ClientUnit", "-");
- //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- //dic.Add("Names", Names);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- int accommodationStartIndex = 6, foodandotherStartIndex = 22;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0.00M)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- foodandotherStartIndex--;
- }
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- }
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- //总计
- decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
- //国际旅费
- string outsideAir = string.Empty;
- string allPriceAir = string.Empty;
- if (_EnterExitCosts.SumJJC == 1)
- {
- outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
- allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1)
- {
- outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
- allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumTDC == 1)
- {
- outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
- allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
- }
- dic.Add("InTravelPrice", $"({outsideAir})");
- dic.Add("FinalSumPrice", $"({allPriceAir})");
- //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
- //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
- //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- string returnCodeLabel = string.Empty;
- if (nationalTravelFeeData.Any())
- {
- List<string> list = new List<string>();
- foreach (var item in nationalTravelFeeData)
- {
- list.Add($"{item.Country}({item.City})");
- }
- list = list.Distinct().ToList();
- returnCodeLabel = string.Join("-", list).TrimEnd('-');
- }
- var countryLabel = string.Empty;
- var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
- if (countryData.Any())
- {
- countryLabel = string.Join("、", countryData);
- }
- dic.Add("ReturnCodeAir", returnCodeLabel);
- dic.Add("VisitStartDate", "-");
- dic.Add("VisitEndDate", "-");
- dic.Add("Day", "0");
- dic.Add("VisitCountry", countryLabel);
- dic.Add("ClientUnit", "-");
- designer.SetDataSource("ClientUnit", "-");
- designer.SetDataSource("VisitCountry", countryLabel);
- designer.SetDataSource("Group", "-");
- designer.SetDataSource("ClientUnitTitle", "-");
- designer.SetDataSource("Name", "-");
- designer.SetDataSource("VisitStartDate", "-" );
- designer.SetDataSource("Day", "0");
- designer.SetDataSource("ReturnCode", returnCodeLabel);
- designer.SetDataSource("ReturnCodeAir", "-");
- int startIndex = 10;
- const int startIndexcopy = 10;
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- DataTable dtdac1 = new DataTable();
- List<string> place = new List<string>();
- dtdac1.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
- });
- DataTable dtdac2 = new DataTable();
- dtdac2.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
- });
- dtdac1.TableName = "tb1";
- dtdac2.TableName = "tb2";
- decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
- foreach (var item in dac1)
- {
- item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac1.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["costRMB"] = rbmPrice;
- dtdac1.Rows.Add(row);
- place.Add(item.Place);
- }
- place = new List<string>();
- foreach (var item in dac2)
- {
- item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac2.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["cost"] = item.SubTotal;
- //row["costRMB"] = rbmPrice;
- dtdac2.Rows.Add(row);
- place.Add(item.Place);
- //dac2totalPrice += rbmPrice;
- }
- dac1totalPrice = dac1.Sum(it => it.SubTotal);
- dac2totalPrice = dac2.Sum(it => it.SubTotal);
- designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- designer.SetDataSource("dac2totalPrice", dac2totalPrice);
- designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
- designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
- string cell4Str1 = string.Empty;
- if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
- string cell4Str = $" 4.国际旅费:{cell4Str1}";
- string cellStr = $" 5.其他费用(";
- if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
- if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
- if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
- if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
- if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
- if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
- #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
- var otherPriceTotal = dac5.Sum(x => x.SubTotal);
- foreach (var otherInfo in dac5)
- {
- cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (cellStr.Length > 8)
- {
- cellStr = cellStr.Substring(0, cellStr.Length - 1);
- }
- cellStr += ")";
- decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
- decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
- decimal pxFee = dac4.Sum(it => it.Cost);
- decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
- string celllastStr1 = "";
- if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
- if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
- if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
- celllastStr1 += $",国际旅费 元";
- if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
- string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
- designer.SetDataSource("cell4Str", cell4Str);
- designer.SetDataSource("cellStr", cellStr);
- designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
- designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- designer.SetDataSource("celllastStr", celllastStr);
- Workbook wb = designer.Workbook;
- var sheet = wb.Worksheets[0];
- //绑定datatable数据集
- designer.SetDataSource(dtdac1);
- designer.SetDataSource(dtdac2);
- designer.Process();
- var rowStart = dtdac1.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
- startIndex += 1; //总计行
- rowStart = dtdac2.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
- wb.CalculateFormula(true);
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("GroupName", "-");
- dic.Add("ClientUnit", "-");
- string missionLeader = ""; //团负责人默认接团客户名单第一个人
- string missionLeaderJob = "";//负责人job
- int groupNumber = 0; //团人数
-
- dic.Add("MissionLeader", "-"); //团负责人
- dic.Add("MissionLeaderJob", "-"); //团负责人job
- dic.Add("GroupNumber", "0"); //团人数
- dic.Add("Day", "0");
- dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
- // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
-
- decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
- dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
- decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
- dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
- decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
- dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
- decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
- dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
- decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
- dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
- //其他费用
- decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
- dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
- //其他费用合计
- decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
- decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
- decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
- //公务舱合计
- //国际旅费
- string outsideJJ = "";
- string allPriceJJ = "";
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
- dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
- dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
- {
- string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
- dic.Add("AirFeeTotal", airFeeTotalStr);
- string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
- dic.Add("FeeTotal", feeTotalStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 2) //表格
- {
- return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
- }
- else if (dto.ExportType == 3)
- {
- return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
- }
- return Ok(JsonView(400, "只可导出明细表!", ""));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(400, ex.Message, ""));
- }
- }
- /// <summary>
- /// 获取三公费用标准city
- /// </summary>
- /// <param name="placeData"></param>
- /// <param name="nationalTravelFeeId"></param>
- /// <returns></returns>
- private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
- {
- string _city = string.Empty;
- if (!placeData.Any()) return _city;
- var data = placeData.Find(it => it.Id == nationalTravelFeeId);
- if (data == null) return _city;
- string country = data.Country;
- string city = data.City;
- if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
- else _city = city;
- return _city;
- }
-
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 一键清空
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
- {
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
- var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
-
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, "操作成功"));
- }
- return Ok(JsonView(false, "操作失败"));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
- {
- var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 三公其他费用草稿 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
- {
- var jw = JsonView(false, "删除失败!");
- var data = new Grp_DayOtherPriceDraft()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0)
- {
- jw.Code = 200;
- jw.Msg = "删除成功!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> EnterExitCostDraftImportDataInit()
- {
- var jw = JsonView(false);
- var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
- var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
- jw.Code = StatusCodes.Status200OK;
- jw.Msg = "操作成功!";
- jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
- {
- int userId = dto.UserId,
- portId = dto.PortType,
- groupId = dto.GroupId,
- draftId = dto.DraftId;
- _portTypeData.Add(1);
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
- if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
- _sqlSugar.BeginTran();
- try
- {
- var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
- if (draftDatas == null)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "草稿数据为空,不可导入!"));
- }
- //验证可覆盖已有数据 两边创建人需为同一人;
- int draftCreateUserId = draftDatas.CreateUserId,
- formalCreateUserId = 0;
- var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
- if (formalData != null)
- {
- formalCreateUserId = formalData.CreateUserId;
- if (draftCreateUserId != formalCreateUserId)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
- }
- }
- var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
- var userIds = permissionUsers.Select(x => x.Id).ToList();
- var permissions = new List<Grp_EnterExitCostPermission>();
- if (userIds.Any())
- {
- foreach (var userId1 in userIds)
- {
- permissions.Add(new Grp_EnterExitCostPermission() {
- GroupId = groupId,
- UserId = userId1,
- CreateUserId = dto.UserId
- });
- }
- }
- var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
- var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
- var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
- newExterData.DiId = groupId;
- newExterData.CreateUserId = userId;
- newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
- var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
- if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
- var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
- if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
- var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
- //数据如果存在执行删除
- if (enterExitCostInfo != null)
- {
- _sqlSugar.Updateable<Grp_EnterExitCost>()
- .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
- .Where(x => x.Id == enterExitCostInfo.Id)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_DayAndCost>()
- .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.DiId == groupId)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_DayOtherPrice>()
- .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.Diid == groupId)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
- .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.GroupId == groupId)
- .ExecuteCommand();
- }
- //执行insert
- var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
- if (insertId < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "草稿数据导入失败!"));
- }
- if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
- if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
- if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
- _sqlSugar.CommitTran();
- //执行操作之后
- //生成默认文件pdf并且通知人员
- var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- {
- DiId = groupId,
- ExportType = 1,
- SubTypeId = 1005
- }, "pdf");
- //发送通知
- string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
-
- string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
- string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false,ex.Message));
- }
- }
- #endregion
- #region 团组经理模块 出入境费用 移动端(Android/IOS)
- /// <summary>
- /// 获取币种基础数据(含逻辑处理)
- /// </summary>
- /// <returns></returns>
- private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
- {
- //默认币种显示
- var _currencyInfos = _currencyInit;
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
- rate1 *= 1.035M;
- item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- }
- }
- }
- return _currencyInfos;
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
- {
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
- var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
- List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
- var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
- List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
- //默认币种显示
- var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
- return Ok(JsonView(true, "查询成功!", new
- {
- WordTypeData = _WordTypeData,
- ExcelTypeData = _ExcelTypeData,
- CurrencyInit = _currencyInfos
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- int diId = 0;
- var status = int.TryParse(dto.GroupName, out diId);
- var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
- .Select(x => new
- {
- Id = x.Id,
- GroupName = x.TeamName
- })
- .OrderByDescending(x => x.Id)
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 66)
- .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
- .Select(x => new
- {
- id = x.Id,
- name = x.Name,
- remark = x.Remark,
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
- if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
- var groupOtherRateData = groupRateData.TeamRates;
- var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
- var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
- groupOtherRateData = groupOtherRateData
- .Select(x => new TeamRateDescAddCurrencyIdView {
- CurrencyId = x.CurrencyId,
- CurrencyName = x.CurrencyName,
- CurrencyCode = x.CurrencyCode,
- Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
- }).ToList();
- var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
- return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var tipsData = new List<int>() {1,2,3 };
- if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
- if (dto.TipsType == 1)
- {
- //默认币种显示
- var _currencyInfos = _currencyInit;
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- List<dynamic> reteInfos = new List<dynamic>();
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
- decimal rate1 = item.Rate;
- rate1 *= 1.03M;
- decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- reteInfos.Add(new
- {
- currCode = item.CurrencyCode,
- currName = item.CurrencyName,
- rate = rate2,
- lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
- });
- }
- }
- }
- return Ok(JsonView(true, "查询成功!", reteInfos));
- }
- else if (dto.TipsType == 2)
- {
- var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
- return Ok(JsonView(true, "查询成功!", visaData.Data));
- }
- else if (dto.TipsType == 3)
- {
- var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
- return Ok(JsonView(true, "查询成功!", airData.Data));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准-移动端 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
- .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
- .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
- .Where((ntf, sd, u) => ntf.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
- .Select((ntf, sd, u) => new
- {
- Id = ntf.Id,
- Area = $"{ntf.Country}-{ntf.City}",
- Currency = ntf.Currency,
- CurrencyCode = sd.Name,
- CurrencyName = sd.Remark,
- RoomCost = ntf.RoomCost,
- FoodCost = ntf.FoodCost,
- PublicCost = ntf.PublicCost,
- LastUpdateUserId = ntf.LastUpdateUserId,
- LastUpdateUserName = u.CnName,
- LastUpdateTime = ntf.LastUpdateTime,
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- sw.Stop();
- return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
-
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
- return Ok(data);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - ParentInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- var mobileInfo = new EnterExitCostMobileParentInfoView();
- mobileInfo.DiId = dto.DiId;
- mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
- if (eecInfo == null) return Ok(mobileInfo);
- //验证查看、操作权限
- // var isView = await _enterExitCostRep.vi
- mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
- var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToList();
- mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
- mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
- mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
- mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
- mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
- mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
- mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
- mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
- mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
- {
- SubId = dop.Id,
- DiId = dop.Diid,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Remark,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
- return Ok(mobileInfo);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - SubInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
- if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
- var subType = dto.SubType;
-
- if (subType == 1) //1:境内费用
- {
- var oneData = new ChoiceOneMobileSubInfoView()
- {
- Id = eecInfo.Id,
- ChoiceOne = eecInfo.ChoiceOne,
- ChoiceOneTotalCost = eecInfo.InsidePay,
- Visa = eecInfo.Visa,
- VisaRemark = eecInfo.VisaRemark,
- YiMiao = eecInfo.YiMiao,
- HeSuan = eecInfo.HeSuan,
- Service = eecInfo.Service,
- Ticket = eecInfo.Ticket,
- Safe = eecInfo.Safe,
- FirstItemRemark = eecInfo.FirstItemRemark
- };
- return Ok(JsonView(oneData));
- }
- else if (subType == 2) //2:国际旅费
- {
- var twoData = new ChoiceTwoMobileSubInfoView() {
- Id = eecInfo.Id,
- ChoiceTwoJJ = eecInfo.SumJJC,
- OutsideJJPay = eecInfo.OutsideJJPay,
- ChoiceTwoGW = eecInfo.SumGWC,
- OutsideGWPay = eecInfo.OutsideGWPay,
- ChoiceTwoTD = eecInfo.SumTDC,
- OutsideTDPay = eecInfo.OutsideTDPay,
- AirJJ = eecInfo.AirJJ,
- AirGW = eecInfo.AirGW,
- AirTD = eecInfo.AirTD,
- CityTranffic = eecInfo.CityTranffic,
- TwoItemRemark = eecInfo.TwoItemRemark
- };
- return Ok(JsonView(twoData));
- }
- else if (subType == 3) //3:住宿费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View() {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceThree,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 4) //4:伙食费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFour,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 5) //5:公杂费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFive,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 6) //6:培训费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceSix,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 7) //7:其他
- {
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
- {
- SubId = dop.Id,
- DiId = dop.Diid,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Name,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- var data = new ChoiceSevenMobileSubInfoView()
- {
- ParentId = eecInfo.Id,
- OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
- OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
- Details = otherData
- };
- return Ok(JsonView(data));
- }
- return Ok(JsonView(false));
- }
- #region op
- /// <summary>
- /// 移动端更新费用消息通知
- /// </summary>
- /// <param name="diid"></param>
- /// <param name="id"></param>
- /// <param name="currUserId"></param>
- private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
- {
- try
- {
- ////生成默认文件pdf并且通知人员
- //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- //{
- // DiId = diid,
- // ExportType = 1,
- // SubTypeId = 1005
- //}, "pdf");
- ////发送通知
- //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
- //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
- //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
- ////汇率信息记录
- //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
- }
- catch (Exception ex)
- {
- //记录日志
- throw;
- }
- }
- /// <summary>
- /// 验证出入境费用数据是否存在
- /// 不存在添加
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- /// <exception cref="CustomException"></exception>
- private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
- {
- var parentId = 0;
- var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
- if (info != null) parentId = info.Id;
- else
- {
- var currencys = await EnterExitCostMobileGetCurrencyInit();
- int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
- if (addId < 1) throw new CustomException("出入境费用添加失败!");
- parentId = addId;
- }
- return parentId;
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
- var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
- int id = dto.Id;
- if (id <= 0) //add
- {
- var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- #region 汇率变更时更改币种相关费用
- var opDayCosts = new List<Grp_DayAndCost>();
- var opDayOtherCosts = new List<Grp_DayOtherPrice>();
- var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
- var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
- .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
- .Select((dac, sd) => new {
- dac.Id,
- dac.DiId,
- CurrencyCode = sd.Name,
- dac.Cost
- })
- .ToList();
- var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
- .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .Select((dop, sd) => new {
- dop.Id,
- dop.Diid,
- CurrencyCode = sd.Name,
- dop.Cost
- })
- .ToList();
- if (dayCosts.Count > 0)
- {
- var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayCosts.Add(new Grp_DayAndCost() {
- Id = dcSub.Id,
- DiId = dcSub.DiId,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- if (dayOtherCosts.Count > 0)
- {
- var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayOtherCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayOtherCosts.Add(new Grp_DayOtherPrice()
- {
- Id = dcSub.Id,
- Diid = dcSub.Diid,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayOtherCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- #endregion
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
- int id = dto.Id;
- if (id <= 0) //add
- {
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(checkboxInfo)
- .UpdateColumns(x => new {
- x.ChoiceOne,
- x.ChoiceTwo,
- x.SumJJC,
- x.SumGWC,
- x.SumTDC,
- x.ChoiceThree,
- x.ChoiceFour,
- x.ChoiceFive,
- x.ChoiceSix,
- x.OtherExpenses_Checked
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
- {
- int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
- var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
- var checkboxInfo = new Grp_EnterExitCost() {
- Id = id,
- DiId = diId,
- CreateUserId = currUserId
- };
- if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
- else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
- else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
- else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
- else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
- if (id <= 0) //add
- {
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
- .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
- .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
- .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
- .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
- .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var info = _mapper.Map<Grp_EnterExitCost>(dto);
- info.FirstItemRemark = dto.FirstItemRemark;
- info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
- int id = dto.Id;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new {
- x.ChoiceOne,
- x.InsidePay,
- x.VisaRemark,
- x.Visa,
- x.Service,
- x.Safe,
- x.Ticket,
- x.HeSuan,
- x.YiMiao,
- x.FirstItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var info = _mapper.Map<Grp_EnterExitCost>(dto);
- info.OutsideJJPay = dto.OutsideJJPay;
- info.OutsideGWPay = dto.OutsideGWPay;
- info.OutsideTDPay = dto.OutsideTDPay;
- info.AirJJ = dto.AirJJ;
- info.AirGW = dto.AirGW;
- info.AirTD = dto.AirTD;
- info.CityTranffic = dto.CityTranffic;
- info.TwoItemRemark = dto.TwoItemRemark;
- info.SumJJC = dto.ChoiceTwoJJ;
- info.SumGWC = dto.ChoiceTwoGW;
- info.SumTDC = dto.ChoiceTwoTD;
- int id = dto.Id;
- decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (addId <= 0) return Ok(JsonView(false));
- id = addId;
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new {
- x.SumJJC,
- x.OutsideJJPay,
- x.SumGWC,
- x.OutsideGWPay,
- x.SumTDC,
- x.OutsideTDPay,
- x.AirJJ,
- x.AirGW,
- x.AirTD,
- x.CityTranffic,
- x.TwoItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd <1) return Ok(JsonView(false));
- }
- jjcItemTotal = info.AirJJ + info.CityTranffic;
- gwcItemTotal = info.AirGW + info.CityTranffic;
- tdcItemTotal = info.AirTD + info.CityTranffic;
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new
- {
- parentId = id,
- choiceTwoJJ = dto.ChoiceTwoJJ,
- jjcItemTotal = jjcItemTotal,
- choiceTwoGW = dto.ChoiceTwoGW,
- gwcItemTotal = gwcItemTotal,
- choiceTwoTD = dto.ChoiceTwoTD,
- tdcItemTotal = tdcItemTotal
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
- var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
- var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayAndCost
- {
- Id = x.Id,
- DiId = dto.DiId,
- Type = dto.FeeType,
- Days = x.Days,
- NationalTravelFeeId = x.NationalTravelFeeId,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId
- })
- .ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
-
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
- //消息通知
- var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
- {
- var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
- int subId = dto.SubId, feeType = dto.FeeType;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
-
- var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
- subInfo.Id = subId;
- subInfo.DiId = dto.DiId;
- if (feeType == 3) subInfo.Type = 1;
- else if (feeType == 4) subInfo.Type = 2;
- else if (feeType == 5) subInfo.Type = 3;
- else if (feeType == 6) subInfo.Type = 4;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- //子表op
- if (subId < 1)
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else
- {
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
-
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
- await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayOtherPrice()
- {
- Id = x.Id,
- Diid = dto.DiId,
- SetDataId = x.SetDataId,
- Index = x.Index,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId,
- Remark = x.Remark
- }).ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
- //消息通知
- var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
- {
- int subId = dto.SubId;
- int diId = dto.Diid;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
- subInfo.Id = subId;
- subInfo.Diid = dto.Diid;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- #region 子表op
- if (subId < 1)//add
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else //upd
- {
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
- #endregion
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
- //消息通知
- await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 其他费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
- {
- var data = new Grp_DayOtherPrice()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0) return Ok(JsonView(true,"删除成功!"));
- return Ok(JsonView(false,"删除失败!"));
- }
- #endregion
- #endregion
- #region 签证费用录入
- /// <summary>
- /// 根据diid查询签证费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
- {
- Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据签证费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
- {
- Result groupData = await _visaPriceRep.PostVisaById(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> DelVisaPrice(DelBaseDto dto)
- {
- _sqlSugar.BeginTran();
- var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
- .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
- .SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .ExecuteCommand();
- if (resSub < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 签证费用录入下拉框初始化
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaPriceAddSelect()
- {
- //支付方式
- List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
- //币种
- List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
- //乘客类型
- List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
- //卡类型
- List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
- //代办费类型
- var agencyFeeTypeData = new List<dynamic>() {
- new { id = 0 , Text = "未选择" },
- new { id = 1 , Text = "小公务" },
- new { id = 2 , Text = "大公务" },
- };
- //签证费用标准国家Data
- var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
- var data = new
- {
- Payment = _Payment,
- CurrencyList = _CurrencyList,
- PassengerType = _PassengerType,
- BankCard = _BankCard,
- AgencyFeeType = agencyFeeTypeData,
- CountryFeeData = visaCountryFeeData
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- /// <summary>
- /// 签证费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
- {
- Result groupData = await _visaPriceRep.OpVisaPrice(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- #endregion
- #region 签证提成录入
- /// <summary>
- /// 签证提成录入
- /// 基础数据
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionInit()
- {
- return Ok(await _visaCommissionRep.Init());
- }
- /// <summary>
- /// 签证提成录入
- /// Item
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
- {
- var validator = new VisaCommissionItemDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Item(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Save
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
- {
- //参数验证
- if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
- foreach (var item in _dto.Items)
- {
- if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
- if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
- if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
- //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
- }
- return Ok(await _visaCommissionRep.Save(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Create
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
- {
- var validator = new VisaCommissionCreateDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Create(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Put(编辑)
- /// </summary>
- /// <param name="id"></param>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPut]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
- {
- if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
- var validator = new VisaCommissionCreateDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Edit(id, _dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Del
- /// </summary>
- /// <param name="id"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
- {
- if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
- if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
- return Ok(await _visaCommissionRep.Del(id, currUserId));
- }
- #endregion
- #region op费用录入
- /// <summary>
- /// 根据diid查询op费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
- {
- Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据op费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
- Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
- var data = new
- {
- CarTouristGuideGround = _groupData,
- CreditCardPayment = _creditCardPayment
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// op费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
- {
- try
- {
- _sqlSugar.BeginTran();
- var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- #region 删除超支相关数据
- //删除导入的超支数据
- var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
- var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "程序错误!" + ex.Message));
- }
- }
- /// <summary>
- /// op费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
- {
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(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 IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(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, ex.Message));
- }
- }
- /// <summary>
- /// 根据op费用Id查询详细数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(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, ex.Message));
- }
- }
- /// <summary>
- /// OP费用录入填写详情
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
- {
- try
- {
- #region 参数校验
- if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
- var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
- if (di == null) return Ok(JsonView(false, "团组错误!"));
- #endregion
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 获取三公详细所有城市
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public IActionResult OpCarCityResult()
- {
- var jw = JsonView(false);
- var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
- {
- x.Id,
- x.Country,
- x.City,
- }).ToList();
- if (data.Count > 0)
- {
- jw = JsonView(true, "获取成功!", data);
- }
- else
- {
- jw.Msg = "城市数据为空!";
- jw.Data = new string[0];
- }
- return Ok(jw);
- }
- /// <summary>
- /// 导出地接费用明细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
- {
- var jw = JsonView(false);
- if (dto.Diid < 1)
- {
- jw.Msg = "请输入正确的diid!";
- return Ok(jw);
- }
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "未找到团组信息!";
- return Ok(jw);
- }
- var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
- if (localGuideArr.Count == 0)
- {
- jw.Msg = "该团组暂无地接信息!";
- return Ok(jw);
- }
- var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
- var overspendSoure = new Dictionary<int, int>
- {
- { 91, 982 }, //车
- { 92 , 1059} ,//导游
- { 994 , 1073}, //翻译
- { 988 , 1074 }, //早餐
- { 93 , 1075 }, //午餐
- { 989 , 1076 }, //晚餐
- };
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- foreach (var groupArr in localGroup)
- {
- var keyValue = groupArr.Key;
- if (int.TryParse(keyValue, out int cityid))
- {
- var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
- keyValue = city == null ? keyValue : city.Country + "-" + city.City;
- }
- List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
- foreach (var item in groupArr)
- {
- var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
- ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
- new Grp_CarTouristGuideGroundReservationsContentExtend
- {
- Count = a.Count,
- CreateTime = a.CreateTime,
- CreateUserId = a.CreateUserId,
- CTGGRId = a.CTGGRId,
- Currency = a.Currency,
- DatePrice = a.DatePrice,
- DeleteTime = a.DeleteTime,
- DeleteUserId = a.DeleteUserId,
- DiId = a.DiId,
- Id = a.Id,
- IsDel = a.IsDel,
- Price = a.Price,
- PriceContent = a.PriceContent,
- Remark = a.Remark,
- SId = a.SId,
- SidName = b.Name,
- Units = a.Units,
- }
- ).ToList();
- if (content.Count > 0)
- {
- contentArr.Add(content);
- }
- }
- //open excel
- //set excel
- //save excel
- try
- {
- string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
- IWorkbook workbook;
- if (Path.GetExtension(filePath).ToLower() == ".xls")
- {
- workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
- }
- else
- {
- workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
- }
- ISheet sheet = workbook.GetSheetAt(0);
- var rowStartIndex = 2;
- var clounmCount = 10;
- var initStyleRow = sheet.GetRow(2);
- var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
- //var overspendArrDetail =
- var existsId = new List<CarCompare>();
- var lastElem = arr.Last();
- var thisSid = -1;
- var curr = arr.Count > 0 ? arr[0].Currency : -1;
- var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
- {
- Name = "未知币种!",
- Remark = "未知币种!",
- };
- sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
- Action cloneRowFn = () =>
- {
- rowStartIndex++;
- var cloneRow = sheet.CreateRow(rowStartIndex);
- // 复制样式
- for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
- {
- ICell sourceCell = initStyleRow.GetCell(i);
- ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
- // 确保单元格存在样式
- if (sourceCell.CellStyle != null)
- {
- targetCell.CellStyle = sourceCell.CellStyle;
- }
- }
- };
- var mergeRow = () =>
- {
- for (int i = 2; i < sheet.LastRowNum; i++)
- {
- var row = sheet.GetRow(i);
- var cellFirst = row.GetCell(0);
- var thisIndex = i + 1;
- while (thisIndex < sheet.LastRowNum)
- {
- var nextRow = sheet.GetRow(thisIndex);
- var nextCellFirst = nextRow.GetCell(0);
- if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
- {
- thisIndex++;
- }
- else
- {
- break;
- }
- }
- thisIndex--;
- if (thisIndex != i)
- {
- //合并row
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- i, // 起始行索引(0-based)
- thisIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 0 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- i = thisIndex;
- }
- }
- };
- var chaoshiNumber = 0;
- var totalNumber = 0.00M;
- string lastStr = "";
- var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
- .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
- {
- b.IsAuditGM,
- x.Id,
- x.Area,
- b.PayPercentage,
- b.PayMoney,
- }).ToList();
- string yesPayment = "", noPayment = "";
- foreach (var item in queryCarArrByCityAndDiid)
- {
- if (item.IsAuditGM == 1)
- {
- yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
- }
- else
- {
- noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
- }
- }
- lastStr = yesPayment + noPayment;
- foreach (var item in arr)
- {
- if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
- {
- if (thisSid != item.SId)
- {
- if (thisSid == -1)
- {
- thisSid = item.SId;
- }
- else
- {
- //合并小计行
- //创建合并区域的实例
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 3 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- var CellStyle = workbook.CreateCellStyle();
- CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
- CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
- for (int i = 0; i <= clounmCount; i++)
- {
- if (i > 6)
- {
- var CellStyle1 = workbook.CreateCellStyle();
- CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- CellStyle1.SetFont(Font);
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
- }
- else
- {
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
- }
- }
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
- sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
- //超时合计
- sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
- //超时数
- sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
- //超时合计费用
- sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
- thisSid = item.SId;
- cloneRowFn();
- chaoshiNumber = 0;
- totalNumber = 0;
- }
- }
- IRow row = sheet.GetRow(rowStartIndex);
- var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
- List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
- if (isOpenOverspendSoure)
- {
- overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
- totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
- }
- for (int i = 0; i <= clounmCount; i++)
- {
- var cell = row.GetCell(i);
- var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
- if (cell == null)
- {
- cell = row.CreateCell(i);
- }
- var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
- fontRed.CloneStyleFrom(cell.CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- fontRed.SetFont(Font);
- byte[] rgb = new byte[3] { 255, 242, 204 };
- var BackgroundColor255_242_204 = workbook.CreateCellStyle();
- BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
- byte[] rgb1 = new byte[3] { 189, 215, 238 };
- if (workbook is XSSFWorkbook)
- {
- BackgroundColor255_242_204.FillForegroundColor = 0;
- ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
- BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
- }
- else
- {
- BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
- }
- if (i == 1 || i > 6)
- {
- if (i > 6)
- {
- fontRed.FillForegroundColor = 0;
- ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
- fontRed.FillPattern = FillPattern.SolidForeground;
- }
- cell.CellStyle = fontRed;
- }
- if (i > 2 && i < 7)
- {
- cell.CellStyle = BackgroundColor255_242_204;
- }
- cell.SetCellValue(setCellValue); //写入单元格
- }
- if (overspendSoure.ContainsKey(thisSid))
- {
- var overspendId = overspendSoure[thisSid];
- whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- }
- cloneRowFn();
- existsId.Add(new CarCompare
- {
- DataPrice = item.DatePrice.ObjToDate(),
- Sid = item.SId
- });
- }
- if (item.Equals(lastElem))
- {
- //合并小计行
- //创建合并区域的实例
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 3 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- var CellStyle = workbook.CreateCellStyle();
- CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
- CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
- for (int i = 0; i <= clounmCount; i++)
- {
- if (i > 6)
- {
- var CellStyle1 = workbook.CreateCellStyle();
- CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- CellStyle1.SetFont(Font);
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
- }
- else
- {
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
- }
- }
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
- sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
- //超时合计
- sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
- //超时数
- sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
- //超时合计费用
- sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
- cloneRowFn();
- // 创建合并区域的实例
- cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
- );
- // 添加合并区域
- sheet.AddMergedRegion(cellRangeAddress);
- sheet.GetRow(rowStartIndex).Height = 30 * 30;
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
- }
- }
- mergeRow();
- // 保存修改后的Excel文件到新文件
- //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
- // new FileStream(newFilePath, FileMode.CreateNew)
- using (var stream = new MemoryStream())
- {
- workbook.Write(stream, true);
- stream.Flush();
- stream.Seek(0, SeekOrigin.Begin);
- MemoryStream memoryStream = new MemoryStream();
- stream.CopyTo(memoryStream);
- memoryStream.Seek(0, SeekOrigin.Begin);
- Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
- }
- workbook.Close();
- workbook.Dispose();
- }
- catch (Exception ex)
- {
- jw.Msg = "出现异常!" + ex.Message;
- return Ok(jw);
- }
- }
- if (Zips.Count > 0)
- {
- IOOperatorHelper io = new IOOperatorHelper();
- var byts = io.ConvertZipStream(Zips);
- io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
- //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
- {
- string outStr = string.Empty;
- switch (i)
- {
- case 0:
- outStr = arr[0].SidName;
- break;
- case 1:
- outStr = arr[0].DataPriceStr;
- break;
- case 2:
- outStr = string.Join("-", arr.Select(x => x.PriceContent));
- break;
- case 4:
- outStr = arr.Sum(x => x.Subtotal).ToString("F2");
- break;
- case 7:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
- var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
- outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
- }
- break;
- case 8:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
- }
- break;
- case 9:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
- }
- break;
- case 10:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
- }
- break;
- }
- return outStr;
- }
- #region OP行程单
- /// <summary>
- /// OP行程单初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult InitOpTravel(InitOpTravelDto dto)
- {
- var jw = JsonView(false);
- var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
- var group = groupList.First();
- var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
- if (group == null)
- {
- jw.Msg = "暂无团组!";
- return Ok(jw);
- }
- group = groupList.Find(x => x.Id == diid);
- if (group == null)
- {
- jw.Msg = "请输入正确的团组ID!";
- return Ok(jw);
- }
- string city = string.Empty;
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
- if (blackCode.Count > 0)
- {
- var black = blackCode.First();
- black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
- var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
- if (blackSp.Length > 0)
- {
- try
- {
- var cityArrCode = new List<string>(20);
- foreach (var item in blackSp)
- {
- var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
- var IndexSelect = itemSp[2];
- var cityArrCodeLength = cityArrCode.Count - 1;
- var startCity = IndexSelect.Substring(0, 3);
- if (cityArrCodeLength > 0)
- {
- var arrEndCity = cityArrCode[cityArrCodeLength];
- if (arrEndCity != startCity)
- {
- cityArrCode.Add(startCity.ToUpper());
- }
- }
- else
- {
- cityArrCode.Add(startCity.ToUpper());
- }
- var endCity = IndexSelect.Substring(3, 3);
- cityArrCode.Add(endCity.ToUpper());
- }
- var cityThree = string.Empty;
- cityArrCode.ForEach(x => cityThree += "'" + x + "',");
- cityThree = cityThree.TrimEnd(',');
- if (string.IsNullOrWhiteSpace(cityThree))
- {
- throw new
- Exception("error");
- }
- string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
- var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
- foreach (var item in cityArrCode)
- {
- var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
- if (find != null)
- {
- city += find.City + "/";
- }
- else
- {
- city += item + "三字码未收入/";
- }
- }
- city = city.TrimEnd('/');
- }
- catch (Exception e)
- {
- city = "黑屏代码格式不正确!";
- }
- }
- }
- else
- {
- city = "未录入黑屏代码";
- }
- var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
- {
- Date = x.Date,
- Days = x.Days,
- Diffgroup = x.Diffgroup,
- Diid = x.Diid,
- Traffic_First = x.Traffic_First,
- Traffic_Second = x.Traffic_Second,
- Trip = x.Trip,
- WeekDay = x.WeekDay,
- Id = x.Id
- }).ToList();
- jw.Data = new
- {
- groupList = groupList.Select(x => new
- {
- x.Id,
- x.TeamName,
- x.TourCode
- }).ToList(),
- groupInfo = new
- {
- group.VisitDays,
- group.TourCode,
- group.VisitPNumber,
- group.TeamName,
- city
- },
- OpTravelList
- };
- jw.Code = 200;
- jw.Msg = "操作成功!";
- return Ok(jw);
- }
- /// <summary>
- /// 删除团组行程单
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DelTravel(DelOpTravelDto dto)
- {
- var jw = JsonView(false);
- if (dto.UserId <= 0 || dto.Diid <= 0)
- {
- jw.Msg = "请输入正确的参数!";
- return Ok(jw);
- }
- var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
- .SetColumns(x => new Grp_TravelList
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
- DeleteUserId = dto.UserId,
- IsDel = 1,
- }).ExecuteCommand();
- jw = JsonView(true);
- return Ok(jw);
- }
- /// <summary>
- /// 行程单保存
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult TravelSave(TravelSaveDto dto)
- {
- var jw = JsonView(false);
- if (dto.Arr.Count > 0)
- {
- try
- {
- var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
- .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
- .ToList();
- _sqlSugar.BeginTran();
- foreach (var item in dto.Arr)
- {
- if (item.Id == 0)
- {
- throw new Exception("请传入正确的Id");
- }
- //比较上一次的差异
- var findTravel = travelList_DB.Find(x => x.Id == item.Id);
- if (findTravel != null)
- {
- item.Trip = item.Trip.Replace("[++]", string.Empty);
- findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
- item.Trip = CheckStr(findTravel.Trip,item.Trip);
- }
- _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
- .SetColumns(x => new Grp_TravelList
- {
- Trip = item.Trip
- }).ExecuteCommand();
- }
- _sqlSugar.CommitTran();
- jw = JsonView(true);
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- jw.Msg = "程序异常!" + ex.Message;
- }
- }
- else
- {
- jw.Msg = "请传入正确的参数!";
- }
- return Ok(jw);
- }
- private string CheckStr(string original, string changed)
- {
- // 创建diff_match_patch对象
- var dmp = new diff_match_patch();
- // 计算差异
- List<Diff> diffs = dmp.diff_main(original, changed);
- // 清理和合并差异
- dmp.diff_cleanupSemantic(diffs);
- // 使用StringBuilder构建最终的字符串
- StringBuilder finalString = new StringBuilder();
- // 输出差异结果,并构建变动后的字符串
- foreach (Diff diff in diffs)
- {
- switch (diff.operation)
- {
- case Operation.EQUAL:
- // 相等的部分,直接添加到最终字符串
- finalString.Append(diff.text);
- break;
- case Operation.INSERT:
- // 插入的部分,添加标记并添加到最终字符串
- finalString.Append("[++]" + diff.text + "[++]");
- break;
- case Operation.DELETE:
- // 删除的部分,不添加到最终字符串
- //finalString.Append("[++]" + diff.text + "[++]");
- break;
- }
- }
- // 输出变动后的字符串
- return finalString.ToString();
- }
- private class tagContent
- {
- public DateTime Date { get; set; }
- public string StartTag { get; set; }
- public string EndTag { get; set; }
- public string Content { get; set; }
- public static int tagLength { get { return 3; } }
- public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
- public string QueryTag { get { return this.StartTag + this.EndTag; } }
- public bool IsFinally { get; set; }
- }
- private List<string> ExtractContentBetweenTags(string input, string tag)
- {
- List<string> results = new List<string>();
- // 构造正则表达式,匹配形如 [++]内容[++] 的部分
- string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
- // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
- MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
- string[] strValueArr = new string[1];
- foreach (Match match in matches)
- {
- var strValue = match.Groups[1].Value;
- strValueArr = Regex.Split(strValue, @"\r\n|\n");
- }
- results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
- return results;
- }
- /// <summary>
- /// 导出行程单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportTravel(ExportTravelDto dto)
- {
- var jw = JsonView(false);
- jw.Data = "";
- int diid = 0;
- var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
- if (Find == null)
- {
- jw.Msg = "请选择正确的团组!";
- return Ok(jw);
- }
- else
- {
- diid = Find.Id;
- }
- //数据源
- List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
- DataTable dtBlack = null;
- try
- {
- dtBlack = GeneralMethod.GetTableByBlackCode(diid);
- }
- catch (Exception)
- {
- jw.Msg = "机票黑屏代码有误!";
- return Ok(jw);
- }
- string CityStr = string.Empty;
- if (dtBlack.Rows.Count == 0)
- {
- jw.Msg = "机票黑屏代码有误!";
- return Ok(jw);
- }
- else
- {
- foreach (DataRow row in dtBlack.Rows)
- {
- if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- {
- jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
- return Ok(jw);
- }
- }
- CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
- _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
- }
- // 指定的文字
- var targetTextDic = new Dictionary<string, List<string>>();
- //创建数据源Table
- DataTable dtSource = new DataTable();
- dtSource.Columns.Add("Days", typeof(string));
- dtSource.Columns.Add("Date", typeof(string));
- dtSource.Columns.Add("Week", typeof(string));
- dtSource.Columns.Add("Traffic", typeof(string));
- dtSource.Columns.Add("Trip", typeof(string));
- //获取数据,放到datatable
- foreach (var item in _travelList)
- {
- targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
- item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
- .Replace(tagContent.TagFormat.Item2, string.Empty)
- .Replace("[++]", string.Empty);
- DataRow dr = dtSource.NewRow();
- dr["Days"] = item.Days;
- dr["Date"] = item.Date;
- dr["Week"] = item.WeekDay;
- dr["Traffic"] = item.Traffic_First
- + "\r\n"
- + item.Traffic_Second;
- dr["Trip"] = item.Trip;
- dtSource.Rows.Add(dr);
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
- dic.Add("City", CityStr);
- dic.Add("Days", Find.VisitDays.ToString());
- dic.Add("DeleCode", Find.TourCode);
- dic.Add("Pnum", Find.VisitPNumber.ToString());
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
- //载入模板
- Document doc = null;
- DocumentBuilder builder = null;
- try
- {
- //载入模板
- doc = new Document(tempPath);
- builder = new DocumentBuilder(doc);
- }
- catch (Exception)
- {
- jw.Msg = "模板位置不存在!";
- return Ok(jw);
- }
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- try
- {
- //循环赋值
- for (int i = 0; i < dtSource.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dtSource.Rows[i]["Days"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dtSource.Rows[i]["Traffic"].ToString());
- var trip = dtSource.Rows[i]["Trip"].ToString();
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(trip);
- var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
- var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
- // 获取特定索引的段落
- Paragraph paragraph = (Paragraph)paragraphs[0];
- Run run = paragraph.Runs[0];
- Aspose.Words.Font font = run.Font;
- font.Name = "黑体";
- //设置双休红色
- cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
- paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
- paragraph = (Paragraph)paragraphs[1];
- if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
- {
- run = paragraph.Runs[0];
- font = run.Font;
- font.Color = Color.Red;
- }
- }
- }
- catch (Exception ex)
- {
- }
- //删除多余行
- while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
- {
- tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
- }
- var targetTextList = new List<string>();
- // 遍历文档中的表格
- foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
- {
- foreach (Aspose.Words.Tables.Row row in table.Rows)
- {
- var cellIndex = 0;
- foreach (Cell cell in row.Cells)
- {
- if (cellIndex == 1 && row.Cells.Count == 4)
- {
- foreach (var target in targetTextDic.Keys)
- {
- if (cell.GetText().Contains(target))
- {
- targetTextList = targetTextDic[target];
- break;
- }
- }
- }
- // 遍历单元格中的所有段落
- foreach (Paragraph paragraph in cell.Paragraphs)
- {
- // 使用临时列表存储原始 Runs,避免修改时影响遍历
- List<Run> runs = new List<Run>();
- foreach (Run run in paragraph.Runs)
- {
- runs.Add(run);
- }
- foreach (Run run in runs)
- {
- foreach (var targetText in targetTextList)
- {
- // 检查文字是否包含指定文字
- if (run.Text.Contains(targetText))
- {
- // 将包含的部分设置为红色
- HighlightText(run, targetText, Color.Red);
- }
- }
- }
- }
- cellIndex++;
- }
- }
- }
- string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
- if (!Directory.Exists(savePath))
- {
- try
- {
- Directory.CreateDirectory(savePath);
- }
- catch
- {
- }
- }
- string path = savePath + Find.TeamName + "出访日程";
- string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
- try
- {
- Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
- string postfix = ".docx";
- if (dto.IsPDF == 1)
- {
- saveFormat = Aspose.Words.SaveFormat.Pdf;
- postfix = ".pdf";
- }
- doc.Save(path + postfix, saveFormat);
- jw = JsonView(true, "导出成功", ftpPath + postfix);
- }
- catch (Exception)
- {
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 根据大写数字返回小写数字或根据小写数字返回大写数字
- /// </summary>
- /// <param name="num"></param>
- /// <returns></returns>
- string GetNum(string num)
- {
- string str = "";
- switch (num)
- {
- case "1":
- str = "一";
- break;
- case "2":
- str = "二";
- break;
- case "3":
- str = "三";
- break;
- case "4":
- str = "四";
- break;
- case "5":
- str = "五";
- break;
- case "6":
- str = "六";
- break;
- case "7":
- str = "七";
- break;
- case "8":
- str = "八";
- break;
- case "9":
- str = "九";
- break;
- case "10":
- str = "十";
- break;
- case "11":
- str = "十一";
- break;
- case "12":
- str = "十二";
- break;
- case "一":
- str = "1";
- break;
- case "二":
- str = "2";
- break;
- case "三":
- str = "3";
- break;
- case "四":
- str = "4";
- break;
- case "五":
- str = "5";
- break;
- case "六":
- str = "6";
- break;
- case "七":
- str = "7";
- break;
- case "八":
- str = "8";
- break;
- case "九":
- str = "9";
- break;
- case "十":
- str = "10";
- break;
- case "十一":
- str = "11";
- break;
- case "十二":
- str = "12";
- break;
- }
- return str;
- }
- // 高亮包含指定文字的部分
- void HighlightText(Run run, string targetText, Color color)
- {
- string text = run.Text;
- int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
- if (startIndex >= 0)
- {
- Paragraph parentParagraph = (Paragraph)run.ParentNode;
- // 前部分
- if (startIndex > 0)
- {
- Run beforeRun = (Run)run.Clone(true);
- beforeRun.Text = text.Substring(0, startIndex);
- parentParagraph.InsertBefore(beforeRun, run);
- }
- // 匹配部分
- Run matchRun = (Run)run.Clone(true);
- matchRun.Text = text.Substring(startIndex, targetText.Length);
- matchRun.Font.Color = color;
- parentParagraph.InsertBefore(matchRun, run);
- // 后部分
- if (startIndex + targetText.Length < text.Length)
- {
- Run afterRun = (Run)run.Clone(true);
- afterRun.Text = text.Substring(startIndex + targetText.Length);
- parentParagraph.InsertBefore(afterRun, run);
- }
- // 删除原始Run
- run.Remove();
- }
- }
- #endregion
- #endregion
- #region 团组成本
- /// <summary>
- /// 团组成本数据初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
- {
- var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
- Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
- WHEN COUNT(*) >= 0 THEN 'True'
- ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
- Where TeamName != '' And IsDel = 0 Order By a.Id Desc
- ").ToList(); //团组列表
- int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
- var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
- List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
- var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
- if (groupinfoValue != null)
- {
- var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
- var spArr = new string[1] { countryArr };
- if (countryArr.Contains("|"))
- {
- spArr = countryArr.Split("|");
- }
- else if (countryArr.Contains("、"))
- {
- spArr = countryArr.Split("、");
- }
- foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
- {
- var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
- if (dbQueryCountry != null)
- {
- visaCountryInfoArr.Add(dbQueryCountry);
- }
- }
- }
- var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
- var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
- var create = _GroupCostRepository.
- CreateGroupCostByBlackCode(dto.Diid);
- if (groupCost.Count == 0 && create.Code == 0)
- {
- groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
- }
- var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
- var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
- groupCostMap = groupCostMap.Select(x =>
- {
- if (DateTime.TryParse(x.Date, out DateTime dataForamt))
- {
- x.Date = dataForamt.ToString("yyyy-MM-dd");
- }
- return x;
- }).ToList();
- //GroupCostParameter.Add(new
- // Grp_GroupCostParameter());
- var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
- bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
- return Ok(JsonView(new
- {
- groupList,
- groupInfo,
- groupChecks,
- groupCost = groupCostMap,
- hotelNumber,
- GroupCostParameter = GroupCostParameterMap,
- visaCountryInfoArr = visaCountryInfoArr.Select(x => new
- {
- x.VisaCountry,
- x.VisaPrice,
- x.Id,
- }).ToList(),
- baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
- blackCodeIsTrue = create.Code == 0 ? true : false,
- hotelIsTrue = hotelIsTrue,
- }));
- }
- /// <summary>
- /// 团组成本信息保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
- {
- if (dto.Diid <= 0 || dto.Userid <= 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- bool isTrue = false;
- #region 复制团组成本
- //if (dto.Diid == 2581)
- //{
- // dto.Diid = 2599;
- // dto.CheckBoxs.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.GroupCosts.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.CostTypeHotelNumbers.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.GroupCostParameters.ForEach(x =>
- // {
- // x.DiId = 2599;
- // });
- //}
- #endregion
- var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
- Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
- var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
- Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
- var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
- var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
- try
- {
- _sqlSugar.BeginTran();
- isTrue = await _GroupCostRepository.
- SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
- isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
- isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
- isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!", isTrue);
- }
- catch (Exception)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 司兼导数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarGuides(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 导游数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetGuidesInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
- // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
- // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
- var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 成本车数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 景点数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
- {
- var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
- return Ok(JsonView(true, "获取成功!", Data));
- }
- /// <summary>
- /// 成本通知
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
- {
- if (dto.Diid < 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
- if (GroupCostParameter != null)
- {
- int IsShare = 0;
- if (GroupCostParameter.IsShare == 0) IsShare = 1;
- else if (GroupCostParameter.IsShare == 1) IsShare = 0;
- bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
- string msg = string.Empty;
- if (isTrue)
- {
- if (IsShare == 0)
- {
- msg = "禁止通知,其他模块操作人员不可见此成本信息!";
- }
- else
- {
- #region 企微通知对应岗位用户
- try
- {
- AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
- }
- catch (Exception ex)
- {
- }
- #endregion
- msg = "通知成功,其他模块操作人员可见此成本信息!";
- }
- jw = JsonView(isTrue, msg, new { IsShare });
- }
- else
- {
- msg = "修改失败!";
- jw = JsonView(isTrue, msg);
- }
- }
- else
- {
- jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
- }
- return Ok(jw);
- }
- /// <summary>
- /// 导出报价单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
- {
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di != null)
- {
- di.TeamName = di.TeamName.Replace("|", "、");
- di.VisitCountry = di.VisitCountry.Replace("|", "、");
- //文件名
- string strFileName = di.TeamName + "-收款账单.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
- //载入模板
- Document doc = new Document(tmppath);
- decimal TotalPrice = 0.00M;
- string itemStr = string.Empty;
- Dictionary<string, string> airSouer = new Dictionary<string, string>();
- //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCSGR", "经济舱及酒店单人间");
- airSouer.Add("GWCSGR", "公务舱及酒店单人间");
- airSouer.Add("GWCJSES", "公务舱及酒店小套房");
- airSouer.Add("GWCSUITE", "公务舱及酒店套房");
- airSouer.Add("JJCSUITE", "经济舱及酒店套房");
- var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
- foreach (var cost in groupCostType)
- {
- var List = cost.ToList();
- if (cost.Key == "A")
- {
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- else
- {
- itemStr = itemStr.Insert(0, "A段\r\n");
- itemStr += "B段\r\n";
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- }
- #region 替换Word模板书签内容
- Dictionary<string, string> marks = new Dictionary<string, string>();
- marks.Add("To", di.ClientUnit);//付款方
- marks.Add("ToTel", di.TellPhone);//付款方电话
- marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
- marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
- marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
- marks.Add("PayDay", (di.PayDay).ToString());//付款预期
- marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
- marks.Add("WeChat", di.WeChatNo ?? "");//微信号
- marks.Add("PayItemContent", itemStr);//详细信息
- marks.Add("Total", TotalPrice.ToString("F2"));//合计
- #endregion
- ////注
- //if (doc.Range.Bookmarks["Attention"] != null)
- //{
- // Bookmark mark = doc.Range.Bookmarks["Attention"];
- // mark.Text = frList[0].Attention;
- //}
- foreach (var item in marks.Keys)
- {
- if (doc.Range.Bookmarks[item] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[item];
- mark.Text = marks[item];
- }
- }
- byte[] bytes = null;
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- else
- {
- return Ok(JsonView(false, "团组信息不存在!"));
- }
- }
- /// <summary>
- /// 导出团组成本
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
- var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
- for (int i = 0; i < List_GC.Count; i++)
- {
- GroupCost_Excel gc = new GroupCost_Excel();
- gc.Id = List_GC[i].Id;
- gc.Diid = List_GC[i].Diid.ToString();
- gc.DAY = List_GC[i].DAY;
- string week = "";
- if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
- week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
- gc.Date = (List_GC[i].Date + "\n" + week).ToString();
- gc.ITIN = List_GC[i].ITIN;
- gc.CarType = List_GC[i].CarType;
- gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
- gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
- gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
- gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
- gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
- gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
- gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
- gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
- gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
- gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
- gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
- gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
- gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
- gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
- gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
- gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
- gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
- gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
- gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
- gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
- gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
- gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
- gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
- gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
- gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
- gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
- gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
- gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
- gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
- gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
- gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
- List_GC1.Add(gc);
- }
- var dt = CommonFun.GetDataTableFromIList(List_GC1);
- dt.TableName = "TB";
- //报表标题等不用dt的值
- designer.SetDataSource("TeamName", dto.title.TeamName);
- designer.SetDataSource("Pnumber", dto.title.GroupNumber);
- designer.SetDataSource("Tax", dto.title.Tax);
- //designer.SetDataSource("FFYS", lblHotelCB.Text);
- designer.SetDataSource("Currency", dto.title.Currency);
- //designer.SetDataSource("HotelXS", txtHotelXS.Text);
- designer.SetDataSource("Rate", dto.title.Rate);
- var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
- var Aparams = hotels.Find(x => x.Type == "Default");
- if (Aparams == null)
- {
- return Ok(jw);
- }
- //酒店数量
- var txtSGRNumber = Aparams.SGR.ToString();
- var txtTBRNumber = Aparams.TBR.ToString();
- var txtJSESNumber = Aparams.JSES.ToString();
- var txtSUITENumbe = Aparams.SUITE.ToString();
- if (dto.costType == "B")
- {
- Aparams = hotels.Find(x => x.Type == "A");
- var Bparams = hotels.Find(x => x.Type == "B");
- if (Aparams == null || Bparams == null)
- {
- return Ok(jw);
- }
- txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
- txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
- txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
- txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
- }
- designer.SetDataSource("SGRNumber", txtSGRNumber);
- designer.SetDataSource("TBRNumber", txtTBRNumber);
- designer.SetDataSource("JSESNumber", txtJSESNumber);
- designer.SetDataSource("SUITENumber", txtSUITENumbe);
- var ws = designer.Workbook.Worksheets[0];
- int Row = List_GC.Count;
- int startIndex = 11;
- int HideRows = 0;
- List<int> hideRowsList = new List<int>();
- decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
- #region A段left数据
- var left = dto.leftInfo.Find(x => x.Type == "A");
- if (left == null)
- {
- return Ok(jw);
- }
- var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
- if (leftBindData != null)
- {
- designer.SetDataSource("VisaDRCB", leftBindData.cb);
- designer.SetDataSource("VisaRS", leftBindData.rs);
- designer.SetDataSource("VisaXS", leftBindData.xs);
- designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BXDRCB", leftBindData.cb);
- designer.SetDataSource("BXRS", leftBindData.rs);
- designer.SetDataSource("BXXS", leftBindData.xs);
- designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HSDRCB", leftBindData.cb);
- designer.SetDataSource("HSRS", leftBindData.rs);
- designer.SetDataSource("HSXS", leftBindData.xs);
- designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPJJCCB", leftBindData.cb);
- designer.SetDataSource("JPJJCPnum", leftBindData.rs);
- designer.SetDataSource("JPJJCXS", leftBindData.xs);
- designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPGWCCB", leftBindData.cb);
- designer.SetDataSource("JPGWCPNum", leftBindData.rs);
- designer.SetDataSource("JPGWCXS", leftBindData.xs);
- designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPTDCCB", leftBindData.cb);
- designer.SetDataSource("JPTDCPNum", leftBindData.rs);
- designer.SetDataSource("JPTDCXS", leftBindData.xs);
- designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- ////TBR
- designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelTBRRS", leftBindData.rs);
- designer.SetDataSource("HotelTBRXS", leftBindData.xs);
- designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- ////SGR
- designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSGRRS", leftBindData.rs);
- designer.SetDataSource("HotelSGRXS", leftBindData.xs);
- designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- ////JS/ES
- designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("HotelJSESRS", leftBindData.rs);
- designer.SetDataSource("HotelJSESXS", leftBindData.xs);
- designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- ////SUITE
- designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSUITERS", leftBindData.rs);
- designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("DJDRCB", leftBindData.cb);
- designer.SetDataSource("DJRS", leftBindData.rs);
- designer.SetDataSource("DJXS", leftBindData.xs);
- designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HCPCB", leftBindData.cb);
- designer.SetDataSource("HCPRS", leftBindData.rs);
- designer.SetDataSource("HCPXS", leftBindData.xs);
- designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("CPCB", leftBindData.cb);
- designer.SetDataSource("CPRS", leftBindData.rs);
- designer.SetDataSource("CPXS", leftBindData.xs);
- designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("GWDRCD", leftBindData.cb);
- designer.SetDataSource("GWRS", leftBindData.rs);
- designer.SetDataSource("GWXS", leftBindData.xs);
- designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("LYJDRCB", leftBindData.cb);
- designer.SetDataSource("LYJRS", leftBindData.rs);
- designer.SetDataSource("LYJXS", leftBindData.xs);
- designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- #endregion
- #region A段Right信息
- var right = dto.rightInfo.Find(x => x.Type == "A");
- if (right == null)
- {
- return Ok(jw);
- }
- HideRows += 4;
- var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData != null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
- if (rightBindData != null)
- {
- //头等舱 + 小套房 JSES
- designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
- designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
- if (rightBindData != null)
- {
- //头等舱 + 大套房
- designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- #endregion
- #region B段标题清空
- designer.SetDataSource("CostBDRCB", "");
- designer.SetDataSource("CostBRS", "");
- designer.SetDataSource("CostBXS", "");
- designer.SetDataSource("CostBZCB", "");
- designer.SetDataSource("CostBDRBJ", "");
- designer.SetDataSource("CostBZBJ", "");
- designer.SetDataSource("CostBDRLR", "");
- designer.SetDataSource("CostBZLR", "");
- designer.SetDataSource("CostBDRCBOM", "");
- designer.SetDataSource("CostBRSOM", "");
- designer.SetDataSource("CostBZCBOM", "");
- designer.SetDataSource("CostBDRBJOM", "");
- designer.SetDataSource("CostBZBJOM", "");
- designer.SetDataSource("CostBDRLROM", "");
- designer.SetDataSource("CostBZLROM", "");
- #endregion
- designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
- designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
- designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
- designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
- designer.SetDataSource("DJName", "地接(CNY)");
- designer.SetDataSource("HCPName", "地接-火车票(CNY)");
- designer.SetDataSource("CPName", "地接-船票(CNY)");
- designer.SetDataSource("GWName", "公务(CNY)");
- designer.SetDataSource("YQHName", "邀请函(CNY)");
- designer.SetDataSource("LYJName", "零用金(CNY)");
- designer.SetDataSource("HSName", "核酸检测(CNY)");
- designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
- designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
- designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
- designer.SetDataSource("BXName", "保险(CNY)");
- designer.SetDataSource("VisaName", "签证(CNY)");
- #region B段基本数据
- if (dto.costType == "B")
- {
- left = dto.leftInfo.Find(x => x.Type == "B");
- if (left == null)
- {
- return Ok(jw);
- }
- #region B段left数据
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHSDRCB", leftBindData.cb);
- designer.SetDataSource("BHSRS", leftBindData.rs);
- designer.SetDataSource("BHSXS", leftBindData.xs);
- designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPJJCCB", leftBindData.cb);
- designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
- designer.SetDataSource("BJPJJCXS", leftBindData.xs);
- designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPGWCCB", leftBindData.cb);
- designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
- designer.SetDataSource("BJPGWCXS", leftBindData.xs);
- designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPTDCCB", leftBindData.cb);
- designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
- designer.SetDataSource("BJPTDCXS", leftBindData.xs);
- designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHCPCB", leftBindData.cb);
- designer.SetDataSource("BHCPRS", leftBindData.rs);
- designer.SetDataSource("BHCPXS", leftBindData.xs);
- designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BCPCB", leftBindData.cb);
- designer.SetDataSource("BCPRS", leftBindData.rs);
- designer.SetDataSource("BCPXS", leftBindData.xs);
- designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //TBR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
- designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
- designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SGR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
- designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
- designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //JS/ES
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
- designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
- designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SUITE
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
- designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BDJDRCB", leftBindData.cb);
- designer.SetDataSource("BDJRS", leftBindData.rs);
- designer.SetDataSource("BDJXS", leftBindData.xs);
- designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BGWDRCD", leftBindData.cb);
- designer.SetDataSource("BGWRS", leftBindData.rs);
- designer.SetDataSource("BGWXS", leftBindData.xs);
- designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- #region 优化方案
- //Dictionary<string, object> excelBind = new Dictionary<string, object>();
- //excelBind.Add("零用金", new {
- //cb="",
- //rs="",
- //xs ="",
- //zcb = "",
- //});
- #endregion
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BLYJDRCB", leftBindData.cb);
- designer.SetDataSource("BLYJRS", leftBindData.rs);
- designer.SetDataSource("BLYJXS", leftBindData.xs);
- designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- #endregion
- #region B段Right信息
- right = dto.rightInfo.Find(x => x.Type == "B");
- if (right == null)
- {
- return Ok(jw);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData != null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
- if (rightBindData != null)
- {
- //头等舱 + 小套房 JSES
- designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
- designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
- if (rightBindData != null)
- {
- //头等舱 + 大套房
- designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- #endregion
- #region 标题
- designer.SetDataSource("CostBDRCB", "单人成本");
- designer.SetDataSource("CostBRS", "人数");
- designer.SetDataSource("CostBXS", "系数");
- designer.SetDataSource("CostBZCB", "总成本");
- designer.SetDataSource("CostBDRBJ", "单人报价");
- designer.SetDataSource("CostBZBJ", "总报价");
- designer.SetDataSource("CostBDRLR", "单人利润");
- designer.SetDataSource("CostBZLR", "总利润");
- designer.SetDataSource("CostBDRCBOM", "单人成本");
- designer.SetDataSource("CostBRSOM", "人数");
- designer.SetDataSource("CostBZCBOM", "总成本");
- designer.SetDataSource("CostBDRBJOM", "单人报价");
- designer.SetDataSource("CostBZBJOM", "总报价");
- designer.SetDataSource("CostBDRLROM", "单人利润");
- designer.SetDataSource("CostBZLROM", "总利润");
- #endregion
- }
- #endregion
- designer.SetDataSource("TzZCB2", TzZCB2);
- designer.SetDataSource("TzZBJ2", TzZBJ2);
- designer.SetDataSource("TzZLR2", TzZLR2);
- string[] dataSourceKeys = new string[]
- {
- "VF",
- "TGS",
- "TGOF",
- "TGM",
- "TGA",
- "TGTF",
- "TGEF",
- "CFM",
- "CFOF",
- "B",
- "L",
- "D",
- "TBR",
- "SGR",
- "JSES",
- "Suite",
- "TV",
- "1L",
- "IF",
- "EF",
- "BRF",
- "TE",
- "TGT",
- "DRVT",
- "PC",
- "TLF",
- "ECT"
- };
- foreach (var item in dataSourceKeys)
- {
- var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
- if (find != null)
- {
- designer.SetDataSource(item, find.text);
- }
- else
- {
- designer.SetDataSource(item, 0);
- }
- }
- designer.SetDataSource(dt);
- //根据数据源处理生成报表内容
- designer.Process();
- designer.Workbook.Worksheets[0].Name = "清单";
- Worksheet sheet = designer.Workbook.Worksheets[0];
- foreach (var Rowindex in hideRowsList)
- {
- ws.Cells.HideRows(Rowindex, 2);
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-团组-成本.xls";
- using (MemoryStream stream = new MemoryStream())
- {
- designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 导出客户报表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- //文件名
- //string strFileName = di.TeamName + "-团组-客户报价.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
- //载入模板
- Document doc = new Document(tmppath);
- Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
- Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
- DickeyValue.Add("DickeyValue", di.TeamName); //团组名
- var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
- var AParameter = ParameterList.Find(x => x.CostType == "A");
- var BParameter = ParameterList.Find(x => x.CostType == "B");
- if (AParameter == null)
- {
- return Ok(JsonView(false, "系数不存在!"));
- }
- string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
- , TzAirDesc, TzZCost;
- CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
- = TzAirDesc = TzZCost = string.Empty;
- TzNumber = AParameter.CostTypenumber.ToString();
- CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
- CarGuides1 = dto.CarGuides1;
- Meal = dto.Meal;
- SubsidizedMeals = dto.SubsidizedMeals;
- NightRepair = dto.NightRepair;
- AttractionsTickets = dto.AttractionsTickets;
- MiscellaneousFees = dto.MiscellaneousFees;
- ATip = dto.ATip;
- TzHotelDesc = "";
- Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
- PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
- Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
- TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
- TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
- TzAirDesc = "";
- TzZCost = dto.TzZCost;
- var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
- var TzAirDescArr = new string[] { "经济舱", "公务舱" };
- var index = 1;
- var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- }
- else
- {
- TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- }
- index++;
- }
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- index++;
- }
- }
- }
- if (dto.costType == "B")
- {
- if (BParameter == null)
- {
- return Ok(JsonView(false, "B段系数不存在!"));
- }
- CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
- Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
- PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
- Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
- TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
- TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
- AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- TzHotelDesc += "B段信息 \r\n";
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- }
- else
- {
- TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- }
- index++;
- }
- TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
- index++;
- }
- }
- }
- }
- Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
- DickeyValue.Add("TzNumber", TzNumber); //团组人数
- DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
- DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
- DickeyValue.Add("Meal", Meal); // 地接 - 餐费
- DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
- DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
- DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
- DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
- DickeyValue.Add("ATip", ATip); // 地接 - 小费
- DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
- DickeyValue.Add("Offcial", Offcial); // 公务单人报价
- DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
- DickeyValue.Add("Visa", Visa); // 签证单人报价
- DickeyValue.Add("TrainTicket", TrainTicket); //火车票
- DickeyValue.Add("TicketPrice", TicketPrice); //船票
- DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
- DickeyValue.Add("TzZCost", TzZCost);
- foreach (var key in DickeyValue.Keys)
- {
- if (doc.Range.Bookmarks[key] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[key];
- mark.Text = DickeyValue[key];
- }
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-客户报价.doc";
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 团组成本 各模块(酒店,地接,机票)成本提示
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.DiId < 0)
- {
- return Ok(JsonView(false, "请传入有效的DiId参数!"));
- }
- List<int> cTableIds = new List<int>() {
- 76 ,//酒店预订
- 77 ,//行程
- 79 ,//车/导游地接
- 80 ,//签证
- 81 ,//邀请/公务活
- 82 ,//团组客户保险
- 85 ,//机票预订
- 98 ,//其他款项
- 285 ,//收款退还
- 751 ,//酒店早餐
- 1015 // 超支费用
- };
- if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
- {
- return Ok(JsonView(false, "请传入有效的CTable参数!"));
- }
- #endregion
- //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
- var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_GroupCostParameters.Count <= 0)
- {
- return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
- }
- if (_GroupCostParameters[0].IsShare == 0)
- {
- return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
- }
- var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- //处理date为空问题
- if (_GroupCosts.Count > 0)
- {
- for (int i = 0; i < _GroupCosts.Count; i++)
- {
- if (string.IsNullOrEmpty(_GroupCosts[i].Date))
- {
- if (i > 0)
- {
- _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
- }
- }
- }
- }
- GroupCostModulePromptView _view = new GroupCostModulePromptView();
- List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
- var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- string currCode = "";
- #region currCode 验证
- bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
- if (isInt)
- {
- var currData = currDatas.Find(it => it.Id == intCurrency);
- if (currData != null)
- {
- currCode = currData.Name;
- }
- }
- else
- {
- currCode = _GroupCostParameters[0].Currency.Trim();
- }
- #endregion
- //op,酒店单段模式存储
- GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = currCode,
- Rate = _GroupCostParameters[0].Rate,
- CostType = _GroupCostParameters[0].CostType,
- CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = _GroupCostParameters[0].CostTypenumber
- };
- List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
- if (_GroupCostParameters.Count == 2)
- {
- _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
- }
- foreach (var item in _GroupCostParameters)
- {
- decimal _rate = 1;
- decimal _rate1 = item.Rate;
- decimal _scale = 1;
- //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
- #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
- //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- //if (userInfo != null)
- //{
- // if (userInfo.DepId == 1 || userInfo.DepId == 7)
- // {
- // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
- // {
- // _scale = 1.00M;
- // }
- // }
- //}
- #endregion
- GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = currCode,
- Rate = _rate1,
- CostType = item.CostType,
- CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = item.CostTypenumber
- };
- if (_GroupCostParameters.Count > 1)
- {
- modulePromptInfo.CostTypeNumber = item.CostTypenumber;
- }
- else
- {
- modulePromptInfo.CostTypeNumber = item.LYJRS;
- }
- if (dto.CTable == 79)//
- {
- modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
- modulePromptInfo.TotalCost = item.DJCB;
- }
- List<string> costTypes = new List<string>() { "A", "B" };
- List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
- var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
- if (_GroupCostsDuplicates.Count() == 1)
- {
- _GroupCostsTypeData = _GroupCosts;
- }
- else
- {
- _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
- Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
- }
- /*
- * 76 酒店预订
- * 77 行程
- * 79 车/导游地接
- * 80 签证
- * 81 邀请/公务活动
- * 82 团组客户保险
- * 85 机票预订
- * 98 其他款项
- * 285 收款退还
- * 751 酒店早餐
- * 1015 超支费用
- */
- switch (dto.CTable)
- {
- case 76: // 酒店预订
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- it.DAY,
- it.Date,
- it.ACCON,
- it.ITIN,
- it.SGR,
- it.TBR,
- it.JS_ES,
- it.Suite
- })
- );
- break;
- case 79: // 车/导游地接
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- Date = it.Date, //日期
- CarFee = it.CarCost * _rate * _scale, //车费用
- CarType = it.CarType, //车型
- DriverFee = it.CFS * _rate * _scale, //司机工资
- DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
- DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
- DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
- GuideFee = it.TGS * _rate * _scale, //导游费用
- GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
- GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
- GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
- GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
- GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
- GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
- Breakfast = it.B * _rate * _scale, //早餐费
- Lunch = it.L * _rate * _scale, //午餐费
- Dinner = it.D * _rate * _scale, //晚餐费
- OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
- OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
- InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
- TicketFee = it.EF * _rate * _scale, //门票费
- TicketRemark = it.EFR, //门票费描述
- DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
- TravelSupplies = it.TE * _rate * _scale, //出行物资
- SpentCash = it.PC * _rate * _scale, //零用金
- LeadersFee = it.TLF * _rate * _scale, //领队费
- ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
- })
- );
- break;
- case 85: // 机票
- List<dynamic> datas = new List<dynamic>();
- datas.Add(
- new
- {
- AirType = "经济舱",
- AirNum = item.JJCRS,
- AirDRCB = item.JJCCB,
- AirZCB = (item.JJCRS * item.JJCCB)
- }
- );
- datas.Add(
- new
- {
- AirType = "公务舱",
- AirNum = item.GWCRS,
- AirDRCB = item.GWCCB,
- AirZCB = (item.GWCRS * item.GWCCB)
- }
- );
- var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
- modulePromptInfo.Data = new
- {
- airFeeData = datas,
- airInitData = initDatas
- };
- _ModulePromptInfos.Add(modulePromptInfo);
- break;
- default:
- break;
- }
- }
- if (dto.CTable != 85)
- {
- _ModulePromptInfo.Data = _ModuleSubPromptInfo;
- _ModulePromptInfos.Add(_ModulePromptInfo);
- }
- _view.ModulePromptInfos = _ModulePromptInfos;
- return Ok(JsonView(true, "操作成功!", _view));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据黑屏代码重新生成行程
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
- {
- var jw = JsonView(false);
- var Create = _GroupCostRepository.
- CreateGroupCostByBlackCode(dto.Diid);
- jw.Msg = Create.Msg;
- if (Create.Code == 0)
- {
- jw.Code = 200;
- jw.Data = new
- {
- groupCost = Create.Data,
- blackCodeIsTrue = true
- };
- }
- else
- {
- jw.Code = 400;
- jw.Data = new
- {
- groupCost = Create.Data,
- blackCodeIsTrue = false,
- };
- }
- return Ok(jw);
- }
- /// <summary>
- /// 成本获取OP历史车费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
- {
- var jw = JsonView(false);
- try
- {
- List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
- //获取现有所有车的数据
- if (!dto.Param.IsNullOrWhiteSpace())
- {
- string sql = $@"
- SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
- FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
- gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
- WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
- AND gctggr.ServiceEndTime is not NULL
- ORDER by gctggrc.id DESC
- ";
- dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
- var numeberResult = await Task.Run(() =>
- {
- var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
- _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
- return numberArr;
- });
- var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
- foreach (var item in numeberResult)
- {
- var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
- {
- Country = "数据异常!",
- City = string.Empty,
- };
- item.Area = find.Country + " " + find.City;
- }
- dbResult.AddRange(numeberResult);
- if (dto.Param.Contains("、"))
- {
- var sp = dto.Param.Split("、");
- dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
- .Where(x =>
- {
- return System.Array.Exists(sp, e =>
- {
- bool where = false;
- if (x.Area != null)
- {
- where = x.Area.Contains(e);
- if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- if (x.PriceName != null && !where)
- {
- where = x.PriceName.Contains(e);
- if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- return where;
- });
- }).ToList();
- }
- else
- {
- dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
- .Where(x =>
- {
- bool where = false;
- if (x.Area != null)
- {
- where = x.Area.Contains(dto.Param);
- if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- if (x.PriceName != null && !where)
- {
- where = x.PriceName.Contains(dto.Param);
- if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- return where;
- }
- )
- .ToList();
- }
- }
- var view = dbResult.Select(x =>
- {
- decimal dp = 0.00M;
- var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
- var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
- if (string.IsNullOrWhiteSpace(x.DatePrice))
- {
- if (startB && endB)
- {
- var timesp = endD.Subtract(startD);
- if ((timesp.Days + 1) != 0)
- {
- dp = x.Price / (timesp.Days + 1);
- }
- }
- }
- else
- {
- dp = x.Price;
- }
- return new
- {
- start = startB ? startD.ToString("yyyy-MM-dd") : "",
- end = endB ? endD.ToString("yyyy-MM-dd") : "",
- x.Area,
- x.id,
- price = x.Price.ToString("F2"),
- x.PriceName,
- x.PriceContent,
- x.TeamName,
- x.DatePrice,
- dayPrice = dp.ToString("F2"),
- };
- }).OrderByDescending(x => x.id).ToList();
- jw = JsonView(true, "获取成功!", view);
- }
- catch (Exception e)
- {
- jw = JsonView(false, e.Message);
- }
- return Ok(jw);
- }
- #endregion
- #region 酒店预订 新 雷怡 2023-12-28 17:45
- /// <summary>
- /// 酒店预订
- /// 酒店费用列表 根据团组Id查询
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
-
- return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
- }
- /// <summary>
- /// 酒店预订
- /// 基础数据
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
- }
- /// <summary>
- /// 酒店预订
- /// 创建 入住卷号码
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- /// <summary>
- /// 酒店预订
- /// 详情
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
- }
- /// <summary>
- /// 酒店预订
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) // Add
- {
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- }
- else if (_dto.Id > 1) // Edit
- {
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- }
- else return Ok(JsonView(false, "请输入正确的数据Id!"));
- #endregion
- #endregion
- JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
- if (_view.Code != 200)
- {
- return Ok(_view);
- }
- #region 成本无酒店价格数据进入超支
- _sqlSugar.BeginTran();
- var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
- var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
- var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
- for (int i = 0; i < groupCost.Count; i++)
- {
- if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
- {
- groupCost[i].Date = groupCost[i - 1].Date;
- }
- }
- var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
- List<Fin_GroupExtraCostDto_OP> extraCostList = new
- List<Fin_GroupExtraCostDto_OP>();
- if (start_Bool && end_Bool)
- {
- while (start_Time < end_Time)
- {
- foreach (var item in groupCost_Grp)
- {
- if (DateTime.TryParse(item.Key, out DateTime cost_Time))
- {
- if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
- {
- extraCostList.Add(new
- Fin_GroupExtraCostDto_OP
- {
- Area = _dto.AreaId,
- coefficient = 1.5M,
- createUser = _dto.UserId,
- currency = _dto.CardPriceCurrency,
- diId = _dto.DiId,
- ManagerConfirm = 0,
- SupervisorConfirm = 0,
- SYsupervisorConfirm = 0,
- editType = 1,
- PortType = 1,
- price = _dto.CardPrice,
- PriceCount = 1,
- priceType = 1027,
- priceDetailType = 1044,
- PriceDt = start_Time.ToString("yyyy-MM-dd"),
- priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
- });
- }
- }
- }
- start_Time = start_Time.AddDays(1);
- }
- }
- if (extraCostList.Any())
- {
- await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
- }
- _sqlSugar.CommitTran();
- #endregion
- #region 应用推送
- try
- {
- int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
- int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
- int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
- var diId = _dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- #region 操作记录
- var opInfo = new Crm_TableOperationRecord() {
- TableName = "Grp_HotelReservations",
- PortType = _dto.PortType,
- DataId = hotelId,
- CreateUserId = _dto.UserId
- };
- var opStatus = OperationEnum.NoOperation;
- if (_dto.Id<1) //添加操作
- {
- opInfo.OperationItem = OperationEnum.Add;
- }
- else if (_dto.Id > 0)
- {
- opInfo.OperationItem = OperationEnum.Edit;
- }
- string opRemark = string.Empty;
- if (ccpInfo != null)
- {
- // USD 1211.86、 CNY 8761.75、汇率:7.2300
- var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
- var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
- opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
- }
- opInfo.Remark = opRemark;
- await _tableorRep.AddAsync(opInfo);
- #endregion
- _logger.LogInformation($"【iOS推送通知Exception】Begin");
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"费用审核";
- string content = "";
- if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- try
- {
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
- //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
- //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
- //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
- }
- catch (Exception ex )
- {
- Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
- }
- }
- catch (Exception ex)
- {
- Logs($"【iOS推送通知Exception】【{ex.Message}】");
- }
- try
- {
- int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
- int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
- int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //自动审核
- var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
- //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
- _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = _dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = "";
- if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(_view);
- }
- /// <summary>
- /// 酒店自动审核测试
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
- {
- #region 应用推送
- try
- {
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "操作失败"));
- }
- #endregion
- return Ok(JsonView(false, "操作成功"));
- }
- /// <summary>
- /// 酒店预订
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
- #region 操作记录
- await _tableorRep.AddAsync(new Crm_TableOperationRecord()
- {
- TableName = "Grp_HotelReservations",
- PortType = _dto.PortType,
- OperationItem = OperationEnum.Del,
- DataId = _dto.Id,
- CreateUserId = _dto.UserId
- });
- #endregion
- return Ok(data);
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER
- /// 2024.05.06 之前版本
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
- //判断数据是否完整
- if (hr != null)
- {
- if (!string.IsNullOrEmpty(hr.DetermineNo))
- {
- string strFileName = "HotelStatement/";
- Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
- if (dele != null)
- strFileName += dele.TourCode;
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- #region 替换Word模板书签内容
- //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
- //入住卷预定号码
- if (doc.Range.Bookmarks["VNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VNO"];
- mark.Text = hr.CheckNumber;
- }
- //酒店时间
- if (doc.Range.Bookmarks["Date"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Date"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //团号
- if (doc.Range.Bookmarks["TNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TNo"];
- mark.Text = dele.TourCode;
- }
- //预定号码
- if (doc.Range.Bookmarks["BookingId"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["BookingId"];
- mark.Text = hr.ReservationsNo;
- }
- if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
- mark.Text = hr.DetermineNo;
- }
- //酒店城市
- if (doc.Range.Bookmarks["City"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["City"];
- mark.Text = hr.City;
- }
- //酒店名称
- if (doc.Range.Bookmarks["HName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HName"];
- mark.Text = hr.HotelName;
- }
- //酒店地址
- if (doc.Range.Bookmarks["Address"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Address"];
- mark.Text = hr.HotelAddress;
- }
- //酒店电话
- if (doc.Range.Bookmarks["Tel"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Tel"];
- mark.Text = hr.HotelTel;
- }
- //酒店传真
- if (doc.Range.Bookmarks["Fax"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Fax"];
- if (!string.IsNullOrWhiteSpace(hr.HotelFax))
- {
- mark.Text = hr.HotelFax;
- }
- }
- //入住时间
- if (doc.Range.Bookmarks["CIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
- }
- //退房时间
- if (doc.Range.Bookmarks["COut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["COut"];
- mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //客户名称
- if (doc.Range.Bookmarks["GName"] != null)
- {
- string guestName = "";
- string[] clients = new string[] { };
- if (hr.GuestName.Contains(","))
- {
- clients = hr.GuestName.Split(",");
- }
- else
- {
- clients = new string[] { hr.GuestName };
- }
- List<int> clientIds_int = new List<int>();
- if (clients.Length > 0)
- {
- foreach (var item in clients)
- {
- if (item.IsNumeric())
- {
- clientIds_int.Add(int.Parse(item));
- }
- }
- }
- if (clientIds_int.Count > 0)
- {
- var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
- foreach (var client in _clientDatas)
- {
- //男
- if (client.Sex == 0) guestName += $"Mr.";
- //女
- else if (client.Sex == 1) guestName += $"Ms.";
- if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
- {
- guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
- }
- //guestName += $"{client.Pinyin},";
- }
- if (guestName.Length > 0)
- {
- guestName = guestName.Substring(0, guestName.Length - 1);
- }
- }
- else
- {
- guestName = hr.GuestName;
- }
- Bookmark mark = doc.Range.Bookmarks["GName"];
- mark.Text = guestName;
- }
- //房间介绍
- if (doc.Range.Bookmarks["ROOM"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ROOM"];
- mark.Text = hr.RoomExplanation;
- }
- //报价描述
- if (doc.Range.Bookmarks["NOTE"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["NOTE"];
- Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
- if (ss != null)
- mark.Text = ss.Name;
- }
- //入住时间
- if (doc.Range.Bookmarks["CheckIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CheckIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- }
- //退房时间
- if (doc.Range.Bookmarks["CheckOut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["CheckOut"];
- mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //日期
- if (doc.Range.Bookmarks["DT"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["DT"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //名称
- if (doc.Range.Bookmarks["VName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VName"];
- mark.Text = hr.HotelName;
- }
- //号码
- if (doc.Range.Bookmarks["VOUCHERNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
- mark.Text = hr.CheckNumber;
- }
- #endregion
- strFileName += "VOUCHER.doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
- }
- }
- else
- {
- return Ok(JsonView(false, "该条数据已删除或不存在!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER
- /// 2024.05.06 之后版本
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
- //判断数据是否完整
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- string strFileName = "HotelStatement/";
- string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
- #region 数据处理
- List<int> guestIds = new List<int>();
- int index = 0;
- foreach (var item in hrDtas)
- {
- if (item.GuestName.Contains(","))
- {
- string[] guestIdArr = item.GuestName.Split(',');
- foreach (var guestIdStr in guestIdArr)
- {
- bool guestBool = int.TryParse(guestIdStr, out int guestId);
- if (guestBool)
- {
- guestIds.Add(guestId);
- }
- }
- }
- else guestNames += item.GuestName;
- var voucherInfo = new HotelVoucherInfoView()
- {
- HotelName = item.HotelName,
- CheckInDate = item.CheckInDate,
- CheckOutDate = item.CheckOutDate,
- ConfirmationNumber = item.DetermineNo.Trim(),
- RoomType = item.RoomExplanation
- };
- vouchers.Add(voucherInfo);
- }
- if (guestIds.Count > 0)
- {
- guestIds = guestIds.Distinct().ToList();
- var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
- if (guestDatas.Count > 0)
- {
- guestNames = "";
- foreach (var guest in guestDatas)
- {
- string guestName = "";
- if (guest.Sex == 0) guestName += @"MR.";
- else if (guest.Sex == 1) guestName += @"MS.";
- if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
- else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
- guestNames += @$"{guestName.Trim()}、";
- }
- if (guestNames.Length > 0)
- {
- guestNames = guestNames.Substring(0, guestNames.Length - 1);
- }
- }
- }
- #endregion
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- if (doc.Range.Bookmarks["GuestName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["GuestName"];
- mark.Text = guestNames;
- }
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
- vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
- for (int i = 1; i <= vouchers.Count; i++)
- {
- HotelVoucherInfoView hviv = vouchers[i - 1];
- builder.MoveToCell(0, i, 0, 0);
- builder.Write(hviv.HotelName);
- builder.MoveToCell(0, i, 1, 0);
- builder.Write(hviv.CheckInDate);
- builder.MoveToCell(0, i, 2, 0);
- builder.Write(hviv.CheckOutDate);
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(hviv.RoomType);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write(hviv.ConfirmationNumber);
- }
- //删除多余行
- int currRowIndex = vouchers.Count + 1;
- int delRows = 21 - currRowIndex;
- if (delRows > 0)
- {
- for (int i = 0; i < delRows; i++)
- {
- table.Rows.RemoveAt(currRowIndex);
- //cultivateRowIndex++;
- }
- }
- strFileName += "VOUCHER.docx";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER 批量生成
- /// New
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28;
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
- .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
- .OrderBy(x => x.CheckInDate)
- .ToListAsync();
- //判断数据是否完整
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
- string strFileName = "HotelStatement/";
- var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
- if (dele != null)
- strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
- var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
- .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
- .Where(it => it.IsDel == 0)
- .ToListAsync();
- foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
- for (int i = 0; i < hrDtas.Count; i++)
- {
- string guestNames = string.Empty;
- List<int> guestIds = new List<int>();
- var item = hrDtas[i];
- //处理客户姓名
- if (item.GuestName.Contains(","))
- {
- string[] guestIdArr = item.GuestName.Split(',');
- foreach (var guestIdStr in guestIdArr)
- if (int.TryParse(guestIdStr, out int guestId))
- guestIds.Add(guestId);
- }
- else
- {
- bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
- if (guestIdBool)
- {
- guestIds.Add(guestId);
- }
- //NaN
- if (item.GuestName.Contains("NaN"))
- {
- guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
- }
- }
- if (guestIds.Count > 0)
- {
- guestIds = guestIds.Distinct().ToList();
- var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
- if (guestDatas1.Count > 0)
- {
- guestNames = "";
- foreach (var guest in guestDatas1)
- {
- string guestName = "";
- if (guest.Sex == 0) guestName += @"MR.";
- else if (guest.Sex == 1) guestName += @"MS.";
- if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
- else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
- guestNames += @$"{guestName.Trim()}、";
- }
- if (guestNames.Length > 0)
- {
- guestNames = guestNames.Substring(0, guestNames.Length - 1);
- }
- }
- }
- //if (!string.IsNullOrEmpty(guestNames))
- //{
- hrDtas[i].GuestName = guestNames;
- //}
- }
- strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
- try
- {
- builder.MoveToDocumentStart();
- foreach (var item in hrDtas)
- {
- //标题
- builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
- builder.ParagraphFormat.LineSpacing = 1;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 9;
- builder.ParagraphFormat.Style.Font.Bold = true;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.Writeln(@$"ACCOMMODATION VOUCHER");
- builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.ParagraphFormat.LineSpacing = 1;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 9;
- builder.ParagraphFormat.Style.Font.Bold = true;
- builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
- builder.StartTable();
- // 设置边框颜色
- builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
- //设置边框样式
- builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
- //表格
- #region 第一行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- //builder.CellFormat.AllowAutoFit = false;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.CellFormat.WrapText = true; //自动换行
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("TOUR NO:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{dele?.TourCode ?? "-"}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"CITY:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.City}");
- builder.EndRow();
- #endregion
- #region 第二行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("CONFIRMATION NO:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.VerticalMerge = CellMerge.None;
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.DetermineNo}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第三行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"HOTEL NAME:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.HotelName}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第四行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"HOTEL ADDRESS:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 8;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.HotelAddress}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第五行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("TEL:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.HotelTel}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"FAX:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.HotelFax}");
- builder.EndRow();
- #endregion
- #region 第六行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("CHECK IN:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
- string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- builder.Write($"{checkInStr}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"CHECK OUT:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
- string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
- builder.Write($"{checkOutStr}");
- builder.EndRow();
- #endregion
- #region 第七行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"GUEST NAME:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 8;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.GuestName}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第八行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"ROOM TYPE:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.RoomExplanation}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第九行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"NOTE:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- builder.EndTable();
- //换行
- builder.Writeln("");
- builder.Writeln("");
- }
- #region 获取文档中的所有表格 设置文字自适应
- // 获取文档中的所有表格。
- foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
- {
- // 遍历表格中的所有行。
- foreach (Aspose.Words.Tables.Row row in table.Rows)
- {
- foreach (Cell cell in row.Cells)
- {
- Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
- cellFormat.Width = 0;
- }
- }
- }
- #endregion
- #region 设置页眉
- builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
- string voucherHeaderPath = $"./Images/VoucherHeader.png";
- if (System.IO.File.Exists(voucherHeaderPath))
- {
- byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
- //Image image = Image.FromStream(imageBytes, ImageType.Png);
- //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
- Shape shape = builder.InsertImage(imageBytes);
- // 调整图片位置
- shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
- shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
- shape.Top = 50; // 将图片距离页眉上边缘的距离
- shape.Left = 0; // 将图片距离页面左边缘的距离
- shape.Width = 81; // 设置图片宽度
- shape.Height = 36; // 设置图片高度
- }
- //靠右
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
- //// 设置页脚上下边距
- //builder.PageSetup.HeaderDistance = 42;
- // 添加页眉线
- Aspose.Words.Border borderHeader = null;
- try
- {
- borderHeader = builder.ParagraphFormat.Borders.Bottom;
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- }
- borderHeader.Shadow = true;
- borderHeader.DistanceFromText = 2;
- borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
- #endregion
- }
- catch (Exception ex)
- {
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- /// <summary>
- /// 酒店预订
- /// 生成 预定成本 Excel
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
- {
- #region 参数验证
- var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
- var vadalitorRes = await vadalitor.ValidateAsync(_dto);
- if (!vadalitorRes.IsValid)
- {
- var errors = new StringBuilder();
- foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
- return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
- }
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- decimal _rate = 1.00M;
- string _currency = string.Empty;
- var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
- var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
- var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
- var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
- var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
- //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
- if (_GroupCostParameter == null)
- {
- //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
- bool isIntType = int.TryParse(_currency, out int currId);
- if (isIntType)
- {
- _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
- }
- var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
- var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
- if (currInfo == null)
- {
- //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
- }
- else _rate = currInfo.Rate;
- if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
- {
- _rate = _GroupCostParameter.Rate;
- }
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- string strFileName = "HotelStatement/";
- string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
- var rateDatas = new List<dynamic>();
- #region 数据处理
- foreach (var item in hrDtas)
- {
- var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
- var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
- var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
- var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
- var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
- if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
- {
- continue;
- }
- string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
- if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
- string singleRoomFeeStr = string.Empty,
- doubleRoomFeeStr = string.Empty,
- suiteRoomFeeStr = string.Empty,
- otherRoomFeeStr = string.Empty,
- payMoneyStr = string.Empty,
- cardPriceStr = string.Empty;
- if (roomCurr.Equals("CNY"))
- {
- rateDatas.Add(new { code = "CNY", rate = 1.0000 });
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
- }
- else
- {
- //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
- //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
- var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
- if (ccpPaymentCurrency.Equals("CNY"))
- {
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
- }
- else
- {
- rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
- }
- var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
- if (hotelcardPriceCurrency.Equals("CNY"))
- {
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
- }
- else
- {
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
- }
- }
- string breakfastPriceStr = string.Empty,
- breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
- governmentRentStr = string.Empty,
- governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
- cityTaxStr = string.Empty,
- cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
- var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(breakfastCurrency1))
- {
- if (breakfastCurrency1.Equals("CNY"))
- {
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
- var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
- }
- }
- else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
- var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(governmentRentCurrency1))
- {
- if (governmentRentCurrency.Equals("CNY"))
- {
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
- var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
- }
- }
- else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
- var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
- {
- if (cityTaxStrCurrency1.Equals("CNY"))
- {
- cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
- var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
- cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
- }
- }
- else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
- int payDId = roomInfo?.PayDId ?? 0;
- pcfds.Add(new HotelReservations_PCFD_View()
- {
- City = item.City,
- HotelName = item.HotelName,
- Date = $"{item.CheckInDate} - {item.CheckOutDate}",
- // SingleRoomCount = item.SingleRoomCount,
- SingleRoomPrice = singleRoomFeeStr,
- // DoubleRoomCount = item.DoubleRoomCount,
- DoubleRoomPrice = doubleRoomFeeStr,
- //SuiteRoomCount = item.SuiteRoomCount,
- SuiteRoomPrice = suiteRoomFeeStr,
- OtherRoomPrice = otherRoomFeeStr,
- //OtherRoomCount = item.OtherRoomCount,
- BreakfastPrice = breakfastPriceStr,
- GovernmentRent = governmentRentStr,
- CityTax = cityTaxStr,
- RoomExplanation = item.RoomExplanation,
- PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
- PayTime = roomInfo?.ConsumptionDate,
- BankNo = roomInfo?.BankNo,
- PayMoney = payMoneyStr,
- //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
- ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
- CardPrice = cardPriceStr,
- Remark = ccpInfo.Remark
- });
- }
- #endregion
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
- var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
- designer.SetDataSource("TourNo", groupInfo.TourCode);
- var rateDatas1 = rateDatas.Distinct();
- var rateStr = string.Empty;
- foreach (var item in rateDatas1)
- {
- rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
- }
- designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
- designer.SetDataSource("Opertor", userInfo.CnName);
- DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
- dt.TableName = "ViewMyHotelReservations";
- designer.SetDataSource(dt);
- designer.Process();
- string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
- designer.Workbook.Save(serverPath);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- #region 删除指定行
- bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
- int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
- doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
- suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
- otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
- zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
- dsIndex = dt.Columns["GovernmentRent"].Ordinal,
- cssIndex = dt.Columns["CityTax"].Ordinal,
- cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
- remarkIndex = dt.Columns["Remark"].Ordinal;
- //删除指定列
- foreach (DataRow item in dt.Rows)
- {
- string singleStr = item["SingleRoomPrice"].ToString();
- bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
- if (containsDigitButNotZero1) singleDel = false;
- singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
- string doubleStr = item["DoubleRoomPrice"].ToString();
- bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero2) doubleDel = false;
- string suiteStr = item["SuiteRoomPrice"].ToString();
- bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero3) suiteDel = false;
- string otherStr = item["OtherRoomPrice"].ToString();
- bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
- if (containsDigitButNotZero4) otherDel = false;
- string zcStr = item["BreakfastPrice"].ToString();
- bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
- if (containsDigitButNotZero5) zcDel = false;
- string dsStr = item["GovernmentRent"].ToString();
- bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
- if (containsDigitButNotZero6) dsDel = false;
- string cssStr = item["CityTax"].ToString();
- bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
- if (containsDigitButNotZero7) cssDel = false;
- string cpStr = item["ConsumptionPatterns"].ToString();
- if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
- string remarkStr = item["Remark"].ToString();
- if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
- }
- DeleteColumn(serverPath, remarkIndex, remarkDel);
- DeleteColumn(serverPath, cpIndex, cpDel);
- DeleteColumn(serverPath, dsIndex, dsDel);
- DeleteColumn(serverPath, cssIndex, cssDel);
- DeleteColumn(serverPath, zcIndex, zcDel);
- DeleteColumn(serverPath, otherIndex, otherDel);
- DeleteColumn(serverPath, suiteIndex, suiteDel);
- DeleteColumn(serverPath, doubleIndex, doubleDel);
- DeleteColumn(serverPath, singleIndex, singleDel);
- #endregion
- //只保留第一个表格
- DeleteSheet(serverPath);
- return Ok(JsonView(true, "操作成功", url = rst));
- }
- else
- {
- _currency = _GroupCostParameter.Currency;
- bool isIntType = int.TryParse(_currency, out int currId);
- if (isIntType)
- {
- _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
- }
- var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
- var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
- if (currInfo == null)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
- }
- if (!_currency.ToUpper().Equals("CNY"))
- {
- _rate = _GroupCostParameter.Rate;
- }
- _rate = currInfo.Rate;
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- string strFileName = "HotelStatement/";
- string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
- #region 数据处理
- foreach (var item in hrDtas)
- {
- var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
- var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
- var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
- var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
- var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
- string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
- string singleRoomFeeStr = string.Empty,
- doubleRoomFeeStr = string.Empty,
- suiteRoomFeeStr = string.Empty,
- otherRoomFeeStr = string.Empty,
- payMoneyStr = string.Empty,
- cardPriceStr = string.Empty;
- if (roomCurr.Equals(_currency))
- {
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
- }
- else
- {
- singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
- cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
- }
- string breakfastPriceStr = string.Empty,
- breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
- governmentRentStr = string.Empty,
- governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
- cityTaxStrStr = string.Empty,
- cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
- cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
- int payDId = roomInfo?.PayDId ?? 0;
- pcfds.Add(new HotelReservations_PCFD_View()
- {
- City = item.City,
- HotelName = item.HotelName,
- Date = $"{item.CheckInDate} - {item.CheckOutDate}",
- // SingleRoomCount = item.SingleRoomCount,
- SingleRoomPrice = singleRoomFeeStr,
- // DoubleRoomCount = item.DoubleRoomCount,
- DoubleRoomPrice = doubleRoomFeeStr,
- //SuiteRoomCount = item.SuiteRoomCount,
- SuiteRoomPrice = suiteRoomFeeStr,
- OtherRoomPrice = otherRoomFeeStr,
- //OtherRoomCount = item.OtherRoomCount,
- BreakfastPrice = breakfastPriceStr,
- GovernmentRent = governmentRentStr,
- CityTax = cityTaxStrStr,
- RoomExplanation = item.RoomExplanation,
- PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
- PayTime = roomInfo?.ConsumptionDate,
- BankNo = roomInfo?.BankNo,
- PayMoney = payMoneyStr,
- //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
- ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
- CardPrice = cardPriceStr,
- Remark = ccpInfo.Remark
- });
- }
- #endregion
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
- var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
- designer.SetDataSource("TourNo", groupInfo.TourCode);
- designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
- designer.SetDataSource("Opertor", userInfo.CnName);
- DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
- dt.TableName = "ViewMyHotelReservations";
- designer.SetDataSource(dt);
- designer.Process();
- string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
- designer.Workbook.Save(serverPath);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- #region 删除指定行
- bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
- int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
- doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
- suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
- otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
- zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
- dsIndex = dt.Columns["GovernmentRent"].Ordinal,
- cssIndex = dt.Columns["CityTax"].Ordinal,
- cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
- remarkIndex = dt.Columns["Remark"].Ordinal;
- //删除指定列
- foreach (DataRow item in dt.Rows)
- {
- string singleStr = item["SingleRoomPrice"].ToString();
- bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
- if (containsDigitButNotZero1) singleDel = false;
- singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
- string doubleStr = item["DoubleRoomPrice"].ToString();
- bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero2) doubleDel = false;
- string suiteStr = item["SuiteRoomPrice"].ToString();
- bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero3) suiteDel = false;
- string otherStr = item["OtherRoomPrice"].ToString();
- bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
- if (containsDigitButNotZero4) otherDel = false;
- string zcStr = item["BreakfastPrice"].ToString();
- bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
- if (containsDigitButNotZero5) zcDel = false;
- string dsStr = item["GovernmentRent"].ToString();
- bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
- if (containsDigitButNotZero6) dsDel = false;
- string cssStr = item["CityTax"].ToString();
- bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
- if (containsDigitButNotZero7) cssDel = false;
- string cpStr = item["ConsumptionPatterns"].ToString();
- if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
- string remarkStr = item["Remark"].ToString();
- if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
- }
- DeleteColumn(serverPath, remarkIndex, remarkDel);
- DeleteColumn(serverPath, cpIndex, cpDel);
- DeleteColumn(serverPath, dsIndex, dsDel);
- DeleteColumn(serverPath, cssIndex, cssDel);
- DeleteColumn(serverPath, zcIndex, zcDel);
- DeleteColumn(serverPath, otherIndex, otherDel);
- DeleteColumn(serverPath, suiteIndex, suiteDel);
- DeleteColumn(serverPath, doubleIndex, doubleDel);
- DeleteColumn(serverPath, singleIndex, singleDel);
- #endregion
- //只保留第一个表格
- DeleteSheet(serverPath);
- return Ok(JsonView(true, "操作成功", url = rst));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 删除指定列
- /// </summary>
- /// <param name="file"></param>
- /// <param name="columnIndex"></param>
- /// <param name="isDel"></param>
- private void DeleteColumn(string file, int columnIndex, bool isDel)
- {
- Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
- //wb.Save(file);
- Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
- if (sheet1 != null)
- {
- if (isDel)
- {
- Cells cells = sheet1.Cells;
- cells.DeleteColumn(columnIndex);
- }
- }
- wb.Save(file);
- }
- /// <summary>
- /// 删除sheet
- /// </summary>
- /// <param name="file"></param>
- /// <param name="sheetName"></param>
- private void DeleteSheet(string file, string sheetName = "")
- {
- Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
- //wb.Save(file);
- List<string> sheets = new List<string>();
- foreach (var item in wb.Worksheets)
- {
- sheets.Add(item.Name);
- }
- if (sheets.Count > 0)
- {
- sheets.RemoveAt(0);//不删除第一个sheet
- foreach (var item in sheets)
- {
- wb.Worksheets.RemoveAt(item);
- }
- }
- wb.Save(file);
- }
- /// <summary>
- /// 酒店预订
- /// 确认单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- //团组信息
- Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
- //酒店数据
- List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
- if (listhoteldata.Count < 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
- }
- //利datatable存储
- DataTable dt = new DataTable();
- dt.Columns.Add("CheckInDate", typeof(string));
- dt.Columns.Add("City", typeof(string));
- dt.Columns.Add("Hotel", typeof(string));
- dt.Columns.Add("Room", typeof(string));
- for (int i = 0; i < listhoteldata.Count; i++)
- {
- DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
- DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
- while (dayStart < dayEnd)
- {
- string temp = "";
- DataRow row = dt.NewRow();
- row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
- row["City"] = listhoteldata[i].City;
- row["Hotel"] = listhoteldata[i].HotelName;
- if (listhoteldata[i].SingleRoomCount > 0)
- {
- temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
- }
- if (listhoteldata[i].DoubleRoomCount > 0)
- {
- temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
- }
- if (listhoteldata[i].SuiteRoomCount > 0)
- {
- temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
- }
- if (listhoteldata[i].OtherRoomCount > 0)
- {
- temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
- }
- row["Room"] = temp;
- dt.Rows.Add(row);
- dayStart = dayStart.AddDays(1);
- }
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", di.TeamName);
- dic.Add("City", di.VisitCountry);
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //获取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 < dt.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dt.Rows[i]["CheckInDate"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dt.Rows[i]["City"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dt.Rows[i]["Hotel"].ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(dt.Rows[i]["Room"].ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > dt.Rows.Count + 1)
- {
- tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
- }
- string strFileName = di.TeamName + "酒店确认单.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
- return Ok(JsonView(true, "成功", url));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
- }
- }
- #endregion
- #region 团组状态
- /// <summary>
- /// 团组状态列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- return Ok(JsonView(true, "查询成功!", _DelegationList, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组状态
- /// 设置操作完成
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
- {
- Id = dto.Id,
- IsSure = 1
- };
- var result = await _sqlSugar.Updateable(_DelegationInfo)
- .UpdateColumns(it => new { it.IsSure })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "操作完成!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 保险费用录入
- /// <summary>
- /// 根据团组Id查询保险费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
- {
- Result groupData = await _customersRep.CustomersByDiId(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> CustomersById(CustomersByIdDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersById(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, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用录入页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersInitialize(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, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
- {
- Result groupData = await _customersRep.OpCustomers(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = "";
- if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
- await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- 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> UploadCus(IFormFile file)
- {
- try
- {
- 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();
- }
- 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> DelFileCus(DelFileDto dto)
- {
- try
- {
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- //int id = 0;
- filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
- // 删除该文件
- try
- {
- System.IO.File.Delete(filePath);
- var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception)
- {
- var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- 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> DelCustomers(DelBaseDto dto)
- {
- try
- {
- var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 接团客户名单 PageId 104
- /// <summary>
- /// 接团客户名单
- /// 迁移数据(慎用!)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListChange()
- {
- try
- {
- _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
- //var groupClinetData1
- string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
- var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
- int updateCount = 0;
- if (oldOAClientList.Count > 0)
- {
- _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
- _sqlSugar.BeginTran();
- var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
- var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
- foreach (var item in oldOAClientList)
- {
- int comId = 0;
- string format = "yyyy-MM-dd HH:mm:ss";
- string data11 = "1990-01-01 00:00";
- var data1 = IsValidDate(item.OPdate, format);
- if (data1) data11 = item.OPdate;
- //客户公司验证
- if (!string.IsNullOrEmpty(item.Company))
- {
- var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
- if (clientComInfo == null) // add
- {
- var addInfo = new Crm_CustomerCompany()
- {
- CompanyAbbreviation = "",
- CompanyFullName = item.Company,
- Address = "",
- PostCodes = "",
- LastedOpUserId = item.OPer,
- LastedOpDt = Convert.ToDateTime(data11),
- CreateUserId = item.OPer,
- CreateTime = Convert.ToDateTime(data11),
- IsDel = 0
- };
- var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
- if (comId1 > 0) comId = comId1;
- }
- else comId = clientComInfo.Id;
- }
- //客户人员验证
- int clientId = 0;
- string name = item.LastName + item.Name;
- if (!string.IsNullOrEmpty(name))
- {
- var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
- if (clientInfo == null)
- {
- DateTime? dateTime = null;
- var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
- if (isDt) dateTime = birthDayDt;
- var addInfo1 = new Crm_DeleClient()
- {
- CrmCompanyId = comId,
- DiId = -1,
- LastName = item.LastName,
- FirstName = item.Name,
- OldName = "",
- Pinyin = item.Pinyin,
- Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
- Marriage = 0,
- Phone = item.Phone,
- Job = item.Job,
- BirthDay = dateTime
- };
- var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
- if (clientId1 > 0) clientId = clientId1;
- }
- else clientId = clientInfo.Id;
- }
- if (clientId < 1)
- {
- continue;
- }
- int airType = 0;
- if (item.AirType == "超经舱") airType = 459;
- else if (item.AirType == "公务舱") airType = 458;
- else if (item.AirType == "经济舱") airType = 460;
- else if (item.AirType == "其他") airType = 565;
- else if (item.AirType == "头等舱") airType = 457;
- var _TourClientListEntity = new Grp_TourClientList()
- {
- DiId = item.Diid,
- ClientId = clientId,
- CreateUserId = item.OPer,
- CreateTime = Convert.ToDateTime(data11),
- Remark = item.Remark,
- IsDel = item.Isdel,
- ShippingSpaceTypeId = airType,
- ShippingSpaceSpecialNeeds = item.AirRemark,
- HotelSpecialNeeds = item.RoomType
- };
- var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
- if (_TourClientList > 0)
- {
- updateCount++;
- }
- }
- _sqlSugar.CommitTran();
- }
- return Ok(JsonView(true, $"更新条数:{updateCount}条"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- return Ok(JsonView(true));
- }
- private bool IsValidDate(string dateString, string format)
- {
- DateTime dateValue;
- bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
- return valid;
- }
- /// <summary>
- /// 接团客户名单
- /// 根据团组Id查询List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
- if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// 基础数据 Init
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
- }
- /// <summary>
- /// 接团客户名单
- /// 根据 Id查询 Details
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) //添加
- {
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- }
- else if (_dto.Id >= 0) //修改
- {
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- }
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddOrEdit(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// json字符串 AddMultiple(添加多个)
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
- {
- #region 参数验证
- string jsonLabel = _dto.JsonLabel;
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- #endregion
- #endregion
- var request = new TourClientListAddMultipleDto();
- request.DiId = _dto.DiId;
- request.UserId = _dto.UserId;
- if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
- if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
- List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
- if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
- var infos = new List<TourClientListInfo>();
- foreach (var data in datas)
- {
- (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
- string lastNameEn = CommonFun.ConvertToPinyin(lastName),
- firstNameEn = CommonFun.ConvertToPinyin(lastName);
- if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
- {
- continue;
- }
- infos.Add(new TourClientListInfo() {
- IsAccompany = 1,
- LastName = lastName,
- FirstName = firstName,
- Pinyin = lastNameEn + @"/" + firstNameEn,
- Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
- CompanyFullName = data.CompanyFullName,
- Job = data.Job
- });
- }
- if (infos.Any())
- {
- var viewData = await _tourClientListRep._AddMultiple(request);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 接团客户名单
- /// AddMultiple(添加多个)
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddMultiple(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// 文件下载 客户名单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
- List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
- if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
- if (_dto.Language == 1)
- {
- tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
- }
- //载入模板
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取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行
- if (_dto.Language == 0)
- {
- //循环赋值
- for (int i = 0; i < DcList.Count; i++)
- {
- EncryptionProcessor.DecryptProperties(DcList[i]);
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DcList[i].LastName + DcList[i].FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = DcList[i].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);
- string birthDay = DcList[i].BirthDay;
- string birthDayStr = string.Empty;
- if (!string.IsNullOrEmpty(birthDay))
- {
- birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
- }
- builder.Write(birthDayStr);
- builder.MoveToCell(0, i + 1, 3, 0);
- string company = "";
- if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
- {
- company = DcList[i].CompanyFullName.ToString();
- }
- builder.Write(company);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DcList[i].Job);
- }
- }
- else if (_dto.Language == 1)
- {
- List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
- List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
- List<string> transArrayStr = new List<string>();
- string transStrRes1 = "";
- for (int i = 0; i < DcList.Count; i++)
- {
- var dc = DcList[i];
- EncryptionProcessor.DecryptProperties(dc);
- if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
- if (dc.Job.Equals("暂无")) dc.Job = "-";
- string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
- if (DcList.Count - 1 == i) transStrRes1 += str1;
- else transStrRes1 += $"{str1}|";
- }
- //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
- string transStrRes = "";
- if (transStrRes1.Length > 0)
- {
- transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
- }
- //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
- //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
- //List<string> transArray = new List<string> { };
- List<TranslateInfo> transArray = new List<TranslateInfo>();
- if (transStrRes.Contains("|"))
- {
- string[] transArray1 = transStrRes.Split('|');
- if (transArray1.Length > 0)
- {
- foreach (var item in transArray1)
- {
- if (item.Contains("&"))
- {
- string[] transArray2 = item.Split('&');
- int index = 0;
- string companyName = "", job = "";
- if (transArray2.Length > 0)
- {
- bool success = int.TryParse(transArray2[0].Trim(), out index);
- if (1 < transArray2.Length) companyName = transArray2[1];
- if (2 < transArray2.Length) job = transArray2[2];
- }
- transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
- }
- }
- }
- }
- //循环赋值
- for (int i = 0; i < DcList.Count; i++)
- {
- string PYName = "";
- if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
- {
- string PY_Last = DcList[i].Pinyin.Split('/')[0];
- string PY_First = DcList[i].Pinyin.Split('/')[1];
- PYName = PY_First + " " + PY_Last;
- }
- else
- {
- string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
- string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
- PYName = PY_First + " " + PY_Last;
- }
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(PYName);
- string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(sex);
- DateTime birthDt;
- bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
- string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(birthday);
- string company = string.Empty, job = string.Empty;
- var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
- if (dcTransInfo != null)
- {
- company = dcTransInfo.CompanyName;
- job = dcTransInfo.Job;
- }
- if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
- {
- //查询对照表
- Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
- if (tempCec != null)
- {
- company = tempCec.enName;
- }
- //翻译
- else
- {
- }
- }
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(company);
- if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
- {
- //查询对照表
- Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
- if (tempPec != null)
- {
- job = tempPec.enName;
- }
- //翻译
- else
- {
- }
- }
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(job);
- }
- }
- //删除多余行
- while (tableOne.Rows.Count > DcList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DcList.Count + 1);
- }
- string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- private class TranslateInfo
- {
- public int Index { get; set; }
- public string CompanyName { get; set; }
- public string Job { get; set; }
- }
- #endregion
- #region 团组倒推表
- /// <summary>
- /// 倒推表基础数据
- /// Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInit()
- {
- var viewData = await _invertedListRep._Init();
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Create
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Update
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
- {
- var viewData = await _invertedListRep._Update(dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// File Download
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
- {
- var info2 = await _invertedListRep._Info(1, dto.DiId);
- if (info2.Code != 0)
- {
- return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
- }
- var info1 = info2.Data as InvertedListInfoView;
- var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
- string teamName = "";
- if (info != null) teamName = info.TeamName;
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("TeamName", teamName);
- dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
- dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
- dic.Add("BPRemark", info1.ApprovalDataRemark);
- dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
- dic.Add("SQRemark", info1.ApprovalRemark);
- dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
- dic.Add("CPJRemark", info1.IssueApprovalRemark);
- //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
- //dic.Add("HZRemark", info1.ApplyPassportRemark);
- dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
- dic.Add("QZRemark", info1.VisaInformationRemark);
- dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
- dic.Add("SQQZRemark", info1.SendVisaRemark);
- dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
- dic.Add("CQRemark", info1.IssueVisaRemark);
- dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
- dic.Add("XQHRemark", info1.PreTripMeetingRemark);
- dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
- dic.Add("SJRemark", info1.AirportdDropOffRemark);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{teamName}团出行准备流程表.doc";
- string filePath = fileDir + $@"InvertedList/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- #endregion
- #region 三公签证费用(签证费、代办费)
- /// <summary>
- /// 三公签证费用(签证费、代办费)
- /// List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
- {
- var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
- if (_view.Code != 0)
- {
- return Ok(JsonView(false, _view.Msg));
- }
- return Ok(JsonView(true, "操作成功!", _view.Data));
- }
- /// <summary>
- /// 三公签证费用(签证费、代办费)
- /// Add Or Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
- {
- var _view = await _visaFeeInfoRep._Update(_dto);
- if (_view.Code != 0)
- {
- return Ok(JsonView(false, _view.Msg));
- }
- return Ok(JsonView(true, _view.Msg));
- }
- #endregion
- #region 酒店询价
- /// <summary>
- /// 酒店询价
- /// Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryInit()
- {
- var res = await _hotelInquiryRep._Init();
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// page Item
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
- {
- var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- var view = res.Data as PageDataViewBase;
- return Ok(JsonView(true, res.Msg, view.Data, view.Total));
- }
- /// <summary>
- /// 酒店询价
- /// info
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
- {
- var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
- {
- var res = await _hotelInquiryRep._AddOrEdit(_dto);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
- {
- var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- #endregion
- #region 下载匹配op行程单
- /// <summary>
- /// 匹配op行程单
- /// Init
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
- {
- Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
- List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
- groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(it => it.IsDel == 0)
- .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
- .OrderByDescending(it => it.CreateUserId)
- .ToList();
- if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
- var country = groupInfos.Select(it => it.VisitCountry).ToList();
- var diids = groupInfos.Select(it => it.Id).ToList();
- List<string> countrys = new List<string>();
- foreach (var item in country)
- {
- var data = _groupRepository.FormartTeamName(item);
- var dataArray = _groupRepository.GroupSplitCountry(data);
- if (dataArray.Count > 0) countrys.AddRange(dataArray);
- }
- countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
- List<string> areaArray = new List<string>(); //GetGroupCityLine
- var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
- foreach (var item in areaItem)
- {
- string areaStr = item.Value;
- if (!string.IsNullOrEmpty(areaStr))
- {
- string[] str1 = areaStr.Split("-");
- if (str1.Length > 0)
- {
- areaArray.AddRange(str1);
- }
- }
- }
- if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
- var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
- .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
- .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
- .ToList();
- List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
- var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
- .Where(it => countriesIds.Contains(it.Id))
- .Select(it => new { it.Id, Name = it.Name_CN })
- .ToList();
- var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
- .Select(it => it.TeamName).ToList();
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
- }
- ///// <summary>
- ///// 匹配op行程单
- ///// Init 查询区域数据
- ///// </summary>
- ///// <param name="dto">团组列表请求dto</param>
- ///// <returns></returns>
- //[HttpPost]
- //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
- //{
- // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
- // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
- // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
- // if (string.IsNullOrEmpty(countriesDataStr))
- // {
- // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
- // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
- // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
- // }
- // else
- // {
- // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
- // }
- // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
- // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
- // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
- // List<dynamic> childList = new List<dynamic>();
- // int parentId = dto.CountriesId;
- // if (provinceData.Count > 1)
- // {
- // foreach (var item1 in provinceData)
- // {
- // List<dynamic> childList1 = new List<dynamic>();
- // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
- // foreach (var item2 in citiesData1)
- // {
- // List<dynamic> childList2 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList2.Add(new
- // {
- // id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN,
- // });
- // }
- // childList1.Add(new
- // {
- // id = item2.Id,
- // parentId = item1.Id,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList2
- // });
- // }
- // childList.Add(new
- // {
- // id = item1.Id,
- // parentId = parentId,
- // level = "province",
- // name = item1.Name_CN,
- // childList = childList1
- // });
- // }
- // //城市
- // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
- // foreach (var item2 in citiesData2)
- // {
- // List<dynamic> childList22 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList22.Add(new
- // {
- // id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN,
- // });
- // }
- // childList.Add(new
- // {
- // id = item2.Id,
- // parentId = parentId,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList22
- // });
- // }
- // }
- // else
- // {
- // foreach (var item2 in citiesData)
- // {
- // string cname = item2.Name_CN;
- // List<dynamic> childList1 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList1.Add(new
- // {
- // Id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN
- // });
- // }
- // childList.Add(new
- // {
- // id = item2.Id,
- // parentId = parentId,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList1
- // });
- // }
- // }
- // stopwatch.Stop();
- // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
- //}
- /// <summary>
- /// 匹配op行程单
- /// 接团信息列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
- {
- var swatch = new Stopwatch();
- swatch.Start();
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
- {
- var _view = await GeneralMethod.MateOpGroupPageListRedis();
- string sqlWhere = "";
- if (!string.IsNullOrEmpty(dto.Country))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
- }
- if (!string.IsNullOrEmpty(dto.Area))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
- }
- if (!string.IsNullOrEmpty(dto.TeamName))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
- }
- int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
- int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
- var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
- swatch.Stop();
- return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 匹配op行程单
- /// 行程单下载
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
- {
- var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
- return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
- }
- else
- {
- return Ok(JsonView(false, "下载失败!"));
- }
- }
- #endregion
- #region 国家信息 数据 注释
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
- //{
- // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
- // foreach (var item in dto)
- // {
- // infos.Add(new Grp_GroupsTaskAssignment()
- // {
- // DIId = item,
- // CTId = 82,
- // UId = 248,
- // IsEnable = 1,
- // CreateUserId = 233,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // });
- // infos.Add(new Grp_GroupsTaskAssignment()
- // {
- // DIId = item,
- // CTId = 82,
- // UId = 286,
- // IsEnable = 1,
- // CreateUserId = 233,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // });
- // }
- // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
- // return Ok("操作成功");
- //}
- //public class paramJsonDto
- //{
- // public List<CountriesInfo> str { get; set; }
- //}
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
- //{
- // //List<CountriesInfo> infos = new List<CountriesInfo>();
- // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
- // List<Sys_Cities> cities = new List<Sys_Cities>();
- // List<Sys_Cities> districts = new List<Sys_Cities>();
- // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
- // _sqlSugar.BeginTran();
- // int countitiesIndex = 0;
- // foreach (var item in dto.str)
- // {
- // dynamic data = item.c;
- // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
- // if (data != null)
- // {
- // countitiesIndex++;
- // foreach (var item1 in data)
- // {
- // string cnname = item1.cn;
- // string enname = item1.en;
- // Sys_Cities provinceInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = cnname,
- // Name_EN = enname,
- // ParentId = 0,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // if (item1.lv == "province") //省份
- // {
- // provinceInfo.Level = 1;
- // int provinceId = 0;
- // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
- // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
- // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
- // var data1 = item1.c;
- // foreach (var item2 in data1)
- // {
- // if (item2.lv == "city")
- // {
- // string citycnname = item2.cn;
- // string cityenname = item2.en;
- // Sys_Cities cityInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // ParentId = provinceId,
- // Level = 2,
- // Name_CN = citycnname,
- // Name_EN = cityenname,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // if (item2.c != null)
- // {
- // int cityId = 0;
- // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
- // if (citiesInfo != null) cityId = citiesInfo.Id;
- // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
- // foreach (var item3 in item2.c)
- // {
- // if (item3.lv == "district")
- // {
- // var districtInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = item3.cn,
- // Name_EN = item3.en,
- // Level = 3,
- // ParentId = cityId,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
- // //{
- // districts.Add(districtInfo);
- // //}
- // }
- // }
- // }
- // else
- // {
- // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
- // //{
- // cities.Add(cityInfo);
- // //}
- // }
- // }
- // }
- // }
- // else if (item1.lv == "city")//城市
- // {
- // provinceInfo.Level = 2;
- // if (item1.c != null)
- // {
- // int cityId = 0;
- // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
- // if (citiesInfo != null) cityId = citiesInfo.Id;
- // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
- // foreach (var item3 in item1.c)
- // {
- // if (item3.lv == "district")
- // {
- // var districtInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = item3.cn,
- // Name_EN = item3.en,
- // Level = 3,
- // ParentId = cityId,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
- // //{
- // districts.Add(districtInfo);
- // //}
- // }
- // }
- // }
- // else
- // {
- // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
- // //{
- // cities.Add(provinceInfo);
- // //}
- // }
- // }
- // }
- // }
- // }
- // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
- // cities = cities.Distinct().ToList();
- // districts = districts.Distinct().ToList();
- // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
- // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
- // cities.AddRange(districts);
- // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
- // //_sqlSugar.RollbackTran();
- // _sqlSugar.CommitTran();
- // return Ok(JsonView(false, "操作成功!"));
- //}
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
- //{
- // List<CountitiesInfo> infos = dto.MyProperty;
- // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
- // _sqlSugar.BeginTran();
- // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
- // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
- // foreach (var item in infos)
- // {
- // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
- // if (countryInfo != null)
- // {
- // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
- // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
- // if (cityInfo1 != null)
- // {
- // cityInfo1.IsCapital = 0;
- // cityInfos.Add(cityInfo1);
- // }
- // }
- // }
- // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
- // .UpdateColumns(it => it.IsCapital)
- // .WhereColumns(it => it.Id)
- // .ExecuteCommand();
- // //_sqlSugar.RollbackTran();
- // _sqlSugar.CommitTran();
- // return Ok(JsonView(false, "操作成功!"));
- //}
- //public class CounrtiesDto
- //{
- // public List<CountitiesInfo> MyProperty { get; set; }
- //}
- //public class CountitiesInfo
- //{
- // /// <summary>
- // /// 圣约翰
- // /// </summary>
- // public string capital_name_chinese { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string capital_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_type { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese_short { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese_UN { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_abbreviation { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_formal { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_UN { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string continent_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string subregion_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_code2 { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_code3 { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string phone_code { get; set; }
- //}
- //public class CountriesInfo : BasicInfo
- //{
- // public List<CitiesInfo> c { get; set; }
- //}
- //public class CitiesInfo : BasicInfo
- //{
- // public List<AreaInfo> c { get; set; }
- //}
- //public class AreaInfo : BasicInfo
- //{
- // public List<AreaInfo> c { get; set; }
- //}
- //public class BasicInfo
- //{
- // public string code { get; set; }
- // public string cn { get; set; }
- // public string lv { get; set; }
- // public string en { get; set; }
- //}
- #endregion
- #region 查看邀请方
- /// <summary>
- /// 查看邀请方
- /// 邀请方信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
- {
- string sqlWhere = string.Empty;
- if (!string.IsNullOrEmpty(dto.Search))
- {
- sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
- }
- string sql = string.Format($@"Select
- ROW_NUMBER() Over(Order By Id desc) As Row_Number,
- Id,
- UnitName
- From Res_InvitationOfficialActivityData
- Where IsDel = 0
- And (UnitName != '' Or UnitName != null) {sqlWhere}");
- RefAsync<int> total = 0;
- var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, _views, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 国家信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
- {
- var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
- var country = groupInfos.Select(it => it.VisitCountry).ToList();
- var diids = groupInfos.Select(it => it.Id).ToList();
- List<string> countrys = new List<string>();
- foreach (var item in country)
- {
- var data = _groupRepository.FormartTeamName(item);
- var dataArray = _groupRepository.GroupSplitCountry(data);
- if (dataArray.Count > 0) countrys.AddRange(dataArray);
- }
- countrys = countrys.Distinct().ToList();
- for (int i = 0; i < countrys.Count; i++)
- {
- string item = countrys[i];
- if (string.IsNullOrEmpty(item) || item.Contains("-"))
- {
- countrys.Remove(item);
- i--;
- }
- }
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
- .Where(it => countrys.Contains(it.Name_CN))
- .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
- .Select(it => new { id = it.Id, name = it.Name_CN })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 城市信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
- {
- if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
- .Where(it => it.CountriesId == dto.CountiesId)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
- .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
- .Select(it => new { id = it.Id, name = it.Name_CN })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 团组名称 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
- .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
- .Where((oa, di) => oa.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
- .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
- .Select((oa, di) => new { id = di.Id, name = di.TeamName })
- .Distinct()
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 团组 & 邀请方信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
- .AS("Grp_DelegationInfo")
- .Includes(x => x.InvitingInfos)
- .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
- .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
- .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
- .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
- .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
- .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
- var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
- infos.ForEach(x =>
- {
- x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
- x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
- x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
- x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
- });
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
- }
- #endregion
- #region 报批行程
- /// <summary>
- /// 报批行程初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
- {
- const int chiNumber = 5;
- var jw = JsonView(false);
- var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
- var group = groupList.First();
- var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
- group = groupList.First(x => x.Id == diid);
- if (group == null)
- {
- jw.Msg = "暂无团组!";
- return Ok(jw);
- }
- var data = new
- {
- groupList = groupList.Select(x => new
- {
- x.TeamName,
- x.Id
- }),
- content = new ArrayList(),
- groupInfo = new
- {
- group.VisitDays,
- group.TourCode,
- group.VisitPNumber,
- group.TeamName,
- group.Id,
- visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
- visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
- },
- };
- var resultArr = new ArrayList();
- var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
- if (content.Count == 0)
- {
- var stay = "-";
- var cityPath = "-";
- //添加城市路径以及住宿地
- //黑屏代码数据
- DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
- if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
- {
- jw = JsonView(true, "黑屏代码有误!", data);
- return Ok(jw);
- }
- foreach (DataRow row in dtBlack.Rows)
- {
- if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- {
- jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
- return Ok(jw);
- }
- }
- //黑屏代码获取时间区间
- var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
- string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- _sqlSugar.BeginTran();
- for (int i = 0; i < timeArr.Count; i++)
- {
- stay = "-";
- cityPath = "-";
- DateTime NewData = DateTime.Parse(timeArr[i]);
- string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
- Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
- var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
- if (tbSelect.Length > 0)
- {
- List<string> threeCodeStr = new List<string>();
- foreach (var item in tbSelect)
- {
- var threeCode = item["Three"].ToString() ?? "";
- if (threeCode.Length == 6)
- {
- var start = threeCode.Substring(0, 3);
- var end = threeCode.Substring(3, 3);
- if (threeCodeStr.Count == 0)
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- else
- {
- if (threeCodeStr[threeCodeStr.Count - 1] == start)
- {
- threeCodeStr.Add(end);
- }
- else
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- }
- }
- }
- var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
- var last = threeCodeStr.Last();
- foreach (var item in threeCodeStr)
- {
- cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
- if (item.Equals(last))
- {
- stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
- }
- }
- cityPath = cityPath.Trim('-');
- }
- appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
- appro.Diid = diid ?? -1;
- var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
- appro.Id = thisId;
- appro.CreateUserId = dto.UserId;
- appro.CreateTime = DateTime.Now;
- content.Add(appro);
- }
- _sqlSugar.CommitTran();
- }
- foreach (var x in content)
- {
- var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
- if (chiList.Count < chiNumber)
- {
- for (int i = chiList.Count; i < chiNumber; i++)
- {
- chiList.Add(new Grp_ApprovalTravelDetails());
- }
- }
- resultArr.Add(new
- {
- x.Id,
- x.Date,
- x.Diid,
- chiList = chiList.Select(x1 => new
- {
- timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
- x1.Details,
- x1.ParentId,
- x1.Id
- })
- });
- }
- data = data with
- {
- content = resultArr,
- };
- jw = JsonView(true, "获取成功!", data);
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "团组参数有误!";
- return Ok(jw);
- }
- try
- {
- _sqlSugar.BeginTran();
- var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.uesrId,
- IsDel = 1
- }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.uesrId,
- IsDel = 1
- }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
- _sqlSugar.CommitTran();
- jw = JsonView(true, "删除成功");
- }
- catch (Exception ex)
- {
- jw = JsonView(false, ex.Message);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
- {
- var jw = JsonView(false);
- var Find = dto.Arr.Find(x => x.id == 0);
- if (Find != null)
- {
- jw.Msg = "生成的ID为0!";
- return Ok(jw);
- }
- foreach (var item in dto.Arr)
- {
- foreach (var chi in item.chiList)
- {
- if (chi.parentId == 0)
- {
- chi.parentId = item.id;
- }
- }
- }
- var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
- _sqlSugar.BeginTran();
- if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
- {
- var parentIds = dto.Arr.Select(x => x.id).ToList();
- _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.UserId,
- IsDel = 1
- }).ExecuteCommand();
- }
- try
- {
- _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Details = x.details,
- ParentId = x.parentId,
- Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
- Remark = "",
- IsDel = 0
- }).ToList()).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
- {
- Id = x.id,
- Details = x.details,
- ParentId = x.parentId,
- Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
- }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
- {
- Details = x.Details,
- ParentId = x.ParentId,
- Time = x.Time
- }).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
- {
- Id = x.id,
- Date = x.date,
- }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
- {
- Date = x.Date
- }).ExecuteCommand();
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!");
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false, "保存失败!" + ex.Message);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程生成
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "暂无该团组!";
- return Ok(jw);
- }
- //黑屏代码数据
- DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
- if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
- {
- jw.Msg = "黑屏代码有误!";
- return Ok(jw);
- }
- foreach (DataRow row in dtBlack.Rows)
- {
- if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- {
- jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
- return Ok(jw);
- }
- }
- var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
- var resultArr = new ArrayList();
- if (officialActivitiesArr.Count == 0)
- {
- jw.Msg = "暂无公务出访信息!";
- return Ok(jw);
- }
- try
- {
- _sqlSugar.BeginTran();
- DeleteApprovalJourney(new
- Domain.Dtos.Groups.DeleteApprovalJourney
- {
- Diid = dto.Diid,
- uesrId = dto.Userid
- });
- var stay = "-";
- var cityPath = "-";
- //添加城市路径以及住宿地
- //黑屏代码获取时间区间
- var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
- var empty = "【未收入该三字码!请机票同事录入】";
- string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- for (int i = 0; i < timeArr.Count; i++)
- {
- stay = "-";
- cityPath = "-";
- var chiarr = new List<Grp_ApprovalTravelDetails>();
- DateTime NewData = DateTime.Parse(timeArr[i]);
- var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
- var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
- if (tbSelect.Length > 0)
- {
- List<string> threeCodeStr = new List<string>();
- bool isTrade = false;
- string trip = string.Empty;
- var rowLast = tbSelect.Last();
- var rowFirst = tbSelect.First();
- var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
- var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
- var takeOffTime = DateTime.Parse(timeArr[i]);
- var fallToTime = DateTime.Parse(timeArr[i]);
- takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
- takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
- fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
- fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
- foreach (var item in tbSelect)
- {
- var start = string.Empty;
- var end = string.Empty;
- var threeCode = item["Three"].ToString() ?? "";
- if (threeCode.Length == 6)
- {
- start = threeCode.Substring(0, 3);
- end = threeCode.Substring(3, 3);
- if (threeCodeStr.Count == 0)
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- else
- {
- if (threeCodeStr[threeCodeStr.Count - 1] == start)
- {
- threeCodeStr.Add(end);
- }
- else
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- }
- }
- //处理机票信息
- var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
- var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
- if (start_Object == null)
- {
- start_Object = new Res_ThreeCode()
- {
- AirPort = empty,
- AirPort_En = empty,
- City = empty,
- Country = empty,
- Four = empty,
- Three = empty,
- };
- }
- if (end_Object == null)
- {
- end_Object = new Res_ThreeCode()
- {
- AirPort = empty,
- AirPort_En = empty,
- City = empty,
- Country = empty,
- Four = empty,
- Three = empty,
- };
- }
- //机型判断
- string airModel = item["AirModel"].ToString();
- airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
- string flightTime = item["FlightTime"].ToString();
- if (flightTime!.Contains(":"))
- {
- flightTime = flightTime.Replace(":", "小时");
- flightTime += "分钟";
- }
- if (flightTime.Contains("H"))
- {
- flightTime = flightTime.Replace("H", "小时");
- }
- if (flightTime.Contains("M"))
- {
- flightTime = flightTime.Replace("M", "分钟");
- }
- IFormatProvider ifp = new CultureInfo("zh-CN", true);
- if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
- {
- flightTime = flightDataTime.Hour > 0
- ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
- ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
- ? flightDataTime.Minute.ToString() + "分钟" : "";
- }
- //航班号
- string flightcode = item["Fliagtcode"].ToString();
- var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
- var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
- if (aircompany == null)
- {
- aircompany = new Res_AirCompany
- {
- CnName = hsEmpty,
- EnName = hsEmpty,
- ShortCode = hsEmpty,
- };
- }
- //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
- trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
- isTrade = Convert.ToBoolean(item["isTransitShipment"]);
- if (isTrade)
- {
- trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
- }
- else
- {
- trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
- }
- }
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = trip
- });
- var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
- var last = threeCodeStr.Last();
- foreach (var item in threeCodeStr)
- {
- cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
- if (item.Equals(last))
- {
- stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
- }
- }
- cityPath = cityPath.Trim('-');
- }
- string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
- Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
- appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
- appro.Diid = dto.Diid;
- var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
- appro.Id = thisId;
- appro.CreateUserId = dto.Userid;
- appro.CreateTime = DateTime.Now;
- foreach (var item in gwinfo)
- {
- Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
- chi.Details = "拜访" + item.Client;
- if (!string.IsNullOrWhiteSpace(item.ReqSample))
- {
- chi.Details += "," + item.ReqSample;
- }
- chi.ParentId = thisId;
- chi.Time = item.Time;
- chiarr.Add(chi);
- }
- if (chiarr.Count < 5)
- {
- for (int j = chiarr.Count; j < 5; j++)
- {
- chiarr.Add(new
- Grp_ApprovalTravelDetails());
- }
- }
- resultArr.Add(new
- {
- appro.Id,
- appro.Date,
- appro.Diid,
- chiList = chiarr.Select(x1 => new
- {
- timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
- x1.Details,
- x1.ParentId,
- x1.Id
- })
- });
- }
- _sqlSugar.CommitTran();
- jw = JsonView(true, "生成成功!", resultArr);
- }
- catch (Exception ex)
- {
- jw.Code = 400;
- jw.Msg = "生成失败!" + ex.Message;
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程word导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "暂无该团组!";
- return Ok(jw);
- }
- //模板路径
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
- //载入模板
- Document doc = new Document(tempPath);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- Aspose.Words.Tables.Row titleRowClone = null;
- Aspose.Words.Tables.Row CenterRowClone = null;
- int index = 0;
- int indexChi = 0;
- int SetIndex = 0;
- var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
- //获取数据,放到datatable
- foreach (var item in ApprovalTravelArr)
- {
- if (index > 0)
- {
- titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
- tableOne.AppendChild(titleRowClone);
- }
- var textTime = item.Date;
- var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
- SetCells(tableOne, doc, SetIndex, 0, textTime);
- SetIndex++;
- if (ChiRep.Count > 0)
- {
- foreach (var itemChi in ChiRep)
- {
- var txtTime = itemChi.Time;
- var txtDetail = itemChi.Details;
- if (indexChi > 0)
- {
- CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- tableOne.AppendChild(CenterRowClone);
- }
- if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
- {
- SetCells(tableOne, doc, SetIndex, 0, "");
- SetCells(tableOne, doc, SetIndex, 1, "");
- indexChi++;
- SetIndex++;
- break;
- }
- SetCells(tableOne, doc, SetIndex, 0, txtTime);
- SetCells(tableOne, doc, SetIndex, 1, txtDetail);
- indexChi++;
- SetIndex++;
- }
- }
- else
- {
- if (indexChi > 0)
- {
- CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- tableOne.AppendChild(CenterRowClone);
- }
- SetCells(tableOne, doc, SetIndex, 0, "");
- SetCells(tableOne, doc, SetIndex, 1, "");
- indexChi++;
- SetIndex++;
- }
- index++;
- }
- string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- jw.Code = 200;
- jw.Msg = "";
- return Ok(jw);
- }
- private string intToString(int numberVal)
- {
- string numberval = numberVal.ToString();
- Dictionary<char, string> Number = new Dictionary<char, string>();
- Number.Add('1', "一");
- Number.Add('2', "二");
- Number.Add('3', "三");
- Number.Add('4', "四");
- Number.Add('5', "五");
- Number.Add('6', "六");
- Number.Add('7', "七");
- Number.Add('8', "八");
- Number.Add('9', "九");
- string stringNumberVal = string.Empty;
- for (int i = 0; i < numberval.Length; i++)
- {
- if (i == 0)
- {
- stringNumberVal += Number[numberval[i]];
- }
- else if (i >= 1)
- {
- if (numberval[i] == '0')
- {
- stringNumberVal = "十";
- }
- else
- {
- stringNumberVal += "十" + Number[numberval[i]];
- }
- }
- }
- return stringNumberVal;
- }
- private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
- {
- //获取table中的某个单元格,从0开始
- Cell lshCell = table.Rows[rows].Cells[cells];
- //将单元格中段落移除
- foreach (Node item in lshCell.Paragraphs)
- {
- lshCell.Paragraphs.Remove(item);
- }
- if (val.Contains("\r\n"))
- {
- var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
- foreach (var item in spArr)
- {
- //新建一个段落
- Paragraph p = new Paragraph(doc);
- var r = new Run(doc, item);
- //把设置的值赋给之前新建的段落
- p.AppendChild(r);
- //将此段落加到单元格内
- lshCell.AppendChild(p);
- }
- }
- else
- {
- //新建一个段落
- Paragraph p = new Paragraph(doc);
- var r = new Run(doc, val);
- //把设置的值赋给之前新建的段落
- p.AppendChild(r);
- //将此段落加到单元格内
- lshCell.AppendChild(p);
- }
- }
- [HttpPost]
- public async Task<IActionResult> ServerHttp(string paramStr)
- {
- paramStr = paramStr.TrimEnd('\'');
- paramStr = paramStr.TrimStart('\'');
- JsonView jw = JsonView(false);
- JObject param = JObject.Parse(paramStr);
- if (!param.ContainsKey("url"))
- {
- jw.Msg = "url null";
- return Ok(jw);
- }
- string url = param["url"]!.ToString();
- var methon = "get";
- Dictionary<string, string> headValues = null;
- string bodyStr = string.Empty;
- if (param.ContainsKey("methon"))
- {
- methon = param["methon"]!.ToString().ToLower();
- }
- if (param.ContainsKey("header"))
- {
- var header = param["header"]!.ToString();
- JObject headerJobject = JObject.Parse(header);
- headValues = new Dictionary<string, string>();
- foreach (JProperty item in headerJobject.Properties())
- {
- var value = item.Value.ToString();
- var head = item.Path;
- headValues.Add(head, value);
- }
- }
- HttpClient client = new HttpClient();
- string responseString = string.Empty;
- StringContent content = null;
- if (headValues != null)
- {
- foreach (var item in headValues.Keys)
- {
- if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
- {
- if (param.ContainsKey("body"))
- {
- bodyStr = param["body"]!.ToString();
- }
- content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
- }
- else
- {
- client.DefaultRequestHeaders.Add(item, headValues[item]);
- }
- }
- }
- try
- {
- if (methon == "get")
- {
- responseString = await client.GetStringAsync(url);
- }
- else if (methon == "post")
- {
- var request = new HttpRequestMessage(HttpMethod.Post, url)
- {
- Content = content
- };
- var response = await client.SendAsync(request);
- try
- {
- Stream responseStream = await response.Content.ReadAsStreamAsync();
- using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
- {
- using (StreamReader reader = new StreamReader(gzipStream))
- {
- responseString = await reader.ReadToEndAsync();
- }
- }
- }
- catch (Exception)
- {
- responseString = await response.Content.ReadAsStringAsync();
- }
- }
- else
- {
- responseString = "methon error";
- }
- jw = JsonView(true, "success", responseString);
- }
- catch (Exception ex)
- {
- jw.Msg = "error " + ex.Message;
- jw.Data = ex.StackTrace;
- }
- finally
- {
- client.Dispose();
- }
- return Ok(jw);
- }
- #endregion
- #region 团组接待意见调查
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 基础数据(团组)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireInit()
- {
- var groupData = await _groupRepository.Query(x => x.IsDel == 0)
- .Select(x => new
- {
- x.Id,
- GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
- })
- .OrderByDescending(x => x.Id)
- .ToListAsync();
- return Ok(JsonView(groupData, groupData.Count));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 列表
- /// </summary>
- /// <param name="groupId"></param>
- /// <returns></returns>
- [HttpGet("{groupId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageList(int groupId)
- {
- if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
- var data = await _opinionaireRep.Query(x => x.DiId == groupId)
- .Select(x => new
- {
- x.Id,
- x.TourGuideName,
- x.CityName,
- CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
- x.CreateTime
- })
- .OrderBy(x => x.Id)
- .ToListAsync();
- return Ok(JsonView(data));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
- {
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
- if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
- var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
- var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
- _opinionaireRep.BeginTran();
- if (addData != null && addData.Count > 0)
- {
- foreach (var item in addData)
- {
- item.CreateUserId = currUserInfo.UserId;
- item.DiId = dto.DiId;
- }
- var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
- }
- if (updData != null && updData.Count > 0)
- {
- var upd = await _opinionaireRep._sqlSugar
- .Updateable(updData)
- .UpdateColumns(x => new { x.CityName, x.TourGuideName })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- }
- _opinionaireRep.CommitTran();
- return Ok(JsonView("操作成功!"));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageDel(int id)
- {
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- if (id < 1) Ok(JsonView(false, "请传入有效的id"));
- var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
- if (!del) return Ok(JsonView("操作失败!"));
- return Ok(JsonView("操作成功!"));
- }
- /// <summary>
- /// 团组接待意见调查 - 用户
- /// 列表
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{diId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireUserList(int diId)
- {
- if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
- var sql = string.Format(@"
- SELECT
- o.Id,
- o.DiId,
- di.TeamName AS 'GroupName',
- di.VisitPNumber AS 'PeopleNumber',
- di.ClientName AS 'LeadGroup',
- di.VisitCountry AS 'Travel',
- di.VisitDays AS 'Days',
- o.CityName,
- o.TourGuideName,
- o.Catering,
- o.CateringReason,
- o.Stay,
- o.StayReason,
- o.[Route],
- o.RouteReason,
- o.OfficialActivity,
- o.OfficialActivityReason,
- o.TourGuide,
- o.TourGuideReason,
- o.[Translate],
- o.TranslateReason,
- o.Trip,
- o.TripReason,
- o.ESFileName,
- o.SignatureDate,
- o.Remark
- FROM
- Grp_Opinionaire o
- LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
- WHERE
- o.IsDel = 0
- AND o.DiId = {0}
- ORDER BY
- o.Id ASC", diId);
- var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
- if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
- return Ok(JsonView(data));
- }
- /// <summary>
- /// 团组接待意见调查 - 用户
- /// 保存
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
- {
- if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
- foreach (var item in dto)
- {
- if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
- if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
- if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
- if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
- if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
- if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
- if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
- if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
- }
- var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
- if (!Directory.Exists(filePathBase))
- {
- Directory.CreateDirectory(filePathBase);
- }
- #region 上传文件
- var filePaths = new List<string>();
- foreach (var item in dto)
- {
- var file = item.File;
- // 将文件保存到指定位置
- var filePath = Path.Combine(filePathBase, file.FileName);
- using (var stream = new FileStream(filePath, FileMode.Create))
- {
- await file.CopyToAsync(stream);
- }
- //验证文件是否上传成功
- if (!System.IO.File.Exists(filePath))
- {
- foreach (var filePathStr in filePaths)
- {
- System.IO.File.Delete(filePathStr);
- }
- return Ok(JsonView(false, "文件上传失败!"));
- }
- item.ESFileName = file.FileName;
- }
- #endregion
- var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
- var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
- .UpdateColumns(x => new
- {
- x.Catering,
- x.CateringReason,
- x.Stay,
- x.StayReason,
- x.Route,
- x.RouteReason,
- x.OfficialActivity,
- x.OfficialActivityReason,
- x.TourGuide,
- x.TourGuideReason,
- x.Translate,
- x.TranslateReason,
- x.Trip,
- x.TripReason,
- x.ESFileName,
- x.SignatureDate,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1)
- {
- foreach (var filePathStr in filePaths)
- {
- System.IO.File.Delete(filePathStr);
- }
- return Ok(JsonView(false));
- }
- return Ok(JsonView(true));
- }
- #endregion
- #region 团组餐厅相关信息
- /// <summary>
- /// 团组相关餐厅信息
- /// 基础数据(团组)
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantInit()
- {
- return Ok(await _restaurantRep.InitAsync());
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Item
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
- {
- int portType = dto.PortType,
- groupId = dto.GroupId;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- return Ok(await _restaurantRep.ItemAsync(portType,groupId));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
- {
- int portType = dto.PortType,
- groupId = dto.GroupId;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var sql = string.Format(@" SELECT
- ri.Id,
- ri.GroupId,
- ri.Date,
- ri.StartTime,
- ri.EndTime,
- CASE WHEN ri.Type = 1 THEN '早餐'
- WHEN ri.Type = 2 THEN '午餐'
- WHEN ri.Type = 3 THEN '晚餐'
- ELSE '其他'
- END AS 'Type',
- ri.Name,
- ri.Address,
- ri.Tel,
- ri.Remark,
- ri.CreateTime,
- u.CnName AS CreateUserName
- FROM
- Grp_RestaurantInfo ri
- LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
- WHERE
- ri.IsDel = 0
- AND ri.GroupId = {0}
- ORDER BY
- ri.Date ASC
- ", groupId);
- var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
- if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
- return Ok(JsonView(infos));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
- {
- int portType = dto.PortType,
- id = dto.Id;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- return Ok(await _restaurantRep.InfoAsync(portType, id));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Op
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
- return Ok(await _restaurantRep.OpAsync(dto));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Del
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
- {
- int userId = dto.DeleteUserId;
- var id = dto.Id;
- if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- return Ok(await _restaurantRep.DelAsync(dto));
- }
- #endregion
- // /// <summary>
- // ///
- // /// </summary>
- // /// <param name="_dto"></param>
- // /// <returns></returns>
- // [HttpPost]
- // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
- // {
- // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
- // string sql = string.Format(@" Select * From Visa With(Nolock) ");
- // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
- // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
- // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
- // dic_psg.Add("客人", 974);
- // dic_psg.Add("司机", 975);
- // dic_psg.Add("导游", 976);
- // dic_psg.Add("公司内部人员", 977);
- // dic_psg.Add("司机/导游/公司内部人员", 978);
- // foreach (var item in list_visa)
- // {
- // Grp_VisaInfo temp = new Grp_VisaInfo();
- // temp.Id = item.Id;
- // temp.DIId = item.DIId;
- // temp.VisaClient = item.VisaClient;
- // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
- // temp.VisaCurrency = item.VisaCurrency;
- // temp.IsThird = item.IsThird;
- // if (dic_psg.ContainsKey(item.PassengerType))
- // {
- // temp.PassengerType = dic_psg[item.PassengerType];
- // }
- // else {
- // temp.PassengerType = -1;
- // }
- // temp.VisaNumber = item.VisaNumber;
- // temp.VisaFreeNumber = item.VisaFreeNumber;
- // temp.CreateUserId = item.Operators;
- // DateTime dt_ct;
- // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
- // if (b_ct)
- // {
- // temp.CreateTime = dt_ct;
- // }
- // else
- // {
- // temp.CreateTime = DateTime.Now;
- // }
- // temp.DeleteTime = "";
- // temp.DeleteUserId = 0;
- // temp.Remark = item.Remark;
- // if (string.IsNullOrEmpty(temp.Remark)) {
- // temp.Remark = "";
- // }
- // temp.IsDel = item.IsDel;
- // temp.VisaDescription = item.VisaAttachment;
- // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
- //([Id]
- // ,[DIId]
- // ,[VisaClient]
- // ,[VisaPrice]
- // ,[VisaCurrency]
- // ,[IsThird]
- // ,[PassengerType]
- // ,[VisaNumber]
- // ,[VisaFreeNumber]
- // ,[CreateUserId]
- // ,[CreateTime]
- // ,[DeleteTime]
- // ,[DeleteUserId]
- // ,[Remark]
- // ,[IsDel]
- // ,[visaDescription])
- // VALUES
- // ({0},{1},'{2}',{3},{4}
- //,{5},{6},{7},{8},{9}
- //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
- //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
- //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
- //);
- // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
- // }
- // return Ok(JsonView(true, "操作成功!"));
- // }
- /// <summary>
- /// 123132123
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
- {
- _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
- string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
- List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
- _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
- Dictionary<int, int> dicDetail = new Dictionary<int, int>();
- dicDetail.Add(789, 1034);
- dicDetail.Add(790, 1035);
- dicDetail.Add(791, 1036);
- dicDetail.Add(792, 1037);
- dicDetail.Add(793, 1038);
- dicDetail.Add(794, 1039);
- dicDetail.Add(795, 1040);
- dicDetail.Add(796, 1041);
- dicDetail.Add(797, 1042);
- dicDetail.Add(798, 1043);
- dicDetail.Add(801, 1044);
- dicDetail.Add(802, 1045);
- dicDetail.Add(803, 1046);
- Dictionary<int, int> dic = new Dictionary<int, int>();
- dic.Add(806, 1027);
- dic.Add(807, 1028);
- dic.Add(808, 1029);
- dic.Add(809, 1030);
- dic.Add(810, 1031);
- dic.Add(811, 1032);
- dic.Add(812, 1033);
- foreach (var item in list_visa)
- {
- Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
- temp.Coefficient = item.coefficient;
- DateTime dtCrt;
- bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
- if (b1)
- {
- temp.CreateTime = dtCrt;
- }
- else
- {
- temp.CreateTime = DateTime.Now;
- }
- temp.CreateUserId = item.Operators;
- temp.DeleteTime = "";
- temp.DeleteUserId = 0;
- temp.DiId = int.Parse(item.DIID);
- temp.FilePath = item.FilePath;
- temp.IsDel = item.IsDel;
- temp.Price = item.Price;
- temp.PriceCount = 1;
- temp.PriceCurrency = item.Currency;
- int detailId = 0;
- if (dicDetail.ContainsKey(item.PriceTypeDetail))
- {
- detailId = dicDetail[item.PriceTypeDetail];
- }
- temp.PriceDetailType = detailId;
- temp.PriceDt = DateTime.Now;
- temp.PriceName = item.PriceName;
- temp.PriceSum = item.Price;
- int tid = 0;
- if (dic.ContainsKey(item.PriceType))
- {
- tid = dic[item.PriceType];
- }
- temp.PriceType = tid;
- temp.Remark = item.Remark;
- await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- [HttpPost]
- public IActionResult TimeTest()
- {
- var jw = JsonView(false, "error");
- _sqlSugar.BeginTran();
- try
- {
- var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
- .Select(x => new Crm_NewClientData
- {
- Id = x.Id,
- Client = x.Client,
- Contact = x.Contact,
- Location = x.Location,
- })
- .ToList();
- var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
- _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
- Stopwatch stopwatch = new Stopwatch();
- // 开始计时
- stopwatch.Start();
- foreach (var item in clientList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- stopwatch.Stop();
- jw.Code = 200;
- jw.Data = stopwatch.ElapsedMilliseconds;
- jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
- }
- catch (Exception ex)
- {
- jw.Code = 400;
- jw.Msg = ex.Message;
- }
- return Ok(jw);
- }
- }
- }
|