GroupsController.cs 613 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. namespace OASystem.API.Controllers
  92. {
  93. /// <summary>
  94. /// 团组相关
  95. /// </summary>
  96. //[Authorize]
  97. [Route("api/[controller]/[action]")]
  98. public class GroupsController : ControllerBase
  99. {
  100. private readonly GrpScheduleRepository _grpScheduleRep;
  101. private readonly IMapper _mapper;
  102. private readonly DelegationInfoRepository _groupRepository;
  103. private readonly TaskAssignmentRepository _taskAssignmentRep;
  104. private readonly AirTicketResRepository _airTicketResRep;
  105. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  106. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  107. private readonly DelegationEnDataRepository _delegationEnDataRep;
  108. private readonly DelegationVisaRepository _delegationVisaRep;
  109. private readonly VisaPriceRepository _visaPriceRep;
  110. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  111. private readonly HotelPriceRepository _hotelPriceRep;
  112. private readonly CustomersRepository _customersRep;
  113. private readonly MessageRepository _message;
  114. private readonly SqlSugarClient _sqlSugar;
  115. private readonly TourClientListRepository _tourClientListRep;
  116. private readonly TeamRateRepository _teamRateRep;
  117. #region 成本相关
  118. private readonly CheckBoxsRepository _checkBoxs;
  119. private readonly GroupCostRepository _GroupCostRepository;
  120. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  121. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  122. #endregion
  123. private readonly SetDataRepository _setDataRep;
  124. private string url;
  125. private string path;
  126. private readonly EnterExitCostRepository _enterExitCostRep;
  127. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  128. private readonly UsersRepository _usersRep;
  129. private readonly IJuHeApiService _juHeApi;
  130. private readonly InvertedListRepository _invertedListRep;
  131. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  132. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  133. private readonly HotelInquiryRepository _hotelInquiryRep;
  134. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  135. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  136. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  137. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  138. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  139. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  140. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  141. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  142. {
  143. _mapper = mapper;
  144. _grpScheduleRep = grpScheduleRep;
  145. _groupRepository = groupRepository;
  146. _taskAssignmentRep = taskAssignmentRep;
  147. _airTicketResRep = airTicketResRep;
  148. _sqlSugar = sqlSugar;
  149. url = AppSettingsHelper.Get("ExcelBaseUrl");
  150. path = AppSettingsHelper.Get("ExcelBasePath");
  151. if (!System.IO.Directory.Exists(path))
  152. {
  153. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  154. }
  155. _decreasePaymentsRep = decreasePaymentsRep;
  156. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  157. _delegationEnDataRep = delegationEnDataRep;
  158. _enterExitCostRep = enterExitCostRep;
  159. _delegationVisaRep = delegationVisaRep;
  160. _message = message;
  161. _visaPriceRep = visaPriceRep;
  162. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  163. _checkBoxs = checkBoxs;
  164. _GroupCostRepository = GroupCostRepository;
  165. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  166. _GroupCostParameterRepository = GroupCostParameterRepository;
  167. _hotelPriceRep = hotelPriceRep;
  168. _customersRep = customersRep;
  169. _setDataRep = setDataRep;
  170. _tourClientListRep = tourClientListRep;
  171. _teamRateRep = teamRateRep;
  172. _hubContext = hubContext;
  173. _usersRep = usersRep;
  174. _juHeApi = juHeApi;
  175. _invertedListRep = invertedListRep;
  176. _visaFeeInfoRep = visaFeeInfoRep;
  177. _ticketBlackCodeRep = ticketBlackCodeRep;
  178. _hotelInquiryRep = hotelInquiryRep;
  179. }
  180. #region 流程管控
  181. /// <summary>
  182. /// 获取团组流程管控信息
  183. /// </summary>
  184. /// <param name="paras">参数Json字符串</param>
  185. /// <returns></returns>
  186. [HttpPost]
  187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  188. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  189. {
  190. if (string.IsNullOrEmpty(_jsonDto.Paras))
  191. {
  192. return Ok(JsonView(false, "参数为空"));
  193. }
  194. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  195. if (_ScheduleDto != null)
  196. {
  197. if (_ScheduleDto.SearchType == 2)//获取列表
  198. {
  199. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  200. return Ok(JsonView(_grpScheduleViewList));
  201. }
  202. else//获取对象
  203. {
  204. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  205. if (_grpScheduleView != null)
  206. {
  207. return Ok(JsonView(_grpScheduleView));
  208. }
  209. }
  210. }
  211. else
  212. {
  213. return Ok(JsonView(false, "参数反序列化失败"));
  214. }
  215. return Ok(JsonView(false, "暂无数据!"));
  216. }
  217. /// <summary>
  218. /// 修改团组流程管控详细表数据
  219. /// </summary>
  220. /// <param name="paras"></param>
  221. /// <returns></returns>
  222. [HttpPost]
  223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  224. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  225. {
  226. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  227. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  228. .SetColumns(it => it.Duty == _detail.Duty)
  229. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  230. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  231. .SetColumns(it => it.JobContent == _detail.JobContent)
  232. .SetColumns(it => it.Remark == _detail.Remark)
  233. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  234. .Where(s => s.Id == dto.Id)
  235. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  236. .ExecuteCommandAsync();
  237. if (result > 0)
  238. {
  239. return Ok(JsonView(true, "保存成功!"));
  240. }
  241. return Ok(JsonView(false, "保存失败!"));
  242. }
  243. /// <summary>
  244. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  245. /// </summary>
  246. /// <param name="dto"></param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  251. {
  252. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  253. _detail.IsDel = 1;
  254. _detail.DeleteUserId = dto.Duty;
  255. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  256. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  257. .SetColumns(it => it.IsDel == _detail.IsDel)
  258. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  259. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  260. .Where(it => it.Id == dto.Id)
  261. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  262. //.WhereColumns(s => s.Id == dto.Id)
  263. .ExecuteCommandAsync();
  264. if (result > 0)
  265. {
  266. return Ok(JsonView(true, "删除成功!"));
  267. }
  268. return Ok(JsonView(false, "删除失败!"));
  269. }
  270. /// <summary>
  271. /// 增加团组流程管控详细表数据
  272. /// </summary>
  273. /// <param name="dto"></param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  277. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  278. {
  279. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  280. if (DateTime.Now < _detail.ExpectBeginDt)
  281. {
  282. _detail.StepStatus = 0;
  283. }
  284. else
  285. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  286. _detail.StepStatus = 1;
  287. }
  288. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  289. if (result > 0)
  290. {
  291. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  292. return Ok(JsonView(true, "添加成功!", _result));
  293. }
  294. return Ok(JsonView(false, "添加失败!"));
  295. }
  296. #endregion
  297. #region 团组基本信息
  298. /// <summary>
  299. /// 接团信息列表
  300. /// </summary>
  301. /// <param name="dto">团组列表请求dto</param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  306. {
  307. var groupData = await _groupRepository.GetGroupList(dto);
  308. if (groupData.Code != 0)
  309. {
  310. return Ok(JsonView(false, groupData.Msg));
  311. }
  312. return Ok(JsonView(groupData.Data));
  313. }
  314. /// <summary>
  315. /// 接团信息列表 Page
  316. /// </summary>
  317. /// <param name="dto">团组列表请求dto</param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  321. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  322. {
  323. #region 参数验证
  324. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  325. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  326. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  327. #region 页面操作权限验证
  328. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  329. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  330. #endregion
  331. #endregion
  332. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  333. {
  334. string sqlWhere = string.Empty;
  335. if (dto.IsSure == 0) //未完成
  336. {
  337. sqlWhere += string.Format(@" And IsSure = 0");
  338. }
  339. else if (dto.IsSure == 1) //已完成
  340. {
  341. sqlWhere += string.Format(@" And IsSure = 1");
  342. }
  343. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  344. {
  345. string tj = dto.SearchCriteria;
  346. 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}%')",
  347. tj, tj, tj, tj, tj);
  348. }
  349. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  350. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  351. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  352. JietuanOperator,IsSure,CreateTime
  353. From (
  354. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  355. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  356. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  358. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  359. From Grp_DelegationInfo gdi
  360. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  361. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  362. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  363. Where gdi.IsDel = 0 {0}
  364. ) temp", sqlWhere);
  365. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  366. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  367. #region 处理所属部门
  368. /*
  369. * 1.sq 和 gyy 等显示 市场部
  370. * 2.王鸽和主管及张总还有管理员号统一国交部
  371. * 2-1. 4 管理员 ,21 张海麟
  372. */
  373. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  374. List<int> userIds1 = new List<int>() { 4, 21 };
  375. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  376. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  377. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  378. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  379. .ToList();
  380. foreach (var item in _DelegationList)
  381. {
  382. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  383. }
  384. #endregion
  385. var _view = new
  386. {
  387. PageFuncAuth = pageFunAuthView,
  388. Data = _DelegationList
  389. };
  390. return Ok(JsonView(true, "查询成功!", _view, total));
  391. }
  392. else
  393. {
  394. return Ok(JsonView(false, "查询失败"));
  395. }
  396. }
  397. /// <summary>
  398. /// 团组列表
  399. /// </summary>
  400. /// <returns></returns>
  401. [HttpPost]
  402. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  403. {
  404. #region 参数验证
  405. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  406. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  407. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  408. #region 页面操作权限验证
  409. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  410. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  411. #endregion
  412. #endregion
  413. if (dto.PortType != 1 && dto.PortType != 2)
  414. {
  415. return Ok(JsonView(false, "查询失败!"));
  416. }
  417. string orderbyStr = "order by gdi.CreateTime Desc";
  418. string sqlWhere = string.Empty;
  419. if (dto.IsSure == 0) //未完成
  420. {
  421. sqlWhere += string.Format(@" And IsSure = 0");
  422. }
  423. else if (dto.IsSure == 1) //已完成
  424. {
  425. sqlWhere += string.Format(@" And IsSure = 1");
  426. }
  427. //团组类型
  428. if (dto.TeamDid > 0)
  429. {
  430. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  431. }
  432. //团组名称
  433. if (!string.IsNullOrEmpty(dto.TeamName))
  434. {
  435. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  436. }
  437. //客户名称
  438. if (!string.IsNullOrEmpty(dto.ClientName))
  439. {
  440. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  441. }
  442. //客户单位
  443. if (!string.IsNullOrEmpty(dto.ClientUnit))
  444. {
  445. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  446. }
  447. //出访时间
  448. if (!string.IsNullOrEmpty(dto.visitDataTime))
  449. {
  450. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  451. orderbyStr = "order by gdi.VisitDate";
  452. }
  453. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  454. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  455. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  456. JietuanOperator,IsSure,CreateTime
  457. From (
  458. Select row_number() over({0}) as Row_Number,
  459. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  460. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  462. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  463. From Grp_DelegationInfo gdi
  464. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  465. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  466. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  467. Where gdi.IsDel = 0 {1}
  468. ) temp ", orderbyStr, sqlWhere);
  469. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  470. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  471. #region 处理所属部门
  472. /*
  473. * 1.sq 和 gyy 等显示 市场部
  474. * 2.王鸽和主管及张总还有管理员号统一国交部
  475. * 2-1. 4 管理员 ,21 张海麟
  476. */
  477. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  478. List<int> userIds1 = new List<int>() { 4, 21 };
  479. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  480. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  481. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  482. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  483. .ToList();
  484. foreach (var item in _DelegationList)
  485. {
  486. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  487. }
  488. #endregion
  489. var _view = new
  490. {
  491. PageFuncAuth = pageFunAuthView,
  492. Data = _DelegationList
  493. };
  494. return Ok(JsonView(true, "查询成功!", _view, total));
  495. }
  496. /// <summary>
  497. /// 接团信息详情
  498. /// </summary>
  499. /// <param name="dto">团组info请求dto</param>
  500. /// <returns></returns>
  501. [HttpPost]
  502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  503. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  504. {
  505. var groupData = await _groupRepository.GetGroupInfo(dto);
  506. if (groupData.Code != 0)
  507. {
  508. return Ok(JsonView(false, groupData.Msg));
  509. }
  510. return Ok(JsonView(groupData.Data));
  511. }
  512. /// <summary>
  513. /// 接团信息 编辑添加
  514. /// 基础信息数据源
  515. /// </summary>
  516. /// <param name="dto"></param>
  517. /// <returns></returns>
  518. [HttpPost]
  519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  520. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  521. {
  522. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  523. if (groupData.Code != 0)
  524. {
  525. return Ok(JsonView(false, groupData.Msg));
  526. }
  527. return Ok(JsonView(groupData.Data));
  528. }
  529. /// <summary>
  530. /// 接团信息 操作(增改)
  531. /// </summary>
  532. /// <param name="dto"></param>
  533. /// <returns></returns>
  534. [HttpPost]
  535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  536. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  537. {
  538. try
  539. {
  540. var groupData = await _groupRepository.GroupOperation(dto);
  541. if (groupData.Code != 0)
  542. {
  543. return Ok(JsonView(false, groupData.Msg));
  544. }
  545. int diId = 0;
  546. //添加时 默认加入团组汇率
  547. if (dto.Status == 1) //添加
  548. {
  549. diId = groupData.Data;
  550. //添加默认币种
  551. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  552. //默认分配权限
  553. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  554. //消息提示 王鸽 主管号
  555. List<int> _managerIds = new List<int>() { 22, 32 };
  556. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  557. if (userIds.Count > 0)
  558. {
  559. userIds.Add(208);
  560. //创建团组管控
  561. GroupStepForDelegation.CreateWorkStep(diId);
  562. //发送消息
  563. string groupName = dto.TeamName;
  564. string createGroupUser = string.Empty;
  565. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  566. if (userInfo != null) createGroupUser = userInfo.CnName;
  567. string title = $"系统通知";
  568. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  569. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  570. }
  571. //默认创建倒推表
  572. await _invertedListRep._Create(dto.UserId, diId);
  573. }
  574. else if (dto.Status == 2)
  575. {
  576. diId = dto.Id;
  577. }
  578. return Ok(JsonView(true, "操作成功!", diId));
  579. }
  580. catch (Exception ex)
  581. {
  582. Logs("[response]" + JsonConvert.SerializeObject(dto));
  583. Logs(ex.Message);
  584. return Ok(JsonView(false, ex.Message));
  585. }
  586. }
  587. /// <summary>
  588. /// 接团流程操作(增改)
  589. /// 安卓端使用 建团时添加客户名单
  590. /// </summary>
  591. /// <param name="dto"></param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  596. {
  597. try
  598. {
  599. #region 参数验证
  600. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  601. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  602. #region 页面操作权限验证
  603. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  604. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  606. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  607. #endregion
  608. #endregion
  609. _sqlSugar.BeginTran();
  610. var _dto = new GroupOperationDto();
  611. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  612. var groupData = await _groupRepository.GroupOperation(_dto);
  613. if (groupData.Code != 0)
  614. {
  615. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  616. }
  617. int diId = 0;
  618. //添加时 默认加入团组汇率
  619. if (dto.Status == 1) //添加
  620. {
  621. diId = groupData.Data;
  622. //添加默认币种
  623. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  624. //默认分配权限
  625. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  626. //消息提示 王鸽 主管号
  627. List<int> _managerIds = new List<int>() { 22, 32 };
  628. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  629. if (userIds.Count > 0)
  630. {
  631. userIds.Add(208);
  632. //创建团组管控
  633. GroupStepForDelegation.CreateWorkStep(diId);
  634. //发送消息
  635. string groupName = dto.TeamName;
  636. string createGroupUser = string.Empty;
  637. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  638. if (userInfo != null) createGroupUser = userInfo.CnName;
  639. string title = $"系统通知";
  640. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  641. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  642. }
  643. }
  644. if (dto.Status == 2)
  645. {
  646. diId = dto.Id;
  647. if (diId == 0)
  648. {
  649. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  650. }
  651. }
  652. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  653. if (viewData.Code != 0)
  654. {
  655. _sqlSugar.RollbackTran();
  656. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  657. }
  658. _sqlSugar.CommitTran();
  659. return Ok(JsonView(true, "添加成功"));
  660. }
  661. catch (Exception ex)
  662. {
  663. _sqlSugar.RollbackTran();
  664. return Ok(JsonView(false, ex.Message));
  665. }
  666. }
  667. /// <summary>
  668. /// 接团信息 操作(删除)
  669. /// </summary>
  670. /// <param name="dto"></param>
  671. /// <returns></returns>
  672. [HttpPost]
  673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  674. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  675. {
  676. try
  677. {
  678. var groupData = await _groupRepository.GroupDel(dto);
  679. if (groupData.Code != 0)
  680. {
  681. return Ok(JsonView(false, groupData.Msg));
  682. }
  683. return Ok(JsonView(true));
  684. }
  685. catch (Exception ex)
  686. {
  687. Logs("[response]" + JsonConvert.SerializeObject(dto));
  688. Logs(ex.Message);
  689. return Ok(JsonView(false, ex.Message));
  690. }
  691. }
  692. /// <summary>
  693. /// 获取团组销售报价号
  694. /// 团组添加时 使用
  695. /// </summary>
  696. /// <returns></returns>
  697. [HttpPost]
  698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  699. public async Task<IActionResult> GetGroupSalesQuoteNo()
  700. {
  701. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  702. if (groupData.Code != 0)
  703. {
  704. return Ok(JsonView(false, groupData.Msg));
  705. }
  706. object salesQuoteNo = new
  707. {
  708. SalesQuoteNo = groupData.Data
  709. };
  710. return Ok(JsonView(salesQuoteNo));
  711. }
  712. /// <summary>
  713. /// 设置确认出团
  714. /// </summary>
  715. /// <param name="dto"></param>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  720. {
  721. var groupData = await _groupRepository.ConfirmationGroup(dto);
  722. if (groupData.Code != 0)
  723. {
  724. return Ok(JsonView(false, groupData.Msg));
  725. }
  726. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  727. #region OA消息推送
  728. try
  729. {
  730. string groupName = groupInfo.TeamName;
  731. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  732. List<int> userIds = new List<int>();
  733. listUser.ForEach(s => userIds.Add(s.Id));
  734. string title = $"系统通知";
  735. string content = $"团组[{groupName}]已确认出团!";
  736. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  737. }
  738. catch (Exception ex)
  739. {
  740. }
  741. #endregion
  742. #region 应用推送
  743. try
  744. {
  745. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  746. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  747. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  748. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  749. {
  750. List<string> userList = new List<string>() { users.QiyeChatUserId };
  751. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  752. }
  753. }
  754. catch (Exception ex)
  755. {
  756. }
  757. #endregion
  758. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  759. return Ok(JsonView(true, "操作成功!", groupData.Data));
  760. }
  761. /// <summary>
  762. /// 获取团组名称data And 签证国别Data
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  769. {
  770. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  771. if (groupData.Code != 0)
  772. {
  773. return Ok(JsonView(false, groupData.Msg));
  774. }
  775. return Ok(JsonView(groupData.Data));
  776. }
  777. /// <summary>
  778. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  779. /// </summary>
  780. /// <returns></returns>
  781. [HttpPost]
  782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  783. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  784. {
  785. try
  786. {
  787. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  788. if (groupData.Code != 0)
  789. {
  790. return Ok(JsonView(false, groupData.Msg));
  791. }
  792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  793. }
  794. catch (Exception ex)
  795. {
  796. return Ok(JsonView(false, "程序错误!"));
  797. throw;
  798. }
  799. }
  800. #endregion
  801. #region 团组&签证
  802. /// <summary>
  803. /// 根据团组Id获取签证客户信息List
  804. /// </summary>
  805. /// <param name="dto">请求dto</param>
  806. /// <returns></returns>
  807. [HttpPost]
  808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  809. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  810. {
  811. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  812. if (groupData.Code != 0)
  813. {
  814. return Ok(JsonView(false, groupData.Msg));
  815. }
  816. return Ok(JsonView(groupData.Data));
  817. }
  818. /// <summary>
  819. /// IOS获取团组签证拍照上传进度01(团组列表)
  820. /// </summary>
  821. /// <param name="dto">请求dto</param>
  822. /// <returns></returns>
  823. [HttpPost]
  824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  825. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  826. {
  827. if (dto == null)
  828. {
  829. return Ok(JsonView(false, "参数为空"));
  830. }
  831. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  832. return Ok(JsonView(visaList));
  833. }
  834. /// <summary>
  835. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  836. /// </summary>
  837. /// <returns></returns>
  838. [HttpPost]
  839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  840. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  841. {
  842. if (dto == null)
  843. {
  844. return Ok(JsonView(false, "请求错误:"));
  845. }
  846. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  847. return Ok(JsonView(list));
  848. }
  849. /// <summary>
  850. /// IOS获取团组签证拍照上传进度03(相册)
  851. /// </summary>
  852. /// <returns></returns>
  853. [HttpPost]
  854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  855. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  856. {
  857. if (dto == null)
  858. {
  859. return Ok(JsonView(false, "请求错误:"));
  860. }
  861. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  862. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  863. list.ForEach(s => s.url = url);
  864. return Ok(JsonView(list));
  865. }
  866. /// <summary>
  867. /// IOS获取团组签证拍照上传进度04(图片上传)
  868. /// </summary>
  869. /// <param name="dto"></param>
  870. /// <returns></returns>
  871. [HttpPost]
  872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  873. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  874. {
  875. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  876. //if (!string.IsNullOrEmpty(result))
  877. //{
  878. //}
  879. //else {
  880. // return Ok(JsonView(false, "上传失败"));
  881. //}
  882. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  883. int sucNum = 0;
  884. try
  885. {
  886. foreach (var item in dto.base64DataList)
  887. {
  888. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  889. string result = decodeBase64ToImage(item, imageName);
  890. if (!string.IsNullOrEmpty(result))
  891. {
  892. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  893. pic.CreateUserId = dto.CreateUserId;
  894. pic.PicName = imageName;
  895. pic.PicPath = result;
  896. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  897. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  898. if (insertResult > 0)
  899. {
  900. sucNum++;
  901. }
  902. }
  903. }
  904. }
  905. catch (Exception ex)
  906. {
  907. return Ok(JsonView(false, ex.Message));
  908. }
  909. string msg = string.Format(@"成功上传{0}张", sucNum);
  910. return Ok(JsonView(true, msg));
  911. }
  912. private string decodeBase64ToImage(string base64DataURL, string imgName)
  913. {
  914. string filename = "";//声明一个string类型的相对路径
  915. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  916. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  917. try//会有异常抛出,try,catch一下
  918. {
  919. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  920. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  921. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  922. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  923. //文件名称
  924. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  925. //上传的文件的路径
  926. string filePath = "";
  927. if (!Directory.Exists(fileDir))
  928. {
  929. Directory.CreateDirectory(fileDir);
  930. }
  931. //上传的文件的路径
  932. filePath = fileDir + filename;
  933. //string url = HttpRuntime.AppDomainAppPath.ToString();
  934. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  935. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  936. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  937. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  938. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  939. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  940. ms.Close();//关闭当前流,并释放所有与之关联的资源
  941. bitmap.Dispose();
  942. }
  943. catch (Exception e)
  944. {
  945. string massage = e.Message;
  946. Logs("IOS图片上传Error:" + massage);
  947. //filename = e.Message;
  948. }
  949. return filename;//返回相对路径
  950. }
  951. /// <summary>
  952. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  953. /// </summary>
  954. /// <param name="dto"></param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  959. {
  960. if (dto == null)
  961. {
  962. return Ok(JsonView(false, "请求错误:"));
  963. }
  964. string msg = "参数错误";
  965. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  966. {
  967. try
  968. {
  969. //_delegationVisaRep.BeginTran();
  970. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  971. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  972. .Where(s => s.Id == dto.visaProgressCustomerId)
  973. .ExecuteCommandAsync();
  974. if (updCount > 0 && dto.publishCode == 1)
  975. {
  976. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  977. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  978. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  979. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  980. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  981. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  982. if (groupData == null)
  983. {
  984. _delegationVisaRep.RollbackTran();
  985. }
  986. string title = string.Format(@"[签证进度更新]");
  987. string content = string.Format(@"测试文本");
  988. bool rst = await _message.AddMsg(new MessageDto()
  989. {
  990. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  991. IssuerId = dto.publisher,
  992. Title = title,
  993. Content = content,
  994. ReleaseTime = DateTime.Now,
  995. UIdList = new List<int> {
  996. 234
  997. }
  998. });
  999. if (rst)
  1000. {
  1001. return Ok(JsonView(true, "发送通知成功"));
  1002. }
  1003. }
  1004. //_delegationVisaRep.CommitTran();
  1005. }
  1006. catch (Exception)
  1007. {
  1008. //_delegationVisaRep.RollbackTran();
  1009. }
  1010. }
  1011. return Ok(JsonView(true, msg));
  1012. }
  1013. #endregion
  1014. #region 团组任务分配
  1015. /// <summary>
  1016. /// 团组任务分配初始化
  1017. /// </summary>
  1018. /// <param name="dto"></param>
  1019. /// <returns></returns>
  1020. [HttpPost]
  1021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1022. public async Task<IActionResult> GetTaskAssignmen()
  1023. {
  1024. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1025. if (groupData.Code != 0)
  1026. {
  1027. return Ok(JsonView(false, groupData.Msg));
  1028. }
  1029. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1030. }
  1031. /// <summary>
  1032. /// 团组任务分配查询
  1033. /// </summary>
  1034. /// <param name="dto"></param>
  1035. /// <returns></returns>
  1036. [HttpPost]
  1037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1038. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1039. {
  1040. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1041. if (groupData.Code != 0)
  1042. {
  1043. return Ok(JsonView(false, groupData.Msg));
  1044. }
  1045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1046. }
  1047. /// <summary>
  1048. /// 团组任务分配操作
  1049. /// </summary>
  1050. /// <param name="dto"></param>
  1051. /// <returns></returns>
  1052. [HttpPost]
  1053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1054. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1055. {
  1056. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1057. if (groupData.Code != 0)
  1058. {
  1059. return Ok(JsonView(false, groupData.Msg));
  1060. }
  1061. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1062. }
  1063. #endregion
  1064. #region 团组费用审核
  1065. /// <summary>
  1066. /// 费用审核
  1067. /// 团组列表 Page
  1068. /// </summary>
  1069. /// <param name="_dto">团组列表请求dto</param>
  1070. /// <returns></returns>
  1071. [HttpPost]
  1072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1073. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1074. {
  1075. #region 参数验证
  1076. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1077. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1078. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1079. #region 页面操作权限验证
  1080. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1081. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1082. #endregion
  1083. #endregion
  1084. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1085. {
  1086. string sqlWhere = string.Empty;
  1087. if (_dto.IsSure == 0) //未完成
  1088. {
  1089. sqlWhere += string.Format(@" And IsSure = 0");
  1090. }
  1091. else if (_dto.IsSure == 1) //已完成
  1092. {
  1093. sqlWhere += string.Format(@" And IsSure = 1");
  1094. }
  1095. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1096. {
  1097. string tj = _dto.SearchCriteria;
  1098. 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}%')",
  1099. tj, tj, tj, tj, tj);
  1100. }
  1101. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1102. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1103. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1104. From (
  1105. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1106. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1107. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1108. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1109. From Grp_DelegationInfo gdi
  1110. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1111. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1112. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1113. Where gdi.IsDel = 0 {0}
  1114. ) temp ", sqlWhere);
  1115. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1116. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1117. var _view = new
  1118. {
  1119. PageFuncAuth = pageFunAuthView,
  1120. Data = _DelegationList
  1121. };
  1122. return Ok(JsonView(true, "查询成功!", _view, total));
  1123. }
  1124. else
  1125. {
  1126. return Ok(JsonView(false, "查询失败"));
  1127. }
  1128. }
  1129. /// <summary>
  1130. /// 获取团组费用审核
  1131. /// </summary>
  1132. /// <param name="paras">参数Json字符串</param>
  1133. /// <returns></returns>
  1134. [HttpPost]
  1135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1136. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1137. {
  1138. try
  1139. {
  1140. #region 参数验证
  1141. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1142. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1143. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1144. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1145. #region 页面操作权限验证
  1146. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1147. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1148. #endregion
  1149. #endregion
  1150. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1151. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1152. #region 费用清单
  1153. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1154. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1155. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1156. List<Grp_CreditCardPayment> entityList = _groupRepository
  1157. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1158. .Where(exp.ToExpression())
  1159. .ToList();
  1160. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1161. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1162. /*
  1163. * 76://酒店预订
  1164. */
  1165. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1166. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1167. .ToListAsync();
  1168. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1169. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1170. .ToListAsync();
  1171. /*
  1172. * 79://车/导游地接
  1173. */
  1174. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1175. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1178. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. /*
  1181. * 80: //签证
  1182. */
  1183. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1184. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. *81: //邀请/公务活动
  1188. */
  1189. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1190. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. * 82: //团组客户保险
  1194. */
  1195. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1196. /*
  1197. * Lable = 85 机票预订
  1198. */
  1199. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1200. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1201. .ToListAsync();
  1202. /*
  1203. * 85 机票预定
  1204. */
  1205. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1206. /*
  1207. * 98 其他款项
  1208. */
  1209. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1210. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1211. .ToListAsync();
  1212. /*
  1213. * 285:收款退还
  1214. */
  1215. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1216. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 1015: //超支费用
  1220. */
  1221. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1222. /*
  1223. * 币种信息
  1224. */
  1225. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1226. /*
  1227. * 车/导游地接 费用类型
  1228. */
  1229. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1230. /*
  1231. * 车/导游地接 费用类型
  1232. */
  1233. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1234. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1235. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 用户信息
  1238. */
  1239. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1240. /*
  1241. * 费用模块
  1242. */
  1243. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1244. string priceModule = string.Empty;
  1245. if (sdPriceName != null)
  1246. {
  1247. priceModule = sdPriceName.Name;
  1248. }
  1249. /*
  1250. * 处理详情数据
  1251. */
  1252. foreach (var entity in entityList)
  1253. {
  1254. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1255. _detail.Id = entity.Id;
  1256. _detail.PriceName = priceModule;
  1257. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1258. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1259. /*
  1260. * 应付款金额
  1261. */
  1262. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1263. string PaymentCurrency_WaitPay = "Unknown";
  1264. string hotelCurrncyCode = "Unknown";
  1265. string hotelCurrncyName = "Unknown";
  1266. if (sdPaymentCurrency_WaitPay != null)
  1267. {
  1268. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1269. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1270. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1271. if (hotelCurrncyCode.Equals("CNY"))
  1272. {
  1273. entity.DayRate = 1.0000M;
  1274. }
  1275. }
  1276. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1277. /*
  1278. * 此次付款金额
  1279. */
  1280. decimal CurrPayStr = 0;
  1281. if (entity.PayPercentage == 0)
  1282. {
  1283. if (entity.PayThenMoney != 0)
  1284. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1285. }
  1286. else
  1287. {
  1288. if (entity.PayMoney != 0)
  1289. {
  1290. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1291. }
  1292. }
  1293. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1294. /*
  1295. * 剩余尾款
  1296. */
  1297. decimal BalanceStr = 0;
  1298. if (CurrPayStr != 0)
  1299. {
  1300. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1301. BalanceStr = 0;
  1302. else
  1303. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1304. }
  1305. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1306. /*
  1307. * Bus名称
  1308. */
  1309. _detail.BusName = "待增加";
  1310. /*
  1311. *费用所属
  1312. */
  1313. switch (entity.CTable)
  1314. {
  1315. case 76://酒店预订
  1316. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1317. if (hotelReservations != null)
  1318. {
  1319. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1320. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1321. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1322. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1323. /*
  1324. * 费用类型
  1325. * 1:房费
  1326. * 2:早餐
  1327. * 3:地税
  1328. * 4:城市税
  1329. * </summary>
  1330. */
  1331. //地税
  1332. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1333. if (governmentRentData != null)
  1334. {
  1335. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1336. governmentRentFee = governmentRentData.Price;
  1337. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1338. if (governmentRentCurrData != null)
  1339. {
  1340. governmentRentCode = governmentRentCurrData.Name;
  1341. governmentRentName = $"({governmentRentCurrData.Remark})";
  1342. }
  1343. }
  1344. //城市税
  1345. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1346. if (cityTaxData != null)
  1347. {
  1348. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1349. cityTaxFee = cityTaxData.Price;
  1350. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1351. if (cityTaxCurrData != null)
  1352. {
  1353. cityTaxCode = cityTaxCurrData.Name;
  1354. cityTaxName = $"({cityTaxCurrData.Remark})";
  1355. }
  1356. }
  1357. //酒店早餐
  1358. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1359. if (breakfastData != null)
  1360. {
  1361. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1362. breakfastFee = breakfastData.Price;
  1363. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1364. if (breakfastCurrData != null)
  1365. {
  1366. breakfastCode = breakfastCurrData.Name;
  1367. breakfastName = $"({breakfastCurrData.Remark})";
  1368. }
  1369. }
  1370. //房间费用
  1371. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1372. if (roomData != null)
  1373. {
  1374. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1375. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1376. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1377. roomFee = roomData.Price;
  1378. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1379. if (roomCurrData != null)
  1380. {
  1381. roomCode = roomCurrData.Name;
  1382. roomName = $"({roomCurrData.Remark})";
  1383. }
  1384. }
  1385. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1386. $"房间说明: {hotelReservations.Remark} <br/>" +
  1387. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1388. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1389. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1390. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1391. _detail.PriceNameContent = hotelReservations.HotelName;
  1392. }
  1393. break;
  1394. case 79://车/导游地接
  1395. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1396. if (touristGuideGroundReservations != null)
  1397. {
  1398. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1399. {
  1400. _detail.BusName = touristGuideGroundReservations.BusName;
  1401. }
  1402. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1403. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1404. //if (isInt)
  1405. //{
  1406. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1407. // if (cityInfo != null)
  1408. // {
  1409. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1410. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1411. // if (carFeeItem != null)
  1412. // {
  1413. // nameContent += $@"({carFeeItem.Name})";
  1414. // }
  1415. // _detail.PriceNameContent = nameContent;
  1416. // }
  1417. //}
  1418. //else
  1419. //{
  1420. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1421. //}
  1422. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1423. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1424. string priceMsg = string.Empty;
  1425. foreach (var item in touristGuideGroundReservationsContents)
  1426. {
  1427. string typeName = "Unknown";
  1428. string carCurrencyCode = "Unknown";
  1429. string carCurrencyName = "Unknown";
  1430. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1431. if (carTypeData != null) typeName = carTypeData.Name;
  1432. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1433. if (currencyData != null)
  1434. {
  1435. carCurrencyCode = currencyData.Name;
  1436. carCurrencyName = currencyData.Remark;
  1437. }
  1438. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1439. "明细:" + item.PriceContent + "<br/>" +
  1440. "备注:" + item.Remark + "<br/><br/>";
  1441. }
  1442. _detail.PriceMsgContent = priceMsg;
  1443. }
  1444. break;
  1445. case 80: //签证
  1446. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1447. if (visaInfo != null)
  1448. {
  1449. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1450. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1451. }
  1452. break;
  1453. case 81: //邀请/公务活动
  1454. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1455. if (_ioa != null)
  1456. {
  1457. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1458. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1459. sendCurrName = "Unknown", //快递费用币种 Name
  1460. sendCurrCode = "Unknown", //快递费用币种 Code
  1461. eventsCurrName = "Unknown", //公务活动费币种 Name
  1462. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1463. translateCurrName = "Unknown", //公务翻译费 Name
  1464. translateCurrCode = "Unknown"; //公务翻译费 Code
  1465. #region 处理费用币种
  1466. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1467. if (inviteCurrData != null)
  1468. {
  1469. inviteCurrName = inviteCurrData.Remark;
  1470. inviteCurrCode = inviteCurrData.Name;
  1471. }
  1472. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1473. if (sendCurrData != null)
  1474. {
  1475. sendCurrName = sendCurrData.Remark;
  1476. sendCurrCode = sendCurrData.Name;
  1477. }
  1478. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1479. if (eventsCurrData != null)
  1480. {
  1481. eventsCurrName = eventsCurrData.Remark;
  1482. eventsCurrCode = eventsCurrData.Name;
  1483. }
  1484. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1485. if (translateCurrData != null)
  1486. {
  1487. translateCurrName = translateCurrData.Remark;
  1488. translateCurrCode = translateCurrData.Name;
  1489. }
  1490. #endregion
  1491. _detail.PriceNameContent = _ioa.InviterArea;
  1492. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1493. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1494. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1495. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1496. $@"备注:" + _ioa.Remark + "<br/>";
  1497. }
  1498. break;
  1499. case 82: //团组客户保险
  1500. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1501. if (customers != null)
  1502. {
  1503. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1504. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1505. }
  1506. break;
  1507. case 85: //机票预订
  1508. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1509. if (jpRes != null)
  1510. {
  1511. string FlightsDescription = jpRes.FlightsDescription;
  1512. string PriceDescription = jpRes.PriceDescription;
  1513. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1514. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1515. }
  1516. break;
  1517. case 98://其他款项
  1518. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1519. if (gdpRes != null)
  1520. {
  1521. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1522. _detail.PriceNameContent = gdpRes.PriceName;
  1523. }
  1524. break;
  1525. case 285://收款退还
  1526. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1527. if (refundAndOtherMoney != null)
  1528. {
  1529. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1530. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1531. }
  1532. break;
  1533. case 751://酒店早餐
  1534. break;
  1535. case 1015://超支费用
  1536. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1537. if (groupExtraCost != null)
  1538. {
  1539. _detail.PriceNameContent = groupExtraCost.PriceName;
  1540. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1541. }
  1542. break;
  1543. default:
  1544. break;
  1545. }
  1546. /*
  1547. * 申请人
  1548. */
  1549. string operatorName = " - ";
  1550. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1551. if (_opUser != null)
  1552. {
  1553. operatorName = _opUser.CnName;
  1554. }
  1555. _detail.OperatorName = operatorName;
  1556. /*
  1557. * 审核人
  1558. */
  1559. string auditOperatorName = "Unknown";
  1560. if (entity.AuditGMOperate == 0)
  1561. auditOperatorName = " - ";
  1562. else if (entity.AuditGMOperate == 4)
  1563. auditOperatorName = "自动审核";
  1564. else
  1565. {
  1566. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1567. if (_adUser != null)
  1568. {
  1569. auditOperatorName = _adUser.CnName;
  1570. }
  1571. }
  1572. _detail.AuditOperatorName = auditOperatorName;
  1573. /*
  1574. * 超预算比例
  1575. */
  1576. string overBudgetStr = "";
  1577. if (entity.ExceedBudget == -1)
  1578. overBudgetStr = sdPriceName.Name + "尚无预算";
  1579. else if (entity.ExceedBudget == 0)
  1580. overBudgetStr = "未超预算";
  1581. else
  1582. overBudgetStr = entity.ExceedBudget.ToString("P");
  1583. _detail.OverBudget = overBudgetStr;
  1584. /*
  1585. * 费用总计
  1586. */
  1587. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1588. {
  1589. CurrencyId = entity.PaymentCurrency,
  1590. CurrencyName = PaymentCurrency_WaitPay,
  1591. AmountPayable = entity.PayMoney,
  1592. ThisPayment = CurrPayStr,
  1593. BalancePayment = BalanceStr,
  1594. AuditedFunds = CurrPayStr
  1595. });
  1596. _detail.IsAuditGM = entity.IsAuditGM;
  1597. detailList.Add(_detail);
  1598. }
  1599. #endregion
  1600. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1601. /*
  1602. * 下方描述处理
  1603. */
  1604. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1605. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1606. if (ccpCurrencyPrice != null)
  1607. {
  1608. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1609. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1610. }
  1611. else
  1612. {
  1613. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1614. }
  1615. string amountPayableStr = string.Format(@"应付款总金额: ");
  1616. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1617. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1618. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1619. foreach (var item in nonDuplicat)
  1620. {
  1621. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1622. if (strs.Count > 0)
  1623. {
  1624. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1625. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1626. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1627. //单独处理此次付款金额
  1628. if (item.CurrencyId == 836) //人民币
  1629. {
  1630. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1631. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1632. }
  1633. else
  1634. {
  1635. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1636. }
  1637. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1638. //单独处理已审核费用
  1639. if (item.CurrencyId == 836) //人民币
  1640. {
  1641. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1642. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1643. }
  1644. else
  1645. {
  1646. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1647. }
  1648. }
  1649. }
  1650. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1651. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1652. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1653. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1654. var _view1 = new
  1655. {
  1656. PageFuncAuth = pageFunAuthView,
  1657. Data = _view
  1658. };
  1659. return Ok(JsonView(_view1));
  1660. }
  1661. catch (Exception ex)
  1662. {
  1663. return Ok(JsonView(false, ex.Message));
  1664. }
  1665. }
  1666. /// <summary>
  1667. /// 费用审核
  1668. /// 修改团组费用审核状态
  1669. /// </summary>
  1670. /// <param name="_dto">参数Json字符串</param>
  1671. /// <returns></returns>
  1672. [HttpPost]
  1673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1674. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1675. {
  1676. #region 参数验证
  1677. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1678. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1679. #endregion
  1680. #region 页面操作权限验证
  1681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1683. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1684. #endregion
  1685. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1686. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1687. DateTime dtNow = DateTime.Now;
  1688. _groupRepository.BeginTran();
  1689. int rst = 0;
  1690. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1691. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1692. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1693. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1694. List<dynamic> msgDatas = new List<dynamic>();
  1695. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1696. foreach (var item in idList)
  1697. {
  1698. int CreditId = int.Parse(item);
  1699. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1700. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1701. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1702. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1703. .Where(s => s.Id == CreditId)
  1704. .ExecuteCommandAsync();
  1705. if (result < 1)
  1706. {
  1707. rst = -1;
  1708. _groupRepository.RollbackTran();
  1709. return Ok(JsonView(false, "操作失败并回滚!"));
  1710. }
  1711. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1712. if (creditData != null)
  1713. {
  1714. #region 应用通知配置
  1715. try
  1716. {
  1717. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1718. }
  1719. catch (Exception ex)
  1720. {
  1721. }
  1722. #endregion
  1723. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1724. string groupNameStr = string.Empty;
  1725. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1726. if (groupData != null) groupNameStr = groupData.TeamName;
  1727. string creditTypeStr = string.Empty;
  1728. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1729. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1730. string creditCurrency = string.Empty;
  1731. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1732. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1733. if (creditCurrency.Equals("CNY"))
  1734. {
  1735. creditData.DayRate = 1.0000M;
  1736. }
  1737. if (creditData.PayPercentage == 0.00M)
  1738. {
  1739. creditData.PayPercentage = 100M;
  1740. }
  1741. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1742. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1743. string msgContent = "";
  1744. if (creditCurrency.Equals("CNY"))
  1745. {
  1746. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1747. }
  1748. else
  1749. {
  1750. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1751. }
  1752. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1753. }
  1754. }
  1755. if (rst == 0)
  1756. {
  1757. _groupRepository.CommitTran();
  1758. foreach (var item in msgDatas)
  1759. {
  1760. //发送消息
  1761. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1762. }
  1763. #region 应用推送
  1764. try
  1765. {
  1766. foreach (var ccpId in dic_ccp_user.Keys)
  1767. {
  1768. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1769. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1770. }
  1771. }
  1772. catch (Exception)
  1773. {
  1774. }
  1775. #endregion
  1776. return Ok(JsonView(true, "操作成功!"));
  1777. }
  1778. return Ok(JsonView(false, "操作失败!"));
  1779. }
  1780. #endregion
  1781. #region 机票费用录入
  1782. /// <summary>
  1783. /// 机票录入当前登录人可操作团组
  1784. /// </summary>
  1785. /// <param name="dto"></param>
  1786. /// <returns></returns>
  1787. [HttpPost]
  1788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1789. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1790. {
  1791. try
  1792. {
  1793. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1794. if (groupData.Code != 0)
  1795. {
  1796. return Ok(JsonView(false, groupData.Msg));
  1797. }
  1798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1799. }
  1800. catch (Exception ex)
  1801. {
  1802. return Ok(JsonView(false, "程序错误!"));
  1803. throw;
  1804. }
  1805. }
  1806. /// <summary>
  1807. /// 机票费用录入列表
  1808. /// </summary>
  1809. /// <param name="dto"></param>
  1810. /// <returns></returns>
  1811. [HttpPost]
  1812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1813. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1814. {
  1815. try
  1816. {
  1817. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1818. if (groupData.Code != 0)
  1819. {
  1820. return Ok(JsonView(false, groupData.Msg));
  1821. }
  1822. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1823. }
  1824. catch (Exception ex)
  1825. {
  1826. return Ok(JsonView(false, ex.Message));
  1827. throw;
  1828. }
  1829. }
  1830. /// <summary>
  1831. /// 根据id查询费用录入信息
  1832. /// </summary>
  1833. /// <param name="dto"></param>
  1834. /// <returns></returns>
  1835. [HttpPost]
  1836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1837. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1838. {
  1839. try
  1840. {
  1841. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1842. if (groupData.Code != 0)
  1843. {
  1844. return Ok(JsonView(false, groupData.Msg));
  1845. }
  1846. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1847. }
  1848. catch (Exception ex)
  1849. {
  1850. return Ok(JsonView(false, "程序错误!"));
  1851. throw;
  1852. }
  1853. }
  1854. /// <summary>
  1855. /// 机票费用录入操作(Status:1.新增,2.修改)
  1856. /// </summary>
  1857. /// <param name="dto"></param>
  1858. /// <returns></returns>
  1859. [HttpPost]
  1860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1861. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1862. {
  1863. try
  1864. {
  1865. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1866. if (groupData.Code != 0)
  1867. {
  1868. return Ok(JsonView(false, groupData.Msg));
  1869. }
  1870. #region 应用推送
  1871. try
  1872. {
  1873. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1874. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1875. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1876. }
  1877. catch (Exception ex)
  1878. {
  1879. }
  1880. #endregion
  1881. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1882. }
  1883. catch (Exception ex)
  1884. {
  1885. return Ok(JsonView(false, "程序错误!"));
  1886. throw;
  1887. }
  1888. }
  1889. /// <summary>
  1890. /// 根据舱位类型查询接团客户名单信息
  1891. /// </summary>
  1892. /// <param name="dto"></param>
  1893. /// <returns></returns>
  1894. [HttpPost]
  1895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1896. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1897. {
  1898. try
  1899. {
  1900. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1901. if (crm_Groups.Count != 0)
  1902. {
  1903. List<dynamic> Customer = new List<dynamic>();
  1904. foreach (var item in crm_Groups)
  1905. {
  1906. var data = new
  1907. {
  1908. Id = item.Id,
  1909. Pinyin = item.Pinyin,
  1910. Name = item.LastName + item.FirstName
  1911. };
  1912. Customer.Add(data);
  1913. }
  1914. return Ok(JsonView(true, "查询成功!", Customer));
  1915. }
  1916. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1917. }
  1918. catch (Exception ex)
  1919. {
  1920. return Ok(JsonView(false, "程序错误!"));
  1921. throw;
  1922. }
  1923. }
  1924. /// <summary>
  1925. /// 根据团号获取客户信息
  1926. /// </summary>
  1927. /// <param name="dto"></param>
  1928. /// <returns></returns>
  1929. [HttpPost]
  1930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1931. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1932. {
  1933. var jw = JsonView(false);
  1934. if (dto.DIID < 1)
  1935. {
  1936. jw.Msg += "请输入正确的diid";
  1937. return Ok(jw);
  1938. }
  1939. var arr = getSimplClientList(dto.DIID);
  1940. jw = JsonView(true, "获取成功!", arr);
  1941. return Ok(jw);
  1942. }
  1943. private List<SimplClientInfo> getSimplClientList(int diId)
  1944. {
  1945. 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);
  1946. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1947. return arr;
  1948. }
  1949. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1950. {
  1951. string result = origin;
  1952. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1953. {
  1954. string[] temparr = origin.Split(',');
  1955. string fistrStr = temparr[0];
  1956. int count = temparr.Count();
  1957. int tempId;
  1958. bool success = int.TryParse(fistrStr, out tempId);
  1959. if (success)
  1960. {
  1961. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1962. if (tempInfo != null)
  1963. {
  1964. if (count > 1)
  1965. {
  1966. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1967. }
  1968. else
  1969. {
  1970. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1971. }
  1972. }
  1973. }
  1974. }
  1975. return result;
  1976. }
  1977. /// <summary>
  1978. /// 机票费用录入,删除
  1979. /// </summary>
  1980. /// <param name="dto"></param>
  1981. /// <returns></returns>
  1982. [HttpPost]
  1983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1984. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1985. {
  1986. try
  1987. {
  1988. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1989. if (res)
  1990. {
  1991. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1992. {
  1993. IsDel = 1,
  1994. DeleteUserId = dto.DeleteUserId,
  1995. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1996. }).ExecuteCommandAsync();
  1997. return Ok(JsonView(true, "删除成功!"));
  1998. }
  1999. return Ok(JsonView(false, "删除失败!"));
  2000. }
  2001. catch (Exception ex)
  2002. {
  2003. return Ok(JsonView(false, "程序错误!"));
  2004. throw;
  2005. }
  2006. }
  2007. /// <summary>
  2008. /// 导出机票录入报表
  2009. /// </summary>
  2010. /// <param name="dto"></param>
  2011. /// <returns></returns>
  2012. [HttpPost]
  2013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2014. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2015. {
  2016. try
  2017. {
  2018. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2019. if (groupData.Code != 0)
  2020. {
  2021. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2022. }
  2023. else
  2024. {
  2025. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2026. if (AirTicketReservations.Count != 0)
  2027. {
  2028. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2029. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2030. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2031. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2032. WorkbookDesigner designer = new WorkbookDesigner();
  2033. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2034. decimal countCost = 0;
  2035. foreach (var item in AirTicketReservations)
  2036. {
  2037. #region 处理客人姓名
  2038. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2039. item.ClientName = clientNames;
  2040. #endregion
  2041. if (item.BankType == "其他")
  2042. {
  2043. item.BankNo = "--";
  2044. }
  2045. else
  2046. {
  2047. if (!string.IsNullOrEmpty(item.BankType))
  2048. {
  2049. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2050. }
  2051. }
  2052. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2053. item.Price = System.Decimal.Round(item.Price, 2);
  2054. countCost += Convert.ToDecimal(item.Price);
  2055. }
  2056. designer.SetDataSource("Export", AirTicketReservations);
  2057. designer.SetDataSource("ExportDiCode", diCode);
  2058. designer.SetDataSource("ExportDiName", diName);
  2059. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2060. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2061. designer.Process();
  2062. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2063. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2064. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2065. return Ok(JsonView(true, "成功", url = rst));
  2066. }
  2067. else
  2068. {
  2069. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2070. }
  2071. }
  2072. }
  2073. catch (Exception ex)
  2074. {
  2075. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2076. throw;
  2077. }
  2078. }
  2079. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2080. /// <summary>
  2081. /// 行程单导出
  2082. /// </summary>
  2083. /// <param name="dto"></param>
  2084. /// <returns></returns>
  2085. [HttpPost]
  2086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2087. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2088. {
  2089. try
  2090. {
  2091. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2092. if (groupData.Code != 0)
  2093. {
  2094. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2095. }
  2096. else
  2097. {
  2098. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2099. if (dto.Language == "CN")
  2100. {
  2101. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2102. DocumentBuilder builder = new DocumentBuilder(doc);
  2103. int tableIndex = 0;//表格索引
  2104. //得到文档中的第一个表格
  2105. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2106. foreach (var item in _AirTicketReservations)
  2107. {
  2108. #region 处理固定数据
  2109. string[] FlightsCode = item.FlightsCode.Split('/');
  2110. if (FlightsCode.Length != 0)
  2111. {
  2112. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2113. if (_AirCompany != null)
  2114. {
  2115. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2116. }
  2117. else
  2118. {
  2119. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2120. }
  2121. }
  2122. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2123. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2124. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2125. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2126. string name = "";
  2127. foreach (string clientName in nameArray)
  2128. {
  2129. if (!name.Contains(clientName))
  2130. {
  2131. name += clientName + ",";
  2132. }
  2133. }
  2134. if (!string.IsNullOrWhiteSpace(name))
  2135. {
  2136. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2137. }
  2138. else
  2139. {
  2140. table.Range.Bookmarks["ClientName"].Text = "--";
  2141. }
  2142. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2143. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2144. table.Range.Bookmarks["JointTicket"].Text = "--";
  2145. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2146. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2147. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2148. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2149. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2150. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2151. #endregion
  2152. #region 循环数据处理
  2153. List<AirInfo> airs = new List<AirInfo>();
  2154. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2155. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2156. for (int i = 0; i < FlightsCode.Length; i++)
  2157. {
  2158. AirInfo air = new AirInfo();
  2159. string[] tempstr = DayArray[i]
  2160. .Replace("\r\n", string.Empty)
  2161. .Replace("\\r\\n", string.Empty)
  2162. .TrimStart().TrimEnd()
  2163. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2164. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2165. string starCity = "";
  2166. if (star_Three != null)
  2167. {
  2168. starCity = star_Three.AirPort;
  2169. }
  2170. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2171. string EndCity = "";
  2172. if (End_Three != null)
  2173. {
  2174. EndCity = End_Three.AirPort;
  2175. }
  2176. air.Destination = starCity + "/" + EndCity;
  2177. air.Flight = FlightsCode[i];
  2178. air.SeatingClass = item.CTypeName;
  2179. string dateTime = tempstr[2];
  2180. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2181. air.FlightDate = DateTemp;
  2182. air.DepartureTime = tempstr[5];
  2183. air.LandingTime = tempstr[6];
  2184. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2185. air.TicketStatus = "--";
  2186. air.Luggage = "--";
  2187. air.DepartureTerminal = "--";
  2188. air.LandingTerminal = "--";
  2189. airs.Add(air);
  2190. }
  2191. int row = 13;
  2192. for (int i = 0; i < airs.Count; i++)
  2193. {
  2194. if (airs.Count > 2)
  2195. {
  2196. for (int j = 0; j < airs.Count - 2; j++)
  2197. {
  2198. var CopyRow = table.Rows[12].Clone(true);
  2199. table.Rows.Add(CopyRow);
  2200. }
  2201. }
  2202. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2203. int index = 0;
  2204. foreach (PropertyInfo property in properties)
  2205. {
  2206. string value = property.GetValue(airs[i]).ToString();
  2207. Cell ishcel0 = table.Rows[row].Cells[index];
  2208. Paragraph p = new Paragraph(doc);
  2209. string s = value;
  2210. p.AppendChild(new Run(doc, s));
  2211. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2212. ishcel0.AppendChild(p);
  2213. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2214. index++;
  2215. }
  2216. row++;
  2217. }
  2218. #endregion
  2219. Paragraph lastParagraph = new Paragraph(doc);
  2220. //第一个表格末尾加段落
  2221. table.ParentNode.InsertAfter(lastParagraph, table);
  2222. //复制第一个表格
  2223. Table cloneTable = (Table)table.Clone(true);
  2224. //在文档末尾段落后面加入复制的表格
  2225. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2226. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2227. {
  2228. int rownewsIndex = 13;
  2229. for (int i = 0; i < 2; i++)
  2230. {
  2231. var CopyRow = table.Rows[12].Clone(true);
  2232. table.Rows.RemoveAt(13);
  2233. table.Rows.Add(CopyRow);
  2234. rownewsIndex++;
  2235. }
  2236. }
  2237. else
  2238. {
  2239. table.Rows.RemoveAt(12);
  2240. }
  2241. cloneTable.Rows.RemoveAt(12);
  2242. }
  2243. if (_AirTicketReservations.Count != 0)
  2244. {
  2245. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2246. if (FlightsCode.Length != 0)
  2247. {
  2248. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2249. if (_AirCompany != null)
  2250. {
  2251. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2252. }
  2253. else
  2254. {
  2255. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2256. }
  2257. }
  2258. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2259. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2260. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2261. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2262. string name = "";
  2263. foreach (string clientName in nameArray)
  2264. {
  2265. if (!name.Contains(clientName))
  2266. {
  2267. name += clientName + ",";
  2268. }
  2269. }
  2270. if (!string.IsNullOrWhiteSpace(name))
  2271. {
  2272. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2273. }
  2274. else
  2275. {
  2276. table.Range.Bookmarks["ClientName"].Text = "--";
  2277. }
  2278. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2279. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2280. table.Range.Bookmarks["JointTicket"].Text = "--";
  2281. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2282. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2283. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2284. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2285. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2286. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2287. }
  2288. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2289. //保存合并后的文档
  2290. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2291. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2292. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2293. return Ok(JsonView(true, "成功!", rst));
  2294. }
  2295. else
  2296. {
  2297. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2298. DocumentBuilder builder = new DocumentBuilder(doc);
  2299. int tableIndex = 0;//表格索引
  2300. //得到文档中的第一个表格
  2301. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2302. List<string> texts = new List<string>();
  2303. foreach (var item in _AirTicketReservations)
  2304. {
  2305. string[] FlightsCode = item.FlightsCode.Split('/');
  2306. if (FlightsCode.Length != 0)
  2307. {
  2308. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2309. if (_AirCompany != null)
  2310. {
  2311. if (!transDic.ContainsKey(_AirCompany.CnName))
  2312. {
  2313. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2314. }
  2315. }
  2316. else
  2317. {
  2318. if (!transDic.ContainsKey("--"))
  2319. {
  2320. transDic.Add("--", "--");
  2321. }
  2322. }
  2323. }
  2324. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2325. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2326. string name = "";
  2327. foreach (string clientName in nameArray)
  2328. {
  2329. name += clientName + ",";
  2330. }
  2331. if (!texts.Contains(name))
  2332. {
  2333. texts.Add(name);
  2334. }
  2335. List<AirInfo> airs = new List<AirInfo>();
  2336. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2337. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2338. for (int i = 0; i < FlightsCode.Length; i++)
  2339. {
  2340. AirInfo air = new AirInfo();
  2341. string[] tempstr = DayArray[i]
  2342. .Replace("\r\n", string.Empty)
  2343. .Replace("\\r\\n", string.Empty)
  2344. .TrimStart().TrimEnd()
  2345. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2346. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2347. if (star_Three != null)
  2348. {
  2349. if (!transDic.ContainsKey(star_Three.AirPort))
  2350. {
  2351. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2352. }
  2353. }
  2354. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2355. if (End_Three != null)
  2356. {
  2357. if (!transDic.ContainsKey(End_Three.AirPort))
  2358. {
  2359. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2360. }
  2361. }
  2362. if (!texts.Contains(item.CTypeName))
  2363. {
  2364. texts.Add(item.CTypeName);
  2365. }
  2366. }
  2367. }
  2368. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2369. if (transData.Count > 0)
  2370. {
  2371. foreach (TranslateResult item in transData)
  2372. {
  2373. if (!transDic.ContainsKey(item.Query))
  2374. {
  2375. transDic.Add(item.Query, item.Translation);
  2376. }
  2377. }
  2378. }
  2379. foreach (var item in _AirTicketReservations)
  2380. {
  2381. #region 处理固定数据
  2382. string[] FlightsCode = item.FlightsCode.Split('/');
  2383. if (FlightsCode.Length != 0)
  2384. {
  2385. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2386. if (_AirCompany != null)
  2387. {
  2388. string str = "--";
  2389. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2390. if (!string.IsNullOrEmpty(translateResult))
  2391. {
  2392. str = translateResult;
  2393. str = _airTicketResRep.Processing(str);
  2394. }
  2395. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2396. }
  2397. else
  2398. {
  2399. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2400. }
  2401. }
  2402. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2403. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2404. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2405. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2406. string names = "";
  2407. foreach (string clientName in nameArray)
  2408. {
  2409. names += clientName + ",";
  2410. }
  2411. if (!string.IsNullOrWhiteSpace(names))
  2412. {
  2413. string str = "--";
  2414. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2415. if (!string.IsNullOrEmpty(translateResult))
  2416. {
  2417. str = translateResult;
  2418. str = _airTicketResRep.Processing(str);
  2419. }
  2420. table.Range.Bookmarks["ClientName"].Text = str;
  2421. }
  2422. else
  2423. {
  2424. table.Range.Bookmarks["ClientName"].Text = "--";
  2425. }
  2426. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2427. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2428. table.Range.Bookmarks["JointTicket"].Text = "--";
  2429. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2430. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2431. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2432. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2433. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2434. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2435. #endregion
  2436. #region 循环数据处理
  2437. List<AirInfo> airs = new List<AirInfo>();
  2438. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2439. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2440. for (int i = 0; i < FlightsCode.Length; i++)
  2441. {
  2442. AirInfo air = new AirInfo();
  2443. string[] tempstr = DayArray[i]
  2444. .Replace("\r\n", string.Empty)
  2445. .Replace("\\r\\n", string.Empty)
  2446. .TrimStart().TrimEnd()
  2447. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2448. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2449. string starCity = "";
  2450. if (star_Three != null)
  2451. {
  2452. string str2 = "--";
  2453. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2454. if (!string.IsNullOrEmpty(translateResult2))
  2455. {
  2456. str2 = translateResult2;
  2457. str2 = _airTicketResRep.Processing(str2);
  2458. }
  2459. starCity = str2;
  2460. }
  2461. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2462. string EndCity = "";
  2463. if (End_Three != null)
  2464. {
  2465. string str1 = "--";
  2466. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2467. if (!string.IsNullOrEmpty(translateResult1))
  2468. {
  2469. str1 = translateResult1;
  2470. str1 = _airTicketResRep.Processing(str1);
  2471. }
  2472. EndCity = str1;
  2473. }
  2474. air.Destination = starCity + "/" + EndCity;
  2475. air.Flight = FlightsCode[i];
  2476. string str = "--";
  2477. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2478. if (!string.IsNullOrEmpty(translateResult))
  2479. {
  2480. str = translateResult;
  2481. str = _airTicketResRep.Processing(str);
  2482. }
  2483. air.SeatingClass = str;
  2484. string dateTime = tempstr[2];
  2485. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2486. air.FlightDate = DateTemp;
  2487. air.DepartureTime = tempstr[5];
  2488. air.LandingTime = tempstr[6];
  2489. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2490. air.TicketStatus = "--";
  2491. air.Luggage = "--";
  2492. air.DepartureTerminal = "--";
  2493. air.LandingTerminal = "--";
  2494. airs.Add(air);
  2495. }
  2496. int row = 13;
  2497. for (int i = 0; i < airs.Count; i++)
  2498. {
  2499. if (airs.Count > 2)
  2500. {
  2501. for (int j = 0; j < airs.Count - 2; j++)
  2502. {
  2503. var CopyRow = table.Rows[12].Clone(true);
  2504. table.Rows.Add(CopyRow);
  2505. }
  2506. }
  2507. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2508. int index = 0;
  2509. foreach (PropertyInfo property in properties)
  2510. {
  2511. string value = property.GetValue(airs[i]).ToString();
  2512. Cell ishcel0 = table.Rows[row].Cells[index];
  2513. Paragraph p = new Paragraph(doc);
  2514. string s = value;
  2515. p.AppendChild(new Run(doc, s));
  2516. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2517. ishcel0.AppendChild(p);
  2518. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2519. //ishcel0.CellFormat.VerticalAlignment=
  2520. index++;
  2521. }
  2522. row++;
  2523. }
  2524. #endregion
  2525. Paragraph lastParagraph = new Paragraph(doc);
  2526. //第一个表格末尾加段落
  2527. table.ParentNode.InsertAfter(lastParagraph, table);
  2528. //复制第一个表格
  2529. Table cloneTable = (Table)table.Clone(true);
  2530. //在文档末尾段落后面加入复制的表格
  2531. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2532. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2533. {
  2534. int rownewsIndex = 13;
  2535. for (int i = 0; i < 2; i++)
  2536. {
  2537. var CopyRow = table.Rows[12].Clone(true);
  2538. table.Rows.RemoveAt(13);
  2539. table.Rows.Add(CopyRow);
  2540. rownewsIndex++;
  2541. }
  2542. }
  2543. else
  2544. {
  2545. table.Rows.RemoveAt(12);
  2546. }
  2547. cloneTable.Rows.RemoveAt(12);
  2548. }
  2549. if (_AirTicketReservations.Count != 0)
  2550. {
  2551. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2552. if (FlightsCode.Length != 0)
  2553. {
  2554. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2555. if (_AirCompany != null)
  2556. {
  2557. string str = "--";
  2558. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2559. if (!string.IsNullOrEmpty(translateResult))
  2560. {
  2561. str = translateResult;
  2562. str = _airTicketResRep.Processing(str);
  2563. }
  2564. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2565. }
  2566. else
  2567. {
  2568. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2569. }
  2570. }
  2571. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2572. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2573. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2574. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2575. string names = "";
  2576. foreach (string clientName in nameArray)
  2577. {
  2578. names += clientName + ",";
  2579. }
  2580. if (!string.IsNullOrWhiteSpace(names))
  2581. {
  2582. string str = "--";
  2583. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2584. if (!string.IsNullOrEmpty(translateResult))
  2585. {
  2586. str = translateResult;
  2587. str = _airTicketResRep.Processing(str);
  2588. }
  2589. table.Range.Bookmarks["ClientName"].Text = str;
  2590. }
  2591. else
  2592. {
  2593. table.Range.Bookmarks["ClientName"].Text = "--";
  2594. }
  2595. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2596. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2597. table.Range.Bookmarks["JointTicket"].Text = "--";
  2598. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2599. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2600. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2601. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2602. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2603. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2604. }
  2605. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2606. //保存合并后的文档
  2607. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2608. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2609. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2610. return Ok(JsonView(true, "成功!", rst));
  2611. }
  2612. }
  2613. }
  2614. catch (Exception ex)
  2615. {
  2616. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2617. throw;
  2618. }
  2619. }
  2620. #endregion
  2621. #region 团组增减款项 --> 其他款项
  2622. /// <summary>
  2623. /// 团组增减款项下拉框绑定
  2624. /// </summary>
  2625. /// <param name="dto"></param>
  2626. /// <returns></returns>
  2627. [HttpPost]
  2628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2629. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2630. {
  2631. #region 参数验证
  2632. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2633. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2634. #endregion
  2635. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2636. }
  2637. /// <summary>
  2638. /// 根据团组Id查询团组增减款项
  2639. /// </summary>
  2640. /// <param name="dto"></param>
  2641. /// <returns></returns>
  2642. [HttpPost]
  2643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2644. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2645. {
  2646. #region 参数验证
  2647. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2648. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2649. #endregion
  2650. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2651. }
  2652. /// <summary>
  2653. /// 团组增减款项操作(Status:1.新增,2.修改)
  2654. /// </summary>
  2655. /// <param name="dto"></param>
  2656. /// <returns></returns>
  2657. [HttpPost]
  2658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2659. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2660. {
  2661. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2662. if (groupData.Code != 200)
  2663. {
  2664. return Ok(JsonView(false, groupData.Msg));
  2665. }
  2666. #region 应用推送
  2667. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2668. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2669. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2670. #endregion
  2671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2672. }
  2673. /// <summary>
  2674. /// 团组增减款项操作 删除
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2681. {
  2682. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2683. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2684. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2685. if (res.Code == 0)
  2686. {
  2687. return Ok(JsonView(true, "删除成功!"));
  2688. }
  2689. return Ok(JsonView(false, "删除失败!"));
  2690. }
  2691. /// <summary>
  2692. /// 根据团组增减款项Id查询
  2693. /// </summary>
  2694. /// <param name="dto"></param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2699. {
  2700. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2701. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2702. }
  2703. /// <summary>
  2704. /// 查询供应商名称
  2705. /// </summary>
  2706. /// <param name="dto"></param>
  2707. /// <returns></returns>
  2708. [HttpPost]
  2709. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2710. {
  2711. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2712. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2713. ?? new List<Grp_DecreasePayments>();
  2714. dbResult = dbResult.Distinct(new
  2715. ProductComparer()).ToList();
  2716. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2717. {
  2718. x.Id,
  2719. x.SupplierAddress,
  2720. x.SupplierArea,
  2721. x.SupplierContact,
  2722. x.SupplierContactNumber,
  2723. x.SupplierEmail,
  2724. x.SupplierName,
  2725. x.SupplierSocialAccount,
  2726. x.SupplierTypeId,
  2727. }).ToList());
  2728. return Ok(jw);
  2729. }
  2730. #endregion
  2731. #region 文件上传、删除
  2732. /// <summary>
  2733. /// region 文件上传 可以带参数
  2734. /// </summary>
  2735. /// <param name="file"></param>
  2736. /// <returns></returns>
  2737. [HttpPost]
  2738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2739. public async Task<IActionResult> UploadProject(IFormFile file)
  2740. {
  2741. try
  2742. {
  2743. var TypeName = Request.Headers["TypeName"].ToString();
  2744. if (file != null)
  2745. {
  2746. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2747. //文件名称
  2748. string projectFileName = file.FileName;
  2749. //上传的文件的路径
  2750. string filePath = "";
  2751. if (TypeName == "A")//A代表团组增减款项
  2752. {
  2753. if (!Directory.Exists(fileDir))
  2754. {
  2755. Directory.CreateDirectory(fileDir);
  2756. }
  2757. //上传的文件的路径
  2758. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2759. }
  2760. else if (TypeName == "B")//B代表商邀相关文件
  2761. {
  2762. if (!Directory.Exists(fileDir))
  2763. {
  2764. Directory.CreateDirectory(fileDir);
  2765. }
  2766. //上传的文件的路径
  2767. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2768. }
  2769. using (FileStream fs = System.IO.File.Create(filePath))
  2770. {
  2771. file.CopyTo(fs);
  2772. fs.Flush();
  2773. }
  2774. return Ok(JsonView(true, "上传成功!", projectFileName));
  2775. }
  2776. else
  2777. {
  2778. return Ok(JsonView(false, "上传失败!"));
  2779. }
  2780. }
  2781. catch (Exception ex)
  2782. {
  2783. return Ok(JsonView(false, "程序错误!"));
  2784. throw;
  2785. }
  2786. }
  2787. /// <summary>
  2788. /// 删除指定文件
  2789. /// </summary>
  2790. /// <param name="dto"></param>
  2791. /// <returns></returns>
  2792. [HttpPost]
  2793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2794. public async Task<IActionResult> DelFile(DelFileDto dto)
  2795. {
  2796. try
  2797. {
  2798. var TypeName = Request.Headers["TypeName"].ToString();
  2799. string filePath = "";
  2800. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2801. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2802. int id = 0;
  2803. if (TypeName == "A")
  2804. {
  2805. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2806. // 删除该文件
  2807. System.IO.File.Delete(filePath);
  2808. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2809. }
  2810. else if (TypeName == "B")
  2811. {
  2812. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2813. // 删除该文件
  2814. System.IO.File.Delete(filePath);
  2815. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2816. }
  2817. if (id != 0)
  2818. {
  2819. return Ok(JsonView(true, "成功!"));
  2820. }
  2821. else
  2822. {
  2823. return Ok(JsonView(false, "失败!"));
  2824. }
  2825. }
  2826. catch (Exception ex)
  2827. {
  2828. return Ok(JsonView(false, "程序错误!"));
  2829. throw;
  2830. }
  2831. }
  2832. #endregion
  2833. #region 商邀费用录入
  2834. /// <summary>
  2835. /// 根据团组Id查询商邀费用列表
  2836. /// </summary>
  2837. /// <param name="dto"></param>
  2838. /// <returns></returns>
  2839. [HttpPost]
  2840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2841. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2842. {
  2843. try
  2844. {
  2845. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2846. if (groupData.Code != 0)
  2847. {
  2848. return Ok(JsonView(false, groupData.Msg));
  2849. }
  2850. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2851. }
  2852. catch (Exception ex)
  2853. {
  2854. return Ok(JsonView(false, "程序错误!"));
  2855. throw;
  2856. }
  2857. }
  2858. //
  2859. /// <summary>
  2860. /// 商邀费用 Info Page 基础数据源
  2861. /// </summary>
  2862. /// <param name="dto"></param>
  2863. /// <returns></returns>
  2864. [HttpPost]
  2865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2866. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2867. {
  2868. try
  2869. {
  2870. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2871. if (groupData.Code != 0)
  2872. {
  2873. return Ok(JsonView(false, groupData.Msg));
  2874. }
  2875. return Ok(JsonView(true, "操作成功", groupData.Data));
  2876. }
  2877. catch (Exception ex)
  2878. {
  2879. return Ok(JsonView(false, ex.Message));
  2880. throw;
  2881. }
  2882. }
  2883. /// <summary>
  2884. /// 根据商邀费用ID查询C表和商邀费用数据
  2885. /// </summary>
  2886. /// <param name="dto"></param>
  2887. /// <returns></returns>
  2888. [HttpPost]
  2889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2890. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2891. {
  2892. try
  2893. {
  2894. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2895. if (groupData.Code != 0)
  2896. {
  2897. return Ok(JsonView(false, groupData.Msg));
  2898. }
  2899. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2900. }
  2901. catch (Exception ex)
  2902. {
  2903. return Ok(JsonView(false, ex.Message));
  2904. throw;
  2905. }
  2906. }
  2907. /// <summary>
  2908. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2909. /// </summary>
  2910. /// <param name="dto"></param>
  2911. /// <returns></returns>
  2912. [HttpPost]
  2913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2914. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2915. {
  2916. try
  2917. {
  2918. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2919. if (groupData.Code != 0)
  2920. {
  2921. return Ok(JsonView(false, groupData.Msg));
  2922. }
  2923. #region 应用推送
  2924. try
  2925. {
  2926. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2927. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2928. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2929. }
  2930. catch (Exception ex)
  2931. {
  2932. }
  2933. #endregion
  2934. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2935. }
  2936. catch (Exception ex)
  2937. {
  2938. return Ok(JsonView(false, "程序错误!"));
  2939. throw;
  2940. }
  2941. }
  2942. /// <summary>
  2943. /// 商邀删除
  2944. /// </summary>
  2945. /// <param name="dto"></param>
  2946. /// <returns></returns>
  2947. [HttpPost]
  2948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2949. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2950. {
  2951. try
  2952. {
  2953. _sqlSugar.BeginTran();
  2954. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2955. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2956. {
  2957. IsDel = 1,
  2958. DeleteUserId = dto.DeleteUserId,
  2959. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2960. })
  2961. .Where(it => it.Id == dto.Id)
  2962. .ExecuteCommand();
  2963. if (res1 > 0)
  2964. {
  2965. int _diId = 0;
  2966. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2967. if (_ioaInfo != null)
  2968. {
  2969. _diId = _ioaInfo.DiId;
  2970. }
  2971. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2972. .SetColumns(a => new Grp_CreditCardPayment()
  2973. {
  2974. IsDel = 1,
  2975. DeleteUserId = dto.DeleteUserId,
  2976. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2977. })
  2978. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2979. .ExecuteCommand();
  2980. if (res2 > 0)
  2981. {
  2982. _sqlSugar.CommitTran();
  2983. return Ok(JsonView(true, "删除成功!"));
  2984. }
  2985. }
  2986. _sqlSugar.RollbackTran();
  2987. return Ok(JsonView(false, "删除失败"));
  2988. }
  2989. catch (Exception ex)
  2990. {
  2991. _sqlSugar.RollbackTran();
  2992. return Ok(JsonView(false, ex.Message));
  2993. }
  2994. }
  2995. #endregion
  2996. #region 团组英文资料
  2997. /// <summary>
  2998. /// 查询团组英文所有资料
  2999. /// </summary>
  3000. /// <param name="dto"></param>
  3001. /// <returns></returns>
  3002. [HttpPost]
  3003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3004. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3005. {
  3006. try
  3007. {
  3008. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3009. if (groupData.Code != 0)
  3010. {
  3011. return Ok(JsonView(false, groupData.Msg));
  3012. }
  3013. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3014. }
  3015. catch (Exception ex)
  3016. {
  3017. return Ok(JsonView(false, "程序错误!"));
  3018. throw;
  3019. }
  3020. }
  3021. /// <summary>
  3022. /// 团组英文资料操作(Status:1.新增,2.修改)
  3023. /// </summary>
  3024. /// <param name="dto"></param>
  3025. /// <returns></returns>
  3026. [HttpPost]
  3027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3028. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3029. {
  3030. try
  3031. {
  3032. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3033. if (groupData.Code != 0)
  3034. {
  3035. return Ok(JsonView(false, groupData.Msg));
  3036. }
  3037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3038. }
  3039. catch (Exception ex)
  3040. {
  3041. return Ok(JsonView(false, "程序错误!"));
  3042. throw;
  3043. }
  3044. }
  3045. /// <summary>
  3046. /// 团组英文资料Id查询数据
  3047. /// </summary>
  3048. /// <param name="dto"></param>
  3049. /// <returns></returns>
  3050. [HttpPost]
  3051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3052. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3053. {
  3054. try
  3055. {
  3056. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3057. if (_DelegationEnData != null)
  3058. {
  3059. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3060. }
  3061. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3062. }
  3063. catch (Exception ex)
  3064. {
  3065. return Ok(JsonView(false, "程序错误!"));
  3066. throw;
  3067. }
  3068. }
  3069. /// <summary>
  3070. /// 团组英文资料删除
  3071. /// </summary>
  3072. /// <param name="dto"></param>
  3073. /// <returns></returns>
  3074. [HttpPost]
  3075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3076. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3077. {
  3078. try
  3079. {
  3080. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3081. if (!res)
  3082. {
  3083. return Ok(JsonView(false, "删除失败"));
  3084. }
  3085. return Ok(JsonView(true, "删除成功!"));
  3086. }
  3087. catch (Exception ex)
  3088. {
  3089. return Ok(JsonView(false, "程序错误!"));
  3090. throw;
  3091. }
  3092. }
  3093. #endregion
  3094. #region 导出邀请函
  3095. /// <summary>
  3096. /// 导出邀请函页面初始化
  3097. /// </summary>
  3098. /// <param name="dto"></param>
  3099. /// <returns></returns>
  3100. [HttpPost]
  3101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3102. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3103. {
  3104. try
  3105. {
  3106. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3107. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3108. if (dto.DiId == 0)
  3109. {
  3110. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3111. }
  3112. else
  3113. {
  3114. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3115. }
  3116. return Ok(JsonView(true, "查询成功!", new
  3117. {
  3118. deleClient = crm_Deles,
  3119. delegations = grp_Delegations
  3120. }));
  3121. }
  3122. catch (Exception ex)
  3123. {
  3124. return Ok(JsonView(false, "程序错误!"));
  3125. throw;
  3126. }
  3127. }
  3128. /// <summary>
  3129. /// 导出邀请函
  3130. /// </summary>
  3131. /// <param name="dto"></param>
  3132. /// <returns></returns>
  3133. [HttpPost]
  3134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3135. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3136. {
  3137. #region 参数验证
  3138. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3139. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3140. #endregion
  3141. try
  3142. {
  3143. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3144. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3145. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3146. From Grp_TourClientList tcl
  3147. Left Join
  3148. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3149. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3150. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3151. From Crm_DeleClient dc
  3152. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3153. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3154. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3155. Where dc.IsDel = 0) temp
  3156. On temp.DcId =tcl.ClientId
  3157. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3158. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3159. List<string> texts = new List<string>();
  3160. if (datas.Count != 0)
  3161. {
  3162. foreach (TourClientListDetailsView item in datas)
  3163. {
  3164. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3165. {
  3166. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3167. }
  3168. else
  3169. {
  3170. string name = item.LastName + item.FirstName;
  3171. texts.Add(name);
  3172. }
  3173. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3174. {
  3175. if (!transDic.ContainsKey(item.Job))
  3176. {
  3177. texts.Add(item.Job);
  3178. }
  3179. }
  3180. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3181. {
  3182. texts.Add(item.CompanyFullName);
  3183. }
  3184. }
  3185. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3186. if (transData.Count > 0)
  3187. {
  3188. foreach (TranslateResult item in transData)
  3189. {
  3190. if (!transDic.ContainsKey(item.Query))
  3191. {
  3192. transDic.Add(item.Query, item.Translation);
  3193. }
  3194. }
  3195. }
  3196. List<GuestList> list = new List<GuestList>();
  3197. foreach (TourClientListDetailsView dele in datas)
  3198. {
  3199. GuestList guestList = new GuestList();
  3200. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3201. {
  3202. guestList.Name = dele.Pinyin;
  3203. }
  3204. else
  3205. {
  3206. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3207. guestList.Name = Name;
  3208. }
  3209. if (dele.Sex == 0)
  3210. {
  3211. guestList.Sex = "Male";
  3212. }
  3213. else if (dele.Sex == 1)
  3214. {
  3215. guestList.Sex = "Female";
  3216. }
  3217. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3218. if (!string.IsNullOrEmpty(dele.Job))
  3219. {
  3220. guestList.Job = dele.Job;
  3221. }
  3222. list.Add(guestList);
  3223. }
  3224. //载入模板
  3225. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3226. DocumentBuilder builder = new DocumentBuilder(doc);
  3227. //获取word里所有表格
  3228. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3229. //获取所填表格的序数
  3230. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3231. var rowStart = tableOne.Rows[0]; //获取第1行
  3232. //循环赋值
  3233. for (int i = 0; i < list.Count; i++)
  3234. {
  3235. builder.MoveToCell(0, i + 1, 0, 0);
  3236. builder.Write(list[i].Name.ToString());
  3237. builder.MoveToCell(0, i + 1, 1, 0);
  3238. builder.Write(list[i].Sex.ToString());
  3239. builder.MoveToCell(0, i + 1, 2, 0);
  3240. builder.Write(list[i].DOB.ToString());
  3241. builder.MoveToCell(0, i + 1, 3, 0);
  3242. builder.Write(list[i].Job.ToString());
  3243. }
  3244. //删除多余行
  3245. while (tableOne.Rows.Count > list.Count + 1)
  3246. {
  3247. tableOne.Rows.RemoveAt(list.Count + 1);
  3248. }
  3249. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3250. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3251. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3252. doc.Save(filePath);
  3253. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3254. return Ok(JsonView(true, "操作成功!", Url));
  3255. }
  3256. else
  3257. {
  3258. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3259. }
  3260. }
  3261. catch (Exception ex)
  3262. {
  3263. return Ok(JsonView(false, ex.Message));
  3264. throw;
  3265. }
  3266. }
  3267. #endregion
  3268. #region 团组经理模块 出入境费用
  3269. ///// <summary>
  3270. ///// 团组模块 - 出入境费用
  3271. ///// </summary>
  3272. ///// <returns></returns>
  3273. //[HttpPost]
  3274. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3275. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3276. //{
  3277. // try
  3278. // {
  3279. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3280. // if (data.Code != 0)
  3281. // {
  3282. // return Ok(JsonView(false, data.Msg));
  3283. // }
  3284. // return Ok(JsonView(true, "查询成功!"));
  3285. // }
  3286. // catch (Exception ex)
  3287. // {
  3288. // return Ok(JsonView(false, ex.Message));
  3289. // throw;
  3290. // }
  3291. //}
  3292. /// <summary>
  3293. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3294. /// </summary>
  3295. /// <returns></returns>
  3296. [HttpPost]
  3297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3298. public async Task<IActionResult> SetDayAndCostAreaChange()
  3299. {
  3300. try
  3301. {
  3302. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3303. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3304. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3305. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3306. foreach (var item in unite) //处理交集数据
  3307. {
  3308. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3309. }
  3310. foreach (var item in merge) //处理差集数据
  3311. {
  3312. int nationalTravelFeeId = 0;
  3313. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3314. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3315. else
  3316. {
  3317. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3318. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3319. }
  3320. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3321. }
  3322. //只更新dayAndCost 的 nationalTravelFeeId;
  3323. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3324. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3325. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3326. }
  3327. catch (Exception ex)
  3328. {
  3329. return Ok(JsonView(false, ex.Message));
  3330. throw;
  3331. }
  3332. }
  3333. /// <summary>
  3334. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3335. /// </summary>
  3336. /// <returns></returns>
  3337. [HttpPost]
  3338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3339. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3340. {
  3341. try
  3342. {
  3343. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3344. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3345. //SetDataInfoView
  3346. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3347. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3348. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3349. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3350. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3351. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3352. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3353. //默认币种显示
  3354. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3355. {
  3356. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3357. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3358. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3359. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3360. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3361. };
  3362. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3363. if (_currencyRate.Count > 0)
  3364. {
  3365. foreach (var item in _currencyInfos)
  3366. {
  3367. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3368. if (rateInfo != null)
  3369. {
  3370. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3371. rate1 *= 1.03M;
  3372. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3373. }
  3374. }
  3375. }
  3376. return Ok(JsonView(true, "查询成功!", new
  3377. {
  3378. GroupNameData = groupNameData.Data,
  3379. CurrencyData = _CurrencyData,
  3380. WordTypeData = _WordTypeData,
  3381. ExcelTypeData = _ExcelTypeData,
  3382. CurrencyInit = _currencyInfos
  3383. }));
  3384. }
  3385. catch (Exception ex)
  3386. {
  3387. return Ok(JsonView(false, ex.Message));
  3388. throw;
  3389. }
  3390. }
  3391. /// <summary>
  3392. /// 团组模块 - 出入境费用
  3393. /// 实时汇率 tips
  3394. /// 签证费用 tips
  3395. /// </summary>
  3396. /// <returns></returns>
  3397. [HttpPost]
  3398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3399. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3400. {
  3401. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3402. //默认币种显示
  3403. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3404. {
  3405. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3406. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3407. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3408. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3409. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3410. };
  3411. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3412. List<dynamic> reteInfos = new List<dynamic>();
  3413. if (_currencyRate.Count > 0)
  3414. {
  3415. foreach (var item in _currencyInfos)
  3416. {
  3417. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3418. if (rateInfo != null)
  3419. {
  3420. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3421. decimal rate1 = item.Rate;
  3422. rate1 *= 1.03M;
  3423. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3424. reteInfos.Add(new
  3425. {
  3426. currCode = item.CurrencyCode,
  3427. currName = item.CurrencyName,
  3428. rate = rate2,
  3429. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3430. });
  3431. }
  3432. }
  3433. }
  3434. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3435. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3436. return Ok(JsonView(true, "查询成功!", new
  3437. {
  3438. //GroupNameData = groupNameData.Data,
  3439. visaData = visaData.Data,
  3440. airData = airData.Data,
  3441. reteInfos = reteInfos
  3442. }));
  3443. }
  3444. /// <summary>
  3445. /// 团组模块 - 出入境费用 - Info
  3446. /// </summary>
  3447. /// <returns></returns>
  3448. [HttpPost]
  3449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3450. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3451. {
  3452. try
  3453. {
  3454. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3455. if (data.Code != 0)
  3456. {
  3457. return Ok(JsonView(false, data.Msg));
  3458. }
  3459. return Ok(JsonView(true, "查询成功!", data.Data));
  3460. }
  3461. catch (Exception ex)
  3462. {
  3463. return Ok(JsonView(false, ex.Message));
  3464. }
  3465. }
  3466. /// <summary>
  3467. /// 团组模块 - 出入境费用 - Add And Update
  3468. /// </summary>
  3469. /// <returns></returns>
  3470. [HttpPost]
  3471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3472. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3473. {
  3474. try
  3475. {
  3476. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3477. if (data.Code != 0)
  3478. {
  3479. return Ok(JsonView(false, data.Msg));
  3480. }
  3481. return Ok(JsonView(true, data.Msg, data.Data));
  3482. }
  3483. catch (Exception ex)
  3484. {
  3485. return Ok(JsonView(false, ex.Message));
  3486. }
  3487. }
  3488. /// <summary>
  3489. /// 团组模块 - 出入境费用 - File downlaod
  3490. /// </summary>
  3491. /// <param name="dto"></param>
  3492. /// <returns></returns>
  3493. [HttpPost]
  3494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3495. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3496. {
  3497. try
  3498. {
  3499. if (dto.DiId < 1)
  3500. {
  3501. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3502. }
  3503. if (dto.ExportType < 1)
  3504. {
  3505. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3506. }
  3507. if (dto.SubTypeId < 1)
  3508. {
  3509. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3510. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3511. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3512. 3 团组成员名单 1 团组成员名单"));
  3513. }
  3514. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3515. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3516. if (_EnterExitCosts == null)
  3517. {
  3518. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3519. }
  3520. //数据源
  3521. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3522. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3523. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3524. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3525. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3526. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3527. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3528. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3529. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3530. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3531. .Select((tcl, dc, cc) => new
  3532. {
  3533. Name = dc.LastName + dc.FirstName,
  3534. Sex = dc.Sex,
  3535. Birthday = dc.BirthDay,
  3536. Company = cc.CompanyFullName,
  3537. Job = dc.Job
  3538. })
  3539. .ToList();
  3540. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3541. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3542. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3543. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3544. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3545. if (dto.ExportType == 1) //明细表
  3546. {
  3547. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3548. {
  3549. //获取模板
  3550. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3551. //载入模板
  3552. Document doc = new Document(tempPath);
  3553. DocumentBuilder builder = new DocumentBuilder(doc);
  3554. //利用键值对存放数据
  3555. Dictionary<string, string> dic = new Dictionary<string, string>();
  3556. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3557. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3558. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3559. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3560. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3561. string row1_1 = "";
  3562. if (_EnterExitCosts.Visa > 0)
  3563. {
  3564. //insidePayTotal += _EnterExitCosts.Visa;
  3565. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3566. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3567. {
  3568. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3569. }
  3570. }
  3571. string row1_2 = "";
  3572. if (_EnterExitCosts.YiMiao > 0)
  3573. {
  3574. //insidePayTotal += _EnterExitCosts.YiMiao;
  3575. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3576. }
  3577. if (_EnterExitCosts.HeSuan > 0)
  3578. {
  3579. //insidePayTotal += _EnterExitCosts.HeSuan;
  3580. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3581. }
  3582. if (_EnterExitCosts.Service > 0)
  3583. {
  3584. //insidePayTotal += _EnterExitCosts.Service;
  3585. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3586. }
  3587. string row1_3 = "";
  3588. if (_EnterExitCosts.Safe > 0)
  3589. {
  3590. //insidePayTotal += _EnterExitCosts.Safe;
  3591. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3592. }
  3593. if (_EnterExitCosts.Ticket > 0)
  3594. {
  3595. //insidePayTotal += _EnterExitCosts.Ticket;
  3596. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3597. }
  3598. string row1 = "";
  3599. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3600. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3601. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3602. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3603. dic.Add("Row1Str", row1);
  3604. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3605. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3606. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3607. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3608. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3609. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3610. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3611. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3612. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3613. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3614. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3615. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3616. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3617. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3618. #region 填充word模板书签内容
  3619. foreach (var key in dic.Keys)
  3620. {
  3621. builder.MoveToBookmark(key);
  3622. builder.Write(dic[key]);
  3623. }
  3624. #endregion
  3625. #region 填充word表格内容
  3626. ////获读取指定表格方法二
  3627. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3628. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3629. for (int i = 0; i < dac1.Count; i++)
  3630. {
  3631. Grp_DayAndCost dac = dac1[i];
  3632. if (dac == null) continue;
  3633. builder.MoveToCell(0, i, 0, 0);
  3634. builder.Write("第" + dac.Days.ToString() + "晚:");
  3635. builder.MoveToCell(0, i, 1, 0);
  3636. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3637. //builder.Write(dac.Place == null ? "" : dac.Place);
  3638. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3639. builder.MoveToCell(0, i, 2, 0);
  3640. builder.Write("费用标准:");
  3641. string curr = "";
  3642. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3643. if (currData != null)
  3644. {
  3645. curr = currData.Name;
  3646. }
  3647. builder.MoveToCell(0, i, 3, 0);
  3648. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3649. builder.MoveToCell(0, i, 4, 0);
  3650. builder.Write("费用小计:");
  3651. builder.MoveToCell(0, i, 5, 0);
  3652. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3653. }
  3654. //删除多余行
  3655. while (table1.Rows.Count > dac1.Count)
  3656. {
  3657. table1.Rows.RemoveAt(dac1.Count);
  3658. }
  3659. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3660. for (int i = 0; i < dac2.Count; i++)
  3661. {
  3662. Grp_DayAndCost dac = dac2[i];
  3663. if (dac == null) continue;
  3664. builder.MoveToCell(1, i, 0, 0);
  3665. builder.Write("第" + dac.Days.ToString() + "天:");
  3666. builder.MoveToCell(1, i, 1, 0);
  3667. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3668. builder.MoveToCell(1, i, 2, 0);
  3669. builder.Write("费用标准:");
  3670. string curr = "";
  3671. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3672. if (currData != null)
  3673. {
  3674. curr = currData.Name;
  3675. }
  3676. builder.MoveToCell(1, i, 3, 0);
  3677. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3678. builder.MoveToCell(1, i, 4, 0);
  3679. builder.Write("费用小计:");
  3680. builder.MoveToCell(1, i, 5, 0);
  3681. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3682. }
  3683. //删除多余行
  3684. while (table2.Rows.Count > dac2.Count)
  3685. {
  3686. table2.Rows.RemoveAt(dac2.Count);
  3687. }
  3688. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3689. for (int i = 0; i < dac3.Count; i++)
  3690. {
  3691. Grp_DayAndCost dac = dac3[i];
  3692. if (dac == null) continue;
  3693. builder.MoveToCell(2, i, 0, 0);
  3694. builder.Write("第" + dac.Days.ToString() + "天:");
  3695. builder.MoveToCell(2, i, 1, 0);
  3696. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3697. builder.MoveToCell(2, i, 2, 0);
  3698. builder.Write("费用标准:");
  3699. string curr = "";
  3700. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3701. if (currData != null)
  3702. {
  3703. curr = currData.Name;
  3704. }
  3705. builder.MoveToCell(2, i, 3, 0);
  3706. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3707. builder.MoveToCell(2, i, 4, 0);
  3708. builder.Write("费用小计:");
  3709. builder.MoveToCell(2, i, 5, 0);
  3710. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3711. }
  3712. //删除多余行
  3713. while (table3.Rows.Count > dac3.Count)
  3714. {
  3715. table3.Rows.RemoveAt(dac3.Count);
  3716. }
  3717. #endregion
  3718. //文件名
  3719. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3720. AsposeHelper.removewatermark_v2180();
  3721. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3722. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3723. return Ok(JsonView(true, "成功", new { Url = url }));
  3724. }
  3725. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3726. {
  3727. //获取模板
  3728. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3729. //载入模板
  3730. Document doc = new Document(tempPath);
  3731. DocumentBuilder builder = new DocumentBuilder(doc);
  3732. Dictionary<string, string> dic = new Dictionary<string, string>();
  3733. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3734. {
  3735. List<string> list = new List<string>();
  3736. try
  3737. {
  3738. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3739. foreach (var item in spilitArr)
  3740. {
  3741. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3742. var depCode = spDotandEmpty[2].Substring(0, 3);
  3743. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3744. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3745. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3746. list.Add(depName);
  3747. list.Add(arrName);
  3748. }
  3749. list = list.Distinct().ToList();
  3750. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3751. }
  3752. catch (Exception)
  3753. {
  3754. dic.Add("ReturnCode", "行程录入不正确!");
  3755. }
  3756. }
  3757. else
  3758. {
  3759. dic.Add("ReturnCode", "未录入行程!");
  3760. }
  3761. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3762. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3763. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3764. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3765. {
  3766. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3767. dic.Add("Day", sp.Days.ToString());
  3768. }
  3769. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3770. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3771. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3772. //dic.Add("Names", Names);
  3773. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3774. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3775. decimal dac1totalPrice = 0.00M;
  3776. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3777. foreach (var dac in dac1)
  3778. {
  3779. if (dac.SubTotal == 0.00M)
  3780. {
  3781. continue;
  3782. }
  3783. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3784. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3785. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3786. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3787. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3788. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3789. builder.Write(currency);//币种
  3790. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3791. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3792. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3793. builder.Write("");//人数
  3794. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3795. builder.Write("");//天数
  3796. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3797. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3798. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3799. decimal rate = 0.00M;
  3800. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3801. builder.Write(rate.ToString("#0.0000"));//汇率
  3802. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3803. decimal rbmPrice = dac.SubTotal;
  3804. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3805. accommodationStartIndex++;
  3806. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3807. }
  3808. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3809. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3810. {
  3811. table1.Rows.RemoveAt(i - 1);
  3812. foodandotherStartIndex--;
  3813. }
  3814. if (dac2.Count == dac3.Count)//国家 币种 金额
  3815. {
  3816. for (int i = 0; i < dac2.Count; i++)
  3817. {
  3818. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3819. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3820. }
  3821. }
  3822. decimal dac2totalPrice = 0.00M;
  3823. foreach (var dac in dac2)
  3824. {
  3825. if (dac.SubTotal == 0)
  3826. {
  3827. continue;
  3828. }
  3829. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3830. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3831. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3832. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3833. builder.Write(currency);//币种
  3834. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3835. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3836. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3837. builder.Write("");//人数
  3838. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3839. builder.Write("");//天数
  3840. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3841. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3842. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3843. decimal rate = 0.00M;
  3844. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3845. builder.Write(rate.ToString("#0.0000"));//汇率
  3846. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3847. decimal rbmPrice = dac.SubTotal;
  3848. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3849. foodandotherStartIndex++;
  3850. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3851. }
  3852. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3853. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3854. {
  3855. table1.Rows.RemoveAt(i - 1);
  3856. }
  3857. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3858. string otherFeeStr = "";
  3859. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3860. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3861. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3862. if (otherFeeStr.Length > 0)
  3863. {
  3864. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3865. otherFeeStr = $"({otherFeeStr})";
  3866. dic.Add("OtherFeeStr", otherFeeStr);
  3867. }
  3868. //总计
  3869. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3870. //国际旅费
  3871. string outsideJJ = "";
  3872. string allPriceJJ = "";
  3873. if (_EnterExitCosts.SumJJC == 1)
  3874. {
  3875. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3876. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3877. }
  3878. string outsideGW = "";
  3879. string allPriceGW = "";
  3880. if (_EnterExitCosts.SumGWC == 1)
  3881. {
  3882. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3883. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3884. }
  3885. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3886. {
  3887. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3888. dic.Add("InTravelPrice", InTravelPriceStr);
  3889. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3890. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3891. }
  3892. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3893. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3894. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3895. foreach (var key in dic.Keys)
  3896. {
  3897. builder.MoveToBookmark(key);
  3898. builder.Write(dic[key]);
  3899. }
  3900. //模板文件名
  3901. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3902. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3903. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3904. return Ok(JsonView(true, "成功", new { Url = url }));
  3905. }
  3906. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3907. {
  3908. //获取模板
  3909. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3910. //载入模板
  3911. WorkbookDesigner designer = new WorkbookDesigner();
  3912. designer.Workbook = new Workbook(tempPath);
  3913. Dictionary<string, string> dic = new Dictionary<string, string>();
  3914. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3915. {
  3916. List<string> list = new List<string>();
  3917. try
  3918. {
  3919. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3920. foreach (var item in spilitArr)
  3921. {
  3922. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3923. var depCode = spDotandEmpty[2].Substring(0, 3);
  3924. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3925. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3926. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3927. list.Add(depName);
  3928. list.Add(arrName);
  3929. }
  3930. list = list.Distinct().ToList();
  3931. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3932. }
  3933. catch (Exception)
  3934. {
  3935. dic.Add("ReturnCode", "行程录入不正确!");
  3936. }
  3937. }
  3938. else
  3939. {
  3940. dic.Add("ReturnCode", "未录入行程!");
  3941. }
  3942. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3943. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3944. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3945. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3946. {
  3947. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3948. dic.Add("Day", sp.Days.ToString());
  3949. }
  3950. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3951. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3952. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3953. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3954. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3955. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3956. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3957. designer.SetDataSource("Name", Names);
  3958. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3959. designer.SetDataSource("Day", dic["Day"] + "天");
  3960. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3961. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3962. int startIndex = 10;
  3963. const int startIndexcopy = 10;
  3964. if (dac2.Count == dac3.Count)//国家 币种 金额
  3965. {
  3966. for (int i = 0; i < dac2.Count; i++)
  3967. {
  3968. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3969. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3970. }
  3971. }
  3972. DataTable dtdac1 = new DataTable();
  3973. List<string> place = new List<string>();
  3974. dtdac1.Columns.AddRange(new DataColumn[] {
  3975. new DataColumn(){ ColumnName = "city"},
  3976. new DataColumn(){ ColumnName = "curr"},
  3977. new DataColumn(){ ColumnName = "criterion"},
  3978. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3979. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3980. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3981. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3982. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3983. });
  3984. DataTable dtdac2 = new DataTable();
  3985. dtdac2.Columns.AddRange(new DataColumn[] {
  3986. new DataColumn(){ ColumnName = "city"},
  3987. new DataColumn(){ ColumnName = "curr"},
  3988. new DataColumn(){ ColumnName = "criterion"},
  3989. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3990. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3991. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3992. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3993. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3994. });
  3995. dtdac1.TableName = "tb1";
  3996. dtdac2.TableName = "tb2";
  3997. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3998. foreach (var item in dac1)
  3999. {
  4000. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4001. if (place.Contains(item.Place))
  4002. {
  4003. continue;
  4004. }
  4005. DataRow row = dtdac1.NewRow();
  4006. row["city"] = item.Place;
  4007. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4008. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4009. row["curr"] = currency;
  4010. row["rate"] = rate.ToString("#0.0000");
  4011. row["criterion"] = item.Cost.ToString("#0.00");
  4012. row["number"] = 1;
  4013. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4014. //row["costRMB"] = rbmPrice;
  4015. dtdac1.Rows.Add(row);
  4016. place.Add(item.Place);
  4017. }
  4018. place = new List<string>();
  4019. foreach (var item in dac2)
  4020. {
  4021. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4022. if (place.Contains(item.Place))
  4023. {
  4024. continue;
  4025. }
  4026. DataRow row = dtdac2.NewRow();
  4027. row["city"] = item.Place;
  4028. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4029. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4030. row["curr"] = currency;
  4031. row["rate"] = rate.ToString("#0.0000");
  4032. row["criterion"] = item.Cost.ToString("#0.00");
  4033. row["number"] = 1;
  4034. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4035. //row["cost"] = item.SubTotal;
  4036. //row["costRMB"] = rbmPrice;
  4037. dtdac2.Rows.Add(row);
  4038. place.Add(item.Place);
  4039. //dac2totalPrice += rbmPrice;
  4040. }
  4041. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4042. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4043. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4044. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4045. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4046. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4047. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4048. string cellStr = $" 5.其他费用(";
  4049. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4050. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4051. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4052. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4053. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4054. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4055. if (cellStr.Length > 8)
  4056. {
  4057. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4058. }
  4059. cellStr += ")";
  4060. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4061. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4062. decimal pxFee = dac4.Sum(it => it.Cost);
  4063. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4064. string celllastStr1 = "";
  4065. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4066. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4067. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4068. celllastStr1 += $",国际旅费 元";
  4069. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4070. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4071. designer.SetDataSource("cell4Str", cell4Str);
  4072. designer.SetDataSource("cellStr", cellStr);
  4073. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4074. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4075. designer.SetDataSource("celllastStr", celllastStr);
  4076. Workbook wb = designer.Workbook;
  4077. var sheet = wb.Worksheets[0];
  4078. //绑定datatable数据集
  4079. designer.SetDataSource(dtdac1);
  4080. designer.SetDataSource(dtdac2);
  4081. designer.Process();
  4082. var rowStart = dtdac1.Rows.Count;
  4083. while (rowStart > 0)
  4084. {
  4085. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4086. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4087. startIndex++;
  4088. rowStart--;
  4089. }
  4090. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4091. startIndex += 1; //总计行
  4092. rowStart = dtdac2.Rows.Count;
  4093. while (rowStart > 0)
  4094. {
  4095. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4096. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4097. startIndex++;
  4098. rowStart--;
  4099. }
  4100. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4101. wb.CalculateFormula(true);
  4102. //模板文件名
  4103. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4104. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4105. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4106. return Ok(JsonView(true, "成功", new { Url = url }));
  4107. }
  4108. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4109. {
  4110. //获取模板
  4111. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4112. //载入模板
  4113. Document doc = new Document(tempPath);
  4114. DocumentBuilder builder = new DocumentBuilder(doc);
  4115. Dictionary<string, string> dic = new Dictionary<string, string>();
  4116. dic.Add("GroupName", _DelegationInfo.TeamName);
  4117. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4118. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4119. string missionLeaderJob = "";//负责人job
  4120. int groupNumber = 0; //团人数
  4121. if (DeleClientList.Count > 0)
  4122. {
  4123. missionLeader = DeleClientList[0]?.Name ?? "";
  4124. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4125. }
  4126. dic.Add("MissionLeader", missionLeader); //团负责人
  4127. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4128. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4129. #region MyRegion
  4130. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4131. //{
  4132. // List<string> list = new List<string>();
  4133. // try
  4134. // {
  4135. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4136. // foreach (var item in spilitArr)
  4137. // {
  4138. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4139. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4140. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4141. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4142. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4143. // list.Add(depName);
  4144. // list.Add(arrName);
  4145. // }
  4146. // list = list.Distinct().ToList();
  4147. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4148. // }
  4149. // catch (Exception)
  4150. // {
  4151. // dic.Add("ReturnCode", "行程录入不正确!");
  4152. // }
  4153. //}
  4154. //else
  4155. //{
  4156. // dic.Add("ReturnCode", "未录入行程!");
  4157. //}
  4158. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4159. dic.Add("ReturnCode", string.Join("、", countrys));
  4160. #endregion
  4161. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4162. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4163. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4164. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4165. //{
  4166. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4167. // dic.Add("Day", sp.Days.ToString());
  4168. //}
  4169. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4170. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4171. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4172. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4173. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4174. //培训人员名单
  4175. int cultivateRowIndex = 7;
  4176. foreach (var item in DeleClientList)
  4177. {
  4178. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4179. builder.Write(item.Name);
  4180. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4181. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4182. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4183. string birthDay = "";
  4184. if (item.Birthday != null)
  4185. {
  4186. DateTime dt = Convert.ToDateTime(item.Birthday);
  4187. birthDay = $"{dt.Year}.{dt.Month}";
  4188. }
  4189. builder.Write(birthDay);
  4190. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4191. builder.Write(item.Company);
  4192. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4193. builder.Write(item.Job);
  4194. cultivateRowIndex++;
  4195. }
  4196. //删除多余行
  4197. //cultivateRowIndex -= 2;
  4198. int delRows = 10 + 7 - cultivateRowIndex;
  4199. if (delRows > 0)
  4200. {
  4201. for (int i = 0; i < delRows; i++)
  4202. {
  4203. table1.Rows.RemoveAt(cultivateRowIndex);
  4204. //cultivateRowIndex++;
  4205. }
  4206. }
  4207. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4208. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4209. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4210. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4211. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4212. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4213. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4214. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4215. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4216. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4217. //其他费用
  4218. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4219. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4220. //其他费用合计
  4221. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4222. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4223. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4224. //公务舱合计
  4225. //国际旅费
  4226. string outsideJJ = "";
  4227. string allPriceJJ = "";
  4228. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4229. {
  4230. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4231. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4232. }
  4233. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4234. {
  4235. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4236. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4237. }
  4238. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4239. {
  4240. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4241. dic.Add("AirFeeTotal", airFeeTotalStr);
  4242. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4243. dic.Add("FeeTotal", feeTotalStr);
  4244. }
  4245. foreach (var key in dic.Keys)
  4246. {
  4247. builder.MoveToBookmark(key);
  4248. builder.Write(dic[key]);
  4249. }
  4250. //模板文件名
  4251. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4252. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4253. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4254. return Ok(JsonView(true, "成功", new { Url = url }));
  4255. }
  4256. }
  4257. else if (dto.ExportType == 2) //表格
  4258. {
  4259. //利用键值对存放数据
  4260. Dictionary<string, string> dic = new Dictionary<string, string>();
  4261. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4262. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4263. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4264. dic.Add("Day", sp.Days.ToString());
  4265. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4266. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4267. {
  4268. //获取模板
  4269. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4270. //载入模板
  4271. Document doc = new Document(tempPath);
  4272. DocumentBuilder builder = new DocumentBuilder(doc);
  4273. dic.Add("TeamName", _DelegationInfo.TeamName);
  4274. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4275. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4276. string missionLeaderName = "",
  4277. missionLeaderJob = "";
  4278. if (DeleClientList.Count > 0)
  4279. {
  4280. missionLeaderName = DeleClientList[0].Name;
  4281. missionLeaderJob = DeleClientList[0].Job;
  4282. }
  4283. dic.Add("MissionLeaderName", missionLeaderName);
  4284. dic.Add("MissionLeaderJob", missionLeaderJob);
  4285. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4286. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4287. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4288. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4289. int rowCount = 10;//总人数行
  4290. int startRowIndex = 7; //起始行
  4291. for (int i = 0; i < DeleClientList.Count; i++)
  4292. {
  4293. builder.MoveToCell(0, startRowIndex, 0, 0);
  4294. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4295. builder.MoveToCell(0, startRowIndex, 1, 0);
  4296. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4297. builder.Write(sex);//性别
  4298. builder.MoveToCell(0, startRowIndex, 2, 0);
  4299. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4300. builder.MoveToCell(0, startRowIndex, 3, 0);
  4301. builder.Write(DeleClientList[i].Company);//工作单位
  4302. builder.MoveToCell(0, startRowIndex, 4, 0);
  4303. builder.Write(DeleClientList[i].Job);//职务及级别
  4304. builder.MoveToCell(0, startRowIndex, 5, 0);
  4305. builder.Write("");//人员属性
  4306. builder.MoveToCell(0, startRowIndex, 6, 0);
  4307. builder.Write("");//上次出国时间
  4308. startRowIndex++;
  4309. }
  4310. int nullRow = rowCount - DeleClientList.Count;//空行
  4311. for (int i = 0; i < nullRow; i++)
  4312. {
  4313. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4314. }
  4315. foreach (var key in dic.Keys)
  4316. {
  4317. builder.MoveToBookmark(key);
  4318. builder.Write(dic[key]);
  4319. }
  4320. //模板文件名
  4321. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4322. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4323. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4324. return Ok(JsonView(true, "成功", new { Url = url }));
  4325. }
  4326. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4327. {
  4328. //获取模板
  4329. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4330. //载入模板
  4331. Document doc = new Document(tempPath);
  4332. DocumentBuilder builder = new DocumentBuilder(doc);
  4333. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4334. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4335. dic.Add("Names", Names);
  4336. int accommodationRows = 12, foodandotherRows = 12;
  4337. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4338. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4339. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4340. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4341. int accommodationStartIndex = 6;
  4342. decimal dac1totalPrice = 0.00M;
  4343. foreach (var dac in dac1)
  4344. {
  4345. if (dac.SubTotal == 0)
  4346. {
  4347. continue;
  4348. }
  4349. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4350. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4351. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4352. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4353. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4354. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4355. builder.Write(currency);//币种
  4356. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4357. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4358. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4359. builder.Write("");//人数
  4360. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4361. builder.Write("");//天数
  4362. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4363. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4364. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4365. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4366. builder.Write(rate.ToString("#0.0000"));//汇率
  4367. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4368. decimal rbmPrice = rate * dac.SubTotal;
  4369. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4370. accommodationStartIndex++;
  4371. dac1totalPrice += rbmPrice;
  4372. }
  4373. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4374. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4375. builder.Write("小计");
  4376. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4377. builder.Write(dac1totalPrice.ToString("#0.00"));
  4378. accommodationStartIndex++;
  4379. int nullRow = accommodationRows - dac1.Count;
  4380. //删除空行
  4381. //if (nullRow > 0)
  4382. //{
  4383. // int rowIndex = accommodationStartIndex;
  4384. // for (int i = 0; i < nullRow; i++)
  4385. // {
  4386. // Row row = table1.Rows[rowIndex];
  4387. // row.Remove();
  4388. // rowIndex++;
  4389. // }
  4390. //}
  4391. if (dac2.Count == dac3.Count)//国家 币种 金额
  4392. {
  4393. for (int i = 0; i < dac2.Count; i++)
  4394. {
  4395. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4396. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4397. }
  4398. }
  4399. int foodandotherStartIndex = 19;//
  4400. decimal dac2totalPrice = 0.00M;
  4401. foreach (var dac in dac2)
  4402. {
  4403. if (dac.SubTotal == 0)
  4404. {
  4405. continue;
  4406. }
  4407. //foodandotherStartIndex = 12;
  4408. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4409. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4410. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4411. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4412. builder.Write(currency);//币种
  4413. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4414. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4415. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4416. builder.Write("");//人数
  4417. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4418. builder.Write("");//天数
  4419. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4420. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4421. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4422. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4423. builder.Write(rate.ToString("#0.0000"));//汇率
  4424. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4425. decimal rbmPrice = rate * dac.SubTotal;
  4426. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4427. foodandotherStartIndex++;
  4428. dac2totalPrice += rbmPrice;
  4429. }
  4430. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4431. //删除空行
  4432. if (dac2.Count < foodandotherRows)
  4433. {
  4434. //int nullRow = accommodationRows - dac2.Count;
  4435. //while (table2.Rows.Count > dac2.Count)
  4436. //{
  4437. // table2.Rows.RemoveAt(dac2.Count);
  4438. //}
  4439. }
  4440. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4441. string otherFeeStr = "";
  4442. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4443. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4444. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4445. if (otherFeeStr.Length > 0)
  4446. {
  4447. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4448. otherFeeStr = $"({otherFeeStr})";
  4449. dic.Add("OtherFeeStr", otherFeeStr);
  4450. }
  4451. foreach (var key in dic.Keys)
  4452. {
  4453. builder.MoveToBookmark(key);
  4454. builder.Write(dic[key]);
  4455. }
  4456. //模板文件名
  4457. string strFileName = $"省级单位出(境)经费报销单.docx";
  4458. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4459. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4460. return Ok(JsonView(true, "成功", new { Url = url }));
  4461. }
  4462. }
  4463. else if (dto.ExportType == 3)
  4464. {
  4465. if (dto.SubTypeId == 1) //团组成员名单
  4466. {
  4467. if (DeleClientList.Count < 1)
  4468. {
  4469. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4470. }
  4471. //获取模板
  4472. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4473. //载入模板
  4474. Document doc = new Document(tempPath);
  4475. DocumentBuilder builder = new DocumentBuilder(doc);
  4476. //获取word里所有表格
  4477. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4478. //获取所填表格的序数
  4479. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4480. var rowStart = tableOne.Rows[0]; //获取第1行
  4481. //循环赋值
  4482. for (int i = 0; i < DeleClientList.Count; i++)
  4483. {
  4484. builder.MoveToCell(0, i + 1, 0, 0);
  4485. builder.Write(DeleClientList[i].Name);
  4486. builder.MoveToCell(0, i + 1, 1, 0);
  4487. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4488. builder.Write(sex);
  4489. builder.MoveToCell(0, i + 1, 2, 0);
  4490. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4491. builder.MoveToCell(0, i + 1, 3, 0);
  4492. builder.Write(DeleClientList[i].Company);
  4493. builder.MoveToCell(0, i + 1, 4, 0);
  4494. builder.Write(DeleClientList[i].Job);
  4495. }
  4496. //删除多余行
  4497. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4498. {
  4499. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4500. }
  4501. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4502. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4503. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4504. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4505. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4506. return Ok(JsonView(true, "成功", new { Url = url }));
  4507. }
  4508. }
  4509. return Ok(JsonView(false, "操作失败!"));
  4510. }
  4511. catch (Exception ex)
  4512. {
  4513. return Ok(JsonView(false, ex.Message));
  4514. }
  4515. }
  4516. /// <summary>
  4517. /// 获取三公费用标准city
  4518. /// </summary>
  4519. /// <param name="placeData"></param>
  4520. /// <param name="nationalTravelFeeId"></param>
  4521. /// <returns></returns>
  4522. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4523. {
  4524. string _city = string.Empty;
  4525. if (placeData.Count < 1) return _city;
  4526. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4527. if (data == null) return _city;
  4528. string country = data.Country;
  4529. string city = data.City;
  4530. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4531. else _city = city;
  4532. return _city;
  4533. }
  4534. /// <summary>
  4535. /// 团组模块 - 出入境费用 - 明细表导出
  4536. /// </summary>
  4537. /// <returns></returns>
  4538. [HttpPost]
  4539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4540. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4541. {
  4542. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4543. if (data.Code != 0)
  4544. {
  4545. return Ok(JsonView(false, data.Msg));
  4546. }
  4547. return Ok(JsonView(true, data.Msg, data.Data));
  4548. }
  4549. /// <summary>
  4550. /// 团组模块 - 出入境费用 - 一键清空
  4551. /// </summary>
  4552. /// <returns></returns>
  4553. [HttpPost]
  4554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4555. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4556. {
  4557. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4558. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4559. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4560. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4561. if (_view.Code == 0)
  4562. {
  4563. return Ok(JsonView(true, "操作成功"));
  4564. }
  4565. return Ok(JsonView(false, "操作失败"));
  4566. }
  4567. /// <summary>
  4568. /// 团组模块 - 出入境费用 - 子项删除
  4569. /// </summary>
  4570. /// <returns></returns>
  4571. [HttpPost]
  4572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4573. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4574. {
  4575. try
  4576. {
  4577. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4578. if (data.Code != 0)
  4579. {
  4580. return Ok(JsonView(false, data.Msg));
  4581. }
  4582. return Ok(JsonView(true, "操作成功!", data.Data));
  4583. }
  4584. catch (Exception ex)
  4585. {
  4586. return Ok(JsonView(false, ex.Message));
  4587. }
  4588. }
  4589. /// <summary>
  4590. /// 团组模块 - 出入境国家费用标准 List
  4591. /// </summary>
  4592. /// <returns></returns>
  4593. [HttpPost]
  4594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4595. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4596. {
  4597. try
  4598. {
  4599. Stopwatch sw = new Stopwatch();
  4600. sw.Start();
  4601. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4602. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4603. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4604. Where gntf.Isdel = 0");
  4605. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4606. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4607. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4608. //foreach (var item in nationalTravel)
  4609. //{
  4610. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4611. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4612. // if (otherData != null)
  4613. // {
  4614. // cityData.Remove(otherData);
  4615. // cityData.Add(otherData);
  4616. // }
  4617. // nationalTravelFeeData1.Add(new
  4618. // {
  4619. // Country = item.Country,
  4620. // CityData = cityData
  4621. // });
  4622. //}
  4623. sw.Stop();
  4624. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4625. }
  4626. catch (Exception ex)
  4627. {
  4628. return Ok(JsonView(false, ex.Message));
  4629. throw;
  4630. }
  4631. }
  4632. /// <summary>
  4633. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4634. /// </summary>
  4635. /// <returns></returns>
  4636. [HttpPost]
  4637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4638. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4639. {
  4640. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4641. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4642. List<string> countryData = new List<string>();
  4643. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4644. countryData = countryData.Distinct().ToList();
  4645. List<dynamic> dataSource = new List<dynamic>();
  4646. foreach (var item in countryData)
  4647. {
  4648. List<string> cityData1 = new List<string>();
  4649. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4650. var countryData2 = new
  4651. {
  4652. CountryName = item,
  4653. CityData = cityData1
  4654. };
  4655. dataSource.Add(countryData2);
  4656. }
  4657. return Ok(JsonView(true, "查询成功!", dataSource));
  4658. }
  4659. /// <summary>
  4660. /// 团组模块 - 出入境国家费用标准 Page List
  4661. /// </summary>
  4662. /// <returns></returns>
  4663. [HttpPost]
  4664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4665. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4666. {
  4667. int portId = dto.PortType;
  4668. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4669. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4670. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4671. string whereSql = string.Empty;
  4672. if (!string.IsNullOrEmpty(dto.Country))
  4673. {
  4674. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4675. }
  4676. if (!string.IsNullOrEmpty(dto.City))
  4677. {
  4678. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4679. }
  4680. string pageSql = string.Format(@"Select * From (
  4681. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4682. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4683. From Grp_NationalTravelFee gntf
  4684. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4685. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4686. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4687. RefAsync<int> total = 0;
  4688. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4689. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4690. }
  4691. /// <summary>
  4692. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4693. /// </summary>
  4694. /// <returns></returns>
  4695. [HttpPost]
  4696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4697. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4698. {
  4699. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4700. int portId = dto.PortType;
  4701. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4702. string whereSql = string.Empty;
  4703. if (!string.IsNullOrEmpty(dto.Country))
  4704. {
  4705. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4706. }
  4707. if (!string.IsNullOrEmpty(dto.City))
  4708. {
  4709. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4710. }
  4711. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4712. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4713. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4714. From Grp_NationalTravelFee gntf
  4715. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4716. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4717. Where gntf.Isdel = 0 {0} ", whereSql);
  4718. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4719. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4720. }
  4721. /// <summary>
  4722. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4723. /// </summary>
  4724. /// <returns></returns>
  4725. [HttpPost]
  4726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4727. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4728. {
  4729. try
  4730. {
  4731. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4732. if (data.Code != 0)
  4733. {
  4734. return Ok(JsonView(false, data.Msg));
  4735. }
  4736. return Ok(JsonView(true, "操作成功!", data.Data));
  4737. }
  4738. catch (Exception ex)
  4739. {
  4740. return Ok(JsonView(false, ex.Message));
  4741. }
  4742. }
  4743. /// <summary>
  4744. /// 团组模块 - 出入境国家费用标准 - Del
  4745. /// </summary>
  4746. /// <returns></returns>
  4747. [HttpPost]
  4748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4749. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4750. {
  4751. try
  4752. {
  4753. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4754. {
  4755. Id = dto.Id,
  4756. DeleteUserId = dto.DeleteUserId,
  4757. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4758. IsDel = 1
  4759. };
  4760. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4761. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4762. .WhereColumns(it => new { it.Id })
  4763. .ExecuteCommandAsync();
  4764. if (delStatus <= 0)
  4765. {
  4766. return Ok(JsonView(false, "删除失败!"));
  4767. }
  4768. return Ok(JsonView(true, "操作成功!"));
  4769. }
  4770. catch (Exception ex)
  4771. {
  4772. return Ok(JsonView(false, ex.Message));
  4773. }
  4774. }
  4775. #endregion
  4776. #region 签证费用录入
  4777. /// <summary>
  4778. /// 根据diid查询签证费用列表
  4779. /// </summary>
  4780. /// <param name="dto"></param>
  4781. /// <returns></returns>
  4782. [HttpPost]
  4783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4784. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4785. {
  4786. try
  4787. {
  4788. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4789. if (groupData.Code != 0)
  4790. {
  4791. return Ok(JsonView(false, groupData.Msg));
  4792. }
  4793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4794. }
  4795. catch (Exception ex)
  4796. {
  4797. return Ok(JsonView(false, ex.Message));
  4798. }
  4799. }
  4800. /// <summary>
  4801. /// 根据签证费用Id查询单条数据及c表数据
  4802. /// </summary>
  4803. /// <param name="dto"></param>
  4804. /// <returns></returns>
  4805. [HttpPost]
  4806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4807. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4808. {
  4809. try
  4810. {
  4811. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4812. if (groupData.Code != 0)
  4813. {
  4814. return Ok(JsonView(false, groupData.Msg));
  4815. }
  4816. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4817. }
  4818. catch (Exception ex)
  4819. {
  4820. return Ok(JsonView(false, ex.Message));
  4821. }
  4822. }
  4823. /// <summary>
  4824. /// 签证费用删除
  4825. /// </summary>
  4826. /// <param name="dto"></param>
  4827. /// <returns></returns>
  4828. [HttpPost]
  4829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4830. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4831. {
  4832. _sqlSugar.BeginTran();
  4833. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4834. if (!res)
  4835. {
  4836. _sqlSugar.RollbackTran();
  4837. return Ok(JsonView(false, "删除失败"));
  4838. }
  4839. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4840. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4841. .SetColumns(a => new Grp_CreditCardPayment()
  4842. {
  4843. IsDel = 1,
  4844. DeleteUserId = dto.DeleteUserId,
  4845. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4846. }).ExecuteCommand();
  4847. if (resSub < 1)
  4848. {
  4849. _sqlSugar.RollbackTran();
  4850. return Ok(JsonView(false, "删除失败"));
  4851. }
  4852. _sqlSugar.CommitTran();
  4853. return Ok(JsonView(true, "删除成功!"));
  4854. }
  4855. /// <summary>
  4856. /// 签证费用录入下拉框初始化
  4857. /// </summary>
  4858. /// <returns></returns>
  4859. [HttpPost]
  4860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4861. public async Task<IActionResult> VisaPriceAddSelect()
  4862. {
  4863. try
  4864. {
  4865. //支付方式
  4866. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4867. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4868. //币种
  4869. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4870. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4871. //乘客类型
  4872. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4873. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4874. //卡类型
  4875. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4876. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4877. var data = new
  4878. {
  4879. Payment = _Payment,
  4880. CurrencyList = _CurrencyList,
  4881. PassengerType = _PassengerType,
  4882. BankCard = _BankCard
  4883. };
  4884. return Ok(JsonView(true, "查询成功!", data));
  4885. }
  4886. catch (Exception ex)
  4887. {
  4888. return Ok(JsonView(false, "程序错误!"));
  4889. throw;
  4890. }
  4891. }
  4892. /// <summary>
  4893. /// 签证费用录入操作(Status:1.新增,2.修改)
  4894. /// </summary>
  4895. /// <param name="dto"></param>
  4896. /// <returns></returns>
  4897. [HttpPost]
  4898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4899. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4900. {
  4901. try
  4902. {
  4903. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4904. if (groupData.Code != 0)
  4905. {
  4906. return Ok(JsonView(false, groupData.Msg));
  4907. }
  4908. #region 应用推送
  4909. try
  4910. {
  4911. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4912. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4913. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4914. }
  4915. catch (Exception ex)
  4916. {
  4917. }
  4918. #endregion
  4919. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4920. }
  4921. catch (Exception ex)
  4922. {
  4923. return Ok(JsonView(false, ex.Message));
  4924. }
  4925. }
  4926. #endregion
  4927. #region op费用录入
  4928. /// <summary>
  4929. /// 根据diid查询op费用列表
  4930. /// </summary>
  4931. /// <param name="dto"></param>
  4932. /// <returns></returns>
  4933. [HttpPost]
  4934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4935. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4936. {
  4937. try
  4938. {
  4939. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4940. if (groupData.Code != 0)
  4941. {
  4942. return Ok(JsonView(false, groupData.Msg));
  4943. }
  4944. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4945. }
  4946. catch (Exception ex)
  4947. {
  4948. return Ok(JsonView(false, ex.Message));
  4949. }
  4950. }
  4951. /// <summary>
  4952. /// 根据op费用Id查询单条数据及c表数据
  4953. /// </summary>
  4954. /// <param name="dto"></param>
  4955. /// <returns></returns>
  4956. [HttpPost]
  4957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4958. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4959. {
  4960. try
  4961. {
  4962. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4963. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4964. var data = new
  4965. {
  4966. CarTouristGuideGround = _groupData,
  4967. CreditCardPayment = _creditCardPayment
  4968. };
  4969. return Ok(JsonView(true, "查询成功!", data));
  4970. }
  4971. catch (Exception ex)
  4972. {
  4973. return Ok(JsonView(false, "程序错误!"));
  4974. }
  4975. }
  4976. /// <summary>
  4977. /// op费用删除
  4978. /// </summary>
  4979. /// <param name="dto"></param>
  4980. /// <returns></returns>
  4981. [HttpPost]
  4982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4983. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4984. {
  4985. try
  4986. {
  4987. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4988. if (!res)
  4989. {
  4990. return Ok(JsonView(false, "删除失败"));
  4991. }
  4992. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4993. {
  4994. IsDel = 1,
  4995. DeleteUserId = dto.DeleteUserId,
  4996. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4997. }).ExecuteCommandAsync();
  4998. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4999. {
  5000. IsDel = 1,
  5001. DeleteUserId = dto.DeleteUserId,
  5002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5003. }).ExecuteCommandAsync();
  5004. return Ok(JsonView(true, "删除成功!"));
  5005. }
  5006. catch (Exception ex)
  5007. {
  5008. return Ok(JsonView(false, "程序错误!"));
  5009. throw;
  5010. }
  5011. }
  5012. /// <summary>
  5013. /// op费用录入操作(Status:1.新增,2.修改)
  5014. /// </summary>
  5015. /// <param name="dto"></param>
  5016. /// <returns></returns>
  5017. [HttpPost]
  5018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5019. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5020. {
  5021. try
  5022. {
  5023. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5024. if (groupData.Code != 0)
  5025. {
  5026. return Ok(JsonView(false, groupData.Msg));
  5027. }
  5028. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5029. }
  5030. catch (Exception ex)
  5031. {
  5032. return Ok(JsonView(false, ex.Message));
  5033. }
  5034. }
  5035. /// <summary>
  5036. /// 填写费用详细页面初始化绑定
  5037. /// </summary>
  5038. /// <param name="dto"></param>
  5039. /// <returns></returns>
  5040. [HttpPost]
  5041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5042. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5043. {
  5044. try
  5045. {
  5046. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5047. if (groupData.Code != 0)
  5048. {
  5049. return Ok(JsonView(false, groupData.Msg));
  5050. }
  5051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5052. }
  5053. catch (Exception ex)
  5054. {
  5055. return Ok(JsonView(false, ex.Message));
  5056. }
  5057. }
  5058. /// <summary>
  5059. /// 根据op费用Id查询详细数据
  5060. /// </summary>
  5061. /// <param name="dto"></param>
  5062. /// <returns></returns>
  5063. [HttpPost]
  5064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5065. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5066. {
  5067. try
  5068. {
  5069. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5070. if (groupData.Code != 0)
  5071. {
  5072. return Ok(JsonView(false, groupData.Msg));
  5073. }
  5074. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5075. }
  5076. catch (Exception ex)
  5077. {
  5078. return Ok(JsonView(false, ex.Message));
  5079. }
  5080. }
  5081. /// <summary>
  5082. /// OP费用录入填写详情
  5083. /// </summary>
  5084. /// <param name="dto"></param>
  5085. /// <returns></returns>
  5086. [HttpPost]
  5087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5088. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5089. {
  5090. try
  5091. {
  5092. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5093. if (groupData.Code != 0)
  5094. {
  5095. return Ok(JsonView(false, groupData.Msg));
  5096. }
  5097. #region 应用推送
  5098. try
  5099. {
  5100. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5101. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5102. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5103. }
  5104. catch (Exception ex)
  5105. {
  5106. }
  5107. #endregion
  5108. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5109. }
  5110. catch (Exception ex)
  5111. {
  5112. return Ok(JsonView(false, ex.Message));
  5113. }
  5114. }
  5115. /// <summary>
  5116. /// 获取三公详细所有城市
  5117. /// </summary>
  5118. /// <returns></returns>
  5119. [HttpGet]
  5120. public IActionResult OpCarCityResult()
  5121. {
  5122. var jw = JsonView(false);
  5123. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5124. {
  5125. x.Id,
  5126. x.Country,
  5127. x.City,
  5128. }).ToList();
  5129. if (data.Count > 0)
  5130. {
  5131. jw = JsonView(true, "获取成功!", data);
  5132. }
  5133. else
  5134. {
  5135. jw.Msg = "城市数据为空!";
  5136. jw.Data = new string[0];
  5137. }
  5138. return Ok(jw);
  5139. }
  5140. /// <summary>
  5141. /// 导出地接费用明细
  5142. /// </summary>
  5143. /// <param name="dto"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5147. {
  5148. var jw = JsonView(false);
  5149. if (dto.Diid < 1)
  5150. {
  5151. jw.Msg = "请输入正确的diid!";
  5152. return Ok(jw);
  5153. }
  5154. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5155. if (group == null)
  5156. {
  5157. jw.Msg = "未找到团组信息!";
  5158. return Ok(jw);
  5159. }
  5160. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5161. if (localGuideArr.Count == 0)
  5162. {
  5163. jw.Msg = "该团组暂无地接信息!";
  5164. return Ok(jw);
  5165. }
  5166. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5167. var overspendSoure = new Dictionary<int, int>
  5168. {
  5169. { 91, 982 }, //车
  5170. { 92 , 1059} ,//导游
  5171. { 994 , 1073}, //翻译
  5172. { 988 , 1074 }, //早餐
  5173. { 93 , 1075 }, //午餐
  5174. { 989 , 1076 }, //晚餐
  5175. };
  5176. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5177. foreach (var groupArr in localGroup)
  5178. {
  5179. var keyValue = groupArr.Key;
  5180. if (int.TryParse(keyValue, out int cityid))
  5181. {
  5182. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5183. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5184. }
  5185. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5186. foreach (var item in groupArr)
  5187. {
  5188. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5189. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5190. new Grp_CarTouristGuideGroundReservationsContentExtend
  5191. {
  5192. Count = a.Count,
  5193. CreateTime = a.CreateTime,
  5194. CreateUserId = a.CreateUserId,
  5195. CTGGRId = a.CTGGRId,
  5196. Currency = a.Currency,
  5197. DatePrice = a.DatePrice,
  5198. DeleteTime = a.DeleteTime,
  5199. DeleteUserId = a.DeleteUserId,
  5200. DiId = a.DiId,
  5201. Id = a.Id,
  5202. IsDel = a.IsDel,
  5203. Price = a.Price,
  5204. PriceContent = a.PriceContent,
  5205. Remark = a.Remark,
  5206. SId = a.SId,
  5207. SidName = b.Name,
  5208. Units = a.Units,
  5209. }
  5210. ).ToList();
  5211. if (content.Count > 0)
  5212. {
  5213. contentArr.Add(content);
  5214. }
  5215. }
  5216. //open excel
  5217. //set excel
  5218. //save excel
  5219. try
  5220. {
  5221. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5222. IWorkbook workbook;
  5223. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5224. {
  5225. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5226. }
  5227. else
  5228. {
  5229. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5230. }
  5231. ISheet sheet = workbook.GetSheetAt(0);
  5232. var rowStartIndex = 2;
  5233. var clounmCount = 10;
  5234. var initStyleRow = sheet.GetRow(2);
  5235. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5236. //var overspendArrDetail =
  5237. var existsId = new List<CarCompare>();
  5238. var lastElem = arr.Last();
  5239. var thisSid = -1;
  5240. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5241. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5242. {
  5243. Name = "未知币种!",
  5244. Remark = "未知币种!",
  5245. };
  5246. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5247. Action cloneRowFn = () =>
  5248. {
  5249. rowStartIndex++;
  5250. var cloneRow = sheet.CreateRow(rowStartIndex);
  5251. // 复制样式
  5252. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5253. {
  5254. ICell sourceCell = initStyleRow.GetCell(i);
  5255. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5256. // 确保单元格存在样式
  5257. if (sourceCell.CellStyle != null)
  5258. {
  5259. targetCell.CellStyle = sourceCell.CellStyle;
  5260. }
  5261. }
  5262. };
  5263. var mergeRow = () =>
  5264. {
  5265. for (int i = 2; i < sheet.LastRowNum; i++)
  5266. {
  5267. var row = sheet.GetRow(i);
  5268. var cellFirst = row.GetCell(0);
  5269. var thisIndex = i + 1;
  5270. while (thisIndex < sheet.LastRowNum)
  5271. {
  5272. var nextRow = sheet.GetRow(thisIndex);
  5273. var nextCellFirst = nextRow.GetCell(0);
  5274. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5275. {
  5276. thisIndex++;
  5277. }
  5278. else
  5279. {
  5280. break;
  5281. }
  5282. }
  5283. thisIndex--;
  5284. if (thisIndex != i)
  5285. {
  5286. //合并row
  5287. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5288. i, // 起始行索引(0-based)
  5289. thisIndex, // 结束行索引(0-based)
  5290. 0, // 起始列索引(0-based)
  5291. 0 // 结束列索引(0-based)
  5292. );
  5293. sheet.AddMergedRegion(cellRangeAddress);
  5294. i = thisIndex;
  5295. }
  5296. }
  5297. };
  5298. var chaoshiNumber = 0;
  5299. var totalNumber = 0.00M;
  5300. string lastStr = "";
  5301. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5302. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5303. {
  5304. b.IsAuditGM,
  5305. x.Id,
  5306. x.Area,
  5307. b.PayPercentage,
  5308. b.PayMoney,
  5309. }).ToList();
  5310. string yesPayment = "", noPayment = "";
  5311. foreach (var item in queryCarArrByCityAndDiid)
  5312. {
  5313. if (item.IsAuditGM == 1)
  5314. {
  5315. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5316. }
  5317. else
  5318. {
  5319. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5320. }
  5321. }
  5322. lastStr = yesPayment + noPayment;
  5323. foreach (var item in arr)
  5324. {
  5325. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5326. {
  5327. if (thisSid != item.SId)
  5328. {
  5329. if (thisSid == -1)
  5330. {
  5331. thisSid = item.SId;
  5332. }
  5333. else
  5334. {
  5335. //合并小计行
  5336. //创建合并区域的实例
  5337. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5338. rowStartIndex, // 起始行索引(0-based)
  5339. rowStartIndex, // 结束行索引(0-based)
  5340. 0, // 起始列索引(0-based)
  5341. 3 // 结束列索引(0-based)
  5342. );
  5343. sheet.AddMergedRegion(cellRangeAddress);
  5344. var CellStyle = workbook.CreateCellStyle();
  5345. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5346. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5347. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5348. for (int i = 0; i <= clounmCount; i++)
  5349. {
  5350. if (i > 6)
  5351. {
  5352. var CellStyle1 = workbook.CreateCellStyle();
  5353. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5354. IFont Font = workbook.CreateFont(); // 创建字体
  5355. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5356. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5357. CellStyle1.SetFont(Font);
  5358. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5359. }
  5360. else
  5361. {
  5362. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5363. }
  5364. }
  5365. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5366. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5367. //超时合计
  5368. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5369. //超时数
  5370. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5371. //超时合计费用
  5372. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5373. thisSid = item.SId;
  5374. cloneRowFn();
  5375. chaoshiNumber = 0;
  5376. totalNumber = 0;
  5377. }
  5378. }
  5379. IRow row = sheet.GetRow(rowStartIndex);
  5380. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5381. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5382. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5383. if (isOpenOverspendSoure)
  5384. {
  5385. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5386. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5387. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5388. }
  5389. for (int i = 0; i <= clounmCount; i++)
  5390. {
  5391. var cell = row.GetCell(i);
  5392. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5393. if (cell == null)
  5394. {
  5395. cell = row.CreateCell(i);
  5396. }
  5397. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5398. fontRed.CloneStyleFrom(cell.CellStyle);
  5399. IFont Font = workbook.CreateFont(); // 创建字体
  5400. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5401. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5402. fontRed.SetFont(Font);
  5403. byte[] rgb = new byte[3] { 255, 242, 204 };
  5404. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5405. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5406. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5407. if (workbook is XSSFWorkbook)
  5408. {
  5409. BackgroundColor255_242_204.FillForegroundColor = 0;
  5410. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5411. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5412. }
  5413. else
  5414. {
  5415. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5416. }
  5417. if (i == 1 || i > 6)
  5418. {
  5419. if (i > 6)
  5420. {
  5421. fontRed.FillForegroundColor = 0;
  5422. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5423. fontRed.FillPattern = FillPattern.SolidForeground;
  5424. }
  5425. cell.CellStyle = fontRed;
  5426. }
  5427. if (i > 2 && i < 7)
  5428. {
  5429. cell.CellStyle = BackgroundColor255_242_204;
  5430. }
  5431. cell.SetCellValue(setCellValue); //写入单元格
  5432. }
  5433. if (overspendSoure.ContainsKey(thisSid)) {
  5434. var overspendId = overspendSoure[thisSid];
  5435. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5436. }
  5437. cloneRowFn();
  5438. existsId.Add(new CarCompare
  5439. {
  5440. DataPrice = item.DatePrice.ObjToDate(),
  5441. Sid = item.SId
  5442. });
  5443. }
  5444. if (item.Equals(lastElem))
  5445. {
  5446. //合并小计行
  5447. //创建合并区域的实例
  5448. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5449. rowStartIndex, // 起始行索引(0-based)
  5450. rowStartIndex, // 结束行索引(0-based)
  5451. 0, // 起始列索引(0-based)
  5452. 3 // 结束列索引(0-based)
  5453. );
  5454. sheet.AddMergedRegion(cellRangeAddress);
  5455. var CellStyle = workbook.CreateCellStyle();
  5456. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5457. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5458. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5459. for (int i = 0; i <= clounmCount; i++)
  5460. {
  5461. if (i > 6)
  5462. {
  5463. var CellStyle1 = workbook.CreateCellStyle();
  5464. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5465. IFont Font = workbook.CreateFont(); // 创建字体
  5466. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5467. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5468. CellStyle1.SetFont(Font);
  5469. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5470. }
  5471. else
  5472. {
  5473. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5474. }
  5475. }
  5476. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5477. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5478. //超时合计
  5479. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5480. //超时数
  5481. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5482. //超时合计费用
  5483. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5484. cloneRowFn();
  5485. // 创建合并区域的实例
  5486. cellRangeAddress = new CellRangeAddress(
  5487. rowStartIndex, // 起始行索引(0-based)
  5488. rowStartIndex, // 结束行索引(0-based)
  5489. 0, // 起始列索引(0-based)
  5490. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5491. );
  5492. // 添加合并区域
  5493. sheet.AddMergedRegion(cellRangeAddress);
  5494. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5495. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5496. }
  5497. }
  5498. mergeRow();
  5499. // 保存修改后的Excel文件到新文件
  5500. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5501. // new FileStream(newFilePath, FileMode.CreateNew)
  5502. using (var stream = new MemoryStream())
  5503. {
  5504. workbook.Write(stream, true);
  5505. stream.Flush();
  5506. stream.Seek(0, SeekOrigin.Begin);
  5507. MemoryStream memoryStream = new MemoryStream();
  5508. stream.CopyTo(memoryStream);
  5509. memoryStream.Seek(0, SeekOrigin.Begin);
  5510. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5511. }
  5512. workbook.Close();
  5513. workbook.Dispose();
  5514. }
  5515. catch (Exception ex)
  5516. {
  5517. jw.Msg = "出现异常!" + ex.Message;
  5518. return Ok(jw);
  5519. }
  5520. }
  5521. if (Zips.Count > 0)
  5522. {
  5523. IOOperatorHelper io = new IOOperatorHelper();
  5524. var byts = io.ConvertZipStream(Zips);
  5525. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5526. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5527. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5528. }
  5529. else
  5530. {
  5531. jw.Msg = "暂无生成文件!";
  5532. }
  5533. return Ok(jw);
  5534. }
  5535. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5536. {
  5537. string outStr = string.Empty;
  5538. switch (i)
  5539. {
  5540. case 0:
  5541. outStr = arr[0].SidName;
  5542. break;
  5543. case 1:
  5544. outStr = arr[0].DataPriceStr;
  5545. break;
  5546. case 2:
  5547. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5548. break;
  5549. case 4:
  5550. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5551. break;
  5552. case 7:
  5553. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5554. {
  5555. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5556. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5557. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5558. }
  5559. break;
  5560. case 8:
  5561. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5562. {
  5563. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5564. }
  5565. break;
  5566. case 9:
  5567. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5568. {
  5569. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5570. }
  5571. break;
  5572. case 10:
  5573. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5574. {
  5575. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5576. }
  5577. break;
  5578. }
  5579. return outStr;
  5580. }
  5581. #region OP行程单
  5582. /// <summary>
  5583. /// OP行程单初始化
  5584. /// </summary>
  5585. /// <param name="dto"></param>
  5586. /// <returns></returns>
  5587. [HttpPost]
  5588. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5589. {
  5590. var jw = JsonView(false);
  5591. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5592. var group = groupList.First();
  5593. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5594. if (group == null)
  5595. {
  5596. jw.Msg = "暂无团组!";
  5597. return Ok(jw);
  5598. }
  5599. group = groupList.Find(x => x.Id == diid);
  5600. if (group == null)
  5601. {
  5602. jw.Msg = "请输入正确的团组ID!";
  5603. return Ok(jw);
  5604. }
  5605. string city = string.Empty;
  5606. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5607. if (blackCode.Count > 0)
  5608. {
  5609. var black = blackCode.First();
  5610. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5611. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5612. if (blackSp.Length > 0)
  5613. {
  5614. try
  5615. {
  5616. var cityArrCode = new List<string>(20);
  5617. foreach (var item in blackSp)
  5618. {
  5619. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5620. var IndexSelect = itemSp[2];
  5621. var cityArrCodeLength = cityArrCode.Count - 1;
  5622. var startCity = IndexSelect.Substring(0, 3);
  5623. if (cityArrCodeLength > 0)
  5624. {
  5625. var arrEndCity = cityArrCode[cityArrCodeLength];
  5626. if (arrEndCity != startCity)
  5627. {
  5628. cityArrCode.Add(startCity.ToUpper());
  5629. }
  5630. }
  5631. else
  5632. {
  5633. cityArrCode.Add(startCity.ToUpper());
  5634. }
  5635. var endCity = IndexSelect.Substring(3, 3);
  5636. cityArrCode.Add(endCity.ToUpper());
  5637. }
  5638. var cityThree = string.Empty;
  5639. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5640. cityThree = cityThree.TrimEnd(',');
  5641. if (string.IsNullOrWhiteSpace(cityThree))
  5642. {
  5643. throw new
  5644. Exception("error");
  5645. }
  5646. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5647. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5648. foreach (var item in cityArrCode)
  5649. {
  5650. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5651. if (find != null)
  5652. {
  5653. city += find.City + "/";
  5654. }
  5655. else
  5656. {
  5657. city += item + "三字码未收入/";
  5658. }
  5659. }
  5660. city = city.TrimEnd('/');
  5661. }
  5662. catch (Exception e)
  5663. {
  5664. city = "黑屏代码格式不正确!";
  5665. }
  5666. }
  5667. }
  5668. else
  5669. {
  5670. city = "未录入黑屏代码";
  5671. }
  5672. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5673. {
  5674. Date = x.Date,
  5675. Days = x.Days,
  5676. Diffgroup = x.Diffgroup,
  5677. Diid = x.Diid,
  5678. Traffic_First = x.Traffic_First,
  5679. Traffic_Second = x.Traffic_Second,
  5680. Trip = x.Trip,
  5681. WeekDay = x.WeekDay,
  5682. Id = x.Id
  5683. }).ToList();
  5684. jw.Data = new
  5685. {
  5686. groupList = groupList.Select(x => new
  5687. {
  5688. x.Id,
  5689. x.TeamName,
  5690. x.TourCode
  5691. }).ToList(),
  5692. groupInfo = new
  5693. {
  5694. group.VisitDays,
  5695. group.TourCode,
  5696. group.VisitPNumber,
  5697. group.TeamName,
  5698. city
  5699. },
  5700. OpTravelList
  5701. };
  5702. jw.Code = 200;
  5703. jw.Msg = "操作成功!";
  5704. return Ok(jw);
  5705. }
  5706. /// <summary>
  5707. /// 删除团组行程单
  5708. /// </summary>
  5709. /// <returns></returns>
  5710. [HttpPost]
  5711. public IActionResult DelTravel(DelOpTravelDto dto)
  5712. {
  5713. var jw = JsonView(false);
  5714. if (dto.UserId <= 0 || dto.Diid <= 0)
  5715. {
  5716. jw.Msg = "请输入正确的参数!";
  5717. return Ok(jw);
  5718. }
  5719. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5720. .SetColumns(x => new Grp_TravelList
  5721. {
  5722. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5723. DeleteUserId = dto.UserId,
  5724. IsDel = 1,
  5725. }).ExecuteCommand();
  5726. jw = JsonView(true);
  5727. return Ok(jw);
  5728. }
  5729. /// <summary>
  5730. /// 行程单保存
  5731. /// </summary>
  5732. /// <returns></returns>
  5733. [HttpPost]
  5734. public IActionResult TravelSave(TravelSaveDto dto)
  5735. {
  5736. var jw = JsonView(false);
  5737. if (dto.Arr.Count > 0)
  5738. {
  5739. try
  5740. {
  5741. _sqlSugar.BeginTran();
  5742. foreach (var item in dto.Arr)
  5743. {
  5744. if (item.Id == 0)
  5745. {
  5746. throw new Exception("请传入正确的Id");
  5747. }
  5748. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5749. .SetColumns(x => new Grp_TravelList
  5750. {
  5751. Trip = item.Trip
  5752. }).ExecuteCommand();
  5753. }
  5754. _sqlSugar.CommitTran();
  5755. jw = JsonView(true);
  5756. }
  5757. catch (Exception ex)
  5758. {
  5759. _sqlSugar.RollbackTran();
  5760. jw.Msg = "程序异常!" + ex.Message;
  5761. }
  5762. }
  5763. else
  5764. {
  5765. jw.Msg = "请传入正确的参数!";
  5766. }
  5767. return Ok(jw);
  5768. }
  5769. /// <summary>
  5770. /// 导出行程单
  5771. /// </summary>
  5772. /// <param name="dto"></param>
  5773. /// <returns></returns>
  5774. [HttpPost]
  5775. public IActionResult ExportTravel(InitOpTravelDto dto)
  5776. {
  5777. var jw = JsonView(false);
  5778. //数据源
  5779. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5780. int diid = 0;
  5781. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5782. if (Find == null)
  5783. {
  5784. jw.Msg = "请选择正确的团组!";
  5785. return Ok(jw);
  5786. }
  5787. else
  5788. {
  5789. diid = Find.Id;
  5790. }
  5791. DataTable dtBlack = null;
  5792. try
  5793. {
  5794. dtBlack = GetTableByBlackCode(diid);
  5795. }
  5796. catch (Exception)
  5797. {
  5798. jw.Msg = "机票黑屏代码有误!";
  5799. return Ok(jw);
  5800. }
  5801. string CityStr1 = "";
  5802. List<string> countriesList = new List<string>();
  5803. List<string> cityList = new List<string>();
  5804. string countriesIntroduction = "";
  5805. string cityIntroduction = "";
  5806. string timeDifference = "";
  5807. string currExchangeRate = "";
  5808. string txt_itemPrepare = "";
  5809. string txt_specialReminder = "";
  5810. string txt_cGPrecautions = "";
  5811. string txt_yGCG = "";
  5812. string txt_conduct = "";
  5813. string txt_commonEnglish = "";
  5814. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5815. {
  5816. //提示
  5817. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5818. }
  5819. else
  5820. {
  5821. //创建三字码示例
  5822. Res_ThreeCode t = new Res_ThreeCode();
  5823. //城市缓存
  5824. string city = "";
  5825. //出访城市
  5826. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5827. {
  5828. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5829. {
  5830. continue;
  5831. }
  5832. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5833. {
  5834. //出发城市
  5835. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5836. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5837. if (t != null)
  5838. {
  5839. city = city + "/" + t.City;
  5840. }
  5841. else
  5842. {
  5843. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5844. }
  5845. if (i == dtBlack.Rows.Count - 1)
  5846. {
  5847. //抵达城市
  5848. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5849. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5850. if (t != null)
  5851. {
  5852. city = city + "/" + t.City;
  5853. }
  5854. else
  5855. {
  5856. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5857. }
  5858. }
  5859. }
  5860. }
  5861. if (city != "" && city != null)
  5862. {
  5863. string[] cityStr2 = city.Split('/');
  5864. string[] strs = cityStr2.Distinct().ToArray(); ;
  5865. string str = "";
  5866. foreach (var s in strs)
  5867. {
  5868. str += s + "/";
  5869. }
  5870. str = str.TrimStart('/');
  5871. str = str.TrimEnd('/');
  5872. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5873. CityStr1 = city.TrimStart('/');
  5874. }
  5875. // 行程repeater
  5876. if (GetByDiid(diid).Count > 0)
  5877. {
  5878. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5879. }
  5880. else
  5881. {
  5882. //生成该时间段日期
  5883. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5884. if (timeList != null)
  5885. {
  5886. string[] str = new string[timeList.Count];
  5887. //rpData.DataSource = str;
  5888. //rpData.DataBind();
  5889. }
  5890. }
  5891. }
  5892. //创建数据源Table
  5893. DataTable dtSource = new DataTable();
  5894. dtSource.Columns.Add("Days", typeof(string));
  5895. dtSource.Columns.Add("Date", typeof(string));
  5896. dtSource.Columns.Add("Week", typeof(string));
  5897. dtSource.Columns.Add("Traffic", typeof(string));
  5898. dtSource.Columns.Add("Trip", typeof(string));
  5899. //获取数据,放到datatable
  5900. foreach (var item in _travelList)
  5901. {
  5902. DataRow dr = dtSource.NewRow();
  5903. dr["Days"] = item.Days;
  5904. dr["Date"] = item.Date;
  5905. dr["Week"] = item.WeekDay;
  5906. dr["Traffic"] = item.Traffic_First
  5907. + "\r\n"
  5908. + item.Traffic_Second;
  5909. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5910. {
  5911. item.Trip += @"
  5912. 08:00 早餐于酒店;
  5913. 09:00 公务活动;
  5914. 10:30 公务活动;
  5915. 12:00 午餐于当地餐厅;
  5916. 14:00 公务活动;
  5917. 16:00 公务活动;
  5918. 18:00 晚餐于当地餐厅;
  5919. 19:00 入住酒店休息;";
  5920. }
  5921. dr["Trip"] = item.Trip;
  5922. dtSource.Rows.Add(dr);
  5923. }
  5924. //lblTeamName.Text = di.TourCode;
  5925. //lblVisitDays.Text = di.VisitDays.ToString();
  5926. //lblVisitDays2.Text = di.VisitDays.ToString();
  5927. //lblPNumber.Text = di.VisitPNumber.ToString();
  5928. //lblGroup.Text = di.TeamName.ToString();
  5929. Dictionary<string, string> dic = new Dictionary<string, string>();
  5930. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5931. dic.Add("City", CityStr1);
  5932. dic.Add("Days", Find.VisitDays.ToString());
  5933. dic.Add("DeleCode", Find.TourCode);
  5934. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5935. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5936. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5937. if (leader != null && leader.Count > 0)
  5938. {
  5939. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5940. }
  5941. else
  5942. {
  5943. dic.Add("Leader", "");
  5944. }
  5945. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5946. int UserId = 253;
  5947. dic.Add("OP", "");
  5948. dic.Add("OPTel", "");
  5949. //dic.Add("OP", "OP姓名");
  5950. //dic.Add("OPTel", "OP手机号码");
  5951. string countriesStr = "";
  5952. countriesList.ForEach(s => countriesStr += s + "、");
  5953. countriesStr = countriesStr.TrimEnd('、');
  5954. string cityStr = "";
  5955. cityList.ForEach(s => cityStr += s + "、");
  5956. cityStr = cityStr.TrimEnd('、');
  5957. //下方数据
  5958. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5959. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5960. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5961. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5962. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5963. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5964. dic.Add("temperature", "");
  5965. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5966. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5967. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5968. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5969. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5970. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5971. //模板路径
  5972. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5973. //载入模板
  5974. Document doc = null;
  5975. DocumentBuilder builder = null;
  5976. try
  5977. {
  5978. //载入模板
  5979. doc = new Document(tempPath);
  5980. builder = new DocumentBuilder(doc);
  5981. }
  5982. catch (Exception)
  5983. {
  5984. jw.Msg = "模板位置不存在!";
  5985. return Ok(jw);
  5986. }
  5987. foreach (var key in dic.Keys)
  5988. {
  5989. Bookmark bookmark = doc.Range.Bookmarks[key];
  5990. if (bookmark != null)
  5991. {
  5992. builder.MoveToBookmark(key);
  5993. builder.Write(dic[key]);
  5994. }
  5995. }
  5996. //获取word里所有表格
  5997. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5998. //获取所填表格的序数
  5999. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6000. try
  6001. {
  6002. //循环赋值
  6003. for (int i = 0; i < dtSource.Rows.Count; i++)
  6004. {
  6005. builder.MoveToCell(0, i + 1, 0, 0);
  6006. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6007. builder.MoveToCell(0, i + 1, 1, 0);
  6008. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6009. builder.MoveToCell(0, i + 1, 2, 0);
  6010. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6011. var trip = dtSource.Rows[i]["Trip"].ToString();
  6012. builder.MoveToCell(0, i + 1, 3, 0);
  6013. builder.Write(trip);
  6014. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6015. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6016. // 获取特定索引的段落
  6017. Paragraph paragraph = (Paragraph)paragraphs[0];
  6018. Run run = paragraph.Runs[0];
  6019. Aspose.Words.Font font = run.Font;
  6020. font.Name = "黑体";
  6021. //设置双休红色
  6022. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6023. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6024. paragraph = (Paragraph)paragraphs[1];
  6025. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6026. {
  6027. run = paragraph.Runs[0];
  6028. font = run.Font;
  6029. font.Color = Color.Red;
  6030. }
  6031. }
  6032. }
  6033. catch (Exception ex)
  6034. {
  6035. }
  6036. //删除多余行
  6037. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6038. {
  6039. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6040. }
  6041. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6042. if (!Directory.Exists(savePath))
  6043. {
  6044. try
  6045. {
  6046. Directory.CreateDirectory(savePath);
  6047. }
  6048. catch
  6049. {
  6050. }
  6051. }
  6052. string path = savePath + Find.TeamName + "出访日程.docx";
  6053. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6054. try
  6055. {
  6056. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6057. jw = JsonView(true, "导出成功", ftpPath);
  6058. }
  6059. catch (Exception)
  6060. {
  6061. jw = JsonView(false);
  6062. }
  6063. return Ok(jw);
  6064. }
  6065. /// <summary>
  6066. ///根据机票黑屏代码整理DataTable
  6067. /// </summary>
  6068. /// <param name="diid"></param>
  6069. /// <returns></returns>
  6070. DataTable GetTableByBlackCode(int diid)
  6071. {
  6072. //黑屏代码信息
  6073. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6074. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6075. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6076. DataTable dt = new DataTable();
  6077. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6078. dt.Columns.Add("Date", typeof(string));//起飞日期
  6079. dt.Columns.Add("Three", typeof(string));//三字码
  6080. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6081. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6082. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6083. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6084. dt.Columns.Add("AirModel", typeof(string)); //机型
  6085. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6086. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6087. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6088. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6089. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6090. //判断是否录入黑屏代码
  6091. if (listcode.Count() == 0 || listcode == null)
  6092. {
  6093. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6094. }
  6095. else
  6096. {
  6097. //读取单段黑屏代码
  6098. for (int i = 0; i < listcode.Count; i++)
  6099. {
  6100. //去除序号
  6101. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6102. //去除多余空格,方法一Linq扩展方法
  6103. CodeList = CodeList.Where(str => str != "").ToArray();
  6104. CodeList = CodeList.Where(str => str != " ").ToArray();
  6105. //年
  6106. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6107. //读取单条黑屏代码
  6108. for (int j = 0; j < CodeList.Count(); j++)
  6109. {
  6110. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6111. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6112. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6113. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6114. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6115. //去除多余空格
  6116. Info = Info.Where(str => str != "").ToArray();
  6117. Info = Info.Where(str => str != " ").ToArray();
  6118. //判断黑屏代码是否正确拆分; 理应拆成9段
  6119. if (Info.Count() < 9)
  6120. {
  6121. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6122. }
  6123. else
  6124. {
  6125. try
  6126. {
  6127. //月
  6128. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6129. //日
  6130. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6131. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6132. if (j > 0)
  6133. {
  6134. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6135. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6136. Temp = Temp.Where(str => str != "").ToArray();
  6137. Temp = Temp.Where(str => str != " ").ToArray();
  6138. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6139. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6140. if (month - monthTemp < 0)
  6141. {
  6142. year = year + 1;
  6143. }
  6144. //如果相邻代码三字码不顶真,提醒
  6145. string FootThree = Temp[2].Substring(3, 3);
  6146. string HeadThree = Info[2].Substring(0, 3);
  6147. if (FootThree != HeadThree)
  6148. {
  6149. //DelegationInfoService s = new DelegationInfoService();
  6150. //UsersService us = new UsersService();
  6151. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6152. //77 行程
  6153. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6154. foreach (var temp in list2)
  6155. {
  6156. //if (temp.UId != 21)
  6157. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6158. // "黑屏代码提醒",
  6159. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6160. }
  6161. //85 机票预订
  6162. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6163. foreach (var temp in list6)
  6164. {
  6165. //if (temp.UId != 21)
  6166. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6167. // "黑屏代码提醒",
  6168. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6169. }
  6170. }
  6171. }
  6172. #endregion
  6173. #region 判断到达日期是否需要加1
  6174. if (Info[4].Contains("+"))
  6175. {
  6176. //日期+1
  6177. day = day + 1;
  6178. //判断是否进入下一月
  6179. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6180. {
  6181. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6182. month = month + 1;
  6183. //判断是否进入下一年
  6184. if (month > 12)
  6185. {
  6186. month = month - 12;
  6187. year = year + 1;
  6188. }
  6189. }
  6190. //月份整理格式
  6191. string monthTemp = month.ToString();
  6192. if (month < 10)
  6193. {
  6194. monthTemp = "0" + monthTemp;
  6195. }
  6196. //日期整理格式
  6197. string daytemp = day.ToString();
  6198. if (day < 10)
  6199. {
  6200. daytemp = "0" + daytemp;
  6201. }
  6202. string temp = Info[4].Split('+')[0];
  6203. //添加起飞数据
  6204. dt.Rows.Add(Info[0],
  6205. Info[1],
  6206. Info[2],
  6207. Info[3],
  6208. temp,
  6209. Info[5],
  6210. Info[6],
  6211. Info[7],
  6212. Info[8],
  6213. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6214. year + "-" + monthTemp + "-" + daytemp,
  6215. "",
  6216. "0");
  6217. //加1天,添加到达数据
  6218. dt.Rows.Add(Info[0],
  6219. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6220. Info[2],
  6221. Info[3],
  6222. temp,
  6223. Info[5],
  6224. Info[6],
  6225. Info[7],
  6226. Info[8],
  6227. year + "-" + monthTemp + "-" + daytemp,
  6228. year + "-" + monthTemp + "-" + daytemp,
  6229. "",
  6230. "1");
  6231. }
  6232. else
  6233. {
  6234. //月份整理格式
  6235. string monthTemp = month.ToString();
  6236. if (month < 10)
  6237. {
  6238. monthTemp = "0" + monthTemp;
  6239. }
  6240. //日期整理格式
  6241. string daytemp = day.ToString();
  6242. if (day < 10)
  6243. {
  6244. daytemp = "0" + daytemp;
  6245. }
  6246. dt.Rows.Add(Info[0],
  6247. Info[1],
  6248. Info[2],
  6249. Info[3],
  6250. Info[4],
  6251. Info[5],
  6252. Info[6],
  6253. Info[7],
  6254. Info[8],
  6255. year + "-" + monthTemp + "-" + daytemp,
  6256. year + "-" + monthTemp + "-" + daytemp,
  6257. "",
  6258. "0");
  6259. }
  6260. #endregion
  6261. }
  6262. catch (Exception ex)
  6263. {
  6264. string exstr = ex.Message.ToString();
  6265. }
  6266. }
  6267. }
  6268. //排序
  6269. dt.DefaultView.Sort = "Day asc";
  6270. dt = dt.DefaultView.ToTable();
  6271. }
  6272. }
  6273. return dt;
  6274. }
  6275. /// <summary>
  6276. /// 根据团组编号查询信息
  6277. /// </summary>
  6278. /// <returns>返回空或者对象信息</returns>
  6279. List<Grp_TravelList> GetByDiid(int Diid)
  6280. {
  6281. //调用获取单个对象的方法
  6282. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6283. }
  6284. /// <summary>
  6285. /// 20210816
  6286. /// 根据datatable生成某一时间段的日期
  6287. /// </summary>
  6288. /// <param name="dt">黑屏代码生成的datatable</param>
  6289. /// <returns></returns>
  6290. List<string> GetTimeListByDataTable(DataTable dt)
  6291. {
  6292. if (dt.Rows[0]["Day"].ToString() != "")
  6293. {
  6294. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6295. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6296. List<string> timeList = new List<string>();
  6297. while (datestart <= dateend)
  6298. {
  6299. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6300. datestart = datestart.AddDays(1);
  6301. }
  6302. return timeList;
  6303. }
  6304. return null;
  6305. }
  6306. /// <summary>
  6307. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6308. /// </summary>
  6309. /// <param name="num"></param>
  6310. /// <returns></returns>
  6311. string GetNum(string num)
  6312. {
  6313. string str = "";
  6314. switch (num)
  6315. {
  6316. case "1":
  6317. str = "一";
  6318. break;
  6319. case "2":
  6320. str = "二";
  6321. break;
  6322. case "3":
  6323. str = "三";
  6324. break;
  6325. case "4":
  6326. str = "四";
  6327. break;
  6328. case "5":
  6329. str = "五";
  6330. break;
  6331. case "6":
  6332. str = "六";
  6333. break;
  6334. case "7":
  6335. str = "七";
  6336. break;
  6337. case "8":
  6338. str = "八";
  6339. break;
  6340. case "9":
  6341. str = "九";
  6342. break;
  6343. case "10":
  6344. str = "十";
  6345. break;
  6346. case "11":
  6347. str = "十一";
  6348. break;
  6349. case "12":
  6350. str = "十二";
  6351. break;
  6352. case "一":
  6353. str = "1";
  6354. break;
  6355. case "二":
  6356. str = "2";
  6357. break;
  6358. case "三":
  6359. str = "3";
  6360. break;
  6361. case "四":
  6362. str = "4";
  6363. break;
  6364. case "五":
  6365. str = "5";
  6366. break;
  6367. case "六":
  6368. str = "6";
  6369. break;
  6370. case "七":
  6371. str = "7";
  6372. break;
  6373. case "八":
  6374. str = "8";
  6375. break;
  6376. case "九":
  6377. str = "9";
  6378. break;
  6379. case "十":
  6380. str = "10";
  6381. break;
  6382. case "十一":
  6383. str = "11";
  6384. break;
  6385. case "十二":
  6386. str = "12";
  6387. break;
  6388. }
  6389. return str;
  6390. }
  6391. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6392. {
  6393. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6394. }
  6395. /// <summary>
  6396. /// 根据星期,月份的缩写,转换成数字或者全称
  6397. /// 根据币种中文名称返回币种代码
  6398. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6399. /// 20210903贾文滔
  6400. /// </summary>
  6401. /// <param name="startDate"></param>
  6402. /// <param name="endDate"></param>
  6403. /// <returns></returns>
  6404. string GetLonger(string temp)
  6405. {
  6406. string str = "";
  6407. switch (temp.ToUpper())
  6408. {
  6409. case "美元":
  6410. str = "USD";
  6411. break;
  6412. case "日元":
  6413. str = "JPY";
  6414. break;
  6415. case "英镑":
  6416. str = "GBP";
  6417. break;
  6418. case "欧元":
  6419. str = "EUR";
  6420. break;
  6421. case "港币":
  6422. str = "HKD";
  6423. break;
  6424. case "MO":
  6425. str = "星期一";
  6426. break;
  6427. case "TU":
  6428. str = "星期二";
  6429. break;
  6430. case "WE":
  6431. str = "星期三";
  6432. break;
  6433. case "TH":
  6434. str = "星期四";
  6435. break;
  6436. case "FR":
  6437. str = "星期五";
  6438. break;
  6439. case "SA":
  6440. str = "星期六";
  6441. break;
  6442. case "SU":
  6443. str = "星期天";
  6444. break;
  6445. case "JAN":
  6446. str = "01";
  6447. break;
  6448. case "FEB":
  6449. str = "02";
  6450. break;
  6451. case "MAR":
  6452. str = "03";
  6453. break;
  6454. case "APR":
  6455. str = "04";
  6456. break;
  6457. case "MAY":
  6458. str = "05";
  6459. break;
  6460. case "JUN":
  6461. str = "06";
  6462. break;
  6463. case "JUL":
  6464. str = "07";
  6465. break;
  6466. case "AUG":
  6467. str = "08";
  6468. break;
  6469. case "SEP":
  6470. str = "09";
  6471. break;
  6472. case "OCT":
  6473. str = "10";
  6474. break;
  6475. case "NOV":
  6476. str = "11";
  6477. break;
  6478. case "DEC":
  6479. str = "12";
  6480. break;
  6481. case "MONDAY":
  6482. str = "星期一";
  6483. break;
  6484. case "TUESDAY":
  6485. str = "星期二";
  6486. break;
  6487. case "WEDNESDAY":
  6488. str = "星期三";
  6489. break;
  6490. case "THURSDAY":
  6491. str = "星期四";
  6492. break;
  6493. case "FRIDAY":
  6494. str = "星期五";
  6495. break;
  6496. case "SATURDAY":
  6497. str = "星期六";
  6498. break;
  6499. case "SUNDAY":
  6500. str = "星期日";
  6501. break;
  6502. case "01":
  6503. str = "JAN";
  6504. break;
  6505. case "02":
  6506. str = "FEB";
  6507. break;
  6508. case "03":
  6509. str = "MAR";
  6510. break;
  6511. case "04":
  6512. str = "APR";
  6513. break;
  6514. case "05":
  6515. str = "MAY";
  6516. break;
  6517. case "06":
  6518. str = "JUN";
  6519. break;
  6520. case "07":
  6521. str = "JUL";
  6522. break;
  6523. case "08":
  6524. str = "AUG";
  6525. break;
  6526. case "09":
  6527. str = "SEP";
  6528. break;
  6529. case "10":
  6530. str = "OCT";
  6531. break;
  6532. case "11":
  6533. str = "NOV";
  6534. break;
  6535. case "12":
  6536. str = "DEC";
  6537. break;
  6538. case "2":
  6539. str = "空客A";
  6540. break;
  6541. case "3":
  6542. str = "空客A";
  6543. break;
  6544. case "7":
  6545. str = "波音";
  6546. break;
  6547. }
  6548. return str;
  6549. }
  6550. /// <summary>
  6551. /// 根据月份返回天数
  6552. /// </summary>
  6553. /// <param name="temp"></param>
  6554. /// <returns></returns>
  6555. string GetDaysByMonth(string Month, int year)
  6556. {
  6557. string str = "";
  6558. //判断是否是闰年
  6559. if (DateTime.IsLeapYear(year) == false)
  6560. {
  6561. switch (Month.ToUpper())
  6562. {
  6563. case "JAN":
  6564. str = "31";
  6565. break;
  6566. case "FEB":
  6567. str = "28";
  6568. break;
  6569. case "MAR":
  6570. str = "31";
  6571. break;
  6572. case "APR":
  6573. str = "30";
  6574. break;
  6575. case "MAY":
  6576. str = "31";
  6577. break;
  6578. case "JUN":
  6579. str = "30";
  6580. break;
  6581. case "JUL":
  6582. str = "31";
  6583. break;
  6584. case "AUG":
  6585. str = "31";
  6586. break;
  6587. case "SEP":
  6588. str = "30";
  6589. break;
  6590. case "OCT":
  6591. str = "31";
  6592. break;
  6593. case "NOV":
  6594. str = "30";
  6595. break;
  6596. case "DEC":
  6597. str = "31";
  6598. break;
  6599. case "01":
  6600. str = "31";
  6601. break;
  6602. case "02":
  6603. str = "28";
  6604. break;
  6605. case "03":
  6606. str = "31";
  6607. break;
  6608. case "04":
  6609. str = "30";
  6610. break;
  6611. case "05":
  6612. str = "31";
  6613. break;
  6614. case "06":
  6615. str = "30";
  6616. break;
  6617. case "07":
  6618. str = "31";
  6619. break;
  6620. case "08":
  6621. str = "31";
  6622. break;
  6623. case "09":
  6624. str = "30";
  6625. break;
  6626. case "10":
  6627. str = "31";
  6628. break;
  6629. case "11":
  6630. str = "30";
  6631. break;
  6632. case "12":
  6633. str = "31";
  6634. break;
  6635. }
  6636. }
  6637. else
  6638. {
  6639. switch (Month.ToUpper())
  6640. {
  6641. case "JAN":
  6642. str = "31";
  6643. break;
  6644. case "FEB":
  6645. str = "29";
  6646. break;
  6647. case "MAR":
  6648. str = "31";
  6649. break;
  6650. case "APR":
  6651. str = "30";
  6652. break;
  6653. case "MAY":
  6654. str = "31";
  6655. break;
  6656. case "JUN":
  6657. str = "30";
  6658. break;
  6659. case "JUL":
  6660. str = "31";
  6661. break;
  6662. case "AUG":
  6663. str = "31";
  6664. break;
  6665. case "SEP":
  6666. str = "30";
  6667. break;
  6668. case "OCT":
  6669. str = "31";
  6670. break;
  6671. case "NOV":
  6672. str = "30";
  6673. break;
  6674. case "DEC":
  6675. str = "31";
  6676. break;
  6677. case "01":
  6678. str = "31";
  6679. break;
  6680. case "02":
  6681. str = "29";
  6682. break;
  6683. case "03":
  6684. str = "31";
  6685. break;
  6686. case "04":
  6687. str = "30";
  6688. break;
  6689. case "05":
  6690. str = "31";
  6691. break;
  6692. case "06":
  6693. str = "30";
  6694. break;
  6695. case "07":
  6696. str = "31";
  6697. break;
  6698. case "08":
  6699. str = "31";
  6700. break;
  6701. case "09":
  6702. str = "30";
  6703. break;
  6704. case "10":
  6705. str = "31";
  6706. break;
  6707. case "11":
  6708. str = "30";
  6709. break;
  6710. case "12":
  6711. str = "31";
  6712. break;
  6713. }
  6714. }
  6715. return str;
  6716. }
  6717. #endregion
  6718. #endregion
  6719. #region 团组成本
  6720. /// <summary>
  6721. /// 团组成本数据初始化
  6722. /// </summary>
  6723. /// <param name="dto"></param>
  6724. /// <returns></returns>
  6725. [HttpPost]
  6726. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6727. {
  6728. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6729. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6730. WHEN COUNT(*) >= 0 THEN 'True'
  6731. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6732. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6733. ").ToList(); //团组列表
  6734. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6735. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6736. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6737. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6738. if (groupinfoValue != null)
  6739. {
  6740. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6741. var spArr = new string[1] { countryArr };
  6742. if (countryArr.Contains("|"))
  6743. {
  6744. spArr = countryArr.Split("|");
  6745. }
  6746. else if (countryArr.Contains("、"))
  6747. {
  6748. spArr = countryArr.Split("、");
  6749. }
  6750. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6751. {
  6752. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6753. if (dbQueryCountry != null)
  6754. {
  6755. visaCountryInfoArr.Add(dbQueryCountry);
  6756. }
  6757. }
  6758. }
  6759. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6760. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6761. var create = _GroupCostRepository.
  6762. CreateGroupCostByBlackCode(dto.Diid);
  6763. if (groupCost.Count == 0 && create.Code == 0)
  6764. {
  6765. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6766. }
  6767. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6768. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6769. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6770. groupCostMap = groupCostMap.Select(x =>
  6771. {
  6772. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6773. {
  6774. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6775. }
  6776. return x;
  6777. }).ToList();
  6778. //GroupCostParameter.Add(new
  6779. // Grp_GroupCostParameter());
  6780. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6781. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6782. return Ok(JsonView(new
  6783. {
  6784. groupList,
  6785. groupInfo,
  6786. groupChecks,
  6787. groupCost = groupCostMap,
  6788. hotelNumber,
  6789. GroupCostParameter = GroupCostParameterMap,
  6790. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6791. {
  6792. x.VisaCountry,
  6793. x.VisaPrice,
  6794. x.Id,
  6795. }).ToList(),
  6796. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6797. blackCodeIsTrue = create.Code == 0 ? true : false,
  6798. hotelIsTrue = hotelIsTrue,
  6799. }));
  6800. }
  6801. /// <summary>
  6802. /// 团组成本信息保存
  6803. /// </summary>
  6804. /// <param name="dto"></param>
  6805. /// <returns></returns>
  6806. [HttpPost]
  6807. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6808. {
  6809. if (dto.Diid <= 0 || dto.Userid <= 0)
  6810. {
  6811. return Ok(JsonView(false));
  6812. }
  6813. JsonView jw = null;
  6814. bool isTrue = false;
  6815. #region 复制团组成本
  6816. //if (dto.Diid == 2581)
  6817. //{
  6818. // dto.Diid = 2599;
  6819. // dto.CheckBoxs.ForEach(x =>
  6820. // {
  6821. // x.Diid = 2599;
  6822. // });
  6823. // dto.GroupCosts.ForEach(x =>
  6824. // {
  6825. // x.Diid = 2599;
  6826. // });
  6827. // dto.CostTypeHotelNumbers.ForEach(x =>
  6828. // {
  6829. // x.Diid = 2599;
  6830. // });
  6831. // dto.GroupCostParameters.ForEach(x =>
  6832. // {
  6833. // x.DiId = 2599;
  6834. // });
  6835. //}
  6836. #endregion
  6837. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6838. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6839. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6840. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6841. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6842. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6843. try
  6844. {
  6845. _sqlSugar.BeginTran();
  6846. isTrue = await _GroupCostRepository.
  6847. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6848. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6849. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6850. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6851. _sqlSugar.CommitTran();
  6852. jw = JsonView(true, "保存成功!", isTrue);
  6853. }
  6854. catch (Exception)
  6855. {
  6856. _sqlSugar.RollbackTran();
  6857. jw = JsonView(false);
  6858. }
  6859. return Ok(jw);
  6860. }
  6861. /// <summary>
  6862. /// 司兼导数据
  6863. /// </summary>
  6864. /// <param name="dto"></param>
  6865. /// <returns></returns>
  6866. [HttpPost]
  6867. public IActionResult GetCarGuides(CarGuidesDto dto)
  6868. {
  6869. JsonView jw = null;
  6870. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6871. jw = JsonView(true, "获取成功!", Data);
  6872. return Ok(jw);
  6873. }
  6874. /// <summary>
  6875. /// 导游数据
  6876. /// </summary>
  6877. /// <param name="dto"></param>
  6878. /// <returns></returns>
  6879. [HttpPost]
  6880. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6881. {
  6882. JsonView jw = null;
  6883. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6884. // 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
  6885. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6886. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6887. jw = JsonView(true, "获取成功!", Data);
  6888. return Ok(jw);
  6889. }
  6890. /// <summary>
  6891. /// 成本车数据
  6892. /// </summary>
  6893. /// <param name="dto"></param>
  6894. /// <returns></returns>
  6895. [HttpPost]
  6896. public IActionResult GetCarInfo(CarGuidesDto dto)
  6897. {
  6898. JsonView jw = null;
  6899. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6900. jw = JsonView(true, "获取成功!", Data);
  6901. return Ok(jw);
  6902. }
  6903. /// <summary>
  6904. /// 景点数据
  6905. /// </summary>
  6906. /// <param name="dto"></param>
  6907. /// <returns></returns>
  6908. [HttpPost]
  6909. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6910. {
  6911. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6912. return Ok(JsonView(true, "获取成功!", Data));
  6913. }
  6914. /// <summary>
  6915. /// 成本通知
  6916. /// </summary>
  6917. /// <param name="dto"></param>
  6918. /// <returns></returns>
  6919. [HttpPost]
  6920. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6921. {
  6922. if (dto.Diid < 0)
  6923. {
  6924. return Ok(JsonView(false));
  6925. }
  6926. JsonView jw = null;
  6927. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6928. if (GroupCostParameter != null)
  6929. {
  6930. int IsShare = 0;
  6931. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6932. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6933. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6934. string msg = string.Empty;
  6935. if (isTrue)
  6936. {
  6937. if (IsShare == 0)
  6938. {
  6939. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6940. }
  6941. else
  6942. {
  6943. #region 企微通知对应岗位用户
  6944. try
  6945. {
  6946. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6947. }
  6948. catch (Exception ex)
  6949. {
  6950. }
  6951. #endregion
  6952. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6953. }
  6954. jw = JsonView(isTrue, msg, new { IsShare });
  6955. }
  6956. else
  6957. {
  6958. msg = "修改失败!";
  6959. jw = JsonView(isTrue, msg);
  6960. }
  6961. }
  6962. else
  6963. {
  6964. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6965. }
  6966. return Ok(jw);
  6967. }
  6968. /// <summary>
  6969. /// 导出收款账单
  6970. /// </summary>
  6971. /// <param name="dto"></param>
  6972. /// <returns></returns>
  6973. [HttpPost]
  6974. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6975. {
  6976. if (dto.Diid == 0)
  6977. {
  6978. return Ok(JsonView(false, "请传递团组id"));
  6979. }
  6980. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6981. if (deleInfo.Code != 0)
  6982. {
  6983. return Ok(JsonView(false, "团组信息查询失败!"));
  6984. }
  6985. var di = deleInfo.Data as DelegationInfoWebView;
  6986. if (di != null)
  6987. {
  6988. //文件名
  6989. string strFileName = di.TeamName + "-收款账单.doc";
  6990. //获取模板
  6991. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6992. //载入模板
  6993. Document doc = new Document(tmppath);
  6994. decimal TotalPrice = 0.00M;
  6995. string itemStr = string.Empty;
  6996. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6997. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6998. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6999. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7000. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7001. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7002. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7003. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7004. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7005. foreach (var cost in groupCostType)
  7006. {
  7007. var List = cost.ToList();
  7008. if (cost.Key == "A")
  7009. {
  7010. foreach (var ListItem in List)
  7011. {
  7012. if (ListItem.number > 0)
  7013. {
  7014. if (ListItem.code.Contains("TBR"))
  7015. {
  7016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7017. }
  7018. else
  7019. {
  7020. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7021. }
  7022. TotalPrice += (ListItem.number * ListItem.price);
  7023. }
  7024. }
  7025. }
  7026. else
  7027. {
  7028. itemStr = itemStr.Insert(0, "A段\r\n");
  7029. itemStr += "B段\r\n";
  7030. foreach (var ListItem in List)
  7031. {
  7032. if (ListItem.number > 0)
  7033. {
  7034. if (ListItem.code.Contains("TBR"))
  7035. {
  7036. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7037. }
  7038. else
  7039. {
  7040. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7041. }
  7042. TotalPrice += (ListItem.number * ListItem.price);
  7043. }
  7044. }
  7045. }
  7046. }
  7047. #region 替换Word模板书签内容
  7048. Dictionary<string, string> marks = new Dictionary<string, string>();
  7049. marks.Add("To", di.ClientUnit);//付款方
  7050. marks.Add("ToTel", di.TellPhone);//付款方电话
  7051. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7052. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7053. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7054. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7055. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7056. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7057. marks.Add("PayItemContent", itemStr);//详细信息
  7058. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7059. #endregion
  7060. ////注
  7061. //if (doc.Range.Bookmarks["Attention"] != null)
  7062. //{
  7063. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7064. // mark.Text = frList[0].Attention;
  7065. //}
  7066. foreach (var item in marks.Keys)
  7067. {
  7068. if (doc.Range.Bookmarks[item] != null)
  7069. {
  7070. Bookmark mark = doc.Range.Bookmarks[item];
  7071. mark.Text = marks[item];
  7072. }
  7073. }
  7074. byte[] bytes = null;
  7075. using (MemoryStream stream = new MemoryStream())
  7076. {
  7077. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7078. bytes = stream.ToArray();
  7079. }
  7080. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7081. return Ok(JsonView(true, "", new
  7082. {
  7083. Data = bytes,
  7084. strFileName,
  7085. }));
  7086. }
  7087. else
  7088. {
  7089. return Ok(JsonView(false, "团组信息不存在!"));
  7090. }
  7091. }
  7092. /// <summary>
  7093. /// 导出团组成本
  7094. /// </summary>
  7095. /// <param name="dto"></param>
  7096. /// <returns></returns>
  7097. [HttpPost]
  7098. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7099. {
  7100. var jw = JsonView(false);
  7101. if (dto.Diid == 0)
  7102. {
  7103. return Ok(JsonView(false, "请传递团组id"));
  7104. }
  7105. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7106. if (deleInfo.Code != 0)
  7107. {
  7108. return Ok(JsonView(false, "团组信息查询失败!"));
  7109. }
  7110. var di = deleInfo.Data as DelegationInfoWebView;
  7111. if (di == null)
  7112. {
  7113. return Ok(JsonView(false, "团组信息查询失败!"));
  7114. }
  7115. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7116. WorkbookDesigner designer = new WorkbookDesigner();
  7117. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7118. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7119. for (int i = 0; i < List_GC.Count; i++)
  7120. {
  7121. GroupCost_Excel gc = new GroupCost_Excel();
  7122. gc.Id = List_GC[i].Id;
  7123. gc.Diid = List_GC[i].Diid.ToString();
  7124. gc.DAY = List_GC[i].DAY;
  7125. string week = "";
  7126. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7127. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7128. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7129. gc.ITIN = List_GC[i].ITIN;
  7130. gc.CarType = List_GC[i].CarType;
  7131. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7132. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7133. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7134. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7135. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7136. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7137. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7138. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7139. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7140. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7141. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7142. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7143. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7144. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7145. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7146. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7147. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7148. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7149. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7150. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7151. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7152. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7153. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7154. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7155. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7156. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7157. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7158. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7159. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7160. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7161. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7162. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7163. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7164. List_GC1.Add(gc);
  7165. }
  7166. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7167. dt.TableName = "TB";
  7168. //报表标题等不用dt的值
  7169. designer.SetDataSource("TeamName", dto.title.TeamName);
  7170. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7171. designer.SetDataSource("Tax", dto.title.Tax);
  7172. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7173. designer.SetDataSource("Currency", dto.title.Currency);
  7174. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7175. designer.SetDataSource("Rate", dto.title.Rate);
  7176. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7177. var Aparams = hotels.Find(x => x.Type == "Default");
  7178. if (Aparams == null)
  7179. {
  7180. return Ok(jw);
  7181. }
  7182. //酒店数量
  7183. var txtSGRNumber = Aparams.SGR.ToString();
  7184. var txtTBRNumber = Aparams.TBR.ToString();
  7185. var txtJSESNumber = Aparams.JSES.ToString();
  7186. var txtSUITENumbe = Aparams.SUITE.ToString();
  7187. if (dto.costType == "B")
  7188. {
  7189. Aparams = hotels.Find(x => x.Type == "A");
  7190. var Bparams = hotels.Find(x => x.Type == "B");
  7191. if (Aparams == null || Bparams == null)
  7192. {
  7193. return Ok(jw);
  7194. }
  7195. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7196. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7197. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7198. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7199. }
  7200. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7201. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7202. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7203. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7204. var ws = designer.Workbook.Worksheets[0];
  7205. int Row = List_GC.Count;
  7206. int startIndex = 11;
  7207. int HideRows = 0;
  7208. List<int> hideRowsList = new List<int>();
  7209. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7210. #region A段left数据
  7211. var left = dto.leftInfo.Find(x => x.Type == "A");
  7212. if (left == null)
  7213. {
  7214. return Ok(jw);
  7215. }
  7216. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7217. if (leftBindData != null)
  7218. {
  7219. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7220. designer.SetDataSource("VisaRS", leftBindData.rs);
  7221. designer.SetDataSource("VisaXS", leftBindData.xs);
  7222. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7223. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7224. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7226. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7227. }
  7228. else
  7229. {
  7230. hideRowsList.Add(Row + startIndex + HideRows);
  7231. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7232. }
  7233. HideRows += 2;
  7234. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7235. if (leftBindData != null)
  7236. {
  7237. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7238. designer.SetDataSource("BXRS", leftBindData.rs);
  7239. designer.SetDataSource("BXXS", leftBindData.xs);
  7240. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7241. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7242. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7243. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7244. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7245. }
  7246. else
  7247. {
  7248. hideRowsList.Add(Row + startIndex + HideRows);
  7249. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7250. }
  7251. HideRows += 2;
  7252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7253. if (leftBindData != null)
  7254. {
  7255. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7256. designer.SetDataSource("HSRS", leftBindData.rs);
  7257. designer.SetDataSource("HSXS", leftBindData.xs);
  7258. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7259. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7260. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7261. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7262. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7263. }
  7264. else
  7265. {
  7266. hideRowsList.Add(Row + startIndex + HideRows);
  7267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7268. }
  7269. HideRows += 2;
  7270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7271. if (leftBindData != null)
  7272. {
  7273. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7274. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7275. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7276. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7277. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7278. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7279. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7280. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7281. }
  7282. else
  7283. {
  7284. hideRowsList.Add(Row + startIndex + HideRows);
  7285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7286. }
  7287. HideRows += 2;
  7288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7289. if (leftBindData != null)
  7290. {
  7291. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7292. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7293. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7294. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7296. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7297. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7298. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7299. }
  7300. else
  7301. {
  7302. hideRowsList.Add(Row + startIndex + HideRows);
  7303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7304. }
  7305. HideRows += 2;
  7306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7307. if (leftBindData != null)
  7308. {
  7309. ////TBR
  7310. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7311. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7312. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7313. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7314. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7315. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7316. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7317. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7318. }
  7319. else
  7320. {
  7321. hideRowsList.Add(Row + startIndex + HideRows);
  7322. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7323. }
  7324. HideRows += 2;
  7325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7326. if (leftBindData != null)
  7327. {
  7328. ////SGR
  7329. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7330. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7331. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7332. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7333. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7334. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7335. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7336. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7337. }
  7338. else
  7339. {
  7340. hideRowsList.Add(Row + startIndex + HideRows);
  7341. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7342. }
  7343. HideRows += 2;
  7344. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7345. if (leftBindData != null)
  7346. {
  7347. ////JS/ES
  7348. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7349. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7350. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7351. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7352. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7353. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7354. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7355. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7356. }
  7357. else
  7358. {
  7359. hideRowsList.Add(Row + startIndex + HideRows);
  7360. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7361. }
  7362. HideRows += 2;
  7363. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7364. if (leftBindData != null)
  7365. {
  7366. ////SUITE
  7367. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7368. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7369. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7370. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7371. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7372. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7373. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7374. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7375. }
  7376. else
  7377. {
  7378. hideRowsList.Add(Row + startIndex + HideRows);
  7379. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7380. }
  7381. HideRows += 2;
  7382. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7383. if (leftBindData != null)
  7384. {
  7385. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7386. designer.SetDataSource("DJRS", leftBindData.rs);
  7387. designer.SetDataSource("DJXS", leftBindData.xs);
  7388. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7389. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7390. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7391. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7392. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7393. }
  7394. else
  7395. {
  7396. hideRowsList.Add(Row + startIndex + HideRows);
  7397. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7398. }
  7399. HideRows += 2;
  7400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7401. if (leftBindData != null)
  7402. {
  7403. designer.SetDataSource("HCPCB", leftBindData.cb);
  7404. designer.SetDataSource("HCPRS", leftBindData.rs);
  7405. designer.SetDataSource("HCPXS", leftBindData.xs);
  7406. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7407. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7408. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7409. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7410. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7411. }
  7412. else
  7413. {
  7414. hideRowsList.Add(Row + startIndex + HideRows);
  7415. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7416. }
  7417. HideRows += 2;
  7418. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7419. if (leftBindData != null)
  7420. {
  7421. designer.SetDataSource("CPCB", leftBindData.cb);
  7422. designer.SetDataSource("CPRS", leftBindData.rs);
  7423. designer.SetDataSource("CPXS", leftBindData.xs);
  7424. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7425. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7426. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7427. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7428. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7429. }
  7430. else
  7431. {
  7432. hideRowsList.Add(Row + startIndex + HideRows);
  7433. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7434. }
  7435. HideRows += 2;
  7436. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7437. if (leftBindData != null)
  7438. {
  7439. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7440. designer.SetDataSource("GWRS", leftBindData.rs);
  7441. designer.SetDataSource("GWXS", leftBindData.xs);
  7442. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7443. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7444. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7445. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7446. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7447. }
  7448. else
  7449. {
  7450. hideRowsList.Add(Row + startIndex + HideRows);
  7451. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7452. }
  7453. HideRows += 2;
  7454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7455. if (leftBindData != null)
  7456. {
  7457. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7458. designer.SetDataSource("LYJRS", leftBindData.rs);
  7459. designer.SetDataSource("LYJXS", leftBindData.xs);
  7460. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7461. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7462. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7463. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7464. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7465. }
  7466. else
  7467. {
  7468. hideRowsList.Add(Row + startIndex + HideRows);
  7469. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7470. }
  7471. #endregion
  7472. #region A段Right信息
  7473. var right = dto.rightInfo.Find(x => x.Type == "A");
  7474. if (right == null)
  7475. {
  7476. return Ok(jw);
  7477. }
  7478. HideRows += 4;
  7479. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7480. if (rightBindData != null)
  7481. {
  7482. //经济舱 + 双人间 TBR
  7483. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7484. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7485. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7486. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7487. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7488. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7489. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7490. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7491. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7492. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7493. }
  7494. else
  7495. {
  7496. hideRowsList.Add(Row + startIndex + HideRows);
  7497. }
  7498. HideRows += 2;
  7499. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7500. if (rightBindData != null)
  7501. {
  7502. //经济舱 + 单人间 SGR
  7503. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7504. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7505. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7506. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7507. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7508. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7509. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7510. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7511. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7512. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7513. }
  7514. else
  7515. {
  7516. hideRowsList.Add(Row + startIndex + HideRows);
  7517. }
  7518. HideRows += 2;
  7519. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7520. if (rightBindData != null)
  7521. {
  7522. //公务舱 + 单人间 SGR
  7523. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7524. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7525. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7526. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7527. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7528. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7529. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7530. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7531. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7532. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7533. }
  7534. else
  7535. {
  7536. hideRowsList.Add(Row + startIndex + HideRows);
  7537. }
  7538. HideRows += 2;
  7539. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7540. if (rightBindData != null)
  7541. {
  7542. //公务舱 + 小套房 JSES
  7543. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7544. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7545. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7546. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7547. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7548. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7549. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7550. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7551. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7552. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7553. }
  7554. else
  7555. {
  7556. hideRowsList.Add(Row + startIndex + HideRows);
  7557. }
  7558. HideRows += 2;
  7559. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7560. if (rightBindData != null)
  7561. {
  7562. //公务舱 + 小套房 JSES
  7563. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7564. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7565. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7566. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7567. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7568. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7569. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7570. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7571. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7572. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7573. }
  7574. else
  7575. {
  7576. hideRowsList.Add(Row + startIndex + HideRows);
  7577. }
  7578. HideRows += 2;
  7579. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7580. if (rightBindData != null)
  7581. {
  7582. //经济舱 + 大套房
  7583. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7584. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7585. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7586. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7587. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7588. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7589. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7590. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7591. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7592. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7593. }
  7594. else
  7595. {
  7596. hideRowsList.Add(Row + startIndex + HideRows);
  7597. }
  7598. #endregion
  7599. #region B段标题清空
  7600. designer.SetDataSource("CostBDRCB", "");
  7601. designer.SetDataSource("CostBRS", "");
  7602. designer.SetDataSource("CostBXS", "");
  7603. designer.SetDataSource("CostBZCB", "");
  7604. designer.SetDataSource("CostBDRBJ", "");
  7605. designer.SetDataSource("CostBZBJ", "");
  7606. designer.SetDataSource("CostBDRLR", "");
  7607. designer.SetDataSource("CostBZLR", "");
  7608. designer.SetDataSource("CostBDRCBOM", "");
  7609. designer.SetDataSource("CostBRSOM", "");
  7610. designer.SetDataSource("CostBZCBOM", "");
  7611. designer.SetDataSource("CostBDRBJOM", "");
  7612. designer.SetDataSource("CostBZBJOM", "");
  7613. designer.SetDataSource("CostBDRLROM", "");
  7614. designer.SetDataSource("CostBZLROM", "");
  7615. #endregion
  7616. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7617. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7618. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7619. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7620. designer.SetDataSource("DJName", "地接(CNY)");
  7621. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7622. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7623. designer.SetDataSource("GWName", "公务(CNY)");
  7624. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7625. designer.SetDataSource("LYJName", "零用金(CNY)");
  7626. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7627. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7628. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7629. designer.SetDataSource("BXName", "保险(CNY)");
  7630. designer.SetDataSource("VisaName", "签证(CNY)");
  7631. #region B段基本数据
  7632. if (dto.costType == "B")
  7633. {
  7634. left = dto.leftInfo.Find(x => x.Type == "B");
  7635. if (left == null)
  7636. {
  7637. return Ok(jw);
  7638. }
  7639. #region B段left数据
  7640. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7641. if (leftBindData != null)
  7642. {
  7643. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7644. designer.SetDataSource("BHSRS", leftBindData.rs);
  7645. designer.SetDataSource("BHSXS", leftBindData.xs);
  7646. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7647. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7648. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7649. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7650. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7651. }
  7652. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7653. if (leftBindData != null)
  7654. {
  7655. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7656. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7657. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7658. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7659. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7660. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7661. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7662. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7663. }
  7664. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7665. if (leftBindData != null)
  7666. {
  7667. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7668. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7669. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7670. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7671. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7672. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7673. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7674. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7675. }
  7676. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7677. if (leftBindData != null)
  7678. {
  7679. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7680. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7681. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7682. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7683. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7684. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7685. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7686. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7687. }
  7688. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7689. if (leftBindData != null)
  7690. {
  7691. designer.SetDataSource("BCPCB", leftBindData.cb);
  7692. designer.SetDataSource("BCPRS", leftBindData.rs);
  7693. designer.SetDataSource("BCPXS", leftBindData.xs);
  7694. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7695. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7696. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7697. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7698. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7699. }
  7700. //TBR
  7701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7702. if (leftBindData != null)
  7703. {
  7704. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7705. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7706. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7707. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7708. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7709. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7710. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7711. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7712. }
  7713. //SGR
  7714. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7715. if (leftBindData != null)
  7716. {
  7717. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7718. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7719. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7720. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7721. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7722. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7723. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7724. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7725. }
  7726. //JS/ES
  7727. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7728. if (leftBindData != null)
  7729. {
  7730. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7731. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7732. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7733. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7734. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7735. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7736. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7737. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7738. }
  7739. //SUITE
  7740. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7741. if (leftBindData != null)
  7742. {
  7743. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7744. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7745. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7746. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7747. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7748. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7749. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7750. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7751. }
  7752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7753. if (leftBindData != null)
  7754. {
  7755. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7756. designer.SetDataSource("BDJRS", leftBindData.rs);
  7757. designer.SetDataSource("BDJXS", leftBindData.xs);
  7758. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7759. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7760. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7761. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7762. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7763. }
  7764. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7765. if (leftBindData != null)
  7766. {
  7767. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7768. designer.SetDataSource("BGWRS", leftBindData.rs);
  7769. designer.SetDataSource("BGWXS", leftBindData.xs);
  7770. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7771. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7772. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7773. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7774. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7775. }
  7776. #region 优化方案
  7777. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7778. //excelBind.Add("零用金", new {
  7779. //cb="",
  7780. //rs="",
  7781. //xs ="",
  7782. //zcb = "",
  7783. //});
  7784. #endregion
  7785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7786. if (leftBindData != null)
  7787. {
  7788. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7789. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7790. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7791. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7792. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7793. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7794. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7795. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7796. }
  7797. #endregion
  7798. #region B段Right信息
  7799. right = dto.rightInfo.Find(x => x.Type == "B");
  7800. if (right == null)
  7801. {
  7802. return Ok(jw);
  7803. }
  7804. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7805. if (rightBindData != null)
  7806. {
  7807. //经济舱 + 双人间 TBR
  7808. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7809. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7810. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7811. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7812. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7813. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7814. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7815. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7816. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7817. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7818. }
  7819. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7820. if (rightBindData != null)
  7821. {
  7822. //经济舱 + 单人间 SGR
  7823. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7824. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7825. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7826. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7827. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7828. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7829. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7830. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7831. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7832. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7833. }
  7834. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7835. if (rightBindData != null)
  7836. {
  7837. //公务舱 + 单人间 SGR
  7838. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7839. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7840. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7841. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7842. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7843. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7844. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7845. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7846. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7847. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7848. }
  7849. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7850. if (rightBindData != null)
  7851. {
  7852. //公务舱 + 小套房 JSES
  7853. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7854. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7855. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7856. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7857. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7858. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7859. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7860. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7861. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7862. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7863. }
  7864. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7865. if (rightBindData != null)
  7866. {
  7867. //公务舱 + 小套房 JSES
  7868. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7869. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7870. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7871. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7872. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7873. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7874. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7875. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7876. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7877. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7878. }
  7879. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7880. if (rightBindData != null)
  7881. {
  7882. //经济舱 + 大套房
  7883. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7884. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7885. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7886. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7887. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7888. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7889. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7890. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7891. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7892. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7893. }
  7894. #endregion
  7895. #region 标题
  7896. designer.SetDataSource("CostBDRCB", "单人成本");
  7897. designer.SetDataSource("CostBRS", "人数");
  7898. designer.SetDataSource("CostBXS", "系数");
  7899. designer.SetDataSource("CostBZCB", "总成本");
  7900. designer.SetDataSource("CostBDRBJ", "单人报价");
  7901. designer.SetDataSource("CostBZBJ", "总报价");
  7902. designer.SetDataSource("CostBDRLR", "单人利润");
  7903. designer.SetDataSource("CostBZLR", "总利润");
  7904. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7905. designer.SetDataSource("CostBRSOM", "人数");
  7906. designer.SetDataSource("CostBZCBOM", "总成本");
  7907. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7908. designer.SetDataSource("CostBZBJOM", "总报价");
  7909. designer.SetDataSource("CostBDRLROM", "单人利润");
  7910. designer.SetDataSource("CostBZLROM", "总利润");
  7911. #endregion
  7912. }
  7913. #endregion
  7914. designer.SetDataSource("TzZCB2", TzZCB2);
  7915. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7916. designer.SetDataSource("TzZLR2", TzZLR2);
  7917. string[] dataSourceKeys = new string[]
  7918. {
  7919. "VF",
  7920. "TGS",
  7921. "TGOF",
  7922. "TGM",
  7923. "TGA",
  7924. "TGTF",
  7925. "TGEF",
  7926. "CFM",
  7927. "CFOF",
  7928. "B",
  7929. "L",
  7930. "D",
  7931. "TBR",
  7932. "SGR",
  7933. "JSES",
  7934. "Suite",
  7935. "TV",
  7936. "1L",
  7937. "IF",
  7938. "EF",
  7939. "BRF",
  7940. "TE",
  7941. "TGT",
  7942. "DRVT",
  7943. "PC",
  7944. "TLF",
  7945. "ECT"
  7946. };
  7947. foreach (var item in dataSourceKeys)
  7948. {
  7949. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7950. if (find != null)
  7951. {
  7952. designer.SetDataSource(item, find.text);
  7953. }
  7954. else
  7955. {
  7956. designer.SetDataSource(item, 0);
  7957. }
  7958. }
  7959. designer.SetDataSource(dt);
  7960. //根据数据源处理生成报表内容
  7961. designer.Process();
  7962. designer.Workbook.Worksheets[0].Name = "清单";
  7963. Worksheet sheet = designer.Workbook.Worksheets[0];
  7964. foreach (var Rowindex in hideRowsList)
  7965. {
  7966. ws.Cells.HideRows(Rowindex, 2);
  7967. }
  7968. byte[] bytes = null;
  7969. string strFileName = di.TeamName + "-团组-成本.xls";
  7970. using (MemoryStream stream = new MemoryStream())
  7971. {
  7972. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7973. bytes = stream.ToArray();
  7974. }
  7975. return Ok(JsonView(true, "", new
  7976. {
  7977. Data = bytes,
  7978. strFileName,
  7979. }));
  7980. }
  7981. /// <summary>
  7982. /// 导出客户报表
  7983. /// </summary>
  7984. /// <returns></returns>
  7985. [HttpPost]
  7986. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7987. {
  7988. var jw = JsonView(false);
  7989. if (dto.Diid == 0)
  7990. {
  7991. return Ok(JsonView(false, "请传递团组id"));
  7992. }
  7993. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7994. if (deleInfo.Code != 0)
  7995. {
  7996. return Ok(JsonView(false, "团组信息查询失败!"));
  7997. }
  7998. var di = deleInfo.Data as DelegationInfoWebView;
  7999. if (di == null)
  8000. {
  8001. return Ok(JsonView(false, "团组信息查询失败!"));
  8002. }
  8003. //文件名
  8004. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8005. //获取模板
  8006. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8007. //载入模板
  8008. Document doc = new Document(tmppath);
  8009. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8010. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8011. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8012. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8013. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8014. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8015. if (AParameter == null)
  8016. {
  8017. return Ok(JsonView(false, "系数不存在!"));
  8018. }
  8019. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8020. , TzAirDesc, TzZCost;
  8021. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8022. = TzAirDesc = TzZCost = string.Empty;
  8023. TzNumber = AParameter.CostTypenumber.ToString();
  8024. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8025. CarGuides1 = dto.CarGuides1;
  8026. Meal = dto.Meal;
  8027. SubsidizedMeals = dto.SubsidizedMeals;
  8028. NightRepair = dto.NightRepair;
  8029. AttractionsTickets = dto.AttractionsTickets;
  8030. MiscellaneousFees = dto.MiscellaneousFees;
  8031. ATip = dto.ATip;
  8032. TzHotelDesc = "";
  8033. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8034. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8035. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8036. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8037. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8038. TzAirDesc = "";
  8039. TzZCost = dto.TzZCost;
  8040. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8041. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8042. var index = 1;
  8043. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8044. foreach (var item in TzHotelDescArr)
  8045. {
  8046. if (AinfoArr != null)
  8047. {
  8048. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8049. if (Ainfo != null)
  8050. {
  8051. if (int.Parse(Ainfo.rs) <= 0)
  8052. {
  8053. continue;
  8054. }
  8055. var hotelText = string.Empty;
  8056. switch (item)
  8057. {
  8058. case "SGR":
  8059. hotelText = "单人间";
  8060. break;
  8061. case "JSES":
  8062. hotelText = "小套房";
  8063. break;
  8064. case "SUITE":
  8065. hotelText = "套房";
  8066. break;
  8067. case "TBR":
  8068. hotelText = "双人间";
  8069. break;
  8070. }
  8071. if (item != "TBR")
  8072. {
  8073. 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";
  8074. }
  8075. else
  8076. {
  8077. 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";
  8078. }
  8079. index++;
  8080. }
  8081. }
  8082. }
  8083. index = 1;
  8084. foreach (var item in TzAirDescArr)
  8085. {
  8086. if (AinfoArr != null)
  8087. {
  8088. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8089. if (Ainfo != null)
  8090. {
  8091. if (int.Parse(Ainfo.rs) <= 0)
  8092. {
  8093. continue;
  8094. }
  8095. 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";
  8096. index++;
  8097. }
  8098. }
  8099. }
  8100. if (dto.costType == "B")
  8101. {
  8102. if (BParameter == null)
  8103. {
  8104. return Ok(JsonView(false, "B段系数不存在!"));
  8105. }
  8106. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8107. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8108. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8109. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8110. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8111. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8112. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8113. foreach (var item in TzHotelDescArr)
  8114. {
  8115. if (AinfoArr != null)
  8116. {
  8117. TzHotelDesc += "B段信息 \r\n";
  8118. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8119. if (Ainfo != null)
  8120. {
  8121. if (int.Parse(Ainfo.rs) <= 0)
  8122. {
  8123. continue;
  8124. }
  8125. var hotelText = string.Empty;
  8126. switch (item)
  8127. {
  8128. case "SGR":
  8129. hotelText = "单人间";
  8130. break;
  8131. case "JSES":
  8132. hotelText = "小套房";
  8133. break;
  8134. case "SUITE":
  8135. hotelText = "套房";
  8136. break;
  8137. case "TBR":
  8138. hotelText = "双人间";
  8139. break;
  8140. }
  8141. if (item != "TBR")
  8142. {
  8143. 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";
  8144. }
  8145. else
  8146. {
  8147. 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";
  8148. }
  8149. index++;
  8150. }
  8151. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8152. }
  8153. }
  8154. index = 1;
  8155. foreach (var item in TzAirDescArr)
  8156. {
  8157. if (AinfoArr != null)
  8158. {
  8159. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8160. if (Ainfo != null)
  8161. {
  8162. if (int.Parse(Ainfo.rs) <= 0)
  8163. {
  8164. continue;
  8165. }
  8166. 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";
  8167. index++;
  8168. }
  8169. }
  8170. }
  8171. }
  8172. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8173. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8174. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8175. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8176. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8177. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8178. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8179. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8180. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8181. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8182. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8183. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8184. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8185. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8186. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8187. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8188. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8189. DickeyValue.Add("TzZCost", TzZCost);
  8190. foreach (var key in DickeyValue.Keys)
  8191. {
  8192. if (doc.Range.Bookmarks[key] != null)
  8193. {
  8194. Bookmark mark = doc.Range.Bookmarks[key];
  8195. mark.Text = DickeyValue[key];
  8196. }
  8197. }
  8198. byte[] bytes = null;
  8199. string strFileName = di.TeamName + "-客户报价.doc";
  8200. using (MemoryStream stream = new MemoryStream())
  8201. {
  8202. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8203. bytes = stream.ToArray();
  8204. }
  8205. return Ok(JsonView(true, "", new
  8206. {
  8207. Data = bytes,
  8208. strFileName,
  8209. }));
  8210. }
  8211. /// <summary>
  8212. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8213. /// </summary>
  8214. /// <param name="dto"></param>
  8215. /// <returns></returns>
  8216. [HttpPost]
  8217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8218. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8219. {
  8220. try
  8221. {
  8222. #region 参数验证
  8223. if (dto.DiId < 0)
  8224. {
  8225. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8226. }
  8227. List<int> cTableIds = new List<int>() {
  8228. 76 ,//酒店预订
  8229. 77 ,//行程
  8230. 79 ,//车/导游地接
  8231. 80 ,//签证
  8232. 81 ,//邀请/公务活
  8233. 82 ,//团组客户保险
  8234. 85 ,//机票预订
  8235. 98 ,//其他款项
  8236. 285 ,//收款退还
  8237. 751 ,//酒店早餐
  8238. 1015 // 超支费用
  8239. };
  8240. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8241. {
  8242. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8243. }
  8244. #endregion
  8245. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8246. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8247. if (_GroupCostParameters.Count <= 0)
  8248. {
  8249. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8250. }
  8251. if (_GroupCostParameters[0].IsShare == 0)
  8252. {
  8253. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8254. }
  8255. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8256. //处理date为空问题
  8257. if (_GroupCosts.Count > 0)
  8258. {
  8259. for (int i = 0; i < _GroupCosts.Count; i++)
  8260. {
  8261. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8262. {
  8263. if (i > 0)
  8264. {
  8265. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8266. }
  8267. }
  8268. }
  8269. }
  8270. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8271. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8272. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8273. string currCode = "";
  8274. #region currCode 验证
  8275. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8276. if (isInt)
  8277. {
  8278. var currData = currDatas.Find(it => it.Id == intCurrency);
  8279. if (currData != null)
  8280. {
  8281. currCode = currData.Name;
  8282. }
  8283. }
  8284. else
  8285. {
  8286. currCode = _GroupCostParameters[0].Currency.Trim();
  8287. }
  8288. #endregion
  8289. //op,酒店单段模式存储
  8290. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8291. {
  8292. CurrencyCode = currCode,
  8293. Rate = _GroupCostParameters[0].Rate,
  8294. CostType = _GroupCostParameters[0].CostType,
  8295. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8296. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8297. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8298. };
  8299. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8300. if (_GroupCostParameters.Count == 2)
  8301. {
  8302. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8303. }
  8304. foreach (var item in _GroupCostParameters)
  8305. {
  8306. decimal _rate = 1;
  8307. decimal _rate1 = item.Rate;
  8308. decimal _scale = 1;
  8309. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8310. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8311. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8312. //if (userInfo != null)
  8313. //{
  8314. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8315. // {
  8316. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8317. // {
  8318. // _scale = 1.00M;
  8319. // }
  8320. // }
  8321. //}
  8322. #endregion
  8323. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8324. {
  8325. CurrencyCode = currCode,
  8326. Rate = _rate1,
  8327. CostType = item.CostType,
  8328. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8329. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8330. CostTypeNumber = item.CostTypenumber
  8331. };
  8332. if (_GroupCostParameters.Count > 1)
  8333. {
  8334. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8335. }
  8336. else
  8337. {
  8338. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8339. }
  8340. if (dto.CTable == 79)//
  8341. {
  8342. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8343. modulePromptInfo.TotalCost = item.DJCB;
  8344. }
  8345. List<string> costTypes = new List<string>() { "A", "B" };
  8346. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8347. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8348. if (_GroupCostsDuplicates.Count() == 1)
  8349. {
  8350. _GroupCostsTypeData = _GroupCosts;
  8351. }
  8352. else
  8353. {
  8354. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8355. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8356. }
  8357. /*
  8358. * 76 酒店预订
  8359. * 77 行程
  8360. * 79 车/导游地接
  8361. * 80 签证
  8362. * 81 邀请/公务活动
  8363. * 82 团组客户保险
  8364. * 85 机票预订
  8365. * 98 其他款项
  8366. * 285 收款退还
  8367. * 751 酒店早餐
  8368. * 1015 超支费用
  8369. */
  8370. switch (dto.CTable)
  8371. {
  8372. case 76: // 酒店预订
  8373. _ModuleSubPromptInfo.AddRange(
  8374. _GroupCostsTypeData.Select(it => new
  8375. {
  8376. it.DAY,
  8377. it.Date,
  8378. it.ACCON,
  8379. it.ITIN,
  8380. it.SGR,
  8381. it.TBR,
  8382. it.JS_ES,
  8383. it.Suite
  8384. })
  8385. );
  8386. break;
  8387. case 79: // 车/导游地接
  8388. _ModuleSubPromptInfo.AddRange(
  8389. _GroupCostsTypeData.Select(it => new
  8390. {
  8391. Date = it.Date, //日期
  8392. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8393. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8394. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8395. TicketFee = it.EF * _rate * _scale, //门票费
  8396. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8397. AirportTransferFee = 0.00M,
  8398. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8399. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8400. LeadersFee = it.TLF * _rate * _scale, //领队费
  8401. CarFee1 = it.CarCost * _rate * _scale,
  8402. CarType = it.CarType, //车型
  8403. SpentCash = it.PC * _rate * _scale, //零用金
  8404. })
  8405. );
  8406. break;
  8407. case 85: // 机票
  8408. List<dynamic> datas = new List<dynamic>();
  8409. datas.Add(
  8410. new
  8411. {
  8412. AirType = "经济舱",
  8413. AirNum = item.JJCRS,
  8414. AirDRCB = item.JJCCB,
  8415. AirZCB = (item.JJCRS * item.JJCCB)
  8416. }
  8417. );
  8418. datas.Add(
  8419. new
  8420. {
  8421. AirType = "公务舱",
  8422. AirNum = item.GWCRS,
  8423. AirDRCB = item.GWCCB,
  8424. AirZCB = (item.GWCRS * item.GWCCB)
  8425. }
  8426. );
  8427. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8428. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8429. modulePromptInfo.Data = new {
  8430. airFeeData = datas,
  8431. airInitData = initDatas
  8432. };
  8433. _ModulePromptInfos.Add(modulePromptInfo);
  8434. break;
  8435. default:
  8436. break;
  8437. }
  8438. }
  8439. if (dto.CTable != 85)
  8440. {
  8441. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8442. _ModulePromptInfos.Add(_ModulePromptInfo);
  8443. }
  8444. _view.ModulePromptInfos = _ModulePromptInfos;
  8445. return Ok(JsonView(true, "操作成功!", _view));
  8446. }
  8447. catch (Exception ex)
  8448. {
  8449. return Ok(JsonView(false, ex.Message));
  8450. }
  8451. }
  8452. /// <summary>
  8453. /// 根据黑屏代码重新生成行程
  8454. /// </summary>
  8455. /// <param name="dto"></param>
  8456. /// <returns></returns>
  8457. [HttpPost]
  8458. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8459. {
  8460. var jw = JsonView(false);
  8461. var Create = _GroupCostRepository.
  8462. CreateGroupCostByBlackCode(dto.Diid);
  8463. jw.Msg = Create.Msg;
  8464. if (Create.Code == 0)
  8465. {
  8466. jw.Code = 200;
  8467. jw.Data = new
  8468. {
  8469. groupCost = Create.Data,
  8470. blackCodeIsTrue = true
  8471. };
  8472. }
  8473. else
  8474. {
  8475. jw.Code = 400;
  8476. jw.Data = new
  8477. {
  8478. groupCost = Create.Data,
  8479. blackCodeIsTrue = false,
  8480. };
  8481. }
  8482. return Ok(jw);
  8483. }
  8484. /// <summary>
  8485. /// 成本获取OP历史车费用
  8486. /// </summary>
  8487. /// <param name="dto"></param>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8491. {
  8492. var jw = JsonView(false);
  8493. try
  8494. {
  8495. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8496. //获取现有所有车的数据
  8497. if (!dto.Param.IsNullOrWhiteSpace())
  8498. {
  8499. string sql = $@"
  8500. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8501. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8502. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8503. 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
  8504. AND gctggr.ServiceEndTime is not NULL
  8505. ORDER by gctggrc.id DESC
  8506. ";
  8507. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8508. var numeberResult = await Task.Run(() =>
  8509. {
  8510. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8511. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8512. return numberArr;
  8513. });
  8514. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8515. foreach (var item in numeberResult)
  8516. {
  8517. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8518. {
  8519. Country = "数据异常!",
  8520. City = string.Empty,
  8521. };
  8522. item.Area = find.Country + " " + find.City;
  8523. }
  8524. dbResult.AddRange(numeberResult);
  8525. if (dto.Param.Contains("、"))
  8526. {
  8527. var sp = dto.Param.Split("、");
  8528. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8529. .Where(x =>
  8530. {
  8531. return System.Array.Exists(sp, e =>
  8532. {
  8533. bool where = false;
  8534. if (x.Area != null)
  8535. {
  8536. where = x.Area.Contains(e);
  8537. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8538. {
  8539. return false;
  8540. }
  8541. }
  8542. if (x.PriceName != null && !where)
  8543. {
  8544. where = x.PriceName.Contains(e);
  8545. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8546. {
  8547. return false;
  8548. }
  8549. }
  8550. return where;
  8551. });
  8552. }).ToList();
  8553. }
  8554. else
  8555. {
  8556. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8557. .Where(x =>
  8558. {
  8559. bool where = false;
  8560. if (x.Area != null)
  8561. {
  8562. where = x.Area.Contains(dto.Param);
  8563. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8564. {
  8565. return false;
  8566. }
  8567. }
  8568. if (x.PriceName != null && !where)
  8569. {
  8570. where = x.PriceName.Contains(dto.Param);
  8571. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8572. {
  8573. return false;
  8574. }
  8575. }
  8576. return where;
  8577. }
  8578. )
  8579. .ToList();
  8580. }
  8581. }
  8582. var view = dbResult.Select(x => {
  8583. decimal dp = 0.00M;
  8584. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8585. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8586. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8587. {
  8588. if (startB && endB)
  8589. {
  8590. var timesp = endD.Subtract(startD);
  8591. if ((timesp.Days + 1) != 0)
  8592. {
  8593. dp = x.Price / (timesp.Days + 1);
  8594. }
  8595. }
  8596. }
  8597. else
  8598. {
  8599. dp = x.Price;
  8600. }
  8601. return new
  8602. {
  8603. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8604. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8605. x.Area,
  8606. x.id,
  8607. price = x.Price.ToString("F2"),
  8608. x.PriceName,
  8609. x.PriceContent,
  8610. x.TeamName,
  8611. x.DatePrice,
  8612. dayPrice = dp.ToString("F2"),
  8613. };
  8614. }).OrderByDescending(x => x.id).ToList();
  8615. jw = JsonView(true, "获取成功!", view);
  8616. }
  8617. catch (Exception e)
  8618. {
  8619. jw = JsonView(false, e.Message);
  8620. }
  8621. return Ok(jw);
  8622. }
  8623. #endregion
  8624. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8625. /// <summary>
  8626. /// 酒店预订
  8627. /// 酒店费用列表 根据团组Id查询
  8628. /// </summary>
  8629. /// <param name="_dto"></param>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8633. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8634. {
  8635. #region 参数验证
  8636. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8637. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8638. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8639. #region 团组操作权限验证 76 酒店预定模块
  8640. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8641. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8642. #endregion
  8643. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8644. #region 页面操作权限验证
  8645. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8646. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8647. #endregion
  8648. #endregion
  8649. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8650. }
  8651. /// <summary>
  8652. /// 酒店预订
  8653. /// 基础数据
  8654. /// </summary>
  8655. /// <param name="_dto"></param>
  8656. /// <returns></returns>
  8657. [HttpPost]
  8658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8659. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8660. {
  8661. #region 参数验证
  8662. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8663. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8664. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8665. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8666. #region 页面操作权限验证
  8667. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8668. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8669. #endregion
  8670. #region 团组操作权限验证 76 酒店预定模块
  8671. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8672. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8673. #endregion
  8674. #endregion
  8675. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8676. }
  8677. /// <summary>
  8678. /// 酒店预订
  8679. /// 创建 入住卷号码
  8680. /// </summary>
  8681. /// <param name="_dto"></param>
  8682. /// <returns></returns>
  8683. [HttpPost]
  8684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8685. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8686. {
  8687. try
  8688. {
  8689. #region 参数验证
  8690. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8691. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8692. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8693. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8694. #region 页面操作权限验证
  8695. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8696. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8697. #endregion
  8698. #region 团组操作权限验证 76 酒店预定模块
  8699. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8700. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8701. #endregion
  8702. #endregion
  8703. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8704. if (data.Code != 0)
  8705. {
  8706. return Ok(JsonView(false, data.Msg));
  8707. }
  8708. return Ok(JsonView(true, data.Msg, data.Data));
  8709. }
  8710. catch (Exception ex)
  8711. {
  8712. return Ok(JsonView(false, ex.Message));
  8713. }
  8714. }
  8715. /// <summary>
  8716. /// 酒店预订
  8717. /// 详情
  8718. /// </summary>
  8719. /// <param name="_dto"></param>
  8720. /// <returns></returns>
  8721. [HttpPost]
  8722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8723. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8724. {
  8725. #region 参数验证
  8726. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8728. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8729. #region 团组操作权限验证 76 酒店预定模块
  8730. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8731. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8732. #endregion
  8733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8734. #region 页面操作权限验证
  8735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8736. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8737. #endregion
  8738. #endregion
  8739. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8740. }
  8741. /// <summary>
  8742. /// 酒店预订
  8743. /// Add Or Edit
  8744. /// </summary>
  8745. /// <param name="_dto"></param>
  8746. /// <returns></returns>
  8747. [HttpPost]
  8748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8749. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8750. {
  8751. #region 参数验证
  8752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8755. #region 团组操作权限验证 76 酒店预定模块
  8756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8757. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8758. #endregion
  8759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8760. #region 页面操作权限验证
  8761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8762. if (_dto.Id == 0) // Add
  8763. {
  8764. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8765. }
  8766. else if (_dto.Id > 1) // Edit
  8767. {
  8768. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8769. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8770. #endregion
  8771. #endregion
  8772. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8773. if (_view.Code != 200)
  8774. {
  8775. return Ok(_view);
  8776. }
  8777. #region 应用推送
  8778. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8779. //try
  8780. //{
  8781. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8782. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8783. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8784. //}
  8785. //catch (Exception ex)
  8786. //{
  8787. //}
  8788. #endregion
  8789. return Ok(_view);
  8790. }
  8791. /// <summary>
  8792. /// 酒店预订
  8793. /// Del
  8794. /// </summary>
  8795. /// <param name="_dto"></param>
  8796. /// <returns></returns>
  8797. [HttpPost]
  8798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8799. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8800. {
  8801. #region 参数验证
  8802. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8803. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8804. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8805. #region 团组操作权限验证 76 酒店预定模块
  8806. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8807. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8808. #endregion
  8809. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8810. #region 页面操作权限验证
  8811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8812. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8813. #endregion
  8814. #endregion
  8815. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8816. }
  8817. /// <summary>
  8818. /// 酒店预订
  8819. /// 生成VOUCHER
  8820. /// 2024.05.06 之前版本
  8821. /// </summary>
  8822. /// <param name="_dto"></param>
  8823. /// <returns></returns>
  8824. [HttpPost]
  8825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8826. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8827. {
  8828. try
  8829. {
  8830. #region 参数验证
  8831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8832. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8833. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8834. #region 团组操作权限验证 76 酒店预定模块
  8835. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8836. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8837. #endregion
  8838. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8839. #region 页面操作权限验证
  8840. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8841. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8842. #endregion
  8843. #endregion
  8844. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8845. //判断数据是否完整
  8846. if (hr != null)
  8847. {
  8848. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8849. {
  8850. string strFileName = "HotelStatement/";
  8851. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8852. if (dele != null)
  8853. strFileName += dele.TourCode;
  8854. //载入模板
  8855. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8856. Document doc = new Document(sss);
  8857. DocumentBuilder builder = new DocumentBuilder(doc);
  8858. #region 替换Word模板书签内容
  8859. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8860. //入住卷预定号码
  8861. if (doc.Range.Bookmarks["VNO"] != null)
  8862. {
  8863. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8864. mark.Text = hr.CheckNumber;
  8865. }
  8866. //酒店时间
  8867. if (doc.Range.Bookmarks["Date"] != null)
  8868. {
  8869. Bookmark mark = doc.Range.Bookmarks["Date"];
  8870. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8871. }
  8872. //团号
  8873. if (doc.Range.Bookmarks["TNo"] != null)
  8874. {
  8875. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8876. mark.Text = dele.TourCode;
  8877. }
  8878. //预定号码
  8879. if (doc.Range.Bookmarks["BookingId"] != null)
  8880. {
  8881. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8882. mark.Text = hr.ReservationsNo;
  8883. }
  8884. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8885. {
  8886. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8887. mark.Text = hr.DetermineNo;
  8888. }
  8889. //酒店城市
  8890. if (doc.Range.Bookmarks["City"] != null)
  8891. {
  8892. Bookmark mark = doc.Range.Bookmarks["City"];
  8893. mark.Text = hr.City;
  8894. }
  8895. //酒店名称
  8896. if (doc.Range.Bookmarks["HName"] != null)
  8897. {
  8898. Bookmark mark = doc.Range.Bookmarks["HName"];
  8899. mark.Text = hr.HotelName;
  8900. }
  8901. //酒店地址
  8902. if (doc.Range.Bookmarks["Address"] != null)
  8903. {
  8904. Bookmark mark = doc.Range.Bookmarks["Address"];
  8905. mark.Text = hr.HotelAddress;
  8906. }
  8907. //酒店电话
  8908. if (doc.Range.Bookmarks["Tel"] != null)
  8909. {
  8910. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8911. mark.Text = hr.HotelTel;
  8912. }
  8913. //酒店传真
  8914. if (doc.Range.Bookmarks["Fax"] != null)
  8915. {
  8916. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8917. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8918. {
  8919. mark.Text = hr.HotelFax;
  8920. }
  8921. }
  8922. //入住时间
  8923. if (doc.Range.Bookmarks["CIn"] != null)
  8924. {
  8925. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8926. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8927. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8928. }
  8929. //退房时间
  8930. if (doc.Range.Bookmarks["COut"] != null)
  8931. {
  8932. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8933. Bookmark mark = doc.Range.Bookmarks["COut"];
  8934. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8935. }
  8936. //客户名称
  8937. if (doc.Range.Bookmarks["GName"] != null)
  8938. {
  8939. string guestName = "";
  8940. string[] clients = new string[] { };
  8941. if (hr.GuestName.Contains(","))
  8942. {
  8943. clients = hr.GuestName.Split(",");
  8944. }
  8945. else
  8946. {
  8947. clients = new string[] { hr.GuestName };
  8948. }
  8949. List<int> clientIds_int = new List<int>();
  8950. if (clients.Length > 0)
  8951. {
  8952. foreach (var item in clients)
  8953. {
  8954. if (item.IsNumeric())
  8955. {
  8956. clientIds_int.Add(int.Parse(item));
  8957. }
  8958. }
  8959. }
  8960. if (clientIds_int.Count > 0)
  8961. {
  8962. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8963. foreach (var client in _clientDatas)
  8964. {
  8965. //男
  8966. if (client.Sex == 0) guestName += $"Mr.";
  8967. //女
  8968. else if (client.Sex == 1) guestName += $"Ms.";
  8969. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8970. {
  8971. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8972. }
  8973. //guestName += $"{client.Pinyin},";
  8974. }
  8975. if (guestName.Length > 0)
  8976. {
  8977. guestName = guestName.Substring(0, guestName.Length - 1);
  8978. }
  8979. }
  8980. else
  8981. {
  8982. guestName = hr.GuestName;
  8983. }
  8984. Bookmark mark = doc.Range.Bookmarks["GName"];
  8985. mark.Text = guestName;
  8986. }
  8987. //房间介绍
  8988. if (doc.Range.Bookmarks["ROOM"] != null)
  8989. {
  8990. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8991. mark.Text = hr.RoomExplanation;
  8992. }
  8993. //报价描述
  8994. if (doc.Range.Bookmarks["NOTE"] != null)
  8995. {
  8996. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8997. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8998. if (ss != null)
  8999. mark.Text = ss.Name;
  9000. }
  9001. //入住时间
  9002. if (doc.Range.Bookmarks["CheckIn"] != null)
  9003. {
  9004. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9005. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9006. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9007. }
  9008. //退房时间
  9009. if (doc.Range.Bookmarks["CheckOut"] != null)
  9010. {
  9011. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9012. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9013. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9014. }
  9015. //日期
  9016. if (doc.Range.Bookmarks["DT"] != null)
  9017. {
  9018. Bookmark mark = doc.Range.Bookmarks["DT"];
  9019. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9020. }
  9021. //名称
  9022. if (doc.Range.Bookmarks["VName"] != null)
  9023. {
  9024. Bookmark mark = doc.Range.Bookmarks["VName"];
  9025. mark.Text = hr.HotelName;
  9026. }
  9027. //号码
  9028. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9029. {
  9030. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9031. mark.Text = hr.CheckNumber;
  9032. }
  9033. #endregion
  9034. strFileName += "VOUCHER.doc";
  9035. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9036. doc.Save(fileDir);
  9037. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9038. return Ok(JsonView(true, "操作成功!", Url));
  9039. }
  9040. else
  9041. {
  9042. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9043. }
  9044. }
  9045. else
  9046. {
  9047. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9048. }
  9049. }
  9050. catch (Exception ex)
  9051. {
  9052. return Ok(JsonView(false, ex.Message));
  9053. }
  9054. }
  9055. /// <summary>
  9056. /// 酒店预订
  9057. /// 生成VOUCHER
  9058. /// 2024.05.06 之后版本
  9059. /// </summary>
  9060. /// <param name="_dto"></param>
  9061. /// <returns></returns>
  9062. [HttpPost]
  9063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9064. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9065. {
  9066. #region 参数验证
  9067. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9068. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9069. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9070. #region 团组操作权限验证 76 酒店预定模块
  9071. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9072. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9073. #endregion
  9074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9075. #region 页面操作权限验证
  9076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9077. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9078. #endregion
  9079. #endregion
  9080. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9081. //判断数据是否完整
  9082. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9083. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9084. string strFileName = "HotelStatement/";
  9085. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9086. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9087. #region 数据处理
  9088. List<int> guestIds = new List<int>();
  9089. int index = 0;
  9090. foreach (var item in hrDtas)
  9091. {
  9092. if (item.GuestName.Contains(","))
  9093. {
  9094. string[] guestIdArr = item.GuestName.Split(',');
  9095. foreach (var guestIdStr in guestIdArr)
  9096. {
  9097. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9098. if (guestBool)
  9099. {
  9100. guestIds.Add(guestId);
  9101. }
  9102. }
  9103. }
  9104. else guestNames += item.GuestName;
  9105. var voucherInfo = new HotelVoucherInfoView()
  9106. {
  9107. HotelName = item.HotelName,
  9108. CheckInDate = item.CheckInDate,
  9109. CheckOutDate = item.CheckOutDate,
  9110. ConfirmationNumber = item.DetermineNo.Trim(),
  9111. RoomType = item.RoomExplanation
  9112. };
  9113. vouchers.Add(voucherInfo);
  9114. }
  9115. if (guestIds.Count > 0)
  9116. {
  9117. guestIds = guestIds.Distinct().ToList();
  9118. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9119. if (guestDatas.Count > 0)
  9120. {
  9121. guestNames = "";
  9122. foreach (var guest in guestDatas)
  9123. {
  9124. string guestName = "";
  9125. if (guest.Sex == 0) guestName += @"MR.";
  9126. else if (guest.Sex == 1) guestName += @"MS.";
  9127. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9128. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9129. guestNames += @$"{guestName.Trim()}、";
  9130. }
  9131. if (guestNames.Length > 0)
  9132. {
  9133. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9134. }
  9135. }
  9136. }
  9137. #endregion
  9138. //载入模板
  9139. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9140. Document doc = new Document(sss);
  9141. DocumentBuilder builder = new DocumentBuilder(doc);
  9142. if (doc.Range.Bookmarks["GuestName"] != null)
  9143. {
  9144. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9145. mark.Text = guestNames;
  9146. }
  9147. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9148. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9149. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9150. for (int i = 1; i <= vouchers.Count; i++)
  9151. {
  9152. HotelVoucherInfoView hviv = vouchers[i - 1];
  9153. builder.MoveToCell(0, i, 0, 0);
  9154. builder.Write(hviv.HotelName);
  9155. builder.MoveToCell(0, i, 1, 0);
  9156. builder.Write(hviv.CheckInDate);
  9157. builder.MoveToCell(0, i, 2, 0);
  9158. builder.Write(hviv.CheckOutDate);
  9159. builder.MoveToCell(0, i, 3, 0);
  9160. builder.Write(hviv.RoomType);
  9161. builder.MoveToCell(0, i, 4, 0);
  9162. builder.Write(hviv.ConfirmationNumber);
  9163. }
  9164. //删除多余行
  9165. int currRowIndex = vouchers.Count + 1;
  9166. int delRows = 21 - currRowIndex;
  9167. if (delRows > 0)
  9168. {
  9169. for (int i = 0; i < delRows; i++)
  9170. {
  9171. table.Rows.RemoveAt(currRowIndex);
  9172. //cultivateRowIndex++;
  9173. }
  9174. }
  9175. strFileName += "VOUCHER.docx";
  9176. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9177. doc.Save(fileDir);
  9178. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9179. return Ok(JsonView(true, "操作成功!", Url));
  9180. }
  9181. /// <summary>
  9182. /// 酒店预订
  9183. /// 生成 预定成本 Excel
  9184. /// </summary>
  9185. /// <param name="_dto"></param>
  9186. /// <returns></returns>
  9187. [HttpPost]
  9188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9189. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9190. {
  9191. #region 参数验证
  9192. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9193. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9194. if (!vadalitorRes.IsValid)
  9195. {
  9196. var errors = new StringBuilder();
  9197. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9198. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9199. }
  9200. #region 团组操作权限验证 76 酒店预定模块
  9201. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9202. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9203. #endregion
  9204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9205. #region 页面操作权限验证
  9206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9207. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9208. #endregion
  9209. #endregion
  9210. decimal _rate = 1.00M;
  9211. string _currency = "";
  9212. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9213. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9214. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9215. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9216. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9217. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9218. {
  9219. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9220. }
  9221. _currency = _GroupCostParameter.Currency;
  9222. bool isIntType = int.TryParse(_currency, out int currId);
  9223. if (isIntType)
  9224. {
  9225. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9226. }
  9227. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9228. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9229. if (currInfo == null)
  9230. {
  9231. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9232. }
  9233. if (!_currency.ToUpper().Equals("CNY"))
  9234. {
  9235. _rate = _GroupCostParameter.Rate;
  9236. }
  9237. _rate = currInfo.Rate;
  9238. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9239. string strFileName = "HotelStatement/";
  9240. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9241. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9242. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9243. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9244. #region 数据处理
  9245. foreach (var item in hrDtas)
  9246. {
  9247. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9248. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9249. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9250. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9251. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9252. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9253. string singleRoomFeeStr = string.Empty,
  9254. doubleRoomFeeStr = string.Empty,
  9255. suiteRoomFeeStr = string.Empty,
  9256. otherRoomFeeStr = string.Empty,
  9257. payMoneyStr = string.Empty,
  9258. cardPriceStr = string.Empty;
  9259. if (roomCurr.Equals(_currency))
  9260. {
  9261. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9262. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9263. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9264. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9265. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9266. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9267. }
  9268. else
  9269. {
  9270. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9271. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9272. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9273. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9274. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9275. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9276. }
  9277. string breakfastPriceStr = string.Empty,
  9278. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9279. governmentRentStr = string.Empty,
  9280. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9281. cityTaxStrStr = string.Empty,
  9282. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9283. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9284. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9285. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9286. pcfds.Add(new HotelReservations_PCFD_View()
  9287. {
  9288. City = item.City,
  9289. HotelName = item.HotelName,
  9290. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9291. // SingleRoomCount = item.SingleRoomCount,
  9292. SingleRoomPrice = singleRoomFeeStr,
  9293. // DoubleRoomCount = item.DoubleRoomCount,
  9294. DoubleRoomPrice = doubleRoomFeeStr,
  9295. //SuiteRoomCount = item.SuiteRoomCount,
  9296. SuiteRoomPrice = suiteRoomFeeStr,
  9297. OtherRoomPrice = otherRoomFeeStr,
  9298. //OtherRoomCount = item.OtherRoomCount,
  9299. BreakfastPrice = breakfastPriceStr,
  9300. GovernmentRent = governmentRentStr,
  9301. CityTax = cityTaxStrStr,
  9302. RoomExplanation = item.RoomExplanation,
  9303. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9304. PayTime = roomInfo.ConsumptionDate,
  9305. BankNo = roomInfo.BankNo,
  9306. PayMoney = payMoneyStr,
  9307. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9308. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9309. CardPrice = cardPriceStr,
  9310. Remark = ccpInfo.Remark
  9311. });
  9312. }
  9313. #endregion
  9314. //载入模板
  9315. WorkbookDesigner designer = new WorkbookDesigner();
  9316. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9317. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9318. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9319. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9320. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9321. designer.SetDataSource("Opertor", userInfo.CnName);
  9322. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9323. dt.TableName = "ViewMyHotelReservations";
  9324. designer.SetDataSource(dt);
  9325. designer.Process();
  9326. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9327. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9328. designer.Workbook.Save(serverPath);
  9329. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9330. #region 删除指定行
  9331. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9332. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9333. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9334. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9335. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9336. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9337. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9338. cssIndex = dt.Columns["CityTax"].Ordinal,
  9339. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9340. remarkIndex = dt.Columns["Remark"].Ordinal;
  9341. //删除指定列
  9342. foreach (DataRow item in dt.Rows)
  9343. {
  9344. string singleStr = item["SingleRoomPrice"].ToString();
  9345. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9346. if (containsDigitButNotZero1) singleDel = false;
  9347. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9348. string doubleStr = item["DoubleRoomPrice"].ToString();
  9349. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9350. if (containsDigitButNotZero2) doubleDel = false;
  9351. string suiteStr = item["SuiteRoomPrice"].ToString();
  9352. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9353. if (containsDigitButNotZero3) suiteDel = false;
  9354. string otherStr = item["OtherRoomPrice"].ToString();
  9355. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9356. if (containsDigitButNotZero4) otherDel = false;
  9357. string zcStr = item["BreakfastPrice"].ToString();
  9358. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9359. if (containsDigitButNotZero5) zcDel = false;
  9360. string dsStr = item["GovernmentRent"].ToString();
  9361. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9362. if (containsDigitButNotZero6) dsDel = false;
  9363. string cssStr = item["CityTax"].ToString();
  9364. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9365. if (containsDigitButNotZero7) cssDel = false;
  9366. string cpStr = item["ConsumptionPatterns"].ToString();
  9367. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9368. string remarkStr = item["Remark"].ToString();
  9369. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9370. }
  9371. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9372. DeleteColumn(serverPath, cpIndex, cpDel);
  9373. DeleteColumn(serverPath, dsIndex, dsDel);
  9374. DeleteColumn(serverPath, cssIndex, cssDel);
  9375. DeleteColumn(serverPath, zcIndex, zcDel);
  9376. DeleteColumn(serverPath, otherIndex, otherDel);
  9377. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9378. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9379. DeleteColumn(serverPath, singleIndex, singleDel);
  9380. #endregion
  9381. //只保留第一个表格
  9382. DeleteSheet(serverPath);
  9383. return Ok(JsonView(true, "操作成功", url = rst));
  9384. }
  9385. /// <summary>
  9386. /// 删除指定列
  9387. /// </summary>
  9388. /// <param name="file"></param>
  9389. /// <param name="columnIndex"></param>
  9390. /// <param name="isDel"></param>
  9391. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9392. {
  9393. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9394. //wb.Save(file);
  9395. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9396. if (sheet1 != null)
  9397. {
  9398. if (isDel)
  9399. {
  9400. Cells cells = sheet1.Cells;
  9401. cells.DeleteColumn(columnIndex);
  9402. }
  9403. }
  9404. wb.Save(file);
  9405. }
  9406. /// <summary>
  9407. /// 删除sheet
  9408. /// </summary>
  9409. /// <param name="file"></param>
  9410. /// <param name="sheetName"></param>
  9411. private void DeleteSheet(string file, string sheetName = "")
  9412. {
  9413. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9414. //wb.Save(file);
  9415. List<string> sheets = new List<string>();
  9416. foreach (var item in wb.Worksheets)
  9417. {
  9418. sheets.Add(item.Name);
  9419. }
  9420. if (sheets.Count > 0)
  9421. {
  9422. sheets.RemoveAt(0);//不删除第一个sheet
  9423. foreach (var item in sheets)
  9424. {
  9425. wb.Worksheets.RemoveAt(item);
  9426. }
  9427. }
  9428. wb.Save(file);
  9429. }
  9430. /// <summary>
  9431. /// 酒店预订
  9432. /// 确认单
  9433. /// </summary>
  9434. /// <param name="_dto"></param>
  9435. /// <returns></returns>
  9436. [HttpPost]
  9437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9438. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9439. {
  9440. try
  9441. {
  9442. #region 参数验证
  9443. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9444. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9445. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9446. #region 团组操作权限验证 76 酒店预定模块
  9447. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9448. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9449. #endregion
  9450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9451. #region 页面操作权限验证
  9452. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9453. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9454. #endregion
  9455. #endregion
  9456. //团组信息
  9457. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9458. //酒店数据
  9459. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9460. if (listhoteldata.Count < 0)
  9461. {
  9462. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9463. }
  9464. //利datatable存储
  9465. DataTable dt = new DataTable();
  9466. dt.Columns.Add("CheckInDate", typeof(string));
  9467. dt.Columns.Add("City", typeof(string));
  9468. dt.Columns.Add("Hotel", typeof(string));
  9469. dt.Columns.Add("Room", typeof(string));
  9470. for (int i = 0; i < listhoteldata.Count; i++)
  9471. {
  9472. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9473. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9474. while (dayStart < dayEnd)
  9475. {
  9476. string temp = "";
  9477. DataRow row = dt.NewRow();
  9478. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9479. row["City"] = listhoteldata[i].City;
  9480. row["Hotel"] = listhoteldata[i].HotelName;
  9481. if (listhoteldata[i].SingleRoomCount > 0)
  9482. {
  9483. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9484. }
  9485. if (listhoteldata[i].DoubleRoomCount > 0)
  9486. {
  9487. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9488. }
  9489. if (listhoteldata[i].SuiteRoomCount > 0)
  9490. {
  9491. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9492. }
  9493. if (listhoteldata[i].OtherRoomCount > 0)
  9494. {
  9495. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9496. }
  9497. row["Room"] = temp;
  9498. dt.Rows.Add(row);
  9499. dayStart = dayStart.AddDays(1);
  9500. }
  9501. }
  9502. Dictionary<string, string> dic = new Dictionary<string, string>();
  9503. dic.Add("Dele", di.TeamName);
  9504. dic.Add("City", di.VisitCountry);
  9505. //模板路径
  9506. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9507. //载入模板
  9508. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9509. DocumentBuilder builder = new DocumentBuilder(doc);
  9510. foreach (var key in dic.Keys)
  9511. {
  9512. builder.MoveToBookmark(key);
  9513. builder.Write(dic[key]);
  9514. }
  9515. //获取word里所有表格
  9516. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9517. //获取所填表格的序数
  9518. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9519. var rowStart = tableOne.Rows[0]; //获取第1行
  9520. //循环赋值
  9521. for (int i = 0; i < dt.Rows.Count; i++)
  9522. {
  9523. builder.MoveToCell(0, i + 1, 0, 0);
  9524. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9525. builder.MoveToCell(0, i + 1, 1, 0);
  9526. builder.Write(dt.Rows[i]["City"].ToString());
  9527. builder.MoveToCell(0, i + 1, 2, 0);
  9528. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9529. builder.MoveToCell(0, i + 1, 3, 0);
  9530. builder.Write(dt.Rows[i]["Room"].ToString());
  9531. }
  9532. //删除多余行
  9533. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9534. {
  9535. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9536. }
  9537. string strFileName = di.TeamName + "酒店确认单.doc";
  9538. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9539. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9540. return Ok(JsonView(true, "成功", url));
  9541. }
  9542. catch (Exception ex)
  9543. {
  9544. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9545. }
  9546. }
  9547. #endregion
  9548. #region 团组状态
  9549. /// <summary>
  9550. /// 团组状态列表 Page
  9551. /// </summary>
  9552. /// <param name="dto">团组列表请求dto</param>
  9553. /// <returns></returns>
  9554. [HttpPost]
  9555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9556. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9557. {
  9558. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9559. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9560. {
  9561. string sqlWhere = string.Empty;
  9562. if (dto.IsSure == 0) //未完成
  9563. {
  9564. sqlWhere += string.Format(@" And IsSure = 0");
  9565. }
  9566. else if (dto.IsSure == 1) //已完成
  9567. {
  9568. sqlWhere += string.Format(@" And IsSure = 1");
  9569. }
  9570. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9571. {
  9572. string tj = dto.SearchCriteria;
  9573. 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}%')",
  9574. tj, tj, tj, tj, tj);
  9575. }
  9576. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9577. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9578. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9579. From (
  9580. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9581. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9582. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9583. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9584. From Grp_DelegationInfo gdi
  9585. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9586. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9587. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9588. Where gdi.IsDel = 0 {0}
  9589. ) temp ", sqlWhere);
  9590. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9591. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9592. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9593. }
  9594. else
  9595. {
  9596. return Ok(JsonView(false, "查询失败"));
  9597. }
  9598. }
  9599. /// <summary>
  9600. /// 团组状态
  9601. /// 设置操作完成
  9602. /// </summary>
  9603. /// <param name="dto">团组列表请求dto</param>
  9604. /// <returns></returns>
  9605. [HttpPost]
  9606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9607. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9608. {
  9609. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9610. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9611. {
  9612. Id = dto.Id,
  9613. IsSure = 1
  9614. };
  9615. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9616. .UpdateColumns(it => new { it.IsSure })
  9617. .WhereColumns(it => new { it.Id })
  9618. .ExecuteCommandAsync();
  9619. if (result > 0)
  9620. {
  9621. return Ok(JsonView(true, "操作完成!"));
  9622. }
  9623. return Ok(JsonView(false, "操作失败!"));
  9624. }
  9625. #endregion
  9626. #region 保险费用录入
  9627. /// <summary>
  9628. /// 根据团组Id查询保险费用列表
  9629. /// </summary>
  9630. /// <param name="dto"></param>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9634. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9635. {
  9636. try
  9637. {
  9638. Result groupData = await _customersRep.CustomersByDiId(dto);
  9639. if (groupData.Code != 0)
  9640. {
  9641. return Ok(JsonView(false, groupData.Msg));
  9642. }
  9643. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9644. }
  9645. catch (Exception ex)
  9646. {
  9647. return Ok(JsonView(false, ex.Message));
  9648. }
  9649. }
  9650. /// <summary>
  9651. /// 根据保险费用Id查询保险费用详细
  9652. /// </summary>
  9653. /// <param name="dto"></param>
  9654. /// <returns></returns>
  9655. [HttpPost]
  9656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9657. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9658. {
  9659. try
  9660. {
  9661. Result groupData = await _customersRep.CustomersById(dto);
  9662. if (groupData.Code != 0)
  9663. {
  9664. return Ok(JsonView(false, groupData.Msg));
  9665. }
  9666. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9667. }
  9668. catch (Exception ex)
  9669. {
  9670. return Ok(JsonView(false, ex.Message));
  9671. }
  9672. }
  9673. /// <summary>
  9674. /// 保险费用录入页面初始化绑定
  9675. /// </summary>
  9676. /// <param name="dto"></param>
  9677. /// <returns></returns>
  9678. [HttpPost]
  9679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9680. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9681. {
  9682. try
  9683. {
  9684. Result groupData = await _customersRep.CustomersInitialize(dto);
  9685. if (groupData.Code != 0)
  9686. {
  9687. return Ok(JsonView(false, groupData.Msg));
  9688. }
  9689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9690. }
  9691. catch (Exception ex)
  9692. {
  9693. return Ok(JsonView(false, ex.Message));
  9694. }
  9695. }
  9696. /// <summary>
  9697. /// 保险费用操作(Status:1.新增,2.修改)
  9698. /// </summary>
  9699. /// <param name="dto"></param>
  9700. /// <returns></returns>
  9701. [HttpPost]
  9702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9703. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9704. {
  9705. try
  9706. {
  9707. Result groupData = await _customersRep.OpCustomers(dto);
  9708. if (groupData.Code != 0)
  9709. {
  9710. return Ok(JsonView(false, groupData.Msg));
  9711. }
  9712. #region 应用推送
  9713. try
  9714. {
  9715. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9716. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9717. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9718. }
  9719. catch (Exception ex)
  9720. {
  9721. }
  9722. #endregion
  9723. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9724. }
  9725. catch (Exception ex)
  9726. {
  9727. return Ok(JsonView(false, ex.Message));
  9728. }
  9729. }
  9730. /// <summary>
  9731. /// 保险文件上传
  9732. /// </summary>
  9733. /// <param name="file"></param>
  9734. /// <returns></returns>
  9735. [HttpPost]
  9736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9737. public async Task<IActionResult> UploadCus(IFormFile file)
  9738. {
  9739. try
  9740. {
  9741. if (file != null)
  9742. {
  9743. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9744. //文件名称
  9745. string projectFileName = file.FileName;
  9746. //上传的文件的路径
  9747. string filePath = "";
  9748. if (!Directory.Exists(fileDir))
  9749. {
  9750. Directory.CreateDirectory(fileDir);
  9751. }
  9752. //上传的文件的路径
  9753. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9754. using (FileStream fs = System.IO.File.Create(filePath))
  9755. {
  9756. file.CopyTo(fs);
  9757. fs.Flush();
  9758. }
  9759. return Ok(JsonView(true, "上传成功!", projectFileName));
  9760. }
  9761. else
  9762. {
  9763. return Ok(JsonView(false, "上传失败!"));
  9764. }
  9765. }
  9766. catch (Exception ex)
  9767. {
  9768. return Ok(JsonView(false, "程序错误!"));
  9769. throw;
  9770. }
  9771. }
  9772. /// <summary>
  9773. /// 保险删除指定文件
  9774. /// </summary>
  9775. /// <param name="dto"></param>
  9776. /// <returns></returns>
  9777. [HttpPost]
  9778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9779. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9780. {
  9781. try
  9782. {
  9783. string filePath = "";
  9784. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9785. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9786. //int id = 0;
  9787. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9788. // 删除该文件
  9789. try
  9790. {
  9791. System.IO.File.Delete(filePath);
  9792. 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()
  9793. {
  9794. Attachment = "",
  9795. }).ExecuteCommandAsync();
  9796. if (result != 0)
  9797. {
  9798. return Ok(JsonView(true, "成功!"));
  9799. }
  9800. else
  9801. {
  9802. return Ok(JsonView(false, "失败!"));
  9803. }
  9804. }
  9805. catch (Exception)
  9806. {
  9807. 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()
  9808. {
  9809. Attachment = "",
  9810. }).ExecuteCommandAsync();
  9811. if (result != 0)
  9812. {
  9813. return Ok(JsonView(true, "成功!"));
  9814. }
  9815. else
  9816. {
  9817. return Ok(JsonView(false, "失败!"));
  9818. }
  9819. }
  9820. }
  9821. catch (Exception ex)
  9822. {
  9823. return Ok(JsonView(false, "程序错误!"));
  9824. throw;
  9825. }
  9826. }
  9827. /// <summary>
  9828. /// 保险费用操作(删除)
  9829. /// </summary>
  9830. /// <param name="dto"></param>
  9831. /// <returns></returns>
  9832. [HttpPost]
  9833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9834. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9835. {
  9836. try
  9837. {
  9838. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9839. if (!res)
  9840. {
  9841. return Ok(JsonView(false, "删除失败"));
  9842. }
  9843. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9844. {
  9845. IsDel = 1,
  9846. DeleteUserId = dto.DeleteUserId,
  9847. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9848. }).ExecuteCommandAsync();
  9849. return Ok(JsonView(true, "删除成功!"));
  9850. }
  9851. catch (Exception ex)
  9852. {
  9853. return Ok(JsonView(false, "程序错误!"));
  9854. throw;
  9855. }
  9856. }
  9857. #endregion
  9858. #region 接团客户名单 PageId 104
  9859. /// <summary>
  9860. /// 接团客户名单
  9861. /// 迁移数据(慎用!)
  9862. /// </summary>
  9863. /// <param name="dto"></param>
  9864. /// <returns></returns>
  9865. [HttpPost]
  9866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9867. public async Task<IActionResult> PostTourClientListChange()
  9868. {
  9869. try
  9870. {
  9871. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9872. //var groupClinetData1
  9873. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9874. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9875. int updateCount = 0;
  9876. if (oldOAClientList.Count > 0)
  9877. {
  9878. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9879. _sqlSugar.BeginTran();
  9880. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9881. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9882. foreach (var item in oldOAClientList)
  9883. {
  9884. int comId = 0;
  9885. string format = "yyyy-MM-dd HH:mm:ss";
  9886. string data11 = "1990-01-01 00:00";
  9887. var data1 = IsValidDate(item.OPdate, format);
  9888. if (data1) data11 = item.OPdate;
  9889. //客户公司验证
  9890. if (!string.IsNullOrEmpty(item.Company))
  9891. {
  9892. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9893. if (clientComInfo == null) // add
  9894. {
  9895. var addInfo = new Crm_CustomerCompany()
  9896. {
  9897. CompanyAbbreviation = "",
  9898. CompanyFullName = item.Company,
  9899. Address = "",
  9900. PostCodes = "",
  9901. LastedOpUserId = item.OPer,
  9902. LastedOpDt = Convert.ToDateTime(data11),
  9903. CreateUserId = item.OPer,
  9904. CreateTime = Convert.ToDateTime(data11),
  9905. IsDel = 0
  9906. };
  9907. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9908. if (comId1 > 0) comId = comId1;
  9909. }
  9910. else comId = clientComInfo.Id;
  9911. }
  9912. //客户人员验证
  9913. int clientId = 0;
  9914. string name = item.LastName + item.Name;
  9915. if (!string.IsNullOrEmpty(name))
  9916. {
  9917. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9918. if (clientInfo == null)
  9919. {
  9920. DateTime? dateTime = null;
  9921. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9922. if (isDt) dateTime = birthDayDt;
  9923. var addInfo1 = new Crm_DeleClient()
  9924. {
  9925. CrmCompanyId = comId,
  9926. DiId = -1,
  9927. LastName = item.LastName,
  9928. FirstName = item.Name,
  9929. OldName = "",
  9930. Pinyin = item.Pinyin,
  9931. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9932. Marriage = 0,
  9933. Phone = item.Phone,
  9934. Job = item.Job,
  9935. BirthDay = dateTime
  9936. };
  9937. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9938. if (clientId1 > 0) clientId = clientId1;
  9939. }
  9940. else clientId = clientInfo.Id;
  9941. }
  9942. if (clientId < 1)
  9943. {
  9944. continue;
  9945. }
  9946. int airType = 0;
  9947. if (item.AirType == "超经舱") airType = 459;
  9948. else if (item.AirType == "公务舱") airType = 458;
  9949. else if (item.AirType == "经济舱") airType = 460;
  9950. else if (item.AirType == "其他") airType = 565;
  9951. else if (item.AirType == "头等舱") airType = 457;
  9952. var _TourClientListEntity = new Grp_TourClientList()
  9953. {
  9954. DiId = item.Diid,
  9955. ClientId = clientId,
  9956. CreateUserId = item.OPer,
  9957. CreateTime = Convert.ToDateTime(data11),
  9958. Remark = item.Remark,
  9959. IsDel = item.Isdel,
  9960. ShippingSpaceTypeId = airType,
  9961. ShippingSpaceSpecialNeeds = item.AirRemark,
  9962. HotelSpecialNeeds = item.RoomType
  9963. };
  9964. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9965. if (_TourClientList > 0)
  9966. {
  9967. updateCount++;
  9968. }
  9969. }
  9970. _sqlSugar.CommitTran();
  9971. }
  9972. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9973. }
  9974. catch (Exception ex)
  9975. {
  9976. _sqlSugar.RollbackTran();
  9977. return Ok(JsonView(false, ex.Message));
  9978. }
  9979. return Ok(JsonView(true));
  9980. }
  9981. private bool IsValidDate(string dateString, string format)
  9982. {
  9983. DateTime dateValue;
  9984. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9985. return valid;
  9986. }
  9987. /// <summary>
  9988. /// 接团客户名单
  9989. /// 根据团组Id查询List
  9990. /// </summary>
  9991. /// <param name="dto"></param>
  9992. /// <returns></returns>
  9993. [HttpPost]
  9994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9995. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9996. {
  9997. #region 参数验证
  9998. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9999. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10000. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10001. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10002. #region 页面操作权限验证
  10003. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10004. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10005. #endregion
  10006. #endregion
  10007. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10008. if (viewData.Code != 0)
  10009. {
  10010. return Ok(JsonView(false, viewData.Msg));
  10011. }
  10012. return Ok(JsonView(viewData.Data));
  10013. }
  10014. /// <summary>
  10015. /// 接团客户名单
  10016. /// 基础数据 Init
  10017. /// </summary>
  10018. /// <param name="_dto"></param>
  10019. /// <returns></returns>
  10020. [HttpPost]
  10021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10022. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10023. {
  10024. #region 参数验证
  10025. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10026. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10027. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10028. #region 页面操作权限验证
  10029. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10030. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10031. #endregion
  10032. #endregion
  10033. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10034. if (viewData.Code != 0)
  10035. {
  10036. return Ok(JsonView(false, viewData.Msg));
  10037. }
  10038. return Ok(JsonView(viewData.Data));
  10039. }
  10040. /// <summary>
  10041. /// 接团客户名单
  10042. /// 根据 Id查询 Details
  10043. /// </summary>
  10044. /// <param name="_dto"></param>
  10045. /// <returns></returns>
  10046. [HttpPost]
  10047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10048. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10049. {
  10050. #region 参数验证
  10051. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10052. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10053. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10055. #region 页面操作权限验证
  10056. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10057. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10058. #endregion
  10059. #endregion
  10060. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10061. if (viewData.Code != 0)
  10062. {
  10063. return Ok(JsonView(false, viewData.Msg));
  10064. }
  10065. return Ok(JsonView(viewData.Data));
  10066. }
  10067. /// <summary>
  10068. /// 接团客户名单
  10069. /// Add Or Edit
  10070. /// </summary>
  10071. /// <param name="_dto"></param>
  10072. /// <returns></returns>
  10073. [HttpPost]
  10074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10075. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10076. {
  10077. #region 参数验证
  10078. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10079. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10080. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10082. #region 页面操作权限验证
  10083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10084. if (_dto.Id == 0) //添加
  10085. {
  10086. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10087. }
  10088. else if (_dto.Id >= 0) //修改
  10089. {
  10090. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10091. }
  10092. #endregion
  10093. #endregion
  10094. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10095. if (viewData.Code != 0)
  10096. {
  10097. return Ok(JsonView(false, viewData.Msg));
  10098. }
  10099. return Ok(JsonView(true));
  10100. }
  10101. /// <summary>
  10102. /// 接团客户名单
  10103. /// AddMultiple(添加多个)
  10104. /// </summary>
  10105. /// <param name="_dto"></param>
  10106. /// <returns></returns>
  10107. [HttpPost]
  10108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10109. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10110. {
  10111. #region 参数验证
  10112. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10113. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10115. #region 页面操作权限验证
  10116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10117. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10118. #endregion
  10119. #endregion
  10120. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10121. if (viewData.Code != 0)
  10122. {
  10123. return Ok(JsonView(false, viewData.Msg));
  10124. }
  10125. return Ok(JsonView(true));
  10126. }
  10127. /// <summary>
  10128. /// 接团客户名单
  10129. /// Del
  10130. /// </summary>
  10131. /// <param name="_dto"></param>
  10132. /// <returns></returns>
  10133. [HttpPost]
  10134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10135. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10136. {
  10137. #region 参数验证
  10138. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10139. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10140. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10141. #region 页面操作权限验证
  10142. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10143. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10144. #endregion
  10145. #endregion
  10146. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10147. if (viewData.Code != 0)
  10148. {
  10149. return Ok(JsonView(false, viewData.Msg));
  10150. }
  10151. return Ok(JsonView(true));
  10152. }
  10153. /// <summary>
  10154. /// 接团客户名单
  10155. /// 文件下载 客户名单
  10156. /// </summary>
  10157. /// <param name="_dto"></param>
  10158. /// <returns></returns>
  10159. [HttpPost]
  10160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10161. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10162. {
  10163. #region 参数验证
  10164. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10165. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10166. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10167. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10168. #region 页面操作权限验证
  10169. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10170. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10171. #endregion
  10172. #endregion
  10173. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10174. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10175. From Grp_TourClientList tcl
  10176. Left Join
  10177. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10178. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10179. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10180. From Crm_DeleClient dc
  10181. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10182. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10183. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10184. Where dc.IsDel = 0) temp
  10185. On temp.DcId =tcl.ClientId
  10186. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10187. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10188. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10189. //载入模板
  10190. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10191. if (_dto.Language == 1)
  10192. {
  10193. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10194. }
  10195. //载入模板
  10196. var doc = new Document(tempPath);
  10197. DocumentBuilder builder = new DocumentBuilder(doc);
  10198. //获取word里所有表格
  10199. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10200. //获取所填表格的序数
  10201. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10202. var rowStart = tableOne.Rows[0]; //获取第1行
  10203. if (_dto.Language == 0)
  10204. {
  10205. //循环赋值
  10206. for (int i = 0; i < DcList.Count; i++)
  10207. {
  10208. builder.MoveToCell(0, i + 1, 0, 0);
  10209. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10210. builder.MoveToCell(0, i + 1, 1, 0);
  10211. int sex = DcList[i].Sex;
  10212. string sexStr = string.Empty;
  10213. if (sex == 0) sexStr = "男";
  10214. else if (sex == 1) sexStr = "女";
  10215. else sexStr = "未设置";
  10216. builder.Write(sexStr);
  10217. builder.MoveToCell(0, i + 1, 2, 0);
  10218. string birthDay = DcList[i].BirthDay;
  10219. string birthDayStr = string.Empty;
  10220. if (!string.IsNullOrEmpty(birthDay))
  10221. {
  10222. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10223. }
  10224. builder.Write(birthDayStr);
  10225. builder.MoveToCell(0, i + 1, 3, 0);
  10226. string company = "";
  10227. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10228. {
  10229. company = DcList[i].CompanyFullName.ToString();
  10230. }
  10231. builder.Write(company);
  10232. builder.MoveToCell(0, i + 1, 4, 0);
  10233. builder.Write(DcList[i].Job);
  10234. }
  10235. }
  10236. else if (_dto.Language == 1)
  10237. {
  10238. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10239. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10240. //循环赋值
  10241. for (int i = 0; i < DcList.Count; i++)
  10242. {
  10243. string PYName = "";
  10244. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10245. {
  10246. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10247. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10248. PYName = PY_First + " " + PY_Last;
  10249. }
  10250. else
  10251. {
  10252. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10253. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10254. PYName = PY_First + " " + PY_Last;
  10255. }
  10256. builder.MoveToCell(0, i + 1, 0, 0);
  10257. builder.Write(PYName);
  10258. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10259. builder.MoveToCell(0, i + 1, 1, 0);
  10260. builder.Write(sex);
  10261. DateTime birthDt;
  10262. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10263. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10264. builder.MoveToCell(0, i + 1, 2, 0);
  10265. builder.Write(birthday);
  10266. string company = "";
  10267. try
  10268. {
  10269. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10270. {
  10271. //查询对照表
  10272. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10273. if (tempCec != null)
  10274. {
  10275. company = tempCec.enName;
  10276. }
  10277. //翻译
  10278. else
  10279. {
  10280. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10281. }
  10282. }
  10283. }
  10284. catch (Exception)
  10285. {
  10286. }
  10287. builder.MoveToCell(0, i + 1, 3, 0);
  10288. builder.Write(company);
  10289. string job = "";
  10290. try
  10291. {
  10292. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10293. {
  10294. //查询对照表
  10295. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10296. if (tempPec != null)
  10297. {
  10298. job = tempPec.enName;
  10299. }
  10300. //翻译
  10301. else
  10302. {
  10303. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10304. }
  10305. }
  10306. }
  10307. catch (Exception ex)
  10308. {
  10309. }
  10310. builder.MoveToCell(0, i + 1, 4, 0);
  10311. builder.Write(job);
  10312. }
  10313. }
  10314. //删除多余行
  10315. while (tableOne.Rows.Count > DcList.Count + 1)
  10316. {
  10317. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10318. }
  10319. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10320. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10321. doc.Save(fileDir);
  10322. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10323. return Ok(JsonView(true, "操作成功!", Url));
  10324. }
  10325. #endregion
  10326. #region 团组倒推表
  10327. /// <summary>
  10328. /// 倒推表基础数据
  10329. /// Init
  10330. /// </summary>
  10331. /// <param name="dto"></param>
  10332. /// <returns></returns>
  10333. [HttpPost]
  10334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10335. public async Task<IActionResult> PostInvertedListInit()
  10336. {
  10337. var viewData = await _invertedListRep._Init();
  10338. if (viewData.Code != 0)
  10339. {
  10340. return Ok(JsonView(false, viewData.Msg));
  10341. }
  10342. return Ok(JsonView(viewData.Data));
  10343. }
  10344. /// <summary>
  10345. /// 倒推表
  10346. /// Info
  10347. /// </summary>
  10348. /// <param name="dto"></param>
  10349. /// <returns></returns>
  10350. [HttpPost]
  10351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10352. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10353. {
  10354. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10355. if (viewData.Code != 0)
  10356. {
  10357. return Ok(JsonView(false, viewData.Msg));
  10358. }
  10359. return Ok(JsonView(viewData.Data));
  10360. }
  10361. /// <summary>
  10362. /// 倒推表
  10363. /// Create
  10364. /// </summary>
  10365. /// <param name="dto"></param>
  10366. /// <returns></returns>
  10367. [HttpPost]
  10368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10369. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10370. {
  10371. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10372. if (viewData.Code != 0)
  10373. {
  10374. return Ok(JsonView(false, viewData.Msg));
  10375. }
  10376. return Ok(JsonView(viewData.Data));
  10377. }
  10378. /// <summary>
  10379. /// 倒推表
  10380. /// Update
  10381. /// </summary>
  10382. /// <param name="dto"></param>
  10383. /// <returns></returns>
  10384. [HttpPost]
  10385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10386. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10387. {
  10388. var viewData = await _invertedListRep._Update(dto);
  10389. if (viewData.Code != 0)
  10390. {
  10391. return Ok(JsonView(false, viewData.Msg));
  10392. }
  10393. return Ok(JsonView(viewData.Data));
  10394. }
  10395. /// <summary>
  10396. /// 倒推表
  10397. /// File Download
  10398. /// </summary>
  10399. /// <param name="dto"></param>
  10400. /// <returns></returns>
  10401. [HttpPost]
  10402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10403. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10404. {
  10405. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10406. if (info2.Code != 0)
  10407. {
  10408. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10409. }
  10410. var info1 = info2.Data as InvertedListInfoView;
  10411. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10412. string teamName = "";
  10413. if (info != null) teamName = info.TeamName;
  10414. //载入模板
  10415. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10416. DocumentBuilder builder = new DocumentBuilder(doc);
  10417. //利用键值对存放数据
  10418. Dictionary<string, string> dic = new Dictionary<string, string>();
  10419. dic.Add("TeamName", teamName);
  10420. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10421. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10422. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10423. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10424. dic.Add("SQRemark", info1.ApprovalRemark);
  10425. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10426. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10427. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10428. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10429. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10430. dic.Add("QZRemark", info1.VisaInformationRemark);
  10431. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10432. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10433. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10434. dic.Add("CQRemark", info1.IssueVisaRemark);
  10435. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10436. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10437. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10438. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10439. #region 填充word模板书签内容
  10440. foreach (var key in dic.Keys)
  10441. {
  10442. builder.MoveToBookmark(key);
  10443. builder.Write(dic[key]);
  10444. }
  10445. #endregion
  10446. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10447. string fileName = $"{teamName}团出行准备流程表.doc";
  10448. string filePath = fileDir + $@"InvertedList/{fileName}";
  10449. doc.Save(filePath);
  10450. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10451. return Ok(JsonView(true, "操作成功!", Url));
  10452. }
  10453. #endregion
  10454. #region 三公签证费用(签证费、代办费)
  10455. /// <summary>
  10456. /// 三公签证费用(签证费、代办费)
  10457. /// List
  10458. /// </summary>
  10459. /// <returns></returns>
  10460. [HttpPost]
  10461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10462. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10463. {
  10464. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10465. if (_view.Code != 0)
  10466. {
  10467. return Ok(JsonView(false, _view.Msg));
  10468. }
  10469. return Ok(JsonView(true, "操作成功!", _view.Data));
  10470. }
  10471. /// <summary>
  10472. /// 三公签证费用(签证费、代办费)
  10473. /// Add Or Update
  10474. /// </summary>
  10475. /// <returns></returns>
  10476. [HttpPost]
  10477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10478. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10479. {
  10480. var _view = await _visaFeeInfoRep._Update(_dto);
  10481. if (_view.Code != 0)
  10482. {
  10483. return Ok(JsonView(false, _view.Msg));
  10484. }
  10485. return Ok(JsonView(true, _view.Msg));
  10486. }
  10487. #endregion
  10488. #region 酒店询价
  10489. /// <summary>
  10490. /// 酒店询价
  10491. /// Init
  10492. /// </summary>
  10493. /// <param name="dto"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> PostHotelInquiryInit()
  10498. {
  10499. var res = await _hotelInquiryRep._Init();
  10500. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10501. return Ok(JsonView(true, res.Msg, res.Data));
  10502. }
  10503. /// <summary>
  10504. /// 酒店询价
  10505. /// page Item
  10506. /// </summary>
  10507. /// <param name="_dto"></param>
  10508. /// <returns></returns>
  10509. [HttpPost]
  10510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10511. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10512. {
  10513. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10514. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10515. var view = res.Data as PageDataViewBase;
  10516. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10517. }
  10518. /// <summary>
  10519. /// 酒店询价
  10520. /// info
  10521. /// </summary>
  10522. /// <param name="_dto"></param>
  10523. /// <returns></returns>
  10524. [HttpPost]
  10525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10526. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10527. {
  10528. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10529. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10530. return Ok(JsonView(true, res.Msg, res.Data));
  10531. }
  10532. /// <summary>
  10533. /// 酒店询价
  10534. /// Add Or Edit
  10535. /// </summary>
  10536. /// <param name="_dto"></param>
  10537. /// <returns></returns>
  10538. [HttpPost]
  10539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10540. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10541. {
  10542. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10543. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10544. return Ok(JsonView(true, res.Msg, res.Data));
  10545. }
  10546. /// <summary>
  10547. /// 酒店询价
  10548. /// Del
  10549. /// </summary>
  10550. /// <param name="_dto"></param>
  10551. /// <returns></returns>
  10552. [HttpPost]
  10553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10554. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10555. {
  10556. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10557. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10558. return Ok(JsonView(true, res.Msg, res.Data));
  10559. }
  10560. #endregion
  10561. #region 下载匹配op行程单
  10562. /// <summary>
  10563. /// 匹配op行程单
  10564. /// Init
  10565. /// </summary>
  10566. /// <param name="dto">团组列表请求dto</param>
  10567. /// <returns></returns>
  10568. [HttpPost]
  10569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10570. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10571. {
  10572. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10573. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10574. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10575. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10576. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10577. .Where(it => it.IsDel == 0)
  10578. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10579. .OrderByDescending(it => it.CreateUserId)
  10580. .ToList();
  10581. if (groupInfos.Count < 1) return Ok(JsonView(false,"暂无和你相关的团组信息!"));
  10582. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10583. var diids = groupInfos.Select(it => it.Id).ToList();
  10584. List<string> countrys = new List<string>();
  10585. foreach (var item in country)
  10586. {
  10587. var data = _groupRepository.FormartTeamName(item);
  10588. var dataArray = _groupRepository.GroupSplitCountry(data);
  10589. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10590. }
  10591. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10592. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10593. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10594. foreach (var item in areaItem)
  10595. {
  10596. string areaStr = item.Value;
  10597. if (!string.IsNullOrEmpty(areaStr))
  10598. {
  10599. string[] str1 = areaStr.Split("-");
  10600. if (str1.Length > 0)
  10601. {
  10602. areaArray.AddRange(str1);
  10603. }
  10604. }
  10605. }
  10606. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10607. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10608. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10609. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10610. .ToList();
  10611. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10612. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10613. .Where(it => countriesIds.Contains(it.Id))
  10614. .Select(it => new { it.Id, Name = it.Name_CN })
  10615. .ToList();
  10616. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName) )
  10617. .Select(it => it.TeamName).ToList();
  10618. stopwatch.Stop();
  10619. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = cityDatas }));
  10620. }
  10621. ///// <summary>
  10622. ///// 匹配op行程单
  10623. ///// Init 查询区域数据
  10624. ///// </summary>
  10625. ///// <param name="dto">团组列表请求dto</param>
  10626. ///// <returns></returns>
  10627. //[HttpPost]
  10628. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10629. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10630. //{
  10631. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10632. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10633. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10634. // if (string.IsNullOrEmpty(countriesDataStr))
  10635. // {
  10636. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10637. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10638. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10639. // }
  10640. // else
  10641. // {
  10642. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10643. // }
  10644. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10645. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10646. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10647. // List<dynamic> childList = new List<dynamic>();
  10648. // int parentId = dto.CountriesId;
  10649. // if (provinceData.Count > 1)
  10650. // {
  10651. // foreach (var item1 in provinceData)
  10652. // {
  10653. // List<dynamic> childList1 = new List<dynamic>();
  10654. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10655. // foreach (var item2 in citiesData1)
  10656. // {
  10657. // List<dynamic> childList2 = new List<dynamic>();
  10658. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10659. // foreach (var item3 in countiesData1)
  10660. // {
  10661. // childList2.Add(new
  10662. // {
  10663. // id = item3.Id,
  10664. // parentId = item2.Id,
  10665. // level = "district",
  10666. // name = item3.Name_CN,
  10667. // });
  10668. // }
  10669. // childList1.Add(new
  10670. // {
  10671. // id = item2.Id,
  10672. // parentId = item1.Id,
  10673. // level = "city",
  10674. // name = item2.Name_CN,
  10675. // childList = childList2
  10676. // });
  10677. // }
  10678. // childList.Add(new
  10679. // {
  10680. // id = item1.Id,
  10681. // parentId = parentId,
  10682. // level = "province",
  10683. // name = item1.Name_CN,
  10684. // childList = childList1
  10685. // });
  10686. // }
  10687. // //城市
  10688. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10689. // foreach (var item2 in citiesData2)
  10690. // {
  10691. // List<dynamic> childList22 = new List<dynamic>();
  10692. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10693. // foreach (var item3 in countiesData1)
  10694. // {
  10695. // childList22.Add(new
  10696. // {
  10697. // id = item3.Id,
  10698. // parentId = item2.Id,
  10699. // level = "district",
  10700. // name = item3.Name_CN,
  10701. // });
  10702. // }
  10703. // childList.Add(new
  10704. // {
  10705. // id = item2.Id,
  10706. // parentId = parentId,
  10707. // level = "city",
  10708. // name = item2.Name_CN,
  10709. // childList = childList22
  10710. // });
  10711. // }
  10712. // }
  10713. // else
  10714. // {
  10715. // foreach (var item2 in citiesData)
  10716. // {
  10717. // string cname = item2.Name_CN;
  10718. // List<dynamic> childList1 = new List<dynamic>();
  10719. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10720. // foreach (var item3 in countiesData1)
  10721. // {
  10722. // childList1.Add(new
  10723. // {
  10724. // Id = item3.Id,
  10725. // parentId = item2.Id,
  10726. // level = "district",
  10727. // name = item3.Name_CN
  10728. // });
  10729. // }
  10730. // childList.Add(new
  10731. // {
  10732. // id = item2.Id,
  10733. // parentId = parentId,
  10734. // level = "city",
  10735. // name = item2.Name_CN,
  10736. // childList = childList1
  10737. // });
  10738. // }
  10739. // }
  10740. // stopwatch.Stop();
  10741. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10742. //}
  10743. /// <summary>
  10744. /// 匹配op行程单
  10745. /// 接团信息列表 Page
  10746. /// </summary>
  10747. /// <param name="dto">团组列表请求dto</param>
  10748. /// <returns></returns>
  10749. [HttpPost]
  10750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10751. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10752. {
  10753. var swatch = new Stopwatch();
  10754. swatch.Start();
  10755. #region 参数验证
  10756. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10757. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10758. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10759. #region 页面操作权限验证
  10760. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10761. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10762. #endregion
  10763. #endregion
  10764. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10765. {
  10766. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10767. string sqlWhere = "";
  10768. if (!string.IsNullOrEmpty(dto.Country))
  10769. {
  10770. _view = _view.Where(x => x.VisitCountry != null && x.VisitCountry.Contains(dto.Country)).ToList();
  10771. }
  10772. if (!string.IsNullOrEmpty(dto.Area))
  10773. {
  10774. _view = _view.Where(x => x.RouteCity != null && x.RouteCity.Contains(dto.Area)).ToList();
  10775. }
  10776. if (!string.IsNullOrEmpty(dto.TeamName))
  10777. {
  10778. _view = _view.Where(x => x.TeamName != null && x.TeamName.Contains(dto.TeamName)).ToList();
  10779. }
  10780. swatch.Stop();
  10781. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view.Skip(dto.PageIndex).Take(dto.PageSize).ToList(), _view.Count));
  10782. }
  10783. else
  10784. {
  10785. return Ok(JsonView(false, "查询失败"));
  10786. }
  10787. }
  10788. /// <summary>
  10789. /// 匹配op行程单
  10790. /// 行程单下载
  10791. /// </summary>
  10792. /// <param name="dto">团组列表请求dto</param>
  10793. /// <returns></returns>
  10794. [HttpPost]
  10795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10796. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10797. {
  10798. #region 参数验证
  10799. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10800. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10801. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10802. #region 页面操作权限验证
  10803. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10804. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10805. #endregion
  10806. #endregion
  10807. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10808. {
  10809. var res = ExportTravel(new InitOpTravelDto() { Diid = dto.diId });
  10810. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10811. }
  10812. else
  10813. {
  10814. return Ok(JsonView(false, "下载失败!"));
  10815. }
  10816. }
  10817. #endregion
  10818. #region 国家信息 数据 注释
  10819. //[HttpPost]
  10820. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10821. //{
  10822. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10823. // foreach (var item in dto)
  10824. // {
  10825. // infos.Add(new Grp_GroupsTaskAssignment()
  10826. // {
  10827. // DIId = item,
  10828. // CTId = 82,
  10829. // UId = 248,
  10830. // IsEnable = 1,
  10831. // CreateUserId = 233,
  10832. // CreateTime = DateTime.Now,
  10833. // IsDel = 0
  10834. // });
  10835. // infos.Add(new Grp_GroupsTaskAssignment()
  10836. // {
  10837. // DIId = item,
  10838. // CTId = 82,
  10839. // UId = 286,
  10840. // IsEnable = 1,
  10841. // CreateUserId = 233,
  10842. // CreateTime = DateTime.Now,
  10843. // IsDel = 0
  10844. // });
  10845. // }
  10846. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10847. // return Ok("操作成功");
  10848. //}
  10849. //public class paramJsonDto
  10850. //{
  10851. // public List<CountriesInfo> str { get; set; }
  10852. //}
  10853. //[HttpPost]
  10854. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10855. //{
  10856. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10857. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10858. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10859. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10860. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10861. // _sqlSugar.BeginTran();
  10862. // int countitiesIndex = 0;
  10863. // foreach (var item in dto.str)
  10864. // {
  10865. // dynamic data = item.c;
  10866. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10867. // if (data != null)
  10868. // {
  10869. // countitiesIndex++;
  10870. // foreach (var item1 in data)
  10871. // {
  10872. // string cnname = item1.cn;
  10873. // string enname = item1.en;
  10874. // Sys_Cities provinceInfo = new Sys_Cities()
  10875. // {
  10876. // CountriesId = countriesId,
  10877. // Name_CN = cnname,
  10878. // Name_EN = enname,
  10879. // ParentId = 0,
  10880. // IsCapital = 1,
  10881. // CreateUserId = 208,
  10882. // CreateTime = DateTime.Now,
  10883. // IsDel = 0
  10884. // };
  10885. // if (item1.lv == "province") //省份
  10886. // {
  10887. // provinceInfo.Level = 1;
  10888. // int provinceId = 0;
  10889. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10890. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10891. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10892. // var data1 = item1.c;
  10893. // foreach (var item2 in data1)
  10894. // {
  10895. // if (item2.lv == "city")
  10896. // {
  10897. // string citycnname = item2.cn;
  10898. // string cityenname = item2.en;
  10899. // Sys_Cities cityInfo = new Sys_Cities()
  10900. // {
  10901. // CountriesId = countriesId,
  10902. // ParentId = provinceId,
  10903. // Level = 2,
  10904. // Name_CN = citycnname,
  10905. // Name_EN = cityenname,
  10906. // IsCapital = 1,
  10907. // CreateUserId = 208,
  10908. // CreateTime = DateTime.Now,
  10909. // IsDel = 0
  10910. // };
  10911. // if (item2.c != null)
  10912. // {
  10913. // int cityId = 0;
  10914. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10915. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10916. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10917. // foreach (var item3 in item2.c)
  10918. // {
  10919. // if (item3.lv == "district")
  10920. // {
  10921. // var districtInfo = new Sys_Cities()
  10922. // {
  10923. // CountriesId = countriesId,
  10924. // Name_CN = item3.cn,
  10925. // Name_EN = item3.en,
  10926. // Level = 3,
  10927. // ParentId = cityId,
  10928. // IsCapital = 1,
  10929. // CreateUserId = 208,
  10930. // CreateTime = DateTime.Now,
  10931. // IsDel = 0
  10932. // };
  10933. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10934. // //{
  10935. // districts.Add(districtInfo);
  10936. // //}
  10937. // }
  10938. // }
  10939. // }
  10940. // else
  10941. // {
  10942. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10943. // //{
  10944. // cities.Add(cityInfo);
  10945. // //}
  10946. // }
  10947. // }
  10948. // }
  10949. // }
  10950. // else if (item1.lv == "city")//城市
  10951. // {
  10952. // provinceInfo.Level = 2;
  10953. // if (item1.c != null)
  10954. // {
  10955. // int cityId = 0;
  10956. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10957. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10958. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10959. // foreach (var item3 in item1.c)
  10960. // {
  10961. // if (item3.lv == "district")
  10962. // {
  10963. // var districtInfo = new Sys_Cities()
  10964. // {
  10965. // CountriesId = countriesId,
  10966. // Name_CN = item3.cn,
  10967. // Name_EN = item3.en,
  10968. // Level = 3,
  10969. // ParentId = cityId,
  10970. // IsCapital = 1,
  10971. // CreateUserId = 208,
  10972. // CreateTime = DateTime.Now,
  10973. // IsDel = 0
  10974. // };
  10975. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10976. // //{
  10977. // districts.Add(districtInfo);
  10978. // //}
  10979. // }
  10980. // }
  10981. // }
  10982. // else
  10983. // {
  10984. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10985. // //{
  10986. // cities.Add(provinceInfo);
  10987. // //}
  10988. // }
  10989. // }
  10990. // }
  10991. // }
  10992. // }
  10993. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10994. // cities = cities.Distinct().ToList();
  10995. // districts = districts.Distinct().ToList();
  10996. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10997. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10998. // cities.AddRange(districts);
  10999. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11000. // //_sqlSugar.RollbackTran();
  11001. // _sqlSugar.CommitTran();
  11002. // return Ok(JsonView(false, "操作成功!"));
  11003. //}
  11004. //[HttpPost]
  11005. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11006. //{
  11007. // List<CountitiesInfo> infos = dto.MyProperty;
  11008. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11009. // _sqlSugar.BeginTran();
  11010. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11011. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11012. // foreach (var item in infos)
  11013. // {
  11014. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11015. // if (countryInfo != null)
  11016. // {
  11017. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11018. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11019. // if (cityInfo1 != null)
  11020. // {
  11021. // cityInfo1.IsCapital = 0;
  11022. // cityInfos.Add(cityInfo1);
  11023. // }
  11024. // }
  11025. // }
  11026. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11027. // .UpdateColumns(it => it.IsCapital)
  11028. // .WhereColumns(it => it.Id)
  11029. // .ExecuteCommand();
  11030. // //_sqlSugar.RollbackTran();
  11031. // _sqlSugar.CommitTran();
  11032. // return Ok(JsonView(false, "操作成功!"));
  11033. //}
  11034. //public class CounrtiesDto
  11035. //{
  11036. // public List<CountitiesInfo> MyProperty { get; set; }
  11037. //}
  11038. //public class CountitiesInfo
  11039. //{
  11040. // /// <summary>
  11041. // /// 圣约翰
  11042. // /// </summary>
  11043. // public string capital_name_chinese { get; set; }
  11044. // /// <summary>
  11045. // ///
  11046. // /// </summary>
  11047. // public string capital_name { get; set; }
  11048. // /// <summary>
  11049. // ///
  11050. // /// </summary>
  11051. // public string country_type { get; set; }
  11052. // /// <summary>
  11053. // /// 安提瓜和巴布达
  11054. // /// </summary>
  11055. // public string country_name_chinese { get; set; }
  11056. // /// <summary>
  11057. // /// 安提瓜和巴布达
  11058. // /// </summary>
  11059. // public string country_name_chinese_short { get; set; }
  11060. // /// <summary>
  11061. // /// 安提瓜和巴布达
  11062. // /// </summary>
  11063. // public string country_name_chinese_UN { get; set; }
  11064. // /// <summary>
  11065. // ///
  11066. // /// </summary>
  11067. // public string country_name_english_abbreviation { get; set; }
  11068. // /// <summary>
  11069. // ///
  11070. // /// </summary>
  11071. // public string country_name_english_formal { get; set; }
  11072. // /// <summary>
  11073. // ///
  11074. // /// </summary>
  11075. // public string country_name_english_UN { get; set; }
  11076. // /// <summary>
  11077. // ///
  11078. // /// </summary>
  11079. // public string continent_name { get; set; }
  11080. // /// <summary>
  11081. // ///
  11082. // /// </summary>
  11083. // public string subregion_name { get; set; }
  11084. // /// <summary>
  11085. // ///
  11086. // /// </summary>
  11087. // public string country_code2 { get; set; }
  11088. // /// <summary>
  11089. // ///
  11090. // /// </summary>
  11091. // public string country_code3 { get; set; }
  11092. // /// <summary>
  11093. // ///
  11094. // /// </summary>
  11095. // public string phone_code { get; set; }
  11096. //}
  11097. //public class CountriesInfo : BasicInfo
  11098. //{
  11099. // public List<CitiesInfo> c { get; set; }
  11100. //}
  11101. //public class CitiesInfo : BasicInfo
  11102. //{
  11103. // public List<AreaInfo> c { get; set; }
  11104. //}
  11105. //public class AreaInfo : BasicInfo
  11106. //{
  11107. // public List<AreaInfo> c { get; set; }
  11108. //}
  11109. //public class BasicInfo
  11110. //{
  11111. // public string code { get; set; }
  11112. // public string cn { get; set; }
  11113. // public string lv { get; set; }
  11114. // public string en { get; set; }
  11115. //}
  11116. #endregion
  11117. #region 查看邀请方
  11118. /// <summary>
  11119. /// 查看邀请方
  11120. /// 邀请方信息 Init
  11121. /// </summary>
  11122. /// <param name="dto"></param>
  11123. /// <returns></returns>
  11124. [HttpPost]
  11125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11126. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11127. {
  11128. string sqlWhere = string.Empty;
  11129. if (!string.IsNullOrEmpty(dto.Search))
  11130. {
  11131. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11132. }
  11133. string sql = string.Format($@"Select
  11134. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11135. Id,
  11136. UnitName
  11137. From Res_InvitationOfficialActivityData
  11138. Where IsDel = 0
  11139. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11140. RefAsync<int> total = 0;
  11141. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11142. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11143. }
  11144. /// <summary>
  11145. /// 查看邀请方
  11146. /// 国家信息 Init
  11147. /// </summary>
  11148. /// <param name="dto"></param>
  11149. /// <returns></returns>
  11150. [HttpPost]
  11151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11152. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11153. {
  11154. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11155. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11156. var diids = groupInfos.Select(it => it.Id).ToList();
  11157. List<string> countrys = new List<string>();
  11158. foreach (var item in country)
  11159. {
  11160. var data = _groupRepository.FormartTeamName(item);
  11161. var dataArray = _groupRepository.GroupSplitCountry(data);
  11162. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11163. }
  11164. countrys = countrys.Distinct().ToList();
  11165. for (int i = 0; i < countrys.Count; i++)
  11166. {
  11167. string item = countrys[i];
  11168. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11169. {
  11170. countrys.Remove(item);
  11171. i--;
  11172. }
  11173. }
  11174. RefAsync<int> total = 0;
  11175. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11176. .Where(it => countrys.Contains(it.Name_CN))
  11177. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11178. .Select(it => new { id = it.Id, name = it.Name_CN })
  11179. .ToPageListAsync(dto.PageIndex,dto.PageSize, total);
  11180. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11181. }
  11182. /// <summary>
  11183. /// 查看邀请方
  11184. /// 城市信息 Init
  11185. /// </summary>
  11186. /// <param name="dto"></param>
  11187. /// <returns></returns>
  11188. [HttpPost]
  11189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11190. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11191. {
  11192. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11193. RefAsync<int> total = 0;
  11194. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11195. .Where(it => it.CountriesId == dto.CountiesId)
  11196. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11197. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11198. .Select(it => new { id = it.Id, name = it.Name_CN })
  11199. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11200. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11201. }
  11202. /// <summary>
  11203. /// 查看邀请方
  11204. /// 团组名称 Init
  11205. /// </summary>
  11206. /// <param name="dto"></param>
  11207. /// <returns></returns>
  11208. [HttpPost]
  11209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11210. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11211. {
  11212. var watch = new Stopwatch();
  11213. watch.Start();
  11214. RefAsync<int> total = 0;
  11215. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11216. .Where(it => it.IsDel == 0)
  11217. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.TeamName.Contains(dto.Search))
  11218. .OrderBy(it => new { JietuanTime = SqlFunc.Desc(it.JietuanTime) })
  11219. .Select(it => new { id = it.Id, name = it.TeamName })
  11220. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11221. watch.Stop();
  11222. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11223. }
  11224. /// <summary>
  11225. /// 查看邀请方
  11226. /// 团组 & 邀请方信息
  11227. /// </summary>
  11228. /// <param name="dto"></param>
  11229. /// <returns></returns>
  11230. [HttpPost]
  11231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11232. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11233. {
  11234. var watch = new Stopwatch();
  11235. watch.Start();
  11236. RefAsync<int> total = 0;
  11237. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11238. .AS("Grp_DelegationInfo")
  11239. .Includes(x => x.InvitingInfos)
  11240. .Where(x => x.IsDel == 0)
  11241. .Where(x => x.InvitingInfos.Any(z => z.IsDel == 0))
  11242. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11243. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //TeamName
  11244. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11245. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11246. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11247. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11248. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11249. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11250. infos.ForEach(x => {
  11251. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11252. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11253. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11254. });
  11255. watch.Stop();
  11256. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11257. }
  11258. #endregion
  11259. #region 报批行程
  11260. /// <summary>
  11261. /// 报批行程初始化
  11262. /// </summary>
  11263. /// <param name="dto"></param>
  11264. /// <returns></returns>
  11265. [HttpPost]
  11266. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11267. {
  11268. const int chiNumber = 5;
  11269. var jw = JsonView(false);
  11270. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11271. var group = groupList.First();
  11272. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11273. group = groupList.First(x => x.Id == diid);
  11274. if (group == null)
  11275. {
  11276. jw.Msg = "暂无团组!";
  11277. return Ok(jw);
  11278. }
  11279. var resultArr = new ArrayList();
  11280. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11281. if (content.Count == 0)
  11282. {
  11283. ////黑屏代码数据
  11284. //DataTable dt = GetTableByBlackCode(group.Id);
  11285. //if (dt.Rows[0]["Day"] == null || dt.Rows[0]["Day"].ToString() == "")//判断黑屏代码数据是否正确生成
  11286. //{
  11287. //}
  11288. //else
  11289. //{
  11290. // jw.Msg = "黑屏代码有误!";
  11291. // return Ok(jw);
  11292. //}
  11293. DateTime StartDate = (group.VisitStartDate);
  11294. DateTime EndDate = (group.VisitEndDate);
  11295. TimeSpan t3 = EndDate - StartDate; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  11296. var getDay = t3.Days;
  11297. if (getDay == 0) getDay = 1;
  11298. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11299. _sqlSugar.BeginTran();
  11300. for (int i = 0; i < getDay; i++)
  11301. {
  11302. DateTime NewData = StartDate.AddDays(i);
  11303. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11304. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11305. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11306. appro.Diid = diid ?? -1;
  11307. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11308. appro.Id = thisId;
  11309. appro.CreateUserId = dto.UserId;
  11310. appro.CreateTime = DateTime.Now;
  11311. content.Add(appro);
  11312. }
  11313. _sqlSugar.CommitTran();
  11314. }
  11315. foreach (var x in content)
  11316. {
  11317. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11318. if (chiList.Count < chiNumber)
  11319. {
  11320. for (int i = chiList.Count; i < chiNumber; i++)
  11321. {
  11322. chiList.Add(new Grp_ApprovalTravelDetails());
  11323. }
  11324. }
  11325. resultArr.Add(new
  11326. {
  11327. x.Id,
  11328. x.Date,
  11329. x.Diid,
  11330. chiList = chiList.Select(x1 => new
  11331. {
  11332. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  11333. x1.Details,
  11334. x1.ParentId,
  11335. x1.Id
  11336. })
  11337. });
  11338. }
  11339. var data = new
  11340. {
  11341. groupList = groupList.Select(x => new
  11342. {
  11343. x.TeamName,
  11344. x.Id
  11345. }),
  11346. content = resultArr,
  11347. groupInfo = new
  11348. {
  11349. group.VisitDays,
  11350. group.TourCode,
  11351. group.VisitPNumber,
  11352. group.TeamName,
  11353. group.Id
  11354. },
  11355. };
  11356. jw = JsonView(true,"获取成功!",data);
  11357. return Ok(jw);
  11358. }
  11359. /// <summary>
  11360. /// 报批行程删除
  11361. /// </summary>
  11362. /// <param name="dto"></param>
  11363. /// <returns></returns>
  11364. [HttpPost]
  11365. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11366. {
  11367. var jw = JsonView(false);
  11368. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  11369. if (group == null)
  11370. {
  11371. jw.Msg = "团组参数有误!";
  11372. return Ok(jw);
  11373. }
  11374. try
  11375. {
  11376. _sqlSugar.BeginTran();
  11377. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  11378. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11379. {
  11380. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11381. DeleteUserId = dto.uesrId,
  11382. IsDel = 1
  11383. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11384. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11385. {
  11386. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11387. DeleteUserId = dto.uesrId,
  11388. IsDel = 1
  11389. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11390. _sqlSugar.CommitTran();
  11391. jw = JsonView(true, "删除成功");
  11392. }
  11393. catch (Exception ex)
  11394. {
  11395. jw = JsonView(false, ex.Message);
  11396. }
  11397. return Ok(jw);
  11398. }
  11399. /// <summary>
  11400. /// 报批行程保存
  11401. /// </summary>
  11402. /// <param name="dto"></param>
  11403. /// <returns></returns>
  11404. [HttpPost]
  11405. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11406. {
  11407. var jw = JsonView(false);
  11408. var Find = dto.Arr.Find(x => x.id == 0);
  11409. if (Find != null)
  11410. {
  11411. jw.Msg = "生成的ID为0!";
  11412. return Ok(jw);
  11413. }
  11414. foreach (var item in dto.Arr)
  11415. {
  11416. foreach (var chi in item.chiList)
  11417. {
  11418. if (chi.parentId == 0)
  11419. {
  11420. chi.parentId = item.id;
  11421. }
  11422. }
  11423. }
  11424. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11425. _sqlSugar.BeginTran();
  11426. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  11427. {
  11428. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11429. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  11430. {
  11431. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11432. DeleteUserId = dto.UserId,
  11433. IsDel = 1
  11434. }).ExecuteCommand();
  11435. }
  11436. try
  11437. {
  11438. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11439. {
  11440. CreateTime = DateTime.Now,
  11441. CreateUserId = dto.UserId,
  11442. Details = x.details,
  11443. ParentId = x.parentId,
  11444. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11445. Remark = "",
  11446. IsDel = 0
  11447. }).ToList()).ExecuteCommand();
  11448. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11449. {
  11450. Id = x.id,
  11451. Details = x.details,
  11452. ParentId = x.parentId,
  11453. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11454. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  11455. {
  11456. Details = x.Details,
  11457. ParentId = x.ParentId,
  11458. Time = x.Time
  11459. }).ExecuteCommand();
  11460. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11461. {
  11462. Id = x.id,
  11463. Date = x.date,
  11464. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11465. {
  11466. Date = x.Date
  11467. }).ExecuteCommand();
  11468. _sqlSugar.CommitTran();
  11469. jw = JsonView(true, "保存成功!");
  11470. }
  11471. catch (Exception ex)
  11472. {
  11473. _sqlSugar.RollbackTran();
  11474. jw = JsonView(false, "保存失败!" + ex.Message);
  11475. }
  11476. return Ok(jw);
  11477. }
  11478. /// <summary>
  11479. /// 报批行程生成
  11480. /// </summary>
  11481. /// <param name="dto"></param>
  11482. /// <returns></returns>
  11483. [HttpPost]
  11484. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11485. {
  11486. var jw = JsonView(false);
  11487. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11488. if (group == null)
  11489. {
  11490. jw.Msg = "暂无该团组!";
  11491. return Ok(jw);
  11492. }
  11493. DateTime StartDate = (group.VisitStartDate);
  11494. DateTime EndDate = (group.VisitEndDate);
  11495. TimeSpan t3 = EndDate - StartDate;
  11496. var getDay = t3.Days;
  11497. if (getDay == 0) getDay = 1;
  11498. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11499. var resultArr = new ArrayList();
  11500. if (officialActivitiesArr.Count == 0)
  11501. {
  11502. jw.Msg = "暂无公务出访信息!";
  11503. return Ok(jw);
  11504. }
  11505. try
  11506. {
  11507. _sqlSugar.BeginTran();
  11508. DeleteApprovalJourney(new
  11509. Domain.Dtos.Groups.DeleteApprovalJourney
  11510. {
  11511. Diid = dto.Diid,
  11512. uesrId = dto.Userid
  11513. });
  11514. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11515. for (int i = 0; i < getDay; i++)
  11516. {
  11517. DateTime NewData = StartDate.AddDays(i);
  11518. 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();
  11519. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11520. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11521. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11522. appro.Diid = dto.Diid;
  11523. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11524. appro.Id = thisId;
  11525. appro.CreateUserId = dto.Userid;
  11526. appro.CreateTime = DateTime.Now;
  11527. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11528. foreach (var item in gwinfo)
  11529. {
  11530. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11531. chi.Details = "拜访" + item.Client;
  11532. chi.ParentId = thisId;
  11533. chi.Time = item.Time;
  11534. chiarr.Add(chi);
  11535. }
  11536. if (chiarr.Count < 5)
  11537. {
  11538. for (int j = chiarr.Count; j < 5; j++)
  11539. {
  11540. chiarr.Add(new
  11541. Grp_ApprovalTravelDetails());
  11542. }
  11543. }
  11544. resultArr.Add(new
  11545. {
  11546. appro.Id,
  11547. appro.Date,
  11548. appro.Diid,
  11549. chiList = chiarr.Select(x1 => new
  11550. {
  11551. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11552. x1.Details,
  11553. x1.ParentId,
  11554. x1.Id
  11555. })
  11556. });
  11557. }
  11558. _sqlSugar.CommitTran();
  11559. jw = JsonView(true, "生成成功!", resultArr);
  11560. }
  11561. catch (Exception ex)
  11562. {
  11563. jw.Code = 400;
  11564. jw.Msg = "生成失败!" + ex.Message;
  11565. }
  11566. return Ok(jw);
  11567. }
  11568. /// <summary>
  11569. /// 报批行程word导出
  11570. /// </summary>
  11571. /// <param name="dto"></param>
  11572. /// <returns></returns>
  11573. [HttpPost]
  11574. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11575. {
  11576. var jw = JsonView(false);
  11577. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11578. if (group == null)
  11579. {
  11580. jw.Msg = "暂无该团组!";
  11581. return Ok(jw);
  11582. }
  11583. //模板路径
  11584. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11585. //载入模板
  11586. Document doc = new Document(tempPath);
  11587. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11588. //获取所填表格的序数
  11589. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11590. Aspose.Words.Tables.Row titleRowClone = null;
  11591. Aspose.Words.Tables.Row CenterRowClone = null;
  11592. int index = 0;
  11593. int indexChi = 0;
  11594. int SetIndex = 0;
  11595. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11596. //获取数据,放到datatable
  11597. foreach (var item in ApprovalTravelArr)
  11598. {
  11599. if (index > 0)
  11600. {
  11601. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11602. tableOne.AppendChild(titleRowClone);
  11603. }
  11604. var textTime = item.Date;
  11605. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11606. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11607. SetIndex++;
  11608. if (ChiRep.Count > 0)
  11609. {
  11610. foreach (var itemChi in ChiRep)
  11611. {
  11612. var txtTime = itemChi.Time;
  11613. var txtDetail = itemChi.Details;
  11614. if (indexChi > 0)
  11615. {
  11616. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11617. tableOne.AppendChild(CenterRowClone);
  11618. }
  11619. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11620. {
  11621. SetCells(tableOne, doc, SetIndex, 0, "");
  11622. SetCells(tableOne, doc, SetIndex, 1, "");
  11623. indexChi++;
  11624. SetIndex++;
  11625. break;
  11626. }
  11627. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11628. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11629. indexChi++;
  11630. SetIndex++;
  11631. }
  11632. }
  11633. else
  11634. {
  11635. if (indexChi > 0)
  11636. {
  11637. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11638. tableOne.AppendChild(CenterRowClone);
  11639. }
  11640. SetCells(tableOne, doc, SetIndex, 0, "");
  11641. SetCells(tableOne, doc, SetIndex, 1, "");
  11642. indexChi++;
  11643. SetIndex++;
  11644. }
  11645. index++;
  11646. }
  11647. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11648. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11649. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11650. jw.Code = 200;
  11651. jw.Msg = "";
  11652. return Ok(jw);
  11653. }
  11654. private string intToString(int numberVal)
  11655. {
  11656. string numberval = numberVal.ToString();
  11657. Dictionary<char, string> Number = new Dictionary<char, string>();
  11658. Number.Add('1', "一");
  11659. Number.Add('2', "二");
  11660. Number.Add('3', "三");
  11661. Number.Add('4', "四");
  11662. Number.Add('5', "五");
  11663. Number.Add('6', "六");
  11664. Number.Add('7', "七");
  11665. Number.Add('8', "八");
  11666. Number.Add('9', "九");
  11667. string stringNumberVal = string.Empty;
  11668. for (int i = 0; i < numberval.Length; i++)
  11669. {
  11670. if (i == 0)
  11671. {
  11672. stringNumberVal += Number[numberval[i]];
  11673. }
  11674. else if (i >= 1)
  11675. {
  11676. if (numberval[i] == '0')
  11677. {
  11678. stringNumberVal = "十";
  11679. }
  11680. else
  11681. {
  11682. stringNumberVal += "十" + Number[numberval[i]];
  11683. }
  11684. }
  11685. }
  11686. return stringNumberVal;
  11687. }
  11688. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11689. {
  11690. //获取table中的某个单元格,从0开始
  11691. Cell lshCell = table.Rows[rows].Cells[cells];
  11692. //将单元格中的第一个段落移除
  11693. lshCell.FirstParagraph.Remove();
  11694. //新建一个段落
  11695. Paragraph p = new Paragraph(doc);
  11696. var r = new Run(doc, val);
  11697. //把设置的值赋给之前新建的段落
  11698. p.AppendChild(r);
  11699. //将此段落加到单元格内
  11700. lshCell.AppendChild(p);
  11701. }
  11702. #endregion
  11703. // /// <summary>
  11704. // ///
  11705. // /// </summary>
  11706. // /// <param name="_dto"></param>
  11707. // /// <returns></returns>
  11708. // [HttpPost]
  11709. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11710. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11711. // {
  11712. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11713. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11714. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11715. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11716. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11717. // dic_psg.Add("客人", 974);
  11718. // dic_psg.Add("司机", 975);
  11719. // dic_psg.Add("导游", 976);
  11720. // dic_psg.Add("公司内部人员", 977);
  11721. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11722. // foreach (var item in list_visa)
  11723. // {
  11724. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11725. // temp.Id = item.Id;
  11726. // temp.DIId = item.DIId;
  11727. // temp.VisaClient = item.VisaClient;
  11728. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11729. // temp.VisaCurrency = item.VisaCurrency;
  11730. // temp.IsThird = item.IsThird;
  11731. // if (dic_psg.ContainsKey(item.PassengerType))
  11732. // {
  11733. // temp.PassengerType = dic_psg[item.PassengerType];
  11734. // }
  11735. // else {
  11736. // temp.PassengerType = -1;
  11737. // }
  11738. // temp.VisaNumber = item.VisaNumber;
  11739. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11740. // temp.CreateUserId = item.Operators;
  11741. // DateTime dt_ct;
  11742. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11743. // if (b_ct)
  11744. // {
  11745. // temp.CreateTime = dt_ct;
  11746. // }
  11747. // else
  11748. // {
  11749. // temp.CreateTime = DateTime.Now;
  11750. // }
  11751. // temp.DeleteTime = "";
  11752. // temp.DeleteUserId = 0;
  11753. // temp.Remark = item.Remark;
  11754. // if (string.IsNullOrEmpty(temp.Remark)) {
  11755. // temp.Remark = "";
  11756. // }
  11757. // temp.IsDel = item.IsDel;
  11758. // temp.VisaDescription = item.VisaAttachment;
  11759. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11760. //([Id]
  11761. // ,[DIId]
  11762. // ,[VisaClient]
  11763. // ,[VisaPrice]
  11764. // ,[VisaCurrency]
  11765. // ,[IsThird]
  11766. // ,[PassengerType]
  11767. // ,[VisaNumber]
  11768. // ,[VisaFreeNumber]
  11769. // ,[CreateUserId]
  11770. // ,[CreateTime]
  11771. // ,[DeleteTime]
  11772. // ,[DeleteUserId]
  11773. // ,[Remark]
  11774. // ,[IsDel]
  11775. // ,[visaDescription])
  11776. // VALUES
  11777. // ({0},{1},'{2}',{3},{4}
  11778. //,{5},{6},{7},{8},{9}
  11779. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11780. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11781. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11782. //);
  11783. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11784. // }
  11785. // return Ok(JsonView(true, "操作成功!"));
  11786. // }
  11787. /// <summary>
  11788. /// 123132123
  11789. /// </summary>
  11790. /// <param name="_dto"></param>
  11791. /// <returns></returns>
  11792. [HttpPost]
  11793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11794. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11795. {
  11796. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11797. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11798. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11799. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11800. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11801. dicDetail.Add(789, 1034);
  11802. dicDetail.Add(790, 1035);
  11803. dicDetail.Add(791, 1036);
  11804. dicDetail.Add(792, 1037);
  11805. dicDetail.Add(793, 1038);
  11806. dicDetail.Add(794, 1039);
  11807. dicDetail.Add(795, 1040);
  11808. dicDetail.Add(796, 1041);
  11809. dicDetail.Add(797, 1042);
  11810. dicDetail.Add(798, 1043);
  11811. dicDetail.Add(801, 1044);
  11812. dicDetail.Add(802, 1045);
  11813. dicDetail.Add(803, 1046);
  11814. Dictionary<int, int> dic = new Dictionary<int, int>();
  11815. dic.Add(806, 1027);
  11816. dic.Add(807, 1028);
  11817. dic.Add(808, 1029);
  11818. dic.Add(809, 1030);
  11819. dic.Add(810, 1031);
  11820. dic.Add(811, 1032);
  11821. dic.Add(812, 1033);
  11822. foreach (var item in list_visa)
  11823. {
  11824. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11825. temp.Coefficient = item.coefficient;
  11826. DateTime dtCrt;
  11827. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11828. if (b1)
  11829. {
  11830. temp.CreateTime = dtCrt;
  11831. }
  11832. else
  11833. {
  11834. temp.CreateTime = DateTime.Now;
  11835. }
  11836. temp.CreateUserId = item.Operators;
  11837. temp.DeleteTime = "";
  11838. temp.DeleteUserId = 0;
  11839. temp.DiId = int.Parse(item.DIID);
  11840. temp.FilePath = item.FilePath;
  11841. temp.IsDel = item.IsDel;
  11842. temp.Price = item.Price;
  11843. temp.PriceCount = 1;
  11844. temp.PriceCurrency = item.Currency;
  11845. int detailId = 0;
  11846. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11847. {
  11848. detailId = dicDetail[item.PriceTypeDetail];
  11849. }
  11850. temp.PriceDetailType = detailId;
  11851. temp.PriceDt = DateTime.Now;
  11852. temp.PriceName = item.PriceName;
  11853. temp.PriceSum = item.Price;
  11854. int tid = 0;
  11855. if (dic.ContainsKey(item.PriceType))
  11856. {
  11857. tid = dic[item.PriceType];
  11858. }
  11859. temp.PriceType = tid;
  11860. temp.Remark = item.Remark;
  11861. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11862. }
  11863. return Ok(JsonView(true, "操作成功!"));
  11864. }
  11865. }
  11866. }