GroupsController.cs 624 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673
  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. using System.Drawing.Printing;
  92. using OASystem.Domain.Dtos.FileDto;
  93. using Microsoft.VisualBasic;
  94. namespace OASystem.API.Controllers
  95. {
  96. /// <summary>
  97. /// 团组相关
  98. /// </summary>
  99. //[Authorize]
  100. [Route("api/[controller]/[action]")]
  101. public class GroupsController : ControllerBase
  102. {
  103. private readonly GrpScheduleRepository _grpScheduleRep;
  104. private readonly IMapper _mapper;
  105. private readonly DelegationInfoRepository _groupRepository;
  106. private readonly TaskAssignmentRepository _taskAssignmentRep;
  107. private readonly AirTicketResRepository _airTicketResRep;
  108. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  109. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  110. private readonly DelegationEnDataRepository _delegationEnDataRep;
  111. private readonly DelegationVisaRepository _delegationVisaRep;
  112. private readonly VisaPriceRepository _visaPriceRep;
  113. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  114. private readonly HotelPriceRepository _hotelPriceRep;
  115. private readonly CustomersRepository _customersRep;
  116. private readonly MessageRepository _message;
  117. private readonly SqlSugarClient _sqlSugar;
  118. private readonly TourClientListRepository _tourClientListRep;
  119. private readonly TeamRateRepository _teamRateRep;
  120. #region 成本相关
  121. private readonly CheckBoxsRepository _checkBoxs;
  122. private readonly GroupCostRepository _GroupCostRepository;
  123. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  124. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  125. #endregion
  126. private readonly SetDataRepository _setDataRep;
  127. private string url;
  128. private string path;
  129. private readonly EnterExitCostRepository _enterExitCostRep;
  130. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  131. private readonly UsersRepository _usersRep;
  132. private readonly IJuHeApiService _juHeApi;
  133. private readonly InvertedListRepository _invertedListRep;
  134. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  135. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  136. private readonly ThreeCodeRepository _threeCodeRepository;
  137. private readonly HotelInquiryRepository _hotelInquiryRep;
  138. private readonly FeeAuditRepository _feeAuditRep;
  139. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  140. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  141. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  142. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  143. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  144. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  145. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  146. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  147. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  148. {
  149. _mapper = mapper;
  150. _grpScheduleRep = grpScheduleRep;
  151. _groupRepository = groupRepository;
  152. _taskAssignmentRep = taskAssignmentRep;
  153. _airTicketResRep = airTicketResRep;
  154. _sqlSugar = sqlSugar;
  155. url = AppSettingsHelper.Get("ExcelBaseUrl");
  156. path = AppSettingsHelper.Get("ExcelBasePath");
  157. if (!System.IO.Directory.Exists(path))
  158. {
  159. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  160. }
  161. _decreasePaymentsRep = decreasePaymentsRep;
  162. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  163. _delegationEnDataRep = delegationEnDataRep;
  164. _enterExitCostRep = enterExitCostRep;
  165. _delegationVisaRep = delegationVisaRep;
  166. _message = message;
  167. _visaPriceRep = visaPriceRep;
  168. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  169. _checkBoxs = checkBoxs;
  170. _GroupCostRepository = GroupCostRepository;
  171. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  172. _GroupCostParameterRepository = GroupCostParameterRepository;
  173. _hotelPriceRep = hotelPriceRep;
  174. _customersRep = customersRep;
  175. _setDataRep = setDataRep;
  176. _tourClientListRep = tourClientListRep;
  177. _teamRateRep = teamRateRep;
  178. _hubContext = hubContext;
  179. _usersRep = usersRep;
  180. _juHeApi = juHeApi;
  181. _invertedListRep = invertedListRep;
  182. _visaFeeInfoRep = visaFeeInfoRep;
  183. _ticketBlackCodeRep = ticketBlackCodeRep;
  184. _hotelInquiryRep = hotelInquiryRep;
  185. _threeCodeRepository = threeCodeRepository;
  186. _feeAuditRep = feeAuditRep;
  187. }
  188. #region 流程管控
  189. /// <summary>
  190. /// 获取团组流程管控信息
  191. /// </summary>
  192. /// <param name="paras">参数Json字符串</param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  196. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  197. {
  198. if (string.IsNullOrEmpty(_jsonDto.Paras))
  199. {
  200. return Ok(JsonView(false, "参数为空"));
  201. }
  202. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  203. if (_ScheduleDto != null)
  204. {
  205. if (_ScheduleDto.SearchType == 2)//获取列表
  206. {
  207. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  208. return Ok(JsonView(_grpScheduleViewList));
  209. }
  210. else//获取对象
  211. {
  212. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  213. if (_grpScheduleView != null)
  214. {
  215. return Ok(JsonView(_grpScheduleView));
  216. }
  217. }
  218. }
  219. else
  220. {
  221. return Ok(JsonView(false, "参数反序列化失败"));
  222. }
  223. return Ok(JsonView(false, "暂无数据!"));
  224. }
  225. /// <summary>
  226. /// 修改团组流程管控详细表数据
  227. /// </summary>
  228. /// <param name="paras"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  233. {
  234. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  235. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  236. .SetColumns(it => it.Duty == _detail.Duty)
  237. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  238. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  239. .SetColumns(it => it.JobContent == _detail.JobContent)
  240. .SetColumns(it => it.Remark == _detail.Remark)
  241. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  242. .Where(s => s.Id == dto.Id)
  243. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  244. .ExecuteCommandAsync();
  245. if (result > 0)
  246. {
  247. return Ok(JsonView(true, "保存成功!"));
  248. }
  249. return Ok(JsonView(false, "保存失败!"));
  250. }
  251. /// <summary>
  252. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  253. /// </summary>
  254. /// <param name="dto"></param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  259. {
  260. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  261. _detail.IsDel = 1;
  262. _detail.DeleteUserId = dto.Duty;
  263. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  264. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  265. .SetColumns(it => it.IsDel == _detail.IsDel)
  266. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  267. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  268. .Where(it => it.Id == dto.Id)
  269. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  270. //.WhereColumns(s => s.Id == dto.Id)
  271. .ExecuteCommandAsync();
  272. if (result > 0)
  273. {
  274. return Ok(JsonView(true, "删除成功!"));
  275. }
  276. return Ok(JsonView(false, "删除失败!"));
  277. }
  278. /// <summary>
  279. /// 增加团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="dto"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. if (DateTime.Now < _detail.ExpectBeginDt)
  289. {
  290. _detail.StepStatus = 0;
  291. }
  292. else
  293. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  294. _detail.StepStatus = 1;
  295. }
  296. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  297. if (result > 0)
  298. {
  299. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  300. return Ok(JsonView(true, "添加成功!", _result));
  301. }
  302. return Ok(JsonView(false, "添加失败!"));
  303. }
  304. #endregion
  305. #region 团组基本信息
  306. /// <summary>
  307. /// 接团信息列表
  308. /// </summary>
  309. /// <param name="dto">团组列表请求dto</param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  313. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  314. {
  315. var groupData = await _groupRepository.GetGroupList(dto);
  316. if (groupData.Code != 0)
  317. {
  318. return Ok(JsonView(false, groupData.Msg));
  319. }
  320. return Ok(JsonView(groupData.Data));
  321. }
  322. /// <summary>
  323. /// 接团信息列表 Page
  324. /// </summary>
  325. /// <param name="dto">团组列表请求dto</param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  330. {
  331. #region 参数验证
  332. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  333. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  335. #region 页面操作权限验证
  336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  337. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  338. #endregion
  339. #endregion
  340. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  341. {
  342. string sqlWhere = string.Empty;
  343. if (dto.IsSure == 0) //未完成
  344. {
  345. sqlWhere += string.Format(@" And IsSure = 0");
  346. }
  347. else if (dto.IsSure == 1) //已完成
  348. {
  349. sqlWhere += string.Format(@" And IsSure = 1");
  350. }
  351. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  352. {
  353. string tj = dto.SearchCriteria;
  354. 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}%')",
  355. tj, tj, tj, tj, tj);
  356. }
  357. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  358. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  359. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  360. JietuanOperator,IsSure,CreateTime
  361. From (
  362. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  363. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  364. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  365. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  366. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  367. From Grp_DelegationInfo gdi
  368. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  369. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  370. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  371. Where gdi.IsDel = 0 {0}
  372. ) temp", sqlWhere);
  373. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  374. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  375. #region 处理所属部门
  376. /*
  377. * 1.sq 和 gyy 等显示 市场部
  378. * 2.王鸽和主管及张总还有管理员号统一国交部
  379. * 2-1. 4 管理员 ,21 张海麟
  380. */
  381. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  382. List<int> userIds1 = new List<int>() { 4, 21 };
  383. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  384. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  385. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  386. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  387. .ToList();
  388. foreach (var item in _DelegationList)
  389. {
  390. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  391. }
  392. #endregion
  393. var _view = new
  394. {
  395. PageFuncAuth = pageFunAuthView,
  396. Data = _DelegationList
  397. };
  398. return Ok(JsonView(true, "查询成功!", _view, total));
  399. }
  400. else
  401. {
  402. return Ok(JsonView(false, "查询失败"));
  403. }
  404. }
  405. /// <summary>
  406. /// 团组列表
  407. /// </summary>
  408. /// <returns></returns>
  409. [HttpPost]
  410. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  411. {
  412. #region 参数验证
  413. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  414. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  415. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  416. #region 页面操作权限验证
  417. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  418. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  419. #endregion
  420. #endregion
  421. if (dto.PortType != 1 && dto.PortType != 2)
  422. {
  423. return Ok(JsonView(false, "查询失败!"));
  424. }
  425. string orderbyStr = "order by gdi.CreateTime Desc";
  426. string sqlWhere = string.Empty;
  427. if (dto.IsSure == 0) //未完成
  428. {
  429. sqlWhere += string.Format(@" And IsSure = 0");
  430. }
  431. else if (dto.IsSure == 1) //已完成
  432. {
  433. sqlWhere += string.Format(@" And IsSure = 1");
  434. }
  435. //团组类型
  436. if (dto.TeamDid > 0)
  437. {
  438. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  439. }
  440. //团组名称
  441. if (!string.IsNullOrEmpty(dto.TeamName))
  442. {
  443. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  444. }
  445. //客户名称
  446. if (!string.IsNullOrEmpty(dto.ClientName))
  447. {
  448. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  449. }
  450. //客户单位
  451. if (!string.IsNullOrEmpty(dto.ClientUnit))
  452. {
  453. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  454. }
  455. //出访时间
  456. if (!string.IsNullOrEmpty(dto.visitDataTime))
  457. {
  458. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  459. orderbyStr = "order by gdi.VisitDate";
  460. }
  461. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  462. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  463. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  464. JietuanOperator,IsSure,CreateTime
  465. From (
  466. Select row_number() over({0}) as Row_Number,
  467. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  468. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  469. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  470. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  471. From Grp_DelegationInfo gdi
  472. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  473. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  474. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  475. Where gdi.IsDel = 0 {1}
  476. ) temp ", orderbyStr, sqlWhere);
  477. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  478. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  479. #region 处理所属部门
  480. /*
  481. * 1.sq 和 gyy 等显示 市场部
  482. * 2.王鸽和主管及张总还有管理员号统一国交部
  483. * 2-1. 4 管理员 ,21 张海麟
  484. */
  485. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  486. List<int> userIds1 = new List<int>() { 4, 21 };
  487. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  488. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  489. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  490. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  491. .ToList();
  492. foreach (var item in _DelegationList)
  493. {
  494. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  495. }
  496. #endregion
  497. var _view = new
  498. {
  499. PageFuncAuth = pageFunAuthView,
  500. Data = _DelegationList
  501. };
  502. return Ok(JsonView(true, "查询成功!", _view, total));
  503. }
  504. /// <summary>
  505. /// 接团信息详情
  506. /// </summary>
  507. /// <param name="dto">团组info请求dto</param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  512. {
  513. var groupData = await _groupRepository.GetGroupInfo(dto);
  514. if (groupData.Code != 0)
  515. {
  516. return Ok(JsonView(false, groupData.Msg));
  517. }
  518. return Ok(JsonView(groupData.Data));
  519. }
  520. /// <summary>
  521. /// 接团信息 编辑添加
  522. /// 基础信息数据源
  523. /// </summary>
  524. /// <param name="dto"></param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  529. {
  530. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  531. if (groupData.Code != 0)
  532. {
  533. return Ok(JsonView(false, groupData.Msg));
  534. }
  535. return Ok(JsonView(groupData.Data));
  536. }
  537. /// <summary>
  538. /// 接团信息 操作(增改)
  539. /// </summary>
  540. /// <param name="dto"></param>
  541. /// <returns></returns>
  542. [HttpPost]
  543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  544. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  545. {
  546. try
  547. {
  548. var groupData = await _groupRepository.GroupOperation(dto);
  549. if (groupData.Code != 0)
  550. {
  551. return Ok(JsonView(false, groupData.Msg));
  552. }
  553. int diId = 0;
  554. //添加时 默认加入团组汇率
  555. if (dto.Status == 1) //添加
  556. {
  557. diId = groupData.Data;
  558. //添加默认币种
  559. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  560. //默认分配权限
  561. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  562. //消息提示 王鸽 主管号
  563. List<int> _managerIds = new List<int>() { 22, 32 };
  564. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  565. if (userIds.Count > 0)
  566. {
  567. userIds.Add(208);
  568. //创建团组管控
  569. GroupStepForDelegation.CreateWorkStep(diId);
  570. //发送消息
  571. string groupName = dto.TeamName;
  572. string createGroupUser = string.Empty;
  573. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  574. if (userInfo != null) createGroupUser = userInfo.CnName;
  575. string title = $"系统通知";
  576. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  577. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  578. }
  579. //默认创建倒推表
  580. await _invertedListRep._Create(dto.UserId, diId);
  581. }
  582. else if (dto.Status == 2)
  583. {
  584. diId = dto.Id;
  585. }
  586. return Ok(JsonView(true, "操作成功!", diId));
  587. }
  588. catch (Exception ex)
  589. {
  590. Logs("[response]" + JsonConvert.SerializeObject(dto));
  591. Logs(ex.Message);
  592. return Ok(JsonView(false, ex.Message));
  593. }
  594. }
  595. /// <summary>
  596. /// 接团流程操作(增改)
  597. /// 安卓端使用 建团时添加客户名单
  598. /// </summary>
  599. /// <param name="dto"></param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  604. {
  605. try
  606. {
  607. #region 参数验证
  608. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  609. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  610. #region 页面操作权限验证
  611. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  612. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  614. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  615. #endregion
  616. #endregion
  617. _sqlSugar.BeginTran();
  618. var _dto = new GroupOperationDto();
  619. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  620. var groupData = await _groupRepository.GroupOperation(_dto);
  621. if (groupData.Code != 0)
  622. {
  623. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  624. }
  625. int diId = 0;
  626. //添加时 默认加入团组汇率
  627. if (dto.Status == 1) //添加
  628. {
  629. diId = groupData.Data;
  630. //添加默认币种
  631. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  632. //默认分配权限
  633. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  634. //消息提示 王鸽 主管号
  635. List<int> _managerIds = new List<int>() { 22, 32 };
  636. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  637. if (userIds.Count > 0)
  638. {
  639. userIds.Add(208);
  640. //创建团组管控
  641. GroupStepForDelegation.CreateWorkStep(diId);
  642. //发送消息
  643. string groupName = dto.TeamName;
  644. string createGroupUser = string.Empty;
  645. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  646. if (userInfo != null) createGroupUser = userInfo.CnName;
  647. string title = $"系统通知";
  648. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  649. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  650. }
  651. }
  652. if (dto.Status == 2)
  653. {
  654. diId = dto.Id;
  655. if (diId == 0)
  656. {
  657. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  658. }
  659. }
  660. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  661. if (viewData.Code != 0)
  662. {
  663. _sqlSugar.RollbackTran();
  664. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  665. }
  666. _sqlSugar.CommitTran();
  667. return Ok(JsonView(true, "添加成功"));
  668. }
  669. catch (Exception ex)
  670. {
  671. _sqlSugar.RollbackTran();
  672. return Ok(JsonView(false, ex.Message));
  673. }
  674. }
  675. /// <summary>
  676. /// 接团信息 操作(删除)
  677. /// </summary>
  678. /// <param name="dto"></param>
  679. /// <returns></returns>
  680. [HttpPost]
  681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  682. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  683. {
  684. try
  685. {
  686. var groupData = await _groupRepository.GroupDel(dto);
  687. if (groupData.Code != 0)
  688. {
  689. return Ok(JsonView(false, groupData.Msg));
  690. }
  691. return Ok(JsonView(true));
  692. }
  693. catch (Exception ex)
  694. {
  695. Logs("[response]" + JsonConvert.SerializeObject(dto));
  696. Logs(ex.Message);
  697. return Ok(JsonView(false, ex.Message));
  698. }
  699. }
  700. /// <summary>
  701. /// 获取团组销售报价号
  702. /// 团组添加时 使用
  703. /// </summary>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> GetGroupSalesQuoteNo()
  708. {
  709. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  710. if (groupData.Code != 0)
  711. {
  712. return Ok(JsonView(false, groupData.Msg));
  713. }
  714. object salesQuoteNo = new
  715. {
  716. SalesQuoteNo = groupData.Data
  717. };
  718. return Ok(JsonView(salesQuoteNo));
  719. }
  720. /// <summary>
  721. /// 设置确认出团
  722. /// </summary>
  723. /// <param name="dto"></param>
  724. /// <returns></returns>
  725. [HttpPost]
  726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  727. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  728. {
  729. var groupData = await _groupRepository.ConfirmationGroup(dto);
  730. if (groupData.Code != 0)
  731. {
  732. return Ok(JsonView(false, groupData.Msg));
  733. }
  734. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  735. #region OA消息推送
  736. try
  737. {
  738. string groupName = groupInfo.TeamName;
  739. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  740. List<int> userIds = new List<int>();
  741. listUser.ForEach(s => userIds.Add(s.Id));
  742. string title = $"系统通知";
  743. string content = $"团组[{groupName}]已确认出团!";
  744. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  745. }
  746. catch (Exception ex)
  747. {
  748. }
  749. #endregion
  750. #region 应用推送
  751. try
  752. {
  753. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  754. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  755. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  756. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  757. {
  758. List<string> userList = new List<string>() { users.QiyeChatUserId };
  759. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  760. }
  761. }
  762. catch (Exception ex)
  763. {
  764. }
  765. #endregion
  766. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  767. return Ok(JsonView(true, "操作成功!", groupData.Data));
  768. }
  769. /// <summary>
  770. /// 获取团组名称data And 签证国别Data
  771. /// </summary>
  772. /// <param name="dto"></param>
  773. /// <returns></returns>
  774. [HttpPost]
  775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  776. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  777. {
  778. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  779. if (groupData.Code != 0)
  780. {
  781. return Ok(JsonView(false, groupData.Msg));
  782. }
  783. return Ok(JsonView(groupData.Data));
  784. }
  785. /// <summary>
  786. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  787. /// </summary>
  788. /// <returns></returns>
  789. [HttpPost]
  790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  791. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  792. {
  793. try
  794. {
  795. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, groupData.Msg));
  799. }
  800. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  801. }
  802. catch (Exception ex)
  803. {
  804. return Ok(JsonView(false, "程序错误!"));
  805. throw;
  806. }
  807. }
  808. #endregion
  809. #region 团组&签证
  810. /// <summary>
  811. /// 根据团组Id获取签证客户信息List
  812. /// </summary>
  813. /// <param name="dto">请求dto</param>
  814. /// <returns></returns>
  815. [HttpPost]
  816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  817. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  818. {
  819. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  820. if (groupData.Code != 0)
  821. {
  822. return Ok(JsonView(false, groupData.Msg));
  823. }
  824. return Ok(JsonView(groupData.Data));
  825. }
  826. /// <summary>
  827. /// IOS获取团组签证拍照上传进度01(团组列表)
  828. /// </summary>
  829. /// <param name="dto">请求dto</param>
  830. /// <returns></returns>
  831. [HttpPost]
  832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  833. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  834. {
  835. if (dto == null)
  836. {
  837. return Ok(JsonView(false, "参数为空"));
  838. }
  839. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  840. return Ok(JsonView(visaList));
  841. }
  842. /// <summary>
  843. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  844. /// </summary>
  845. /// <returns></returns>
  846. [HttpPost]
  847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  848. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  849. {
  850. if (dto == null)
  851. {
  852. return Ok(JsonView(false, "请求错误:"));
  853. }
  854. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  855. return Ok(JsonView(list));
  856. }
  857. /// <summary>
  858. /// IOS获取团组签证拍照上传进度03(相册)
  859. /// </summary>
  860. /// <returns></returns>
  861. [HttpPost]
  862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  863. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  864. {
  865. if (dto == null)
  866. {
  867. return Ok(JsonView(false, "请求错误:"));
  868. }
  869. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  870. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  871. list.ForEach(s => s.url = url);
  872. return Ok(JsonView(list));
  873. }
  874. /// <summary>
  875. /// IOS获取团组签证拍照上传进度04(图片上传)
  876. /// </summary>
  877. /// <param name="dto"></param>
  878. /// <returns></returns>
  879. [HttpPost]
  880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  881. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  882. {
  883. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  884. //if (!string.IsNullOrEmpty(result))
  885. //{
  886. //}
  887. //else {
  888. // return Ok(JsonView(false, "上传失败"));
  889. //}
  890. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  891. int sucNum = 0;
  892. try
  893. {
  894. foreach (var item in dto.base64DataList)
  895. {
  896. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  897. string result = decodeBase64ToImage(item, imageName);
  898. if (!string.IsNullOrEmpty(result))
  899. {
  900. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  901. pic.CreateUserId = dto.CreateUserId;
  902. pic.PicName = imageName;
  903. pic.PicPath = result;
  904. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  905. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  906. if (insertResult > 0)
  907. {
  908. sucNum++;
  909. }
  910. }
  911. }
  912. }
  913. catch (Exception ex)
  914. {
  915. return Ok(JsonView(false, ex.Message));
  916. }
  917. string msg = string.Format(@"成功上传{0}张", sucNum);
  918. return Ok(JsonView(true, msg));
  919. }
  920. private string decodeBase64ToImage(string base64DataURL, string imgName)
  921. {
  922. string filename = "";//声明一个string类型的相对路径
  923. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  924. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  925. try//会有异常抛出,try,catch一下
  926. {
  927. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  928. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  929. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  930. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  931. //文件名称
  932. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  933. //上传的文件的路径
  934. string filePath = "";
  935. if (!Directory.Exists(fileDir))
  936. {
  937. Directory.CreateDirectory(fileDir);
  938. }
  939. //上传的文件的路径
  940. filePath = fileDir + filename;
  941. //string url = HttpRuntime.AppDomainAppPath.ToString();
  942. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  943. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  944. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  945. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  946. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  947. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  948. ms.Close();//关闭当前流,并释放所有与之关联的资源
  949. bitmap.Dispose();
  950. }
  951. catch (Exception e)
  952. {
  953. string massage = e.Message;
  954. Logs("IOS图片上传Error:" + massage);
  955. //filename = e.Message;
  956. }
  957. return filename;//返回相对路径
  958. }
  959. /// <summary>
  960. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  967. {
  968. if (dto == null)
  969. {
  970. return Ok(JsonView(false, "请求错误:"));
  971. }
  972. string msg = "参数错误";
  973. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  974. {
  975. try
  976. {
  977. //_delegationVisaRep.BeginTran();
  978. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  979. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  980. .Where(s => s.Id == dto.visaProgressCustomerId)
  981. .ExecuteCommandAsync();
  982. if (updCount > 0 && dto.publishCode == 1)
  983. {
  984. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  985. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  986. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  987. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  988. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  989. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  990. if (groupData == null)
  991. {
  992. _delegationVisaRep.RollbackTran();
  993. }
  994. string title = string.Format(@"[签证进度更新]");
  995. string content = string.Format(@"测试文本");
  996. bool rst = await _message.AddMsg(new MessageDto()
  997. {
  998. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  999. IssuerId = dto.publisher,
  1000. Title = title,
  1001. Content = content,
  1002. ReleaseTime = DateTime.Now,
  1003. UIdList = new List<int> {
  1004. 234
  1005. }
  1006. });
  1007. if (rst)
  1008. {
  1009. return Ok(JsonView(true, "发送通知成功"));
  1010. }
  1011. }
  1012. //_delegationVisaRep.CommitTran();
  1013. }
  1014. catch (Exception)
  1015. {
  1016. //_delegationVisaRep.RollbackTran();
  1017. }
  1018. }
  1019. return Ok(JsonView(true, msg));
  1020. }
  1021. #endregion
  1022. #region 团组任务分配
  1023. /// <summary>
  1024. /// 团组任务分配初始化
  1025. /// </summary>
  1026. /// <param name="dto"></param>
  1027. /// <returns></returns>
  1028. [HttpPost]
  1029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1030. public async Task<IActionResult> GetTaskAssignmen()
  1031. {
  1032. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1033. if (groupData.Code != 0)
  1034. {
  1035. return Ok(JsonView(false, groupData.Msg));
  1036. }
  1037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1038. }
  1039. /// <summary>
  1040. /// 团组任务分配查询
  1041. /// </summary>
  1042. /// <param name="dto"></param>
  1043. /// <returns></returns>
  1044. [HttpPost]
  1045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1046. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1047. {
  1048. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1049. if (groupData.Code != 0)
  1050. {
  1051. return Ok(JsonView(false, groupData.Msg));
  1052. }
  1053. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1054. }
  1055. /// <summary>
  1056. /// 团组任务分配操作
  1057. /// </summary>
  1058. /// <param name="dto"></param>
  1059. /// <returns></returns>
  1060. [HttpPost]
  1061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1062. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1063. {
  1064. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1065. if (groupData.Code != 0)
  1066. {
  1067. return Ok(JsonView(false, groupData.Msg));
  1068. }
  1069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1070. }
  1071. #endregion
  1072. #region 团组费用审核
  1073. /// <summary>
  1074. /// 费用审核
  1075. /// 团组列表 Page
  1076. /// </summary>
  1077. /// <param name="_dto">团组列表请求dto</param>
  1078. /// <returns></returns>
  1079. [HttpPost]
  1080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1081. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1082. {
  1083. #region 参数验证
  1084. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1085. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1087. #region 页面操作权限验证
  1088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1089. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1090. #endregion
  1091. #endregion
  1092. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1093. {
  1094. string sqlWhere = string.Empty;
  1095. if (_dto.IsSure == 0) //未完成
  1096. {
  1097. sqlWhere += string.Format(@" And IsSure = 0");
  1098. }
  1099. else if (_dto.IsSure == 1) //已完成
  1100. {
  1101. sqlWhere += string.Format(@" And IsSure = 1");
  1102. }
  1103. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1104. {
  1105. string tj = _dto.SearchCriteria;
  1106. 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}%')",
  1107. tj, tj, tj, tj, tj);
  1108. }
  1109. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1110. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1111. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1112. From (
  1113. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1114. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1115. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1116. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1117. From Grp_DelegationInfo gdi
  1118. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1119. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1120. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1121. Where gdi.IsDel = 0 {0}
  1122. ) temp ", sqlWhere);
  1123. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1124. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1125. var _view = new
  1126. {
  1127. PageFuncAuth = pageFunAuthView,
  1128. Data = _DelegationList
  1129. };
  1130. return Ok(JsonView(true, "查询成功!", _view, total));
  1131. }
  1132. else
  1133. {
  1134. return Ok(JsonView(false, "查询失败"));
  1135. }
  1136. }
  1137. /// <summary>
  1138. /// 获取团组费用审核
  1139. /// </summary>
  1140. /// <param name="paras">参数Json字符串</param>
  1141. /// <returns></returns>
  1142. [HttpPost]
  1143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1144. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1145. {
  1146. try
  1147. {
  1148. #region 参数验证
  1149. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1150. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1151. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1152. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1153. #region 页面操作权限验证
  1154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1155. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1156. #endregion
  1157. #endregion
  1158. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1159. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1160. #region 费用清单
  1161. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1162. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1163. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1164. List<Grp_CreditCardPayment> entityList = _groupRepository
  1165. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1166. .Where(exp.ToExpression())
  1167. .ToList();
  1168. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1169. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1170. /*
  1171. * 76://酒店预订
  1172. */
  1173. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1174. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1175. .ToListAsync();
  1176. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1177. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1178. .ToListAsync();
  1179. /*
  1180. * 79://车/导游地接
  1181. */
  1182. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1183. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1184. .ToListAsync();
  1185. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1186. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1187. .ToListAsync();
  1188. /*
  1189. * 80: //签证
  1190. */
  1191. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1192. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1193. .ToListAsync();
  1194. /*
  1195. *81: //邀请/公务活动
  1196. */
  1197. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1198. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1199. .ToListAsync();
  1200. /*
  1201. * 82: //团组客户保险
  1202. */
  1203. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1204. /*
  1205. * Lable = 85 机票预订
  1206. */
  1207. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1208. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1209. .ToListAsync();
  1210. /*
  1211. * 85 机票预定
  1212. */
  1213. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1214. /*
  1215. * 98 其他款项
  1216. */
  1217. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1218. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1219. .ToListAsync();
  1220. /*
  1221. * 285:收款退还
  1222. */
  1223. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1224. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1225. .ToListAsync();
  1226. /*
  1227. * 1015: //超支费用
  1228. */
  1229. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1230. /*
  1231. * 币种信息
  1232. */
  1233. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1234. /*
  1235. * 车/导游地接 费用类型
  1236. */
  1237. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1238. /*
  1239. * 车/导游地接 费用类型
  1240. */
  1241. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1242. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1243. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1244. /*
  1245. * 用户信息
  1246. */
  1247. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1248. /*
  1249. * 费用模块
  1250. */
  1251. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1252. string priceModule = string.Empty;
  1253. if (sdPriceName != null)
  1254. {
  1255. priceModule = sdPriceName.Name;
  1256. }
  1257. /*
  1258. * 成本信息
  1259. */
  1260. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1261. decimal _groupRate = 0.0000M;
  1262. string _groupCurrencyCode = "-";
  1263. if (groupCost != null)
  1264. {
  1265. _groupRate = groupCost.Rate;
  1266. if (int.TryParse(groupCost.Currency, out int _currency))
  1267. {
  1268. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1269. }
  1270. else _groupCurrencyCode = groupCost.Currency;
  1271. }
  1272. string costContentSql = $"Select * From Grp_GroupCost";
  1273. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1274. //处理日期为空的天数
  1275. for (int i = 0; i < groupCostDetails.Count; i++)
  1276. if (i != 0)
  1277. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1278. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1279. /*
  1280. * 处理详情数据
  1281. */
  1282. foreach (var entity in entityList)
  1283. {
  1284. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1285. _detail.Id = entity.Id;
  1286. _detail.PriceName = priceModule;
  1287. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1288. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1289. /*
  1290. * 应付款金额
  1291. */
  1292. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1293. string PaymentCurrency_WaitPay = "Unknown";
  1294. string hotelCurrncyCode = "Unknown";
  1295. string hotelCurrncyName = "Unknown";
  1296. if (sdPaymentCurrency_WaitPay != null)
  1297. {
  1298. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1299. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1300. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1301. if (hotelCurrncyCode.Equals("CNY"))
  1302. {
  1303. entity.DayRate = 1.0000M;
  1304. }
  1305. }
  1306. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1307. /*
  1308. * 此次付款金额
  1309. */
  1310. decimal CurrPayStr = 0;
  1311. if (entity.PayPercentage == 0)
  1312. {
  1313. if (entity.PayThenMoney != 0)
  1314. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1315. }
  1316. else
  1317. {
  1318. if (entity.PayMoney != 0)
  1319. {
  1320. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1321. }
  1322. }
  1323. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1324. /*
  1325. * 剩余尾款
  1326. */
  1327. decimal BalanceStr = 0;
  1328. if (CurrPayStr != 0)
  1329. {
  1330. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1331. BalanceStr = 0;
  1332. else
  1333. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1334. }
  1335. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1336. /*
  1337. * Bus名称
  1338. */
  1339. _detail.BusName = "待增加";
  1340. /*
  1341. *费用所属
  1342. */
  1343. switch (entity.CTable)
  1344. {
  1345. case 76://酒店预订
  1346. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1347. if (hotelReservations != null)
  1348. {
  1349. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1350. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1351. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1352. string roomFeeStr = "", roomFeestr1 = "";
  1353. //是否比较房型价格
  1354. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1355. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1356. if (hotelReservations.SingleRoomPrice > 0)
  1357. { roomFeestr1 += $"单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}"; __isSingle = true; }
  1358. if (hotelReservations.DoubleRoomPrice > 0)
  1359. { roomFeestr1 += $"双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}"; __isDouble = true; }
  1360. if (hotelReservations.SuiteRoomPrice > 0)
  1361. { roomFeestr1 += $"套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}"; __isSuite = true; }
  1362. if (hotelReservations.OtherRoomPrice > 0)
  1363. { roomFeestr1 += $"其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}"; __isOther = true; }
  1364. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1365. else roomFeeStr += " 0.00 * 0";
  1366. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1367. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1368. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1369. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1370. /*
  1371. * 费用类型
  1372. * 1:房费
  1373. * 2:早餐
  1374. * 3:地税
  1375. * 4:城市税
  1376. * </summary>
  1377. */
  1378. //地税
  1379. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1380. if (governmentRentData != null)
  1381. {
  1382. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1383. governmentRentFee = governmentRentData.Price;
  1384. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1385. if (governmentRentCurrData != null)
  1386. {
  1387. governmentRentCode = governmentRentCurrData.Name;
  1388. governmentRentName = $"({governmentRentCurrData.Remark})";
  1389. }
  1390. }
  1391. //城市税
  1392. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1393. if (cityTaxData != null)
  1394. {
  1395. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1396. cityTaxFee = cityTaxData.Price;
  1397. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1398. if (cityTaxCurrData != null)
  1399. {
  1400. cityTaxCode = cityTaxCurrData.Name;
  1401. cityTaxName = $"({cityTaxCurrData.Remark})";
  1402. }
  1403. }
  1404. //酒店早餐
  1405. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1406. if (breakfastData != null)
  1407. {
  1408. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1409. breakfastFee = breakfastData.Price;
  1410. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1411. if (breakfastCurrData != null)
  1412. {
  1413. breakfastCode = breakfastCurrData.Name;
  1414. breakfastName = $"({breakfastCurrData.Remark})";
  1415. }
  1416. }
  1417. //房间费用
  1418. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1419. if (roomData != null)
  1420. {
  1421. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1422. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1423. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1424. roomFee = roomData.Price;
  1425. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1426. if (roomCurrData != null)
  1427. {
  1428. roomCode = roomCurrData.Name;
  1429. roomName = $"({roomCurrData.Remark})";
  1430. }
  1431. }
  1432. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1433. string hotelCostStr = "";
  1434. decimal hotelCsotTotal = 0.00M;
  1435. if (groupCost != null)
  1436. {
  1437. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1438. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1439. }
  1440. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1441. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1442. string hotelCost_day = "";
  1443. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1444. foreach (var item in hotelCostDetails1)
  1445. {
  1446. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1447. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1448. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1449. else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1450. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1451. else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1452. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1453. else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1454. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1455. else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1456. hotelCost_day += @$"</br>";
  1457. }
  1458. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1459. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1460. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1461. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1462. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1463. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1464. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1465. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1466. $"房间说明: {hotelReservations.Remark} <br/>" +
  1467. $"房间费用: {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接代付:{roomBool}<br/><br/>" +
  1468. $"{hotelBreakfastStr}" +
  1469. $"{hotelGovernmentRentStr}" +
  1470. $"{hotelCityTaxStr}";
  1471. _detail.PriceNameContent = hotelReservations.HotelName;
  1472. }
  1473. break;
  1474. case 79://车/导游地接
  1475. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1476. if (touristGuideGroundReservations != null)
  1477. {
  1478. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1479. {
  1480. _detail.BusName = touristGuideGroundReservations.BusName;
  1481. }
  1482. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1483. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1484. //if (isInt)
  1485. //{
  1486. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1487. // if (cityInfo != null)
  1488. // {
  1489. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1490. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1491. // if (carFeeItem != null)
  1492. // {
  1493. // nameContent += $@"({carFeeItem.Name})";
  1494. // }
  1495. // _detail.PriceNameContent = nameContent;
  1496. // }
  1497. //}
  1498. //else
  1499. //{
  1500. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1501. //}
  1502. var touristGuideGroundReservationsContents =
  1503. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1504. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1505. foreach (var item in touristGuideGroundReservationsContents)
  1506. {
  1507. string typeName = "Unknown";
  1508. string carCurrencyCode = "Unknown";
  1509. string carCurrencyName = "Unknown";
  1510. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1511. if (carTypeData != null) typeName = carTypeData.Name;
  1512. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1513. if (currencyData != null)
  1514. {
  1515. carCurrencyCode = currencyData.Name;
  1516. carCurrencyName = currencyData.Remark;
  1517. }
  1518. string opCostStr = string.Empty;
  1519. decimal opCostTypePrice = 0.00M;
  1520. #region 处理成本各项费用
  1521. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1522. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1523. if (opCost.Count > 0)
  1524. {
  1525. switch (item.SId)
  1526. {
  1527. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1528. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1529. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1530. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1531. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1532. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1533. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1534. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1535. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1536. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1537. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1538. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1539. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1540. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1541. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1542. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1543. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1544. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1545. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1546. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1547. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1548. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1549. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1550. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1551. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1552. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1553. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1554. }
  1555. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1556. }
  1557. #endregion
  1558. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1559. $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1560. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1561. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1562. }
  1563. _detail.PriceMsgContent = priceMsg;
  1564. }
  1565. break;
  1566. case 80: //签证
  1567. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1568. if (visaInfo != null)
  1569. {
  1570. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1571. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1572. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1573. }
  1574. break;
  1575. case 81: //邀请/公务活动
  1576. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1577. if (_ioa != null)
  1578. {
  1579. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1580. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1581. sendCurrName = "Unknown", //快递费用币种 Name
  1582. sendCurrCode = "Unknown", //快递费用币种 Code
  1583. eventsCurrName = "Unknown", //公务活动费币种 Name
  1584. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1585. translateCurrName = "Unknown", //公务翻译费 Name
  1586. translateCurrCode = "Unknown"; //公务翻译费 Code
  1587. #region 处理费用币种
  1588. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1589. if (inviteCurrData != null)
  1590. {
  1591. inviteCurrName = inviteCurrData.Remark;
  1592. inviteCurrCode = inviteCurrData.Name;
  1593. }
  1594. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1595. if (sendCurrData != null)
  1596. {
  1597. sendCurrName = sendCurrData.Remark;
  1598. sendCurrCode = sendCurrData.Name;
  1599. }
  1600. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1601. if (eventsCurrData != null)
  1602. {
  1603. eventsCurrName = eventsCurrData.Remark;
  1604. eventsCurrCode = eventsCurrData.Name;
  1605. }
  1606. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1607. if (translateCurrData != null)
  1608. {
  1609. translateCurrName = translateCurrData.Remark;
  1610. translateCurrCode = translateCurrData.Name;
  1611. }
  1612. #endregion
  1613. _detail.PriceNameContent = _ioa.InviterArea;
  1614. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1615. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1616. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1617. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1618. $@"备注:" + _ioa.Remark + "<br/>";
  1619. }
  1620. break;
  1621. case 82: //团组客户保险
  1622. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1623. if (customers != null)
  1624. {
  1625. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1626. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1627. }
  1628. break;
  1629. case 85: //机票预订
  1630. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1631. if (jpRes != null)
  1632. {
  1633. string FlightsDescription = jpRes.FlightsDescription;
  1634. string PriceDescription = jpRes.PriceDescription;
  1635. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1636. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1637. }
  1638. break;
  1639. case 98://其他款项
  1640. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1641. if (gdpRes != null)
  1642. {
  1643. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1644. _detail.PriceNameContent = gdpRes.PriceName;
  1645. }
  1646. break;
  1647. case 285://收款退还
  1648. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1649. if (refundAndOtherMoney != null)
  1650. {
  1651. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1652. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1653. }
  1654. break;
  1655. case 751://酒店早餐
  1656. break;
  1657. case 1015://超支费用
  1658. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1659. if (groupExtraCost != null)
  1660. {
  1661. _detail.PriceNameContent = groupExtraCost.PriceName;
  1662. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1663. }
  1664. break;
  1665. default:
  1666. break;
  1667. }
  1668. /*
  1669. * 申请人
  1670. */
  1671. string operatorName = " - ";
  1672. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1673. if (_opUser != null)
  1674. {
  1675. operatorName = _opUser.CnName;
  1676. }
  1677. _detail.OperatorName = operatorName;
  1678. /*
  1679. * 审核人
  1680. */
  1681. string auditOperatorName = "Unknown";
  1682. if (entity.AuditGMOperate == 0)
  1683. auditOperatorName = " - ";
  1684. else if (entity.AuditGMOperate == 4)
  1685. auditOperatorName = "自动审核";
  1686. else
  1687. {
  1688. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1689. if (_adUser != null)
  1690. {
  1691. auditOperatorName = _adUser.CnName;
  1692. }
  1693. }
  1694. _detail.AuditOperatorName = auditOperatorName;
  1695. /*
  1696. * 超预算比例
  1697. */
  1698. string overBudgetStr = "";
  1699. if (entity.ExceedBudget == -1)
  1700. overBudgetStr = sdPriceName.Name + "尚无预算";
  1701. else if (entity.ExceedBudget == 0)
  1702. {
  1703. if (entity.CTable == 76 || entity.CTable == 79)
  1704. {
  1705. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1706. else overBudgetStr = "超预算";
  1707. }
  1708. else
  1709. {
  1710. overBudgetStr = "未超预算";
  1711. }
  1712. }
  1713. else
  1714. overBudgetStr = entity.ExceedBudget.ToString("P");
  1715. _detail.OverBudget = overBudgetStr;
  1716. /*
  1717. * 费用总计
  1718. */
  1719. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1720. {
  1721. CurrencyId = entity.PaymentCurrency,
  1722. CurrencyName = PaymentCurrency_WaitPay,
  1723. AmountPayable = entity.PayMoney,
  1724. ThisPayment = CurrPayStr,
  1725. BalancePayment = BalanceStr,
  1726. AuditedFunds = CurrPayStr
  1727. });
  1728. _detail.IsAuditGM = entity.IsAuditGM;
  1729. detailList.Add(_detail);
  1730. }
  1731. #endregion
  1732. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1733. /*
  1734. * 下方描述处理
  1735. */
  1736. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1737. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1738. if (ccpCurrencyPrice != null)
  1739. {
  1740. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1741. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1742. }
  1743. else
  1744. {
  1745. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1746. }
  1747. string amountPayableStr = string.Format(@"应付款总金额: ");
  1748. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1749. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1750. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1751. foreach (var item in nonDuplicat)
  1752. {
  1753. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1754. if (strs.Count > 0)
  1755. {
  1756. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1757. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1758. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1759. //单独处理此次付款金额
  1760. if (item.CurrencyId == 836) //人民币
  1761. {
  1762. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1763. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1764. }
  1765. else
  1766. {
  1767. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1768. }
  1769. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1770. //单独处理已审核费用
  1771. if (item.CurrencyId == 836) //人民币
  1772. {
  1773. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1774. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1775. }
  1776. else
  1777. {
  1778. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1779. }
  1780. }
  1781. }
  1782. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1783. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1784. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1785. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1786. var _view1 = new
  1787. {
  1788. PageFuncAuth = pageFunAuthView,
  1789. Data = _view
  1790. };
  1791. return Ok(JsonView(_view1));
  1792. }
  1793. catch (Exception ex)
  1794. {
  1795. return Ok(JsonView(false, ex.Message));
  1796. }
  1797. }
  1798. /// <summary>
  1799. /// 费用审核
  1800. /// 修改团组费用审核状态
  1801. /// </summary>
  1802. /// <param name="_dto">参数Json字符串</param>
  1803. /// <returns></returns>
  1804. [HttpPost]
  1805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1806. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1807. {
  1808. #region 参数验证
  1809. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1810. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1811. #endregion
  1812. #region 页面操作权限验证
  1813. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1814. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1815. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1816. #endregion
  1817. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1818. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1819. DateTime dtNow = DateTime.Now;
  1820. _groupRepository.BeginTran();
  1821. int rst = 0;
  1822. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1823. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1824. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1825. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1826. List<dynamic> msgDatas = new List<dynamic>();
  1827. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1828. foreach (var item in idList)
  1829. {
  1830. int CreditId = int.Parse(item);
  1831. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1832. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1833. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1834. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1835. .Where(s => s.Id == CreditId)
  1836. .ExecuteCommandAsync();
  1837. if (result < 1)
  1838. {
  1839. rst = -1;
  1840. _groupRepository.RollbackTran();
  1841. return Ok(JsonView(false, "操作失败并回滚!"));
  1842. }
  1843. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1844. if (creditData != null)
  1845. {
  1846. #region 应用通知配置
  1847. try
  1848. {
  1849. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1850. }
  1851. catch (Exception ex)
  1852. {
  1853. }
  1854. #endregion
  1855. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1856. string groupNameStr = string.Empty;
  1857. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1858. if (groupData != null) groupNameStr = groupData.TeamName;
  1859. string creditTypeStr = string.Empty;
  1860. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1861. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1862. string creditCurrency = string.Empty;
  1863. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1864. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1865. if (creditCurrency.Equals("CNY"))
  1866. {
  1867. creditData.DayRate = 1.0000M;
  1868. }
  1869. if (creditData.PayPercentage == 0.00M)
  1870. {
  1871. creditData.PayPercentage = 100M;
  1872. }
  1873. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1874. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1875. string msgContent = "";
  1876. if (creditCurrency.Equals("CNY"))
  1877. {
  1878. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1879. }
  1880. else
  1881. {
  1882. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1883. }
  1884. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1885. }
  1886. }
  1887. if (rst == 0)
  1888. {
  1889. _groupRepository.CommitTran();
  1890. foreach (var item in msgDatas)
  1891. {
  1892. //发送消息
  1893. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1894. }
  1895. #region 应用推送
  1896. try
  1897. {
  1898. foreach (var ccpId in dic_ccp_user.Keys)
  1899. {
  1900. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1901. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1902. }
  1903. }
  1904. catch (Exception)
  1905. {
  1906. }
  1907. #endregion
  1908. return Ok(JsonView(true, "操作成功!"));
  1909. }
  1910. return Ok(JsonView(false, "操作失败!"));
  1911. }
  1912. #endregion
  1913. #region 机票费用录入
  1914. /// <summary>
  1915. /// 机票录入当前登录人可操作团组
  1916. /// </summary>
  1917. /// <param name="dto"></param>
  1918. /// <returns></returns>
  1919. [HttpPost]
  1920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1921. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1922. {
  1923. try
  1924. {
  1925. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1926. if (groupData.Code != 0)
  1927. {
  1928. return Ok(JsonView(false, groupData.Msg));
  1929. }
  1930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1931. }
  1932. catch (Exception ex)
  1933. {
  1934. return Ok(JsonView(false, "程序错误!"));
  1935. throw;
  1936. }
  1937. }
  1938. /// <summary>
  1939. /// 机票费用录入列表
  1940. /// </summary>
  1941. /// <param name="dto"></param>
  1942. /// <returns></returns>
  1943. [HttpPost]
  1944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1945. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1946. {
  1947. try
  1948. {
  1949. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1950. if (groupData.Code != 0)
  1951. {
  1952. return Ok(JsonView(false, groupData.Msg));
  1953. }
  1954. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1955. }
  1956. catch (Exception ex)
  1957. {
  1958. return Ok(JsonView(false, ex.Message));
  1959. throw;
  1960. }
  1961. }
  1962. /// <summary>
  1963. /// 根据id查询费用录入信息
  1964. /// </summary>
  1965. /// <param name="dto"></param>
  1966. /// <returns></returns>
  1967. [HttpPost]
  1968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1969. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1970. {
  1971. try
  1972. {
  1973. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1974. if (groupData.Code != 0)
  1975. {
  1976. return Ok(JsonView(false, groupData.Msg));
  1977. }
  1978. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1979. }
  1980. catch (Exception ex)
  1981. {
  1982. return Ok(JsonView(false, "程序错误!"));
  1983. throw;
  1984. }
  1985. }
  1986. /// <summary>
  1987. /// 机票费用录入操作(Status:1.新增,2.修改)
  1988. /// </summary>
  1989. /// <param name="dto"></param>
  1990. /// <returns></returns>
  1991. [HttpPost]
  1992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1993. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1994. {
  1995. try
  1996. {
  1997. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1998. if (groupData.Code != 0)
  1999. {
  2000. return Ok(JsonView(false, groupData.Msg));
  2001. }
  2002. #region 应用推送
  2003. try
  2004. {
  2005. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2006. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2007. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2008. }
  2009. catch (Exception ex)
  2010. {
  2011. }
  2012. #endregion
  2013. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2014. }
  2015. catch (Exception ex)
  2016. {
  2017. return Ok(JsonView(false, "程序错误!"));
  2018. throw;
  2019. }
  2020. }
  2021. /// <summary>
  2022. /// 根据舱位类型查询接团客户名单信息
  2023. /// </summary>
  2024. /// <param name="dto"></param>
  2025. /// <returns></returns>
  2026. [HttpPost]
  2027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2028. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2029. {
  2030. try
  2031. {
  2032. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2033. if (crm_Groups.Count != 0)
  2034. {
  2035. List<dynamic> Customer = new List<dynamic>();
  2036. foreach (var item in crm_Groups)
  2037. {
  2038. var data = new
  2039. {
  2040. Id = item.Id,
  2041. Pinyin = item.Pinyin,
  2042. Name = item.LastName + item.FirstName
  2043. };
  2044. Customer.Add(data);
  2045. }
  2046. return Ok(JsonView(true, "查询成功!", Customer));
  2047. }
  2048. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2049. }
  2050. catch (Exception ex)
  2051. {
  2052. return Ok(JsonView(false, "程序错误!"));
  2053. throw;
  2054. }
  2055. }
  2056. /// <summary>
  2057. /// 根据团号获取客户信息
  2058. /// </summary>
  2059. /// <param name="dto"></param>
  2060. /// <returns></returns>
  2061. [HttpPost]
  2062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2063. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2064. {
  2065. var jw = JsonView(false);
  2066. if (dto.DIID < 1)
  2067. {
  2068. jw.Msg += "请输入正确的diid";
  2069. return Ok(jw);
  2070. }
  2071. var arr = getSimplClientList(dto.DIID);
  2072. jw = JsonView(true, "获取成功!", arr);
  2073. return Ok(jw);
  2074. }
  2075. private List<SimplClientInfo> getSimplClientList(int diId)
  2076. {
  2077. 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);
  2078. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2079. return arr;
  2080. }
  2081. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2082. {
  2083. string result = origin;
  2084. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2085. {
  2086. string[] temparr = origin.Split(',');
  2087. string fistrStr = temparr[0];
  2088. int count = temparr.Count();
  2089. int tempId;
  2090. bool success = int.TryParse(fistrStr, out tempId);
  2091. if (success)
  2092. {
  2093. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2094. if (tempInfo != null)
  2095. {
  2096. if (count > 1)
  2097. {
  2098. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2099. }
  2100. else
  2101. {
  2102. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2103. }
  2104. }
  2105. }
  2106. }
  2107. return result;
  2108. }
  2109. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2110. {
  2111. string result = origin;
  2112. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2113. {
  2114. string[] temparr = origin.Split(',');
  2115. result = "";
  2116. foreach (var item in temparr)
  2117. {
  2118. int tempId;
  2119. bool success = int.TryParse(item, out tempId);
  2120. if (success)
  2121. {
  2122. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2123. if (tempInfo != null)
  2124. {
  2125. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2126. }
  2127. }
  2128. }
  2129. }
  2130. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2131. return result;
  2132. }
  2133. /// <summary>
  2134. /// 机票费用录入,删除
  2135. /// </summary>
  2136. /// <param name="dto"></param>
  2137. /// <returns></returns>
  2138. [HttpPost]
  2139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2140. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2141. {
  2142. try
  2143. {
  2144. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2145. if (res)
  2146. {
  2147. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2148. {
  2149. IsDel = 1,
  2150. DeleteUserId = dto.DeleteUserId,
  2151. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2152. }).ExecuteCommandAsync();
  2153. return Ok(JsonView(true, "删除成功!"));
  2154. }
  2155. return Ok(JsonView(false, "删除失败!"));
  2156. }
  2157. catch (Exception ex)
  2158. {
  2159. return Ok(JsonView(false, "程序错误!"));
  2160. throw;
  2161. }
  2162. }
  2163. /// <summary>
  2164. /// 导出机票录入报表
  2165. /// </summary>
  2166. /// <param name="dto"></param>
  2167. /// <returns></returns>
  2168. [HttpPost]
  2169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2170. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2171. {
  2172. try
  2173. {
  2174. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2175. if (groupData.Code != 0)
  2176. {
  2177. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2178. }
  2179. else
  2180. {
  2181. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2182. if (AirTicketReservations.Count != 0)
  2183. {
  2184. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2185. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2186. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2187. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2188. WorkbookDesigner designer = new WorkbookDesigner();
  2189. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2190. decimal countCost = 0;
  2191. foreach (var item in AirTicketReservations)
  2192. {
  2193. #region 处理客人姓名
  2194. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2195. item.ClientName = clientNames;
  2196. #endregion
  2197. if (item.BankType == "其他")
  2198. {
  2199. item.BankNo = "--";
  2200. }
  2201. else
  2202. {
  2203. if (!string.IsNullOrEmpty(item.BankType))
  2204. {
  2205. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2206. }
  2207. }
  2208. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2209. item.Price = System.Decimal.Round(item.Price, 2);
  2210. countCost += Convert.ToDecimal(item.Price);
  2211. }
  2212. designer.SetDataSource("Export", AirTicketReservations);
  2213. designer.SetDataSource("ExportDiCode", diCode);
  2214. designer.SetDataSource("ExportDiName", diName);
  2215. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2216. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2217. designer.Process();
  2218. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2219. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2220. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2221. return Ok(JsonView(true, "成功", url = rst));
  2222. }
  2223. else
  2224. {
  2225. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2226. }
  2227. }
  2228. }
  2229. catch (Exception ex)
  2230. {
  2231. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2232. throw;
  2233. }
  2234. }
  2235. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2236. /// <summary>
  2237. /// 行程单导出
  2238. /// </summary>
  2239. /// <param name="dto"></param>
  2240. /// <returns></returns>
  2241. [HttpPost]
  2242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2243. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2244. {
  2245. try
  2246. {
  2247. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2248. if (groupData.Code != 0)
  2249. {
  2250. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2251. }
  2252. else
  2253. {
  2254. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2255. if (dto.Language == "CN")
  2256. {
  2257. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2258. DocumentBuilder builder = new DocumentBuilder(doc);
  2259. int tableIndex = 0;//表格索引
  2260. //得到文档中的第一个表格
  2261. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2262. foreach (var item in _AirTicketReservations)
  2263. {
  2264. #region 处理固定数据
  2265. string[] FlightsCode = item.FlightsCode.Split('/');
  2266. if (FlightsCode.Length != 0)
  2267. {
  2268. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2269. if (_AirCompany != null)
  2270. {
  2271. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2272. }
  2273. else
  2274. {
  2275. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2276. }
  2277. }
  2278. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2279. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2280. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2281. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2282. string name = "";
  2283. foreach (string clientName in nameArray)
  2284. {
  2285. if (!name.Contains(clientName))
  2286. {
  2287. name += clientName + ",";
  2288. }
  2289. }
  2290. if (!string.IsNullOrWhiteSpace(name))
  2291. {
  2292. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2293. }
  2294. else
  2295. {
  2296. table.Range.Bookmarks["ClientName"].Text = "--";
  2297. }
  2298. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2299. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2300. table.Range.Bookmarks["JointTicket"].Text = "--";
  2301. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2302. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2303. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2304. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2305. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2306. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2307. #endregion
  2308. #region 循环数据处理
  2309. List<AirInfo> airs = new List<AirInfo>();
  2310. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2311. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2312. for (int i = 0; i < FlightsCode.Length; i++)
  2313. {
  2314. AirInfo air = new AirInfo();
  2315. string[] tempstr = DayArray[i]
  2316. .Replace("\r\n", string.Empty)
  2317. .Replace("\\r\\n", string.Empty)
  2318. .TrimStart().TrimEnd()
  2319. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2320. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2321. string starCity = "";
  2322. if (star_Three != null)
  2323. {
  2324. starCity = star_Three.AirPort;
  2325. }
  2326. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2327. string EndCity = "";
  2328. if (End_Three != null)
  2329. {
  2330. EndCity = End_Three.AirPort;
  2331. }
  2332. air.Destination = starCity + "/" + EndCity;
  2333. air.Flight = FlightsCode[i];
  2334. air.SeatingClass = item.CTypeName;
  2335. string dateTime = tempstr[2];
  2336. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2337. air.FlightDate = DateTemp;
  2338. air.DepartureTime = tempstr[5];
  2339. air.LandingTime = tempstr[6];
  2340. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2341. air.TicketStatus = "--";
  2342. air.Luggage = "--";
  2343. air.DepartureTerminal = "--";
  2344. air.LandingTerminal = "--";
  2345. airs.Add(air);
  2346. }
  2347. int row = 13;
  2348. for (int i = 0; i < airs.Count; i++)
  2349. {
  2350. if (airs.Count > 2)
  2351. {
  2352. for (int j = 0; j < airs.Count - 2; j++)
  2353. {
  2354. var CopyRow = table.Rows[12].Clone(true);
  2355. table.Rows.Add(CopyRow);
  2356. }
  2357. }
  2358. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2359. int index = 0;
  2360. foreach (PropertyInfo property in properties)
  2361. {
  2362. string value = property.GetValue(airs[i]).ToString();
  2363. Cell ishcel0 = table.Rows[row].Cells[index];
  2364. Paragraph p = new Paragraph(doc);
  2365. string s = value;
  2366. p.AppendChild(new Run(doc, s));
  2367. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2368. ishcel0.AppendChild(p);
  2369. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2370. index++;
  2371. }
  2372. row++;
  2373. }
  2374. #endregion
  2375. Paragraph lastParagraph = new Paragraph(doc);
  2376. //第一个表格末尾加段落
  2377. table.ParentNode.InsertAfter(lastParagraph, table);
  2378. //复制第一个表格
  2379. Table cloneTable = (Table)table.Clone(true);
  2380. //在文档末尾段落后面加入复制的表格
  2381. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2382. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2383. {
  2384. int rownewsIndex = 13;
  2385. for (int i = 0; i < 2; i++)
  2386. {
  2387. var CopyRow = table.Rows[12].Clone(true);
  2388. table.Rows.RemoveAt(13);
  2389. table.Rows.Add(CopyRow);
  2390. rownewsIndex++;
  2391. }
  2392. }
  2393. else
  2394. {
  2395. table.Rows.RemoveAt(12);
  2396. }
  2397. cloneTable.Rows.RemoveAt(12);
  2398. }
  2399. if (_AirTicketReservations.Count != 0)
  2400. {
  2401. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2402. if (FlightsCode.Length != 0)
  2403. {
  2404. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2405. if (_AirCompany != null)
  2406. {
  2407. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2408. }
  2409. else
  2410. {
  2411. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2412. }
  2413. }
  2414. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2415. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2416. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2417. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2418. string name = "";
  2419. foreach (string clientName in nameArray)
  2420. {
  2421. if (!name.Contains(clientName))
  2422. {
  2423. name += clientName + ",";
  2424. }
  2425. }
  2426. if (!string.IsNullOrWhiteSpace(name))
  2427. {
  2428. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2429. }
  2430. else
  2431. {
  2432. table.Range.Bookmarks["ClientName"].Text = "--";
  2433. }
  2434. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2435. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2436. table.Range.Bookmarks["JointTicket"].Text = "--";
  2437. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2438. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2439. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2440. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2441. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2442. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2443. }
  2444. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2445. //保存合并后的文档
  2446. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2447. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2448. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2449. return Ok(JsonView(true, "成功!", rst));
  2450. }
  2451. else
  2452. {
  2453. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2454. DocumentBuilder builder = new DocumentBuilder(doc);
  2455. int tableIndex = 0;//表格索引
  2456. //得到文档中的第一个表格
  2457. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2458. List<string> texts = new List<string>();
  2459. foreach (var item in _AirTicketReservations)
  2460. {
  2461. string[] FlightsCode = item.FlightsCode.Split('/');
  2462. if (FlightsCode.Length != 0)
  2463. {
  2464. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2465. if (_AirCompany != null)
  2466. {
  2467. if (!transDic.ContainsKey(_AirCompany.CnName))
  2468. {
  2469. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2470. }
  2471. }
  2472. else
  2473. {
  2474. if (!transDic.ContainsKey("--"))
  2475. {
  2476. transDic.Add("--", "--");
  2477. }
  2478. }
  2479. }
  2480. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2481. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2482. string name = "";
  2483. foreach (string clientName in nameArray)
  2484. {
  2485. name += clientName + ",";
  2486. }
  2487. if (!texts.Contains(name))
  2488. {
  2489. texts.Add(name);
  2490. }
  2491. List<AirInfo> airs = new List<AirInfo>();
  2492. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2493. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2494. for (int i = 0; i < FlightsCode.Length; i++)
  2495. {
  2496. AirInfo air = new AirInfo();
  2497. string[] tempstr = DayArray[i]
  2498. .Replace("\r\n", string.Empty)
  2499. .Replace("\\r\\n", string.Empty)
  2500. .TrimStart().TrimEnd()
  2501. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2502. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2503. if (star_Three != null)
  2504. {
  2505. if (!transDic.ContainsKey(star_Three.AirPort))
  2506. {
  2507. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2508. }
  2509. }
  2510. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2511. if (End_Three != null)
  2512. {
  2513. if (!transDic.ContainsKey(End_Three.AirPort))
  2514. {
  2515. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2516. }
  2517. }
  2518. if (!texts.Contains(item.CTypeName))
  2519. {
  2520. texts.Add(item.CTypeName);
  2521. }
  2522. }
  2523. }
  2524. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2525. if (transData.Count > 0)
  2526. {
  2527. foreach (TranslateResult item in transData)
  2528. {
  2529. if (!transDic.ContainsKey(item.Query))
  2530. {
  2531. transDic.Add(item.Query, item.Translation);
  2532. }
  2533. }
  2534. }
  2535. foreach (var item in _AirTicketReservations)
  2536. {
  2537. #region 处理固定数据
  2538. string[] FlightsCode = item.FlightsCode.Split('/');
  2539. if (FlightsCode.Length != 0)
  2540. {
  2541. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2542. if (_AirCompany != null)
  2543. {
  2544. string str = "--";
  2545. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2546. if (!string.IsNullOrEmpty(translateResult))
  2547. {
  2548. str = translateResult;
  2549. str = _airTicketResRep.Processing(str);
  2550. }
  2551. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2552. }
  2553. else
  2554. {
  2555. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2556. }
  2557. }
  2558. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2559. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2560. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2561. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2562. string names = "";
  2563. foreach (string clientName in nameArray)
  2564. {
  2565. names += clientName + ",";
  2566. }
  2567. if (!string.IsNullOrWhiteSpace(names))
  2568. {
  2569. string str = "--";
  2570. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2571. if (!string.IsNullOrEmpty(translateResult))
  2572. {
  2573. str = translateResult;
  2574. str = _airTicketResRep.Processing(str);
  2575. }
  2576. table.Range.Bookmarks["ClientName"].Text = str;
  2577. }
  2578. else
  2579. {
  2580. table.Range.Bookmarks["ClientName"].Text = "--";
  2581. }
  2582. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2583. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2584. table.Range.Bookmarks["JointTicket"].Text = "--";
  2585. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2586. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2587. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2588. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2589. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2590. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2591. #endregion
  2592. #region 循环数据处理
  2593. List<AirInfo> airs = new List<AirInfo>();
  2594. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2595. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2596. for (int i = 0; i < FlightsCode.Length; i++)
  2597. {
  2598. AirInfo air = new AirInfo();
  2599. string[] tempstr = DayArray[i]
  2600. .Replace("\r\n", string.Empty)
  2601. .Replace("\\r\\n", string.Empty)
  2602. .TrimStart().TrimEnd()
  2603. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2604. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2605. string starCity = "";
  2606. if (star_Three != null)
  2607. {
  2608. string str2 = "--";
  2609. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2610. if (!string.IsNullOrEmpty(translateResult2))
  2611. {
  2612. str2 = translateResult2;
  2613. str2 = _airTicketResRep.Processing(str2);
  2614. }
  2615. starCity = str2;
  2616. }
  2617. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2618. string EndCity = "";
  2619. if (End_Three != null)
  2620. {
  2621. string str1 = "--";
  2622. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2623. if (!string.IsNullOrEmpty(translateResult1))
  2624. {
  2625. str1 = translateResult1;
  2626. str1 = _airTicketResRep.Processing(str1);
  2627. }
  2628. EndCity = str1;
  2629. }
  2630. air.Destination = starCity + "/" + EndCity;
  2631. air.Flight = FlightsCode[i];
  2632. string str = "--";
  2633. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2634. if (!string.IsNullOrEmpty(translateResult))
  2635. {
  2636. str = translateResult;
  2637. str = _airTicketResRep.Processing(str);
  2638. }
  2639. air.SeatingClass = str;
  2640. string dateTime = tempstr[2];
  2641. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2642. air.FlightDate = DateTemp;
  2643. air.DepartureTime = tempstr[5];
  2644. air.LandingTime = tempstr[6];
  2645. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2646. air.TicketStatus = "--";
  2647. air.Luggage = "--";
  2648. air.DepartureTerminal = "--";
  2649. air.LandingTerminal = "--";
  2650. airs.Add(air);
  2651. }
  2652. int row = 13;
  2653. for (int i = 0; i < airs.Count; i++)
  2654. {
  2655. if (airs.Count > 2)
  2656. {
  2657. for (int j = 0; j < airs.Count - 2; j++)
  2658. {
  2659. var CopyRow = table.Rows[12].Clone(true);
  2660. table.Rows.Add(CopyRow);
  2661. }
  2662. }
  2663. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2664. int index = 0;
  2665. foreach (PropertyInfo property in properties)
  2666. {
  2667. string value = property.GetValue(airs[i]).ToString();
  2668. Cell ishcel0 = table.Rows[row].Cells[index];
  2669. Paragraph p = new Paragraph(doc);
  2670. string s = value;
  2671. p.AppendChild(new Run(doc, s));
  2672. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2673. ishcel0.AppendChild(p);
  2674. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2675. //ishcel0.CellFormat.VerticalAlignment=
  2676. index++;
  2677. }
  2678. row++;
  2679. }
  2680. #endregion
  2681. Paragraph lastParagraph = new Paragraph(doc);
  2682. //第一个表格末尾加段落
  2683. table.ParentNode.InsertAfter(lastParagraph, table);
  2684. //复制第一个表格
  2685. Table cloneTable = (Table)table.Clone(true);
  2686. //在文档末尾段落后面加入复制的表格
  2687. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2688. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2689. {
  2690. int rownewsIndex = 13;
  2691. for (int i = 0; i < 2; i++)
  2692. {
  2693. var CopyRow = table.Rows[12].Clone(true);
  2694. table.Rows.RemoveAt(13);
  2695. table.Rows.Add(CopyRow);
  2696. rownewsIndex++;
  2697. }
  2698. }
  2699. else
  2700. {
  2701. table.Rows.RemoveAt(12);
  2702. }
  2703. cloneTable.Rows.RemoveAt(12);
  2704. }
  2705. if (_AirTicketReservations.Count != 0)
  2706. {
  2707. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2708. if (FlightsCode.Length != 0)
  2709. {
  2710. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2711. if (_AirCompany != null)
  2712. {
  2713. string str = "--";
  2714. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2715. if (!string.IsNullOrEmpty(translateResult))
  2716. {
  2717. str = translateResult;
  2718. str = _airTicketResRep.Processing(str);
  2719. }
  2720. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2721. }
  2722. else
  2723. {
  2724. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2725. }
  2726. }
  2727. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2728. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2729. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2730. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2731. string names = "";
  2732. foreach (string clientName in nameArray)
  2733. {
  2734. names += clientName + ",";
  2735. }
  2736. if (!string.IsNullOrWhiteSpace(names))
  2737. {
  2738. string str = "--";
  2739. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2740. if (!string.IsNullOrEmpty(translateResult))
  2741. {
  2742. str = translateResult;
  2743. str = _airTicketResRep.Processing(str);
  2744. }
  2745. table.Range.Bookmarks["ClientName"].Text = str;
  2746. }
  2747. else
  2748. {
  2749. table.Range.Bookmarks["ClientName"].Text = "--";
  2750. }
  2751. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2752. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2753. table.Range.Bookmarks["JointTicket"].Text = "--";
  2754. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2755. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2756. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2757. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2758. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2759. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2760. }
  2761. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2762. //保存合并后的文档
  2763. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2764. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2765. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2766. return Ok(JsonView(true, "成功!", rst));
  2767. }
  2768. }
  2769. }
  2770. catch (Exception ex)
  2771. {
  2772. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2773. throw;
  2774. }
  2775. }
  2776. #endregion
  2777. #region 团组增减款项 --> 其他款项
  2778. /// <summary>
  2779. /// 团组增减款项下拉框绑定
  2780. /// </summary>
  2781. /// <param name="dto"></param>
  2782. /// <returns></returns>
  2783. [HttpPost]
  2784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2785. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2786. {
  2787. #region 参数验证
  2788. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2789. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2790. #endregion
  2791. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2792. }
  2793. /// <summary>
  2794. /// 根据团组Id查询团组增减款项
  2795. /// </summary>
  2796. /// <param name="dto"></param>
  2797. /// <returns></returns>
  2798. [HttpPost]
  2799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2800. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2801. {
  2802. #region 参数验证
  2803. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2804. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2805. #endregion
  2806. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2807. }
  2808. /// <summary>
  2809. /// 团组增减款项操作(Status:1.新增,2.修改)
  2810. /// </summary>
  2811. /// <param name="dto"></param>
  2812. /// <returns></returns>
  2813. [HttpPost]
  2814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2815. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2816. {
  2817. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2818. if (groupData.Code != 200)
  2819. {
  2820. return Ok(JsonView(false, groupData.Msg));
  2821. }
  2822. #region 应用推送
  2823. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2824. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2825. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2826. #endregion
  2827. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2828. }
  2829. /// <summary>
  2830. /// 团组增减款项操作 删除
  2831. /// </summary>
  2832. /// <param name="dto"></param>
  2833. /// <returns></returns>
  2834. [HttpPost]
  2835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2836. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2837. {
  2838. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2839. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2840. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2841. if (res.Code == 0)
  2842. {
  2843. return Ok(JsonView(true, "删除成功!"));
  2844. }
  2845. return Ok(JsonView(false, "删除失败!"));
  2846. }
  2847. /// <summary>
  2848. /// 根据团组增减款项Id查询
  2849. /// </summary>
  2850. /// <param name="dto"></param>
  2851. /// <returns></returns>
  2852. [HttpPost]
  2853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2854. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2855. {
  2856. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2857. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2858. }
  2859. /// <summary>
  2860. /// 查询供应商名称
  2861. /// </summary>
  2862. /// <param name="dto"></param>
  2863. /// <returns></returns>
  2864. [HttpPost]
  2865. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2866. {
  2867. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2868. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2869. ?? new List<Grp_DecreasePayments>();
  2870. dbResult = dbResult.Distinct(new
  2871. ProductComparer()).ToList();
  2872. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2873. {
  2874. x.Id,
  2875. x.SupplierAddress,
  2876. x.SupplierArea,
  2877. x.SupplierContact,
  2878. x.SupplierContactNumber,
  2879. x.SupplierEmail,
  2880. x.SupplierName,
  2881. x.SupplierSocialAccount,
  2882. x.SupplierTypeId,
  2883. }).ToList());
  2884. return Ok(jw);
  2885. }
  2886. #endregion
  2887. #region 文件上传、删除
  2888. /// <summary>
  2889. /// region 文件上传 可以带参数
  2890. /// </summary>
  2891. /// <param name="file"></param>
  2892. /// <returns></returns>
  2893. [HttpPost]
  2894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2895. public async Task<IActionResult> UploadProject(IFormFile file)
  2896. {
  2897. try
  2898. {
  2899. var TypeName = Request.Headers["TypeName"].ToString();
  2900. if (file != null)
  2901. {
  2902. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2903. //文件名称
  2904. string projectFileName = file.FileName;
  2905. //上传的文件的路径
  2906. string filePath = "";
  2907. if (TypeName == "A")//A代表团组增减款项
  2908. {
  2909. if (!Directory.Exists(fileDir))
  2910. {
  2911. Directory.CreateDirectory(fileDir);
  2912. }
  2913. //上传的文件的路径
  2914. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2915. }
  2916. else if (TypeName == "B")//B代表商邀相关文件
  2917. {
  2918. if (!Directory.Exists(fileDir))
  2919. {
  2920. Directory.CreateDirectory(fileDir);
  2921. }
  2922. //上传的文件的路径
  2923. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2924. }
  2925. using (FileStream fs = System.IO.File.Create(filePath))
  2926. {
  2927. file.CopyTo(fs);
  2928. fs.Flush();
  2929. }
  2930. return Ok(JsonView(true, "上传成功!", projectFileName));
  2931. }
  2932. else
  2933. {
  2934. return Ok(JsonView(false, "上传失败!"));
  2935. }
  2936. }
  2937. catch (Exception ex)
  2938. {
  2939. return Ok(JsonView(false, "程序错误!"));
  2940. throw;
  2941. }
  2942. }
  2943. /// <summary>
  2944. /// 删除指定文件
  2945. /// </summary>
  2946. /// <param name="dto"></param>
  2947. /// <returns></returns>
  2948. [HttpPost]
  2949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2950. public async Task<IActionResult> DelFile(DelFileDto dto)
  2951. {
  2952. try
  2953. {
  2954. var TypeName = Request.Headers["TypeName"].ToString();
  2955. string filePath = "";
  2956. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2957. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2958. int id = 0;
  2959. if (TypeName == "A")
  2960. {
  2961. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2962. // 删除该文件
  2963. System.IO.File.Delete(filePath);
  2964. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2965. }
  2966. else if (TypeName == "B")
  2967. {
  2968. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2969. // 删除该文件
  2970. System.IO.File.Delete(filePath);
  2971. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2972. }
  2973. if (id != 0)
  2974. {
  2975. return Ok(JsonView(true, "成功!"));
  2976. }
  2977. else
  2978. {
  2979. return Ok(JsonView(false, "失败!"));
  2980. }
  2981. }
  2982. catch (Exception ex)
  2983. {
  2984. return Ok(JsonView(false, "程序错误!"));
  2985. throw;
  2986. }
  2987. }
  2988. #endregion
  2989. #region 商邀费用录入
  2990. /// <summary>
  2991. /// 根据团组Id查询商邀费用列表
  2992. /// </summary>
  2993. /// <param name="dto"></param>
  2994. /// <returns></returns>
  2995. [HttpPost]
  2996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2997. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2998. {
  2999. try
  3000. {
  3001. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3002. if (groupData.Code != 0)
  3003. {
  3004. return Ok(JsonView(false, groupData.Msg));
  3005. }
  3006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3007. }
  3008. catch (Exception ex)
  3009. {
  3010. return Ok(JsonView(false, "程序错误!"));
  3011. throw;
  3012. }
  3013. }
  3014. //
  3015. /// <summary>
  3016. /// 商邀费用 Info Page 基础数据源
  3017. /// </summary>
  3018. /// <param name="dto"></param>
  3019. /// <returns></returns>
  3020. [HttpPost]
  3021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3022. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3023. {
  3024. try
  3025. {
  3026. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3027. if (groupData.Code != 0)
  3028. {
  3029. return Ok(JsonView(false, groupData.Msg));
  3030. }
  3031. return Ok(JsonView(true, "操作成功", groupData.Data));
  3032. }
  3033. catch (Exception ex)
  3034. {
  3035. return Ok(JsonView(false, ex.Message));
  3036. throw;
  3037. }
  3038. }
  3039. /// <summary>
  3040. /// 根据商邀费用ID查询C表和商邀费用数据
  3041. /// </summary>
  3042. /// <param name="dto"></param>
  3043. /// <returns></returns>
  3044. [HttpPost]
  3045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3046. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3047. {
  3048. try
  3049. {
  3050. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3051. if (groupData.Code != 0)
  3052. {
  3053. return Ok(JsonView(false, groupData.Msg));
  3054. }
  3055. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3056. }
  3057. catch (Exception ex)
  3058. {
  3059. return Ok(JsonView(false, ex.Message));
  3060. throw;
  3061. }
  3062. }
  3063. /// <summary>
  3064. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3065. /// </summary>
  3066. /// <param name="dto"></param>
  3067. /// <returns></returns>
  3068. [HttpPost]
  3069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3070. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3071. {
  3072. try
  3073. {
  3074. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3075. if (groupData.Code != 0)
  3076. {
  3077. return Ok(JsonView(false, groupData.Msg));
  3078. }
  3079. #region 应用推送
  3080. try
  3081. {
  3082. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3083. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3084. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3085. }
  3086. catch (Exception ex)
  3087. {
  3088. }
  3089. #endregion
  3090. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3091. }
  3092. catch (Exception ex)
  3093. {
  3094. return Ok(JsonView(false, "程序错误!"));
  3095. throw;
  3096. }
  3097. }
  3098. /// <summary>
  3099. /// 商邀删除
  3100. /// </summary>
  3101. /// <param name="dto"></param>
  3102. /// <returns></returns>
  3103. [HttpPost]
  3104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3105. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3106. {
  3107. try
  3108. {
  3109. _sqlSugar.BeginTran();
  3110. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3111. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3112. {
  3113. IsDel = 1,
  3114. DeleteUserId = dto.DeleteUserId,
  3115. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3116. })
  3117. .Where(it => it.Id == dto.Id)
  3118. .ExecuteCommand();
  3119. if (res1 > 0)
  3120. {
  3121. int _diId = 0;
  3122. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3123. if (_ioaInfo != null)
  3124. {
  3125. _diId = _ioaInfo.DiId;
  3126. }
  3127. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3128. .SetColumns(a => new Grp_CreditCardPayment()
  3129. {
  3130. IsDel = 1,
  3131. DeleteUserId = dto.DeleteUserId,
  3132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3133. })
  3134. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3135. .ExecuteCommand();
  3136. if (res2 > 0)
  3137. {
  3138. _sqlSugar.CommitTran();
  3139. return Ok(JsonView(true, "删除成功!"));
  3140. }
  3141. }
  3142. _sqlSugar.RollbackTran();
  3143. return Ok(JsonView(false, "删除失败"));
  3144. }
  3145. catch (Exception ex)
  3146. {
  3147. _sqlSugar.RollbackTran();
  3148. return Ok(JsonView(false, ex.Message));
  3149. }
  3150. }
  3151. /// <summary>
  3152. /// 团组模块文件上传
  3153. /// </summary>
  3154. /// <param name="dto"></param>
  3155. /// <returns></returns>
  3156. [HttpPost]
  3157. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3158. {
  3159. var jw = JsonView(false);
  3160. if (dto.File == null)
  3161. {
  3162. jw.Msg = "无文件信息!";
  3163. return Ok(jw);
  3164. }
  3165. var nameSp = dto.File.FileName.Split(".");
  3166. if (nameSp.Length < 2)
  3167. {
  3168. jw.Msg = "拓展名称有误!";
  3169. return Ok(jw);
  3170. }
  3171. var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3172. if (!existsName.Contains(nameSp[1].ToUpper()))
  3173. {
  3174. jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3175. return Ok(jw);
  3176. }
  3177. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3178. if (Ctable == null)
  3179. {
  3180. jw.Msg = "Ctable指向有误!";
  3181. return Ok(jw);
  3182. }
  3183. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3184. if (groupInfo == null)
  3185. {
  3186. jw.Msg = "团组信息不存在!";
  3187. return Ok(jw);
  3188. }
  3189. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3190. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3191. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3192. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3193. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3194. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3195. try
  3196. {
  3197. if (!Directory.Exists(fileBase))
  3198. {
  3199. Directory.CreateDirectory(fileBase);
  3200. }
  3201. var saveFilePath = fileBase +"\\"+ dto.File.FileName;
  3202. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3203. {
  3204. Cid = dto.Cid,
  3205. CreateTime = DateTime.Now,
  3206. CreateUserId = dto.Userid,
  3207. Ctable = dto.Ctable,
  3208. Diid = dto.Diid,
  3209. IsDel = 0,
  3210. FilePath = saveFilePath,
  3211. };
  3212. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3213. {
  3214. dto.File.CopyTo(fs);
  3215. fs.Flush();
  3216. }
  3217. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(file).ExecuteCommand();
  3218. jw = JsonView(true, "保存成功!", new
  3219. {
  3220. url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3221. });
  3222. }
  3223. catch (Exception ex)
  3224. {
  3225. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3226. {
  3227. url = ""
  3228. }) ;
  3229. }
  3230. return Ok(jw);
  3231. }
  3232. #endregion
  3233. #region 团组英文资料
  3234. /// <summary>
  3235. /// 查询团组英文所有资料
  3236. /// </summary>
  3237. /// <param name="dto"></param>
  3238. /// <returns></returns>
  3239. [HttpPost]
  3240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3241. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3242. {
  3243. try
  3244. {
  3245. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3246. if (groupData.Code != 0)
  3247. {
  3248. return Ok(JsonView(false, groupData.Msg));
  3249. }
  3250. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3251. }
  3252. catch (Exception ex)
  3253. {
  3254. return Ok(JsonView(false, "程序错误!"));
  3255. throw;
  3256. }
  3257. }
  3258. /// <summary>
  3259. /// 团组英文资料操作(Status:1.新增,2.修改)
  3260. /// </summary>
  3261. /// <param name="dto"></param>
  3262. /// <returns></returns>
  3263. [HttpPost]
  3264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3265. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3266. {
  3267. try
  3268. {
  3269. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3270. if (groupData.Code != 0)
  3271. {
  3272. return Ok(JsonView(false, groupData.Msg));
  3273. }
  3274. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3275. }
  3276. catch (Exception ex)
  3277. {
  3278. return Ok(JsonView(false, "程序错误!"));
  3279. throw;
  3280. }
  3281. }
  3282. /// <summary>
  3283. /// 团组英文资料Id查询数据
  3284. /// </summary>
  3285. /// <param name="dto"></param>
  3286. /// <returns></returns>
  3287. [HttpPost]
  3288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3289. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3290. {
  3291. try
  3292. {
  3293. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3294. if (_DelegationEnData != null)
  3295. {
  3296. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3297. }
  3298. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3299. }
  3300. catch (Exception ex)
  3301. {
  3302. return Ok(JsonView(false, "程序错误!"));
  3303. throw;
  3304. }
  3305. }
  3306. /// <summary>
  3307. /// 团组英文资料删除
  3308. /// </summary>
  3309. /// <param name="dto"></param>
  3310. /// <returns></returns>
  3311. [HttpPost]
  3312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3313. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3314. {
  3315. try
  3316. {
  3317. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3318. if (!res)
  3319. {
  3320. return Ok(JsonView(false, "删除失败"));
  3321. }
  3322. return Ok(JsonView(true, "删除成功!"));
  3323. }
  3324. catch (Exception ex)
  3325. {
  3326. return Ok(JsonView(false, "程序错误!"));
  3327. throw;
  3328. }
  3329. }
  3330. #endregion
  3331. #region 导出邀请函
  3332. /// <summary>
  3333. /// 导出邀请函页面初始化
  3334. /// </summary>
  3335. /// <param name="dto"></param>
  3336. /// <returns></returns>
  3337. [HttpPost]
  3338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3339. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3340. {
  3341. try
  3342. {
  3343. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3344. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3345. if (dto.DiId == 0)
  3346. {
  3347. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3348. }
  3349. else
  3350. {
  3351. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3352. }
  3353. return Ok(JsonView(true, "查询成功!", new
  3354. {
  3355. deleClient = crm_Deles,
  3356. delegations = grp_Delegations
  3357. }));
  3358. }
  3359. catch (Exception ex)
  3360. {
  3361. return Ok(JsonView(false, "程序错误!"));
  3362. throw;
  3363. }
  3364. }
  3365. /// <summary>
  3366. /// 导出邀请函
  3367. /// </summary>
  3368. /// <param name="dto"></param>
  3369. /// <returns></returns>
  3370. [HttpPost]
  3371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3372. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3373. {
  3374. #region 参数验证
  3375. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3376. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3377. #endregion
  3378. try
  3379. {
  3380. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3381. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3382. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3383. From Grp_TourClientList tcl
  3384. Left Join
  3385. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3386. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3387. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3388. From Crm_DeleClient dc
  3389. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3390. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3391. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3392. Where dc.IsDel = 0) temp
  3393. On temp.DcId =tcl.ClientId
  3394. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3395. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3396. List<string> texts = new List<string>();
  3397. if (datas.Count != 0)
  3398. {
  3399. foreach (TourClientListDetailsView item in datas)
  3400. {
  3401. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3402. {
  3403. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3404. }
  3405. else
  3406. {
  3407. string name = item.LastName + item.FirstName;
  3408. texts.Add(name);
  3409. }
  3410. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3411. {
  3412. if (!transDic.ContainsKey(item.Job))
  3413. {
  3414. texts.Add(item.Job);
  3415. }
  3416. }
  3417. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3418. {
  3419. texts.Add(item.CompanyFullName);
  3420. }
  3421. }
  3422. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3423. if (transData.Count > 0)
  3424. {
  3425. foreach (TranslateResult item in transData)
  3426. {
  3427. if (!transDic.ContainsKey(item.Query))
  3428. {
  3429. transDic.Add(item.Query, item.Translation);
  3430. }
  3431. }
  3432. }
  3433. List<GuestList> list = new List<GuestList>();
  3434. foreach (TourClientListDetailsView dele in datas)
  3435. {
  3436. GuestList guestList = new GuestList();
  3437. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3438. {
  3439. guestList.Name = dele.Pinyin;
  3440. }
  3441. else
  3442. {
  3443. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3444. guestList.Name = Name;
  3445. }
  3446. if (dele.Sex == 0)
  3447. {
  3448. guestList.Sex = "Male";
  3449. }
  3450. else if (dele.Sex == 1)
  3451. {
  3452. guestList.Sex = "Female";
  3453. }
  3454. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3455. if (!string.IsNullOrEmpty(dele.Job))
  3456. {
  3457. guestList.Job = dele.Job;
  3458. }
  3459. list.Add(guestList);
  3460. }
  3461. //载入模板
  3462. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3463. DocumentBuilder builder = new DocumentBuilder(doc);
  3464. //获取word里所有表格
  3465. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3466. //获取所填表格的序数
  3467. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3468. var rowStart = tableOne.Rows[0]; //获取第1行
  3469. //循环赋值
  3470. for (int i = 0; i < list.Count; i++)
  3471. {
  3472. builder.MoveToCell(0, i + 1, 0, 0);
  3473. builder.Write(list[i].Name.ToString());
  3474. builder.MoveToCell(0, i + 1, 1, 0);
  3475. builder.Write(list[i].Sex.ToString());
  3476. builder.MoveToCell(0, i + 1, 2, 0);
  3477. builder.Write(list[i].DOB.ToString());
  3478. builder.MoveToCell(0, i + 1, 3, 0);
  3479. builder.Write(list[i].Job.ToString());
  3480. }
  3481. //删除多余行
  3482. while (tableOne.Rows.Count > list.Count + 1)
  3483. {
  3484. tableOne.Rows.RemoveAt(list.Count + 1);
  3485. }
  3486. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3487. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3488. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3489. doc.Save(filePath);
  3490. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3491. return Ok(JsonView(true, "操作成功!", Url));
  3492. }
  3493. else
  3494. {
  3495. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3496. }
  3497. }
  3498. catch (Exception ex)
  3499. {
  3500. return Ok(JsonView(false, ex.Message));
  3501. throw;
  3502. }
  3503. }
  3504. #endregion
  3505. #region 团组经理模块 出入境费用
  3506. ///// <summary>
  3507. ///// 团组模块 - 出入境费用
  3508. ///// </summary>
  3509. ///// <returns></returns>
  3510. //[HttpPost]
  3511. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3512. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3513. //{
  3514. // try
  3515. // {
  3516. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3517. // if (data.Code != 0)
  3518. // {
  3519. // return Ok(JsonView(false, data.Msg));
  3520. // }
  3521. // return Ok(JsonView(true, "查询成功!"));
  3522. // }
  3523. // catch (Exception ex)
  3524. // {
  3525. // return Ok(JsonView(false, ex.Message));
  3526. // throw;
  3527. // }
  3528. //}
  3529. /// <summary>
  3530. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3531. /// </summary>
  3532. /// <returns></returns>
  3533. [HttpPost]
  3534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3535. public async Task<IActionResult> SetDayAndCostAreaChange()
  3536. {
  3537. try
  3538. {
  3539. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3540. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3541. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3542. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3543. foreach (var item in unite) //处理交集数据
  3544. {
  3545. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3546. }
  3547. foreach (var item in merge) //处理差集数据
  3548. {
  3549. int nationalTravelFeeId = 0;
  3550. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3551. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3552. else
  3553. {
  3554. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3555. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3556. }
  3557. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3558. }
  3559. //只更新dayAndCost 的 nationalTravelFeeId;
  3560. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3561. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3562. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3563. }
  3564. catch (Exception ex)
  3565. {
  3566. return Ok(JsonView(false, ex.Message));
  3567. throw;
  3568. }
  3569. }
  3570. /// <summary>
  3571. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3572. /// </summary>
  3573. /// <returns></returns>
  3574. [HttpPost]
  3575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3576. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3577. {
  3578. try
  3579. {
  3580. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3581. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3582. //SetDataInfoView
  3583. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3584. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3585. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3586. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3587. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3588. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3589. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3590. //默认币种显示
  3591. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3592. {
  3593. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3594. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3595. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3596. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3597. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3598. };
  3599. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3600. if (_currencyRate.Count > 0)
  3601. {
  3602. foreach (var item in _currencyInfos)
  3603. {
  3604. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3605. if (rateInfo != null)
  3606. {
  3607. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3608. rate1 *= 1.035M;
  3609. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3610. }
  3611. }
  3612. }
  3613. return Ok(JsonView(true, "查询成功!", new
  3614. {
  3615. GroupNameData = groupNameData.Data,
  3616. CurrencyData = _CurrencyData,
  3617. WordTypeData = _WordTypeData,
  3618. ExcelTypeData = _ExcelTypeData,
  3619. CurrencyInit = _currencyInfos
  3620. }));
  3621. }
  3622. catch (Exception ex)
  3623. {
  3624. return Ok(JsonView(false, ex.Message));
  3625. throw;
  3626. }
  3627. }
  3628. /// <summary>
  3629. /// 团组模块 - 出入境费用
  3630. /// 实时汇率 tips
  3631. /// 签证费用 tips
  3632. /// </summary>
  3633. /// <returns></returns>
  3634. [HttpPost]
  3635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3636. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3637. {
  3638. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3639. //默认币种显示
  3640. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3641. {
  3642. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3643. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3644. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3645. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3646. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3647. };
  3648. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3649. List<dynamic> reteInfos = new List<dynamic>();
  3650. if (_currencyRate.Count > 0)
  3651. {
  3652. foreach (var item in _currencyInfos)
  3653. {
  3654. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3655. if (rateInfo != null)
  3656. {
  3657. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3658. decimal rate1 = item.Rate;
  3659. rate1 *= 1.03M;
  3660. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3661. reteInfos.Add(new
  3662. {
  3663. currCode = item.CurrencyCode,
  3664. currName = item.CurrencyName,
  3665. rate = rate2,
  3666. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3667. });
  3668. }
  3669. }
  3670. }
  3671. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3672. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3673. return Ok(JsonView(true, "查询成功!", new
  3674. {
  3675. //GroupNameData = groupNameData.Data,
  3676. visaData = visaData.Data,
  3677. airData = airData.Data,
  3678. reteInfos = reteInfos
  3679. }));
  3680. }
  3681. /// <summary>
  3682. /// 团组模块 - 出入境费用 - Info
  3683. /// </summary>
  3684. /// <returns></returns>
  3685. [HttpPost]
  3686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3687. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3688. {
  3689. try
  3690. {
  3691. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3692. if (data.Code != 0)
  3693. {
  3694. return Ok(JsonView(false, data.Msg));
  3695. }
  3696. return Ok(JsonView(true, "查询成功!", data.Data));
  3697. }
  3698. catch (Exception ex)
  3699. {
  3700. return Ok(JsonView(false, ex.Message));
  3701. }
  3702. }
  3703. /// <summary>
  3704. /// 团组模块 - 出入境费用 - Add And Update
  3705. /// </summary>
  3706. /// <returns></returns>
  3707. [HttpPost]
  3708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3709. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3710. {
  3711. try
  3712. {
  3713. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3714. if (data.Code != 0)
  3715. {
  3716. return Ok(JsonView(false, data.Msg));
  3717. }
  3718. //生成默认文件pdf并且通知人员
  3719. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3720. {
  3721. DiId = dto.DiId,
  3722. ExportType = 1,
  3723. SubTypeId = 1005
  3724. }, "pdf");
  3725. //发送通知
  3726. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3727. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3728. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3729. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3730. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3731. return Ok(JsonView(true, data.Msg, data.Data));
  3732. }
  3733. catch (Exception ex)
  3734. {
  3735. return Ok(JsonView(false, ex.Message));
  3736. }
  3737. }
  3738. /// <summary>
  3739. /// 团组模块 - 出入境费用 - Confirm 费用
  3740. /// </summary>
  3741. /// <returns></returns>
  3742. [HttpPost]
  3743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3744. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3745. {
  3746. //TODO:测试完毕需把对应的用户ID更改
  3747. //1、数据表添加字段
  3748. //2、更改字段接口()
  3749. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3750. //3、确认成功 给财务发送消息
  3751. if (_view.Code == 200)
  3752. {
  3753. if (dto.Type == 1)
  3754. {
  3755. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3756. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3757. }
  3758. }
  3759. return Ok(_view);
  3760. }
  3761. /// <summary>
  3762. /// 团组模块 - 出入境费用 - File downlaod
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3769. {
  3770. try
  3771. {
  3772. if (dto.DiId < 1)
  3773. {
  3774. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3775. }
  3776. if (dto.ExportType < 1)
  3777. {
  3778. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3779. }
  3780. if (dto.SubTypeId < 1)
  3781. {
  3782. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3783. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3784. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3785. 3 团组成员名单 1 团组成员名单"));
  3786. }
  3787. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3788. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3789. if (_EnterExitCosts == null)
  3790. {
  3791. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3792. }
  3793. //数据源
  3794. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3795. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3796. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3797. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3798. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3799. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3800. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3801. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3802. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3803. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3804. .Select((tcl, dc, cc) => new
  3805. {
  3806. Name = dc.LastName + dc.FirstName,
  3807. Sex = dc.Sex,
  3808. Birthday = dc.BirthDay,
  3809. Company = cc.CompanyFullName,
  3810. Job = dc.Job
  3811. })
  3812. .ToList();
  3813. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3814. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3815. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3816. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3817. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3818. if (dto.ExportType == 1) //明细表
  3819. {
  3820. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3821. {
  3822. //获取模板
  3823. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3824. //载入模板
  3825. Document doc = new Document(tempPath);
  3826. DocumentBuilder builder = new DocumentBuilder(doc);
  3827. //利用键值对存放数据
  3828. Dictionary<string, string> dic = new Dictionary<string, string>();
  3829. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3830. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3831. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3832. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3833. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3834. string row1_1 = "";
  3835. if (_EnterExitCosts.Visa > 0)
  3836. {
  3837. //insidePayTotal += _EnterExitCosts.Visa;
  3838. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3839. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3840. {
  3841. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3842. }
  3843. }
  3844. string row1_2 = "";
  3845. if (_EnterExitCosts.YiMiao > 0)
  3846. {
  3847. //insidePayTotal += _EnterExitCosts.YiMiao;
  3848. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3849. }
  3850. if (_EnterExitCosts.HeSuan > 0)
  3851. {
  3852. //insidePayTotal += _EnterExitCosts.HeSuan;
  3853. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3854. }
  3855. if (_EnterExitCosts.Service > 0)
  3856. {
  3857. //insidePayTotal += _EnterExitCosts.Service;
  3858. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3859. }
  3860. string row1_3 = "";
  3861. if (_EnterExitCosts.Safe > 0)
  3862. {
  3863. //insidePayTotal += _EnterExitCosts.Safe;
  3864. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3865. }
  3866. if (_EnterExitCosts.Ticket > 0)
  3867. {
  3868. //insidePayTotal += _EnterExitCosts.Ticket;
  3869. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3870. }
  3871. string row1 = "";
  3872. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3873. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3874. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3875. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3876. dic.Add("Row1Str", row1);
  3877. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3878. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3879. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3880. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3881. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3882. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3883. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3884. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3885. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3886. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3887. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3888. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3889. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3890. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3891. #region 填充word模板书签内容
  3892. foreach (var key in dic.Keys)
  3893. {
  3894. builder.MoveToBookmark(key);
  3895. builder.Write(dic[key]);
  3896. }
  3897. #endregion
  3898. #region 填充word表格内容
  3899. ////获读取指定表格方法二
  3900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3901. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3902. for (int i = 0; i < dac1.Count; i++)
  3903. {
  3904. Grp_DayAndCost dac = dac1[i];
  3905. if (dac == null) continue;
  3906. builder.MoveToCell(0, i, 0, 0);
  3907. builder.Write("第" + dac.Days.ToString() + "晚:");
  3908. builder.MoveToCell(0, i, 1, 0);
  3909. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3910. //builder.Write(dac.Place == null ? "" : dac.Place);
  3911. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3912. builder.MoveToCell(0, i, 2, 0);
  3913. builder.Write("费用标准:");
  3914. string curr = "";
  3915. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3916. if (currData != null)
  3917. {
  3918. curr = currData.Name;
  3919. }
  3920. builder.MoveToCell(0, i, 3, 0);
  3921. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3922. builder.MoveToCell(0, i, 4, 0);
  3923. builder.Write("费用小计:");
  3924. builder.MoveToCell(0, i, 5, 0);
  3925. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3926. }
  3927. //删除多余行
  3928. while (table1.Rows.Count > dac1.Count)
  3929. {
  3930. table1.Rows.RemoveAt(dac1.Count);
  3931. }
  3932. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3933. for (int i = 0; i < dac2.Count; i++)
  3934. {
  3935. Grp_DayAndCost dac = dac2[i];
  3936. if (dac == null) continue;
  3937. builder.MoveToCell(1, i, 0, 0);
  3938. builder.Write("第" + dac.Days.ToString() + "天:");
  3939. builder.MoveToCell(1, i, 1, 0);
  3940. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3941. builder.MoveToCell(1, i, 2, 0);
  3942. builder.Write("费用标准:");
  3943. string curr = "";
  3944. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3945. if (currData != null)
  3946. {
  3947. curr = currData.Name;
  3948. }
  3949. builder.MoveToCell(1, i, 3, 0);
  3950. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3951. builder.MoveToCell(1, i, 4, 0);
  3952. builder.Write("费用小计:");
  3953. builder.MoveToCell(1, i, 5, 0);
  3954. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3955. }
  3956. //删除多余行
  3957. while (table2.Rows.Count > dac2.Count)
  3958. {
  3959. table2.Rows.RemoveAt(dac2.Count);
  3960. }
  3961. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3962. for (int i = 0; i < dac3.Count; i++)
  3963. {
  3964. Grp_DayAndCost dac = dac3[i];
  3965. if (dac == null) continue;
  3966. builder.MoveToCell(2, i, 0, 0);
  3967. builder.Write("第" + dac.Days.ToString() + "天:");
  3968. builder.MoveToCell(2, i, 1, 0);
  3969. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3970. builder.MoveToCell(2, i, 2, 0);
  3971. builder.Write("费用标准:");
  3972. string curr = "";
  3973. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3974. if (currData != null)
  3975. {
  3976. curr = currData.Name;
  3977. }
  3978. builder.MoveToCell(2, i, 3, 0);
  3979. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3980. builder.MoveToCell(2, i, 4, 0);
  3981. builder.Write("费用小计:");
  3982. builder.MoveToCell(2, i, 5, 0);
  3983. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3984. }
  3985. //删除多余行
  3986. while (table3.Rows.Count > dac3.Count)
  3987. {
  3988. table3.Rows.RemoveAt(dac3.Count);
  3989. }
  3990. #endregion
  3991. //文件名
  3992. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3993. AsposeHelper.removewatermark_v2180();
  3994. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3995. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3996. return Ok(JsonView(true, "成功", new { Url = url }));
  3997. }
  3998. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3999. {
  4000. //获取模板
  4001. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4002. //载入模板
  4003. Document doc = new Document(tempPath);
  4004. DocumentBuilder builder = new DocumentBuilder(doc);
  4005. Dictionary<string, string> dic = new Dictionary<string, string>();
  4006. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4007. {
  4008. List<string> list = new List<string>();
  4009. try
  4010. {
  4011. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4012. foreach (var item in spilitArr)
  4013. {
  4014. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4015. var depCode = spDotandEmpty[2].Substring(0, 3);
  4016. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4017. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4018. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4019. list.Add(depName);
  4020. list.Add(arrName);
  4021. }
  4022. list = list.Distinct().ToList();
  4023. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4024. }
  4025. catch (Exception)
  4026. {
  4027. dic.Add("ReturnCode", "行程录入不正确!");
  4028. }
  4029. }
  4030. else
  4031. {
  4032. dic.Add("ReturnCode", "未录入行程!");
  4033. }
  4034. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4035. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4036. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4037. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4038. {
  4039. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4040. dic.Add("Day", sp.Days.ToString());
  4041. }
  4042. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4043. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4044. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4045. //dic.Add("Names", Names);
  4046. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4047. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4048. decimal dac1totalPrice = 0.00M;
  4049. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4050. foreach (var dac in dac1)
  4051. {
  4052. if (dac.SubTotal == 0.00M)
  4053. {
  4054. continue;
  4055. }
  4056. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4057. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4058. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4059. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4060. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4061. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4062. builder.Write(currency);//币种
  4063. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4064. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4065. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4066. builder.Write("");//人数
  4067. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4068. builder.Write("");//天数
  4069. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4070. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4071. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4072. decimal rate = 0.00M;
  4073. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4074. builder.Write(rate.ToString("#0.0000"));//汇率
  4075. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4076. decimal rbmPrice = dac.SubTotal;
  4077. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4078. accommodationStartIndex++;
  4079. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4080. }
  4081. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4082. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4083. {
  4084. table1.Rows.RemoveAt(i - 1);
  4085. foodandotherStartIndex--;
  4086. }
  4087. if (dac2.Count == dac3.Count)//国家 币种 金额
  4088. {
  4089. for (int i = 0; i < dac2.Count; i++)
  4090. {
  4091. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4092. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4093. }
  4094. }
  4095. decimal dac2totalPrice = 0.00M;
  4096. foreach (var dac in dac2)
  4097. {
  4098. if (dac.SubTotal == 0)
  4099. {
  4100. continue;
  4101. }
  4102. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4103. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4104. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4105. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4106. builder.Write(currency);//币种
  4107. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4108. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4109. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4110. builder.Write("");//人数
  4111. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4112. builder.Write("");//天数
  4113. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4114. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4115. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4116. decimal rate = 0.00M;
  4117. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4118. builder.Write(rate.ToString("#0.0000"));//汇率
  4119. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4120. decimal rbmPrice = dac.SubTotal;
  4121. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4122. foodandotherStartIndex++;
  4123. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4124. }
  4125. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4126. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4127. {
  4128. table1.Rows.RemoveAt(i - 1);
  4129. }
  4130. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4131. string otherFeeStr = "";
  4132. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4133. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4134. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4135. if (otherFeeStr.Length > 0)
  4136. {
  4137. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4138. otherFeeStr = $"({otherFeeStr})";
  4139. dic.Add("OtherFeeStr", otherFeeStr);
  4140. }
  4141. //总计
  4142. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4143. //国际旅费
  4144. string outsideJJ = "";
  4145. string allPriceJJ = "";
  4146. if (_EnterExitCosts.SumJJC == 1)
  4147. {
  4148. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4149. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4150. }
  4151. string outsideGW = "";
  4152. string allPriceGW = "";
  4153. if (_EnterExitCosts.SumGWC == 1)
  4154. {
  4155. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  4156. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4157. }
  4158. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  4159. {
  4160. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4161. dic.Add("InTravelPrice", InTravelPriceStr);
  4162. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4163. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4164. }
  4165. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4166. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4167. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4168. foreach (var key in dic.Keys)
  4169. {
  4170. builder.MoveToBookmark(key);
  4171. builder.Write(dic[key]);
  4172. }
  4173. //模板文件名
  4174. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4175. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4176. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4177. return Ok(JsonView(true, "成功", new { Url = url }));
  4178. }
  4179. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4180. {
  4181. //获取模板
  4182. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4183. //载入模板
  4184. WorkbookDesigner designer = new WorkbookDesigner();
  4185. designer.Workbook = new Workbook(tempPath);
  4186. Dictionary<string, string> dic = new Dictionary<string, string>();
  4187. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4188. {
  4189. List<string> list = new List<string>();
  4190. try
  4191. {
  4192. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4193. foreach (var item in spilitArr)
  4194. {
  4195. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4196. var depCode = spDotandEmpty[2].Substring(0, 3);
  4197. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4198. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4199. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4200. list.Add(depName);
  4201. list.Add(arrName);
  4202. }
  4203. list = list.Distinct().ToList();
  4204. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4205. }
  4206. catch (Exception)
  4207. {
  4208. dic.Add("ReturnCode", "行程录入不正确!");
  4209. }
  4210. }
  4211. else
  4212. {
  4213. dic.Add("ReturnCode", "未录入行程!");
  4214. }
  4215. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4216. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4217. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4218. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4219. {
  4220. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4221. dic.Add("Day", sp.Days.ToString());
  4222. }
  4223. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4224. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4225. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4226. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4227. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4228. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4229. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4230. designer.SetDataSource("Name", Names);
  4231. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4232. designer.SetDataSource("Day", dic["Day"] + "天");
  4233. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4234. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4235. int startIndex = 10;
  4236. const int startIndexcopy = 10;
  4237. if (dac2.Count == dac3.Count)//国家 币种 金额
  4238. {
  4239. for (int i = 0; i < dac2.Count; i++)
  4240. {
  4241. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4242. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4243. }
  4244. }
  4245. DataTable dtdac1 = new DataTable();
  4246. List<string> place = new List<string>();
  4247. dtdac1.Columns.AddRange(new DataColumn[] {
  4248. new DataColumn(){ ColumnName = "city"},
  4249. new DataColumn(){ ColumnName = "curr"},
  4250. new DataColumn(){ ColumnName = "criterion"},
  4251. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4252. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4253. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4254. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4255. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4256. });
  4257. DataTable dtdac2 = new DataTable();
  4258. dtdac2.Columns.AddRange(new DataColumn[] {
  4259. new DataColumn(){ ColumnName = "city"},
  4260. new DataColumn(){ ColumnName = "curr"},
  4261. new DataColumn(){ ColumnName = "criterion"},
  4262. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4263. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4264. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4265. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4266. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4267. });
  4268. dtdac1.TableName = "tb1";
  4269. dtdac2.TableName = "tb2";
  4270. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4271. foreach (var item in dac1)
  4272. {
  4273. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4274. if (place.Contains(item.Place))
  4275. {
  4276. continue;
  4277. }
  4278. DataRow row = dtdac1.NewRow();
  4279. row["city"] = item.Place;
  4280. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4281. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4282. row["curr"] = currency;
  4283. row["rate"] = rate.ToString("#0.0000");
  4284. row["criterion"] = item.Cost.ToString("#0.00");
  4285. row["number"] = 1;
  4286. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4287. //row["costRMB"] = rbmPrice;
  4288. dtdac1.Rows.Add(row);
  4289. place.Add(item.Place);
  4290. }
  4291. place = new List<string>();
  4292. foreach (var item in dac2)
  4293. {
  4294. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4295. if (place.Contains(item.Place))
  4296. {
  4297. continue;
  4298. }
  4299. DataRow row = dtdac2.NewRow();
  4300. row["city"] = item.Place;
  4301. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4302. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4303. row["curr"] = currency;
  4304. row["rate"] = rate.ToString("#0.0000");
  4305. row["criterion"] = item.Cost.ToString("#0.00");
  4306. row["number"] = 1;
  4307. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4308. //row["cost"] = item.SubTotal;
  4309. //row["costRMB"] = rbmPrice;
  4310. dtdac2.Rows.Add(row);
  4311. place.Add(item.Place);
  4312. //dac2totalPrice += rbmPrice;
  4313. }
  4314. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4315. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4316. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4317. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4318. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4319. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4320. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4321. string cellStr = $" 5.其他费用(";
  4322. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4323. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4324. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4325. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4326. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4327. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4328. if (cellStr.Length > 8)
  4329. {
  4330. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4331. }
  4332. cellStr += ")";
  4333. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4334. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4335. decimal pxFee = dac4.Sum(it => it.Cost);
  4336. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4337. string celllastStr1 = "";
  4338. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4339. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4340. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4341. celllastStr1 += $",国际旅费 元";
  4342. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4343. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4344. designer.SetDataSource("cell4Str", cell4Str);
  4345. designer.SetDataSource("cellStr", cellStr);
  4346. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4347. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4348. designer.SetDataSource("celllastStr", celllastStr);
  4349. Workbook wb = designer.Workbook;
  4350. var sheet = wb.Worksheets[0];
  4351. //绑定datatable数据集
  4352. designer.SetDataSource(dtdac1);
  4353. designer.SetDataSource(dtdac2);
  4354. designer.Process();
  4355. var rowStart = dtdac1.Rows.Count;
  4356. while (rowStart > 0)
  4357. {
  4358. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4359. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4360. startIndex++;
  4361. rowStart--;
  4362. }
  4363. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4364. startIndex += 1; //总计行
  4365. rowStart = dtdac2.Rows.Count;
  4366. while (rowStart > 0)
  4367. {
  4368. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4369. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4370. startIndex++;
  4371. rowStart--;
  4372. }
  4373. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4374. wb.CalculateFormula(true);
  4375. //模板文件名
  4376. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4377. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4378. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4379. return Ok(JsonView(true, "成功", new { Url = url }));
  4380. }
  4381. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4382. {
  4383. //获取模板
  4384. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4385. //载入模板
  4386. Document doc = new Document(tempPath);
  4387. DocumentBuilder builder = new DocumentBuilder(doc);
  4388. Dictionary<string, string> dic = new Dictionary<string, string>();
  4389. dic.Add("GroupName", _DelegationInfo.TeamName);
  4390. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4391. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4392. string missionLeaderJob = "";//负责人job
  4393. int groupNumber = 0; //团人数
  4394. if (DeleClientList.Count > 0)
  4395. {
  4396. missionLeader = DeleClientList[0]?.Name ?? "";
  4397. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4398. }
  4399. dic.Add("MissionLeader", missionLeader); //团负责人
  4400. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4401. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4402. #region MyRegion
  4403. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4404. //{
  4405. // List<string> list = new List<string>();
  4406. // try
  4407. // {
  4408. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4409. // foreach (var item in spilitArr)
  4410. // {
  4411. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4412. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4413. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4414. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4415. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4416. // list.Add(depName);
  4417. // list.Add(arrName);
  4418. // }
  4419. // list = list.Distinct().ToList();
  4420. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4421. // }
  4422. // catch (Exception)
  4423. // {
  4424. // dic.Add("ReturnCode", "行程录入不正确!");
  4425. // }
  4426. //}
  4427. //else
  4428. //{
  4429. // dic.Add("ReturnCode", "未录入行程!");
  4430. //}
  4431. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4432. dic.Add("ReturnCode", string.Join("、", countrys));
  4433. #endregion
  4434. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4435. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4436. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4437. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4438. //{
  4439. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4440. // dic.Add("Day", sp.Days.ToString());
  4441. //}
  4442. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4443. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4444. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4445. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4446. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4447. //培训人员名单
  4448. int cultivateRowIndex = 7;
  4449. foreach (var item in DeleClientList)
  4450. {
  4451. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4452. builder.Write(item.Name);
  4453. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4454. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4455. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4456. string birthDay = "";
  4457. if (item.Birthday != null)
  4458. {
  4459. DateTime dt = Convert.ToDateTime(item.Birthday);
  4460. birthDay = $"{dt.Year}.{dt.Month}";
  4461. }
  4462. builder.Write(birthDay);
  4463. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4464. builder.Write(item.Company);
  4465. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4466. builder.Write(item.Job);
  4467. cultivateRowIndex++;
  4468. }
  4469. //删除多余行
  4470. //cultivateRowIndex -= 2;
  4471. int delRows = 10 + 7 - cultivateRowIndex;
  4472. if (delRows > 0)
  4473. {
  4474. for (int i = 0; i < delRows; i++)
  4475. {
  4476. table1.Rows.RemoveAt(cultivateRowIndex);
  4477. //cultivateRowIndex++;
  4478. }
  4479. }
  4480. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4481. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4482. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4483. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4484. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4485. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4486. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4487. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4488. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4489. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4490. //其他费用
  4491. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4492. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4493. //其他费用合计
  4494. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4495. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4496. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4497. //公务舱合计
  4498. //国际旅费
  4499. string outsideJJ = "";
  4500. string allPriceJJ = "";
  4501. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4502. {
  4503. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4504. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4505. }
  4506. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4507. {
  4508. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4509. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4510. }
  4511. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4512. {
  4513. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4514. dic.Add("AirFeeTotal", airFeeTotalStr);
  4515. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4516. dic.Add("FeeTotal", feeTotalStr);
  4517. }
  4518. foreach (var key in dic.Keys)
  4519. {
  4520. builder.MoveToBookmark(key);
  4521. builder.Write(dic[key]);
  4522. }
  4523. //模板文件名
  4524. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4525. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4526. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4527. return Ok(JsonView(true, "成功", new { Url = url }));
  4528. }
  4529. }
  4530. else if (dto.ExportType == 2) //表格
  4531. {
  4532. //利用键值对存放数据
  4533. Dictionary<string, string> dic = new Dictionary<string, string>();
  4534. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4535. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4536. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4537. dic.Add("Day", sp.Days.ToString());
  4538. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4539. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4540. {
  4541. //获取模板
  4542. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4543. //载入模板
  4544. Document doc = new Document(tempPath);
  4545. DocumentBuilder builder = new DocumentBuilder(doc);
  4546. dic.Add("TeamName", _DelegationInfo.TeamName);
  4547. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4548. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4549. string missionLeaderName = "",
  4550. missionLeaderJob = "";
  4551. if (DeleClientList.Count > 0)
  4552. {
  4553. missionLeaderName = DeleClientList[0].Name;
  4554. missionLeaderJob = DeleClientList[0].Job;
  4555. }
  4556. dic.Add("MissionLeaderName", missionLeaderName);
  4557. dic.Add("MissionLeaderJob", missionLeaderJob);
  4558. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4559. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4560. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4561. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4562. int rowCount = 10;//总人数行
  4563. int startRowIndex = 7; //起始行
  4564. for (int i = 0; i < DeleClientList.Count; i++)
  4565. {
  4566. builder.MoveToCell(0, startRowIndex, 0, 0);
  4567. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4568. builder.MoveToCell(0, startRowIndex, 1, 0);
  4569. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4570. builder.Write(sex);//性别
  4571. builder.MoveToCell(0, startRowIndex, 2, 0);
  4572. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4573. builder.MoveToCell(0, startRowIndex, 3, 0);
  4574. builder.Write(DeleClientList[i].Company);//工作单位
  4575. builder.MoveToCell(0, startRowIndex, 4, 0);
  4576. builder.Write(DeleClientList[i].Job);//职务及级别
  4577. builder.MoveToCell(0, startRowIndex, 5, 0);
  4578. builder.Write("");//人员属性
  4579. builder.MoveToCell(0, startRowIndex, 6, 0);
  4580. builder.Write("");//上次出国时间
  4581. startRowIndex++;
  4582. }
  4583. int nullRow = rowCount - DeleClientList.Count;//空行
  4584. for (int i = 0; i < nullRow; i++)
  4585. {
  4586. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4587. }
  4588. foreach (var key in dic.Keys)
  4589. {
  4590. builder.MoveToBookmark(key);
  4591. builder.Write(dic[key]);
  4592. }
  4593. //模板文件名
  4594. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4595. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4596. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4597. return Ok(JsonView(true, "成功", new { Url = url }));
  4598. }
  4599. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4600. {
  4601. //获取模板
  4602. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4603. //载入模板
  4604. Document doc = new Document(tempPath);
  4605. DocumentBuilder builder = new DocumentBuilder(doc);
  4606. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4607. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4608. dic.Add("Names", Names);
  4609. int accommodationRows = 12, foodandotherRows = 12;
  4610. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4611. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4612. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4613. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4614. int accommodationStartIndex = 6;
  4615. decimal dac1totalPrice = 0.00M;
  4616. foreach (var dac in dac1)
  4617. {
  4618. if (dac.SubTotal == 0)
  4619. {
  4620. continue;
  4621. }
  4622. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4623. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4624. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4625. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4626. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4627. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4628. builder.Write(currency);//币种
  4629. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4630. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4631. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4632. builder.Write("");//人数
  4633. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4634. builder.Write("");//天数
  4635. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4636. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4637. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4638. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4639. builder.Write(rate.ToString("#0.0000"));//汇率
  4640. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4641. decimal rbmPrice = rate * dac.SubTotal;
  4642. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4643. accommodationStartIndex++;
  4644. dac1totalPrice += rbmPrice;
  4645. }
  4646. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4647. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4648. builder.Write("小计");
  4649. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4650. builder.Write(dac1totalPrice.ToString("#0.00"));
  4651. accommodationStartIndex++;
  4652. int nullRow = accommodationRows - dac1.Count;
  4653. //删除空行
  4654. //if (nullRow > 0)
  4655. //{
  4656. // int rowIndex = accommodationStartIndex;
  4657. // for (int i = 0; i < nullRow; i++)
  4658. // {
  4659. // Row row = table1.Rows[rowIndex];
  4660. // row.Remove();
  4661. // rowIndex++;
  4662. // }
  4663. //}
  4664. if (dac2.Count == dac3.Count)//国家 币种 金额
  4665. {
  4666. for (int i = 0; i < dac2.Count; i++)
  4667. {
  4668. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4669. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4670. }
  4671. }
  4672. int foodandotherStartIndex = 19;//
  4673. decimal dac2totalPrice = 0.00M;
  4674. foreach (var dac in dac2)
  4675. {
  4676. if (dac.SubTotal == 0)
  4677. {
  4678. continue;
  4679. }
  4680. //foodandotherStartIndex = 12;
  4681. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4682. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4683. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4684. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4685. builder.Write(currency);//币种
  4686. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4687. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4688. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4689. builder.Write("");//人数
  4690. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4691. builder.Write("");//天数
  4692. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4693. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4694. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4695. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4696. builder.Write(rate.ToString("#0.0000"));//汇率
  4697. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4698. decimal rbmPrice = rate * dac.SubTotal;
  4699. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4700. foodandotherStartIndex++;
  4701. dac2totalPrice += rbmPrice;
  4702. }
  4703. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4704. //删除空行
  4705. if (dac2.Count < foodandotherRows)
  4706. {
  4707. //int nullRow = accommodationRows - dac2.Count;
  4708. //while (table2.Rows.Count > dac2.Count)
  4709. //{
  4710. // table2.Rows.RemoveAt(dac2.Count);
  4711. //}
  4712. }
  4713. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4714. string otherFeeStr = "";
  4715. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4716. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4717. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4718. if (otherFeeStr.Length > 0)
  4719. {
  4720. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4721. otherFeeStr = $"({otherFeeStr})";
  4722. dic.Add("OtherFeeStr", otherFeeStr);
  4723. }
  4724. foreach (var key in dic.Keys)
  4725. {
  4726. builder.MoveToBookmark(key);
  4727. builder.Write(dic[key]);
  4728. }
  4729. //模板文件名
  4730. string strFileName = $"省级单位出(境)经费报销单.docx";
  4731. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4732. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4733. return Ok(JsonView(true, "成功", new { Url = url }));
  4734. }
  4735. }
  4736. else if (dto.ExportType == 3)
  4737. {
  4738. if (dto.SubTypeId == 1) //团组成员名单
  4739. {
  4740. if (DeleClientList.Count < 1)
  4741. {
  4742. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4743. }
  4744. //获取模板
  4745. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4746. //载入模板
  4747. Document doc = new Document(tempPath);
  4748. DocumentBuilder builder = new DocumentBuilder(doc);
  4749. //获取word里所有表格
  4750. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4751. //获取所填表格的序数
  4752. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4753. var rowStart = tableOne.Rows[0]; //获取第1行
  4754. //循环赋值
  4755. for (int i = 0; i < DeleClientList.Count; i++)
  4756. {
  4757. builder.MoveToCell(0, i + 1, 0, 0);
  4758. builder.Write(DeleClientList[i].Name);
  4759. builder.MoveToCell(0, i + 1, 1, 0);
  4760. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4761. builder.Write(sex);
  4762. builder.MoveToCell(0, i + 1, 2, 0);
  4763. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4764. builder.MoveToCell(0, i + 1, 3, 0);
  4765. builder.Write(DeleClientList[i].Company);
  4766. builder.MoveToCell(0, i + 1, 4, 0);
  4767. builder.Write(DeleClientList[i].Job);
  4768. }
  4769. //删除多余行
  4770. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4771. {
  4772. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4773. }
  4774. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4775. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4776. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4777. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4778. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4779. return Ok(JsonView(true, "成功", new { Url = url }));
  4780. }
  4781. }
  4782. return Ok(JsonView(false, "操作失败!"));
  4783. }
  4784. catch (Exception ex)
  4785. {
  4786. return Ok(JsonView(false, ex.Message));
  4787. }
  4788. }
  4789. /// <summary>
  4790. /// 获取三公费用标准city
  4791. /// </summary>
  4792. /// <param name="placeData"></param>
  4793. /// <param name="nationalTravelFeeId"></param>
  4794. /// <returns></returns>
  4795. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4796. {
  4797. string _city = string.Empty;
  4798. if (placeData.Count < 1) return _city;
  4799. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4800. if (data == null) return _city;
  4801. string country = data.Country;
  4802. string city = data.City;
  4803. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4804. else _city = city;
  4805. return _city;
  4806. }
  4807. /// <summary>
  4808. /// 团组模块 - 出入境费用 - 明细表导出
  4809. /// </summary>
  4810. /// <returns></returns>
  4811. [HttpPost]
  4812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4813. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4814. {
  4815. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4816. if (data.Code != 0)
  4817. {
  4818. return Ok(JsonView(false, data.Msg));
  4819. }
  4820. return Ok(JsonView(true, data.Msg, data.Data));
  4821. }
  4822. /// <summary>
  4823. /// 团组模块 - 出入境费用 - 一键清空
  4824. /// </summary>
  4825. /// <returns></returns>
  4826. [HttpPost]
  4827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4828. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4829. {
  4830. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4831. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4832. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4833. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4834. if (_view.Code == 0)
  4835. {
  4836. return Ok(JsonView(true, "操作成功"));
  4837. }
  4838. return Ok(JsonView(false, "操作失败"));
  4839. }
  4840. /// <summary>
  4841. /// 团组模块 - 出入境费用 - 子项删除
  4842. /// </summary>
  4843. /// <returns></returns>
  4844. [HttpPost]
  4845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4846. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4847. {
  4848. try
  4849. {
  4850. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4851. if (data.Code != 0)
  4852. {
  4853. return Ok(JsonView(false, data.Msg));
  4854. }
  4855. return Ok(JsonView(true, "操作成功!", data.Data));
  4856. }
  4857. catch (Exception ex)
  4858. {
  4859. return Ok(JsonView(false, ex.Message));
  4860. }
  4861. }
  4862. /// <summary>
  4863. /// 团组模块 - 出入境国家费用标准 List
  4864. /// </summary>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4868. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4869. {
  4870. try
  4871. {
  4872. Stopwatch sw = new Stopwatch();
  4873. sw.Start();
  4874. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4875. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4876. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4877. Where gntf.Isdel = 0");
  4878. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4879. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4880. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4881. //foreach (var item in nationalTravel)
  4882. //{
  4883. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4884. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4885. // if (otherData != null)
  4886. // {
  4887. // cityData.Remove(otherData);
  4888. // cityData.Add(otherData);
  4889. // }
  4890. // nationalTravelFeeData1.Add(new
  4891. // {
  4892. // Country = item.Country,
  4893. // CityData = cityData
  4894. // });
  4895. //}
  4896. sw.Stop();
  4897. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4898. }
  4899. catch (Exception ex)
  4900. {
  4901. return Ok(JsonView(false, ex.Message));
  4902. throw;
  4903. }
  4904. }
  4905. /// <summary>
  4906. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4907. /// </summary>
  4908. /// <returns></returns>
  4909. [HttpPost]
  4910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4911. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4912. {
  4913. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4914. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4915. List<string> countryData = new List<string>();
  4916. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4917. countryData = countryData.Distinct().ToList();
  4918. List<dynamic> dataSource = new List<dynamic>();
  4919. foreach (var item in countryData)
  4920. {
  4921. List<string> cityData1 = new List<string>();
  4922. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4923. var countryData2 = new
  4924. {
  4925. CountryName = item,
  4926. CityData = cityData1
  4927. };
  4928. dataSource.Add(countryData2);
  4929. }
  4930. return Ok(JsonView(true, "查询成功!", dataSource));
  4931. }
  4932. /// <summary>
  4933. /// 团组模块 - 出入境国家费用标准 Page List
  4934. /// </summary>
  4935. /// <returns></returns>
  4936. [HttpPost]
  4937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4938. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4939. {
  4940. int portId = dto.PortType;
  4941. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4942. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4943. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4944. string whereSql = string.Empty;
  4945. if (!string.IsNullOrEmpty(dto.Country))
  4946. {
  4947. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4948. }
  4949. if (!string.IsNullOrEmpty(dto.City))
  4950. {
  4951. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4952. }
  4953. string pageSql = string.Format(@"Select * From (
  4954. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4955. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4956. From Grp_NationalTravelFee gntf
  4957. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4958. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4959. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4960. RefAsync<int> total = 0;
  4961. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4962. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4963. }
  4964. /// <summary>
  4965. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4966. /// </summary>
  4967. /// <returns></returns>
  4968. [HttpPost]
  4969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4970. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4971. {
  4972. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4973. int portId = dto.PortType;
  4974. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4975. string whereSql = string.Empty;
  4976. if (!string.IsNullOrEmpty(dto.Country))
  4977. {
  4978. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4979. }
  4980. if (!string.IsNullOrEmpty(dto.City))
  4981. {
  4982. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4983. }
  4984. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4985. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4986. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4987. From Grp_NationalTravelFee gntf
  4988. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4989. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4990. Where gntf.Isdel = 0 {0} ", whereSql);
  4991. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4992. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4993. }
  4994. /// <summary>
  4995. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4996. /// </summary>
  4997. /// <returns></returns>
  4998. [HttpPost]
  4999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5000. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5001. {
  5002. try
  5003. {
  5004. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5005. if (data.Code != 0)
  5006. {
  5007. return Ok(JsonView(false, data.Msg));
  5008. }
  5009. return Ok(JsonView(true, "操作成功!", data.Data));
  5010. }
  5011. catch (Exception ex)
  5012. {
  5013. return Ok(JsonView(false, ex.Message));
  5014. }
  5015. }
  5016. /// <summary>
  5017. /// 团组模块 - 出入境国家费用标准 - Del
  5018. /// </summary>
  5019. /// <returns></returns>
  5020. [HttpPost]
  5021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5022. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5023. {
  5024. try
  5025. {
  5026. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5027. {
  5028. Id = dto.Id,
  5029. DeleteUserId = dto.DeleteUserId,
  5030. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5031. IsDel = 1
  5032. };
  5033. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5034. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5035. .WhereColumns(it => new { it.Id })
  5036. .ExecuteCommandAsync();
  5037. if (delStatus <= 0)
  5038. {
  5039. return Ok(JsonView(false, "删除失败!"));
  5040. }
  5041. return Ok(JsonView(true, "操作成功!"));
  5042. }
  5043. catch (Exception ex)
  5044. {
  5045. return Ok(JsonView(false, ex.Message));
  5046. }
  5047. }
  5048. #endregion
  5049. #region 签证费用录入
  5050. /// <summary>
  5051. /// 根据diid查询签证费用列表
  5052. /// </summary>
  5053. /// <param name="dto"></param>
  5054. /// <returns></returns>
  5055. [HttpPost]
  5056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5057. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5058. {
  5059. try
  5060. {
  5061. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5062. if (groupData.Code != 0)
  5063. {
  5064. return Ok(JsonView(false, groupData.Msg));
  5065. }
  5066. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5067. }
  5068. catch (Exception ex)
  5069. {
  5070. return Ok(JsonView(false, ex.Message));
  5071. }
  5072. }
  5073. /// <summary>
  5074. /// 根据签证费用Id查询单条数据及c表数据
  5075. /// </summary>
  5076. /// <param name="dto"></param>
  5077. /// <returns></returns>
  5078. [HttpPost]
  5079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5080. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5081. {
  5082. try
  5083. {
  5084. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5085. if (groupData.Code != 0)
  5086. {
  5087. return Ok(JsonView(false, groupData.Msg));
  5088. }
  5089. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5090. }
  5091. catch (Exception ex)
  5092. {
  5093. return Ok(JsonView(false, ex.Message));
  5094. }
  5095. }
  5096. /// <summary>
  5097. /// 签证费用删除
  5098. /// </summary>
  5099. /// <param name="dto"></param>
  5100. /// <returns></returns>
  5101. [HttpPost]
  5102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5103. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5104. {
  5105. _sqlSugar.BeginTran();
  5106. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5107. if (!res)
  5108. {
  5109. _sqlSugar.RollbackTran();
  5110. return Ok(JsonView(false, "删除失败"));
  5111. }
  5112. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5113. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5114. .SetColumns(a => new Grp_CreditCardPayment()
  5115. {
  5116. IsDel = 1,
  5117. DeleteUserId = dto.DeleteUserId,
  5118. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5119. }).ExecuteCommand();
  5120. if (resSub < 1)
  5121. {
  5122. _sqlSugar.RollbackTran();
  5123. return Ok(JsonView(false, "删除失败"));
  5124. }
  5125. _sqlSugar.CommitTran();
  5126. return Ok(JsonView(true, "删除成功!"));
  5127. }
  5128. /// <summary>
  5129. /// 签证费用录入下拉框初始化
  5130. /// </summary>
  5131. /// <returns></returns>
  5132. [HttpPost]
  5133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5134. public async Task<IActionResult> VisaPriceAddSelect()
  5135. {
  5136. try
  5137. {
  5138. //支付方式
  5139. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5140. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5141. //币种
  5142. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5143. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5144. //乘客类型
  5145. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5146. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5147. //卡类型
  5148. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5149. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5150. var data = new
  5151. {
  5152. Payment = _Payment,
  5153. CurrencyList = _CurrencyList,
  5154. PassengerType = _PassengerType,
  5155. BankCard = _BankCard
  5156. };
  5157. return Ok(JsonView(true, "查询成功!", data));
  5158. }
  5159. catch (Exception ex)
  5160. {
  5161. return Ok(JsonView(false, "程序错误!"));
  5162. throw;
  5163. }
  5164. }
  5165. /// <summary>
  5166. /// 签证费用录入操作(Status:1.新增,2.修改)
  5167. /// </summary>
  5168. /// <param name="dto"></param>
  5169. /// <returns></returns>
  5170. [HttpPost]
  5171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5172. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5173. {
  5174. try
  5175. {
  5176. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5177. if (groupData.Code != 0)
  5178. {
  5179. return Ok(JsonView(false, groupData.Msg));
  5180. }
  5181. #region 应用推送
  5182. try
  5183. {
  5184. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5185. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5186. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5187. }
  5188. catch (Exception ex)
  5189. {
  5190. }
  5191. #endregion
  5192. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5193. }
  5194. catch (Exception ex)
  5195. {
  5196. return Ok(JsonView(false, ex.Message));
  5197. }
  5198. }
  5199. #endregion
  5200. #region op费用录入
  5201. /// <summary>
  5202. /// 根据diid查询op费用列表
  5203. /// </summary>
  5204. /// <param name="dto"></param>
  5205. /// <returns></returns>
  5206. [HttpPost]
  5207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5208. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5209. {
  5210. try
  5211. {
  5212. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5213. if (groupData.Code != 0)
  5214. {
  5215. return Ok(JsonView(false, groupData.Msg));
  5216. }
  5217. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5218. }
  5219. catch (Exception ex)
  5220. {
  5221. return Ok(JsonView(false, ex.Message));
  5222. }
  5223. }
  5224. /// <summary>
  5225. /// 根据op费用Id查询单条数据及c表数据
  5226. /// </summary>
  5227. /// <param name="dto"></param>
  5228. /// <returns></returns>
  5229. [HttpPost]
  5230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5231. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5232. {
  5233. try
  5234. {
  5235. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5236. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5237. var data = new
  5238. {
  5239. CarTouristGuideGround = _groupData,
  5240. CreditCardPayment = _creditCardPayment
  5241. };
  5242. return Ok(JsonView(true, "查询成功!", data));
  5243. }
  5244. catch (Exception ex)
  5245. {
  5246. return Ok(JsonView(false, "程序错误!"));
  5247. }
  5248. }
  5249. /// <summary>
  5250. /// op费用删除
  5251. /// </summary>
  5252. /// <param name="dto"></param>
  5253. /// <returns></returns>
  5254. [HttpPost]
  5255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5256. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5257. {
  5258. try
  5259. {
  5260. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5261. if (!res)
  5262. {
  5263. return Ok(JsonView(false, "删除失败"));
  5264. }
  5265. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5266. {
  5267. IsDel = 1,
  5268. DeleteUserId = dto.DeleteUserId,
  5269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5270. }).ExecuteCommandAsync();
  5271. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5272. {
  5273. IsDel = 1,
  5274. DeleteUserId = dto.DeleteUserId,
  5275. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5276. }).ExecuteCommandAsync();
  5277. return Ok(JsonView(true, "删除成功!"));
  5278. }
  5279. catch (Exception ex)
  5280. {
  5281. return Ok(JsonView(false, "程序错误!"));
  5282. throw;
  5283. }
  5284. }
  5285. /// <summary>
  5286. /// op费用录入操作(Status:1.新增,2.修改)
  5287. /// </summary>
  5288. /// <param name="dto"></param>
  5289. /// <returns></returns>
  5290. [HttpPost]
  5291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5292. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5293. {
  5294. try
  5295. {
  5296. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5297. if (groupData.Code != 0)
  5298. {
  5299. return Ok(JsonView(false, groupData.Msg));
  5300. }
  5301. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5302. }
  5303. catch (Exception ex)
  5304. {
  5305. return Ok(JsonView(false, ex.Message));
  5306. }
  5307. }
  5308. /// <summary>
  5309. /// 填写费用详细页面初始化绑定
  5310. /// </summary>
  5311. /// <param name="dto"></param>
  5312. /// <returns></returns>
  5313. [HttpPost]
  5314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5315. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5316. {
  5317. try
  5318. {
  5319. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5320. if (groupData.Code != 0)
  5321. {
  5322. return Ok(JsonView(false, groupData.Msg));
  5323. }
  5324. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5325. }
  5326. catch (Exception ex)
  5327. {
  5328. return Ok(JsonView(false, ex.Message));
  5329. }
  5330. }
  5331. /// <summary>
  5332. /// 根据op费用Id查询详细数据
  5333. /// </summary>
  5334. /// <param name="dto"></param>
  5335. /// <returns></returns>
  5336. [HttpPost]
  5337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5338. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5339. {
  5340. try
  5341. {
  5342. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5343. if (groupData.Code != 0)
  5344. {
  5345. return Ok(JsonView(false, groupData.Msg));
  5346. }
  5347. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5348. }
  5349. catch (Exception ex)
  5350. {
  5351. return Ok(JsonView(false, ex.Message));
  5352. }
  5353. }
  5354. /// <summary>
  5355. /// OP费用录入填写详情
  5356. /// </summary>
  5357. /// <param name="dto"></param>
  5358. /// <returns></returns>
  5359. [HttpPost]
  5360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5361. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5362. {
  5363. try
  5364. {
  5365. #region 参数校验
  5366. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5367. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5368. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5369. #endregion
  5370. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5371. if (groupData.Code != 0)
  5372. {
  5373. return Ok(JsonView(false, groupData.Msg));
  5374. }
  5375. //自动审核
  5376. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5377. #region 应用推送
  5378. try
  5379. {
  5380. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5381. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5382. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5383. }
  5384. catch (Exception ex)
  5385. {
  5386. }
  5387. #endregion
  5388. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5389. }
  5390. catch (Exception ex)
  5391. {
  5392. return Ok(JsonView(false, ex.Message));
  5393. }
  5394. }
  5395. /// <summary>
  5396. /// 获取三公详细所有城市
  5397. /// </summary>
  5398. /// <returns></returns>
  5399. [HttpGet]
  5400. public IActionResult OpCarCityResult()
  5401. {
  5402. var jw = JsonView(false);
  5403. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5404. {
  5405. x.Id,
  5406. x.Country,
  5407. x.City,
  5408. }).ToList();
  5409. if (data.Count > 0)
  5410. {
  5411. jw = JsonView(true, "获取成功!", data);
  5412. }
  5413. else
  5414. {
  5415. jw.Msg = "城市数据为空!";
  5416. jw.Data = new string[0];
  5417. }
  5418. return Ok(jw);
  5419. }
  5420. /// <summary>
  5421. /// 导出地接费用明细
  5422. /// </summary>
  5423. /// <param name="dto"></param>
  5424. /// <returns></returns>
  5425. [HttpPost]
  5426. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5427. {
  5428. var jw = JsonView(false);
  5429. if (dto.Diid < 1)
  5430. {
  5431. jw.Msg = "请输入正确的diid!";
  5432. return Ok(jw);
  5433. }
  5434. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5435. if (group == null)
  5436. {
  5437. jw.Msg = "未找到团组信息!";
  5438. return Ok(jw);
  5439. }
  5440. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5441. if (localGuideArr.Count == 0)
  5442. {
  5443. jw.Msg = "该团组暂无地接信息!";
  5444. return Ok(jw);
  5445. }
  5446. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5447. var overspendSoure = new Dictionary<int, int>
  5448. {
  5449. { 91, 982 }, //车
  5450. { 92 , 1059} ,//导游
  5451. { 994 , 1073}, //翻译
  5452. { 988 , 1074 }, //早餐
  5453. { 93 , 1075 }, //午餐
  5454. { 989 , 1076 }, //晚餐
  5455. };
  5456. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5457. foreach (var groupArr in localGroup)
  5458. {
  5459. var keyValue = groupArr.Key;
  5460. if (int.TryParse(keyValue, out int cityid))
  5461. {
  5462. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5463. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5464. }
  5465. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5466. foreach (var item in groupArr)
  5467. {
  5468. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5469. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5470. new Grp_CarTouristGuideGroundReservationsContentExtend
  5471. {
  5472. Count = a.Count,
  5473. CreateTime = a.CreateTime,
  5474. CreateUserId = a.CreateUserId,
  5475. CTGGRId = a.CTGGRId,
  5476. Currency = a.Currency,
  5477. DatePrice = a.DatePrice,
  5478. DeleteTime = a.DeleteTime,
  5479. DeleteUserId = a.DeleteUserId,
  5480. DiId = a.DiId,
  5481. Id = a.Id,
  5482. IsDel = a.IsDel,
  5483. Price = a.Price,
  5484. PriceContent = a.PriceContent,
  5485. Remark = a.Remark,
  5486. SId = a.SId,
  5487. SidName = b.Name,
  5488. Units = a.Units,
  5489. }
  5490. ).ToList();
  5491. if (content.Count > 0)
  5492. {
  5493. contentArr.Add(content);
  5494. }
  5495. }
  5496. //open excel
  5497. //set excel
  5498. //save excel
  5499. try
  5500. {
  5501. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5502. IWorkbook workbook;
  5503. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5504. {
  5505. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5506. }
  5507. else
  5508. {
  5509. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5510. }
  5511. ISheet sheet = workbook.GetSheetAt(0);
  5512. var rowStartIndex = 2;
  5513. var clounmCount = 10;
  5514. var initStyleRow = sheet.GetRow(2);
  5515. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5516. //var overspendArrDetail =
  5517. var existsId = new List<CarCompare>();
  5518. var lastElem = arr.Last();
  5519. var thisSid = -1;
  5520. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5521. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5522. {
  5523. Name = "未知币种!",
  5524. Remark = "未知币种!",
  5525. };
  5526. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5527. Action cloneRowFn = () =>
  5528. {
  5529. rowStartIndex++;
  5530. var cloneRow = sheet.CreateRow(rowStartIndex);
  5531. // 复制样式
  5532. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5533. {
  5534. ICell sourceCell = initStyleRow.GetCell(i);
  5535. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5536. // 确保单元格存在样式
  5537. if (sourceCell.CellStyle != null)
  5538. {
  5539. targetCell.CellStyle = sourceCell.CellStyle;
  5540. }
  5541. }
  5542. };
  5543. var mergeRow = () =>
  5544. {
  5545. for (int i = 2; i < sheet.LastRowNum; i++)
  5546. {
  5547. var row = sheet.GetRow(i);
  5548. var cellFirst = row.GetCell(0);
  5549. var thisIndex = i + 1;
  5550. while (thisIndex < sheet.LastRowNum)
  5551. {
  5552. var nextRow = sheet.GetRow(thisIndex);
  5553. var nextCellFirst = nextRow.GetCell(0);
  5554. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5555. {
  5556. thisIndex++;
  5557. }
  5558. else
  5559. {
  5560. break;
  5561. }
  5562. }
  5563. thisIndex--;
  5564. if (thisIndex != i)
  5565. {
  5566. //合并row
  5567. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5568. i, // 起始行索引(0-based)
  5569. thisIndex, // 结束行索引(0-based)
  5570. 0, // 起始列索引(0-based)
  5571. 0 // 结束列索引(0-based)
  5572. );
  5573. sheet.AddMergedRegion(cellRangeAddress);
  5574. i = thisIndex;
  5575. }
  5576. }
  5577. };
  5578. var chaoshiNumber = 0;
  5579. var totalNumber = 0.00M;
  5580. string lastStr = "";
  5581. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5582. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5583. {
  5584. b.IsAuditGM,
  5585. x.Id,
  5586. x.Area,
  5587. b.PayPercentage,
  5588. b.PayMoney,
  5589. }).ToList();
  5590. string yesPayment = "", noPayment = "";
  5591. foreach (var item in queryCarArrByCityAndDiid)
  5592. {
  5593. if (item.IsAuditGM == 1)
  5594. {
  5595. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5596. }
  5597. else
  5598. {
  5599. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5600. }
  5601. }
  5602. lastStr = yesPayment + noPayment;
  5603. foreach (var item in arr)
  5604. {
  5605. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5606. {
  5607. if (thisSid != item.SId)
  5608. {
  5609. if (thisSid == -1)
  5610. {
  5611. thisSid = item.SId;
  5612. }
  5613. else
  5614. {
  5615. //合并小计行
  5616. //创建合并区域的实例
  5617. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5618. rowStartIndex, // 起始行索引(0-based)
  5619. rowStartIndex, // 结束行索引(0-based)
  5620. 0, // 起始列索引(0-based)
  5621. 3 // 结束列索引(0-based)
  5622. );
  5623. sheet.AddMergedRegion(cellRangeAddress);
  5624. var CellStyle = workbook.CreateCellStyle();
  5625. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5626. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5627. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5628. for (int i = 0; i <= clounmCount; i++)
  5629. {
  5630. if (i > 6)
  5631. {
  5632. var CellStyle1 = workbook.CreateCellStyle();
  5633. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5634. IFont Font = workbook.CreateFont(); // 创建字体
  5635. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5636. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5637. CellStyle1.SetFont(Font);
  5638. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5639. }
  5640. else
  5641. {
  5642. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5643. }
  5644. }
  5645. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5646. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5647. //超时合计
  5648. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5649. //超时数
  5650. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5651. //超时合计费用
  5652. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5653. thisSid = item.SId;
  5654. cloneRowFn();
  5655. chaoshiNumber = 0;
  5656. totalNumber = 0;
  5657. }
  5658. }
  5659. IRow row = sheet.GetRow(rowStartIndex);
  5660. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5661. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5662. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5663. if (isOpenOverspendSoure)
  5664. {
  5665. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5666. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5667. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5668. }
  5669. for (int i = 0; i <= clounmCount; i++)
  5670. {
  5671. var cell = row.GetCell(i);
  5672. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5673. if (cell == null)
  5674. {
  5675. cell = row.CreateCell(i);
  5676. }
  5677. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5678. fontRed.CloneStyleFrom(cell.CellStyle);
  5679. IFont Font = workbook.CreateFont(); // 创建字体
  5680. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5681. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5682. fontRed.SetFont(Font);
  5683. byte[] rgb = new byte[3] { 255, 242, 204 };
  5684. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5685. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5686. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5687. if (workbook is XSSFWorkbook)
  5688. {
  5689. BackgroundColor255_242_204.FillForegroundColor = 0;
  5690. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5691. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5692. }
  5693. else
  5694. {
  5695. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5696. }
  5697. if (i == 1 || i > 6)
  5698. {
  5699. if (i > 6)
  5700. {
  5701. fontRed.FillForegroundColor = 0;
  5702. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5703. fontRed.FillPattern = FillPattern.SolidForeground;
  5704. }
  5705. cell.CellStyle = fontRed;
  5706. }
  5707. if (i > 2 && i < 7)
  5708. {
  5709. cell.CellStyle = BackgroundColor255_242_204;
  5710. }
  5711. cell.SetCellValue(setCellValue); //写入单元格
  5712. }
  5713. if (overspendSoure.ContainsKey(thisSid))
  5714. {
  5715. var overspendId = overspendSoure[thisSid];
  5716. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5717. }
  5718. cloneRowFn();
  5719. existsId.Add(new CarCompare
  5720. {
  5721. DataPrice = item.DatePrice.ObjToDate(),
  5722. Sid = item.SId
  5723. });
  5724. }
  5725. if (item.Equals(lastElem))
  5726. {
  5727. //合并小计行
  5728. //创建合并区域的实例
  5729. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5730. rowStartIndex, // 起始行索引(0-based)
  5731. rowStartIndex, // 结束行索引(0-based)
  5732. 0, // 起始列索引(0-based)
  5733. 3 // 结束列索引(0-based)
  5734. );
  5735. sheet.AddMergedRegion(cellRangeAddress);
  5736. var CellStyle = workbook.CreateCellStyle();
  5737. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5738. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5739. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5740. for (int i = 0; i <= clounmCount; i++)
  5741. {
  5742. if (i > 6)
  5743. {
  5744. var CellStyle1 = workbook.CreateCellStyle();
  5745. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5746. IFont Font = workbook.CreateFont(); // 创建字体
  5747. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5748. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5749. CellStyle1.SetFont(Font);
  5750. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5751. }
  5752. else
  5753. {
  5754. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5755. }
  5756. }
  5757. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5758. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5759. //超时合计
  5760. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5761. //超时数
  5762. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5763. //超时合计费用
  5764. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5765. cloneRowFn();
  5766. // 创建合并区域的实例
  5767. cellRangeAddress = new CellRangeAddress(
  5768. rowStartIndex, // 起始行索引(0-based)
  5769. rowStartIndex, // 结束行索引(0-based)
  5770. 0, // 起始列索引(0-based)
  5771. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5772. );
  5773. // 添加合并区域
  5774. sheet.AddMergedRegion(cellRangeAddress);
  5775. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5776. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5777. }
  5778. }
  5779. mergeRow();
  5780. // 保存修改后的Excel文件到新文件
  5781. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5782. // new FileStream(newFilePath, FileMode.CreateNew)
  5783. using (var stream = new MemoryStream())
  5784. {
  5785. workbook.Write(stream, true);
  5786. stream.Flush();
  5787. stream.Seek(0, SeekOrigin.Begin);
  5788. MemoryStream memoryStream = new MemoryStream();
  5789. stream.CopyTo(memoryStream);
  5790. memoryStream.Seek(0, SeekOrigin.Begin);
  5791. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5792. }
  5793. workbook.Close();
  5794. workbook.Dispose();
  5795. }
  5796. catch (Exception ex)
  5797. {
  5798. jw.Msg = "出现异常!" + ex.Message;
  5799. return Ok(jw);
  5800. }
  5801. }
  5802. if (Zips.Count > 0)
  5803. {
  5804. IOOperatorHelper io = new IOOperatorHelper();
  5805. var byts = io.ConvertZipStream(Zips);
  5806. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5807. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5808. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5809. }
  5810. else
  5811. {
  5812. jw.Msg = "暂无生成文件!";
  5813. }
  5814. return Ok(jw);
  5815. }
  5816. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5817. {
  5818. string outStr = string.Empty;
  5819. switch (i)
  5820. {
  5821. case 0:
  5822. outStr = arr[0].SidName;
  5823. break;
  5824. case 1:
  5825. outStr = arr[0].DataPriceStr;
  5826. break;
  5827. case 2:
  5828. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5829. break;
  5830. case 4:
  5831. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5832. break;
  5833. case 7:
  5834. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5835. {
  5836. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5837. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5838. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5839. }
  5840. break;
  5841. case 8:
  5842. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5843. {
  5844. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5845. }
  5846. break;
  5847. case 9:
  5848. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5849. {
  5850. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5851. }
  5852. break;
  5853. case 10:
  5854. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5855. {
  5856. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5857. }
  5858. break;
  5859. }
  5860. return outStr;
  5861. }
  5862. #region OP行程单
  5863. /// <summary>
  5864. /// OP行程单初始化
  5865. /// </summary>
  5866. /// <param name="dto"></param>
  5867. /// <returns></returns>
  5868. [HttpPost]
  5869. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5870. {
  5871. var jw = JsonView(false);
  5872. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5873. var group = groupList.First();
  5874. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5875. if (group == null)
  5876. {
  5877. jw.Msg = "暂无团组!";
  5878. return Ok(jw);
  5879. }
  5880. group = groupList.Find(x => x.Id == diid);
  5881. if (group == null)
  5882. {
  5883. jw.Msg = "请输入正确的团组ID!";
  5884. return Ok(jw);
  5885. }
  5886. string city = string.Empty;
  5887. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5888. if (blackCode.Count > 0)
  5889. {
  5890. var black = blackCode.First();
  5891. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5892. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5893. if (blackSp.Length > 0)
  5894. {
  5895. try
  5896. {
  5897. var cityArrCode = new List<string>(20);
  5898. foreach (var item in blackSp)
  5899. {
  5900. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5901. var IndexSelect = itemSp[2];
  5902. var cityArrCodeLength = cityArrCode.Count - 1;
  5903. var startCity = IndexSelect.Substring(0, 3);
  5904. if (cityArrCodeLength > 0)
  5905. {
  5906. var arrEndCity = cityArrCode[cityArrCodeLength];
  5907. if (arrEndCity != startCity)
  5908. {
  5909. cityArrCode.Add(startCity.ToUpper());
  5910. }
  5911. }
  5912. else
  5913. {
  5914. cityArrCode.Add(startCity.ToUpper());
  5915. }
  5916. var endCity = IndexSelect.Substring(3, 3);
  5917. cityArrCode.Add(endCity.ToUpper());
  5918. }
  5919. var cityThree = string.Empty;
  5920. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5921. cityThree = cityThree.TrimEnd(',');
  5922. if (string.IsNullOrWhiteSpace(cityThree))
  5923. {
  5924. throw new
  5925. Exception("error");
  5926. }
  5927. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5928. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5929. foreach (var item in cityArrCode)
  5930. {
  5931. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5932. if (find != null)
  5933. {
  5934. city += find.City + "/";
  5935. }
  5936. else
  5937. {
  5938. city += item + "三字码未收入/";
  5939. }
  5940. }
  5941. city = city.TrimEnd('/');
  5942. }
  5943. catch (Exception e)
  5944. {
  5945. city = "黑屏代码格式不正确!";
  5946. }
  5947. }
  5948. }
  5949. else
  5950. {
  5951. city = "未录入黑屏代码";
  5952. }
  5953. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5954. {
  5955. Date = x.Date,
  5956. Days = x.Days,
  5957. Diffgroup = x.Diffgroup,
  5958. Diid = x.Diid,
  5959. Traffic_First = x.Traffic_First,
  5960. Traffic_Second = x.Traffic_Second,
  5961. Trip = x.Trip,
  5962. WeekDay = x.WeekDay,
  5963. Id = x.Id
  5964. }).ToList();
  5965. jw.Data = new
  5966. {
  5967. groupList = groupList.Select(x => new
  5968. {
  5969. x.Id,
  5970. x.TeamName,
  5971. x.TourCode
  5972. }).ToList(),
  5973. groupInfo = new
  5974. {
  5975. group.VisitDays,
  5976. group.TourCode,
  5977. group.VisitPNumber,
  5978. group.TeamName,
  5979. city
  5980. },
  5981. OpTravelList
  5982. };
  5983. jw.Code = 200;
  5984. jw.Msg = "操作成功!";
  5985. return Ok(jw);
  5986. }
  5987. /// <summary>
  5988. /// 删除团组行程单
  5989. /// </summary>
  5990. /// <returns></returns>
  5991. [HttpPost]
  5992. public IActionResult DelTravel(DelOpTravelDto dto)
  5993. {
  5994. var jw = JsonView(false);
  5995. if (dto.UserId <= 0 || dto.Diid <= 0)
  5996. {
  5997. jw.Msg = "请输入正确的参数!";
  5998. return Ok(jw);
  5999. }
  6000. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6001. .SetColumns(x => new Grp_TravelList
  6002. {
  6003. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6004. DeleteUserId = dto.UserId,
  6005. IsDel = 1,
  6006. }).ExecuteCommand();
  6007. jw = JsonView(true);
  6008. return Ok(jw);
  6009. }
  6010. /// <summary>
  6011. /// 行程单保存
  6012. /// </summary>
  6013. /// <returns></returns>
  6014. [HttpPost]
  6015. public IActionResult TravelSave(TravelSaveDto dto)
  6016. {
  6017. var jw = JsonView(false);
  6018. if (dto.Arr.Count > 0)
  6019. {
  6020. try
  6021. {
  6022. _sqlSugar.BeginTran();
  6023. foreach (var item in dto.Arr)
  6024. {
  6025. if (item.Id == 0)
  6026. {
  6027. throw new Exception("请传入正确的Id");
  6028. }
  6029. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6030. .SetColumns(x => new Grp_TravelList
  6031. {
  6032. Trip = item.Trip
  6033. }).ExecuteCommand();
  6034. }
  6035. _sqlSugar.CommitTran();
  6036. jw = JsonView(true);
  6037. }
  6038. catch (Exception ex)
  6039. {
  6040. _sqlSugar.RollbackTran();
  6041. jw.Msg = "程序异常!" + ex.Message;
  6042. }
  6043. }
  6044. else
  6045. {
  6046. jw.Msg = "请传入正确的参数!";
  6047. }
  6048. return Ok(jw);
  6049. }
  6050. /// <summary>
  6051. /// 导出行程单
  6052. /// </summary>
  6053. /// <param name="dto"></param>
  6054. /// <returns></returns>
  6055. [HttpPost]
  6056. public IActionResult ExportTravel(ExportTravelDto dto)
  6057. {
  6058. var jw = JsonView(false);
  6059. jw.Data = "";
  6060. int diid = 0;
  6061. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6062. if (Find == null)
  6063. {
  6064. jw.Msg = "请选择正确的团组!";
  6065. return Ok(jw);
  6066. }
  6067. else
  6068. {
  6069. diid = Find.Id;
  6070. }
  6071. //数据源
  6072. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6073. DataTable dtBlack = null;
  6074. try
  6075. {
  6076. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6077. }
  6078. catch (Exception)
  6079. {
  6080. jw.Msg = "机票黑屏代码有误!";
  6081. return Ok(jw);
  6082. }
  6083. string CityStr = string.Empty;
  6084. if (dtBlack.Rows.Count == 0)
  6085. {
  6086. jw.Msg = "机票黑屏代码有误!";
  6087. return Ok(jw);
  6088. }
  6089. else
  6090. {
  6091. foreach (DataRow row in dtBlack.Rows)
  6092. {
  6093. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6094. {
  6095. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6096. return Ok(jw);
  6097. }
  6098. }
  6099. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6100. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6101. }
  6102. //创建数据源Table
  6103. DataTable dtSource = new DataTable();
  6104. dtSource.Columns.Add("Days", typeof(string));
  6105. dtSource.Columns.Add("Date", typeof(string));
  6106. dtSource.Columns.Add("Week", typeof(string));
  6107. dtSource.Columns.Add("Traffic", typeof(string));
  6108. dtSource.Columns.Add("Trip", typeof(string));
  6109. //获取数据,放到datatable
  6110. foreach (var item in _travelList)
  6111. {
  6112. DataRow dr = dtSource.NewRow();
  6113. dr["Days"] = item.Days;
  6114. dr["Date"] = item.Date;
  6115. dr["Week"] = item.WeekDay;
  6116. dr["Traffic"] = item.Traffic_First
  6117. + "\r\n"
  6118. + item.Traffic_Second;
  6119. dr["Trip"] = item.Trip;
  6120. dtSource.Rows.Add(dr);
  6121. }
  6122. Dictionary<string, string> dic = new Dictionary<string, string>();
  6123. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6124. dic.Add("City", CityStr);
  6125. dic.Add("Days", Find.VisitDays.ToString());
  6126. dic.Add("DeleCode", Find.TourCode);
  6127. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6128. //模板路径
  6129. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6130. //载入模板
  6131. Document doc = null;
  6132. DocumentBuilder builder = null;
  6133. try
  6134. {
  6135. //载入模板
  6136. doc = new Document(tempPath);
  6137. builder = new DocumentBuilder(doc);
  6138. }
  6139. catch (Exception)
  6140. {
  6141. jw.Msg = "模板位置不存在!";
  6142. return Ok(jw);
  6143. }
  6144. foreach (var key in dic.Keys)
  6145. {
  6146. Bookmark bookmark = doc.Range.Bookmarks[key];
  6147. if (bookmark != null)
  6148. {
  6149. builder.MoveToBookmark(key);
  6150. builder.Write(dic[key]);
  6151. }
  6152. }
  6153. //获取word里所有表格
  6154. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6155. //获取所填表格的序数
  6156. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6157. try
  6158. {
  6159. //循环赋值
  6160. for (int i = 0; i < dtSource.Rows.Count; i++)
  6161. {
  6162. builder.MoveToCell(0, i + 1, 0, 0);
  6163. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6164. builder.MoveToCell(0, i + 1, 1, 0);
  6165. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6166. builder.MoveToCell(0, i + 1, 2, 0);
  6167. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6168. var trip = dtSource.Rows[i]["Trip"].ToString();
  6169. builder.MoveToCell(0, i + 1, 3, 0);
  6170. builder.Write(trip);
  6171. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6172. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6173. // 获取特定索引的段落
  6174. Paragraph paragraph = (Paragraph)paragraphs[0];
  6175. Run run = paragraph.Runs[0];
  6176. Aspose.Words.Font font = run.Font;
  6177. font.Name = "黑体";
  6178. //设置双休红色
  6179. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6180. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6181. paragraph = (Paragraph)paragraphs[1];
  6182. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6183. {
  6184. run = paragraph.Runs[0];
  6185. font = run.Font;
  6186. font.Color = Color.Red;
  6187. }
  6188. }
  6189. }
  6190. catch (Exception ex)
  6191. {
  6192. }
  6193. //删除多余行
  6194. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6195. {
  6196. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6197. }
  6198. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6199. if (!Directory.Exists(savePath))
  6200. {
  6201. try
  6202. {
  6203. Directory.CreateDirectory(savePath);
  6204. }
  6205. catch
  6206. {
  6207. }
  6208. }
  6209. string path = savePath + Find.TeamName + "出访日程";
  6210. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6211. try
  6212. {
  6213. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6214. string postfix = ".docx";
  6215. if (dto.IsPDF == 1)
  6216. {
  6217. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6218. postfix = ".pdf";
  6219. }
  6220. doc.Save(path + postfix, saveFormat);
  6221. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6222. }
  6223. catch (Exception)
  6224. {
  6225. jw = JsonView(false);
  6226. }
  6227. return Ok(jw);
  6228. }
  6229. /// <summary>
  6230. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6231. /// </summary>
  6232. /// <param name="num"></param>
  6233. /// <returns></returns>
  6234. string GetNum(string num)
  6235. {
  6236. string str = "";
  6237. switch (num)
  6238. {
  6239. case "1":
  6240. str = "一";
  6241. break;
  6242. case "2":
  6243. str = "二";
  6244. break;
  6245. case "3":
  6246. str = "三";
  6247. break;
  6248. case "4":
  6249. str = "四";
  6250. break;
  6251. case "5":
  6252. str = "五";
  6253. break;
  6254. case "6":
  6255. str = "六";
  6256. break;
  6257. case "7":
  6258. str = "七";
  6259. break;
  6260. case "8":
  6261. str = "八";
  6262. break;
  6263. case "9":
  6264. str = "九";
  6265. break;
  6266. case "10":
  6267. str = "十";
  6268. break;
  6269. case "11":
  6270. str = "十一";
  6271. break;
  6272. case "12":
  6273. str = "十二";
  6274. break;
  6275. case "一":
  6276. str = "1";
  6277. break;
  6278. case "二":
  6279. str = "2";
  6280. break;
  6281. case "三":
  6282. str = "3";
  6283. break;
  6284. case "四":
  6285. str = "4";
  6286. break;
  6287. case "五":
  6288. str = "5";
  6289. break;
  6290. case "六":
  6291. str = "6";
  6292. break;
  6293. case "七":
  6294. str = "7";
  6295. break;
  6296. case "八":
  6297. str = "8";
  6298. break;
  6299. case "九":
  6300. str = "9";
  6301. break;
  6302. case "十":
  6303. str = "10";
  6304. break;
  6305. case "十一":
  6306. str = "11";
  6307. break;
  6308. case "十二":
  6309. str = "12";
  6310. break;
  6311. }
  6312. return str;
  6313. }
  6314. #endregion
  6315. #endregion
  6316. #region 团组成本
  6317. /// <summary>
  6318. /// 团组成本数据初始化
  6319. /// </summary>
  6320. /// <param name="dto"></param>
  6321. /// <returns></returns>
  6322. [HttpPost]
  6323. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6324. {
  6325. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6326. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6327. WHEN COUNT(*) >= 0 THEN 'True'
  6328. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6329. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6330. ").ToList(); //团组列表
  6331. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6332. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6333. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6334. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6335. if (groupinfoValue != null)
  6336. {
  6337. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6338. var spArr = new string[1] { countryArr };
  6339. if (countryArr.Contains("|"))
  6340. {
  6341. spArr = countryArr.Split("|");
  6342. }
  6343. else if (countryArr.Contains("、"))
  6344. {
  6345. spArr = countryArr.Split("、");
  6346. }
  6347. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6348. {
  6349. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6350. if (dbQueryCountry != null)
  6351. {
  6352. visaCountryInfoArr.Add(dbQueryCountry);
  6353. }
  6354. }
  6355. }
  6356. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6357. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6358. var create = _GroupCostRepository.
  6359. CreateGroupCostByBlackCode(dto.Diid);
  6360. if (groupCost.Count == 0 && create.Code == 0)
  6361. {
  6362. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6363. }
  6364. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6365. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6366. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6367. groupCostMap = groupCostMap.Select(x =>
  6368. {
  6369. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6370. {
  6371. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6372. }
  6373. return x;
  6374. }).ToList();
  6375. //GroupCostParameter.Add(new
  6376. // Grp_GroupCostParameter());
  6377. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6378. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6379. return Ok(JsonView(new
  6380. {
  6381. groupList,
  6382. groupInfo,
  6383. groupChecks,
  6384. groupCost = groupCostMap,
  6385. hotelNumber,
  6386. GroupCostParameter = GroupCostParameterMap,
  6387. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6388. {
  6389. x.VisaCountry,
  6390. x.VisaPrice,
  6391. x.Id,
  6392. }).ToList(),
  6393. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6394. blackCodeIsTrue = create.Code == 0 ? true : false,
  6395. hotelIsTrue = hotelIsTrue,
  6396. }));
  6397. }
  6398. /// <summary>
  6399. /// 团组成本信息保存
  6400. /// </summary>
  6401. /// <param name="dto"></param>
  6402. /// <returns></returns>
  6403. [HttpPost]
  6404. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6405. {
  6406. if (dto.Diid <= 0 || dto.Userid <= 0)
  6407. {
  6408. return Ok(JsonView(false));
  6409. }
  6410. JsonView jw = null;
  6411. bool isTrue = false;
  6412. #region 复制团组成本
  6413. //if (dto.Diid == 2581)
  6414. //{
  6415. // dto.Diid = 2599;
  6416. // dto.CheckBoxs.ForEach(x =>
  6417. // {
  6418. // x.Diid = 2599;
  6419. // });
  6420. // dto.GroupCosts.ForEach(x =>
  6421. // {
  6422. // x.Diid = 2599;
  6423. // });
  6424. // dto.CostTypeHotelNumbers.ForEach(x =>
  6425. // {
  6426. // x.Diid = 2599;
  6427. // });
  6428. // dto.GroupCostParameters.ForEach(x =>
  6429. // {
  6430. // x.DiId = 2599;
  6431. // });
  6432. //}
  6433. #endregion
  6434. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6435. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6436. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6437. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6438. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6439. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6440. try
  6441. {
  6442. _sqlSugar.BeginTran();
  6443. isTrue = await _GroupCostRepository.
  6444. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6445. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6446. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6447. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6448. _sqlSugar.CommitTran();
  6449. jw = JsonView(true, "保存成功!", isTrue);
  6450. }
  6451. catch (Exception)
  6452. {
  6453. _sqlSugar.RollbackTran();
  6454. jw = JsonView(false);
  6455. }
  6456. return Ok(jw);
  6457. }
  6458. /// <summary>
  6459. /// 司兼导数据
  6460. /// </summary>
  6461. /// <param name="dto"></param>
  6462. /// <returns></returns>
  6463. [HttpPost]
  6464. public IActionResult GetCarGuides(CarGuidesDto dto)
  6465. {
  6466. JsonView jw = null;
  6467. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6468. jw = JsonView(true, "获取成功!", Data);
  6469. return Ok(jw);
  6470. }
  6471. /// <summary>
  6472. /// 导游数据
  6473. /// </summary>
  6474. /// <param name="dto"></param>
  6475. /// <returns></returns>
  6476. [HttpPost]
  6477. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6478. {
  6479. JsonView jw = null;
  6480. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6481. // 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
  6482. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6483. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6484. jw = JsonView(true, "获取成功!", Data);
  6485. return Ok(jw);
  6486. }
  6487. /// <summary>
  6488. /// 成本车数据
  6489. /// </summary>
  6490. /// <param name="dto"></param>
  6491. /// <returns></returns>
  6492. [HttpPost]
  6493. public IActionResult GetCarInfo(CarGuidesDto dto)
  6494. {
  6495. JsonView jw = null;
  6496. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6497. jw = JsonView(true, "获取成功!", Data);
  6498. return Ok(jw);
  6499. }
  6500. /// <summary>
  6501. /// 景点数据
  6502. /// </summary>
  6503. /// <param name="dto"></param>
  6504. /// <returns></returns>
  6505. [HttpPost]
  6506. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6507. {
  6508. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6509. return Ok(JsonView(true, "获取成功!", Data));
  6510. }
  6511. /// <summary>
  6512. /// 成本通知
  6513. /// </summary>
  6514. /// <param name="dto"></param>
  6515. /// <returns></returns>
  6516. [HttpPost]
  6517. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6518. {
  6519. if (dto.Diid < 0)
  6520. {
  6521. return Ok(JsonView(false));
  6522. }
  6523. JsonView jw = null;
  6524. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6525. if (GroupCostParameter != null)
  6526. {
  6527. int IsShare = 0;
  6528. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6529. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6530. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6531. string msg = string.Empty;
  6532. if (isTrue)
  6533. {
  6534. if (IsShare == 0)
  6535. {
  6536. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6537. }
  6538. else
  6539. {
  6540. #region 企微通知对应岗位用户
  6541. try
  6542. {
  6543. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6544. }
  6545. catch (Exception ex)
  6546. {
  6547. }
  6548. #endregion
  6549. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6550. }
  6551. jw = JsonView(isTrue, msg, new { IsShare });
  6552. }
  6553. else
  6554. {
  6555. msg = "修改失败!";
  6556. jw = JsonView(isTrue, msg);
  6557. }
  6558. }
  6559. else
  6560. {
  6561. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6562. }
  6563. return Ok(jw);
  6564. }
  6565. /// <summary>
  6566. /// 导出报价单
  6567. /// </summary>
  6568. /// <param name="dto"></param>
  6569. /// <returns></returns>
  6570. [HttpPost]
  6571. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6572. {
  6573. if (dto.Diid == 0)
  6574. {
  6575. return Ok(JsonView(false, "请传递团组id"));
  6576. }
  6577. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6578. if (deleInfo.Code != 0)
  6579. {
  6580. return Ok(JsonView(false, "团组信息查询失败!"));
  6581. }
  6582. var di = deleInfo.Data as DelegationInfoWebView;
  6583. if (di != null)
  6584. {
  6585. //文件名
  6586. string strFileName = di.TeamName + "-收款账单.doc";
  6587. //获取模板
  6588. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6589. //载入模板
  6590. Document doc = new Document(tmppath);
  6591. decimal TotalPrice = 0.00M;
  6592. string itemStr = string.Empty;
  6593. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6594. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6595. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6596. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6597. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6598. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6599. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6600. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6601. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6602. foreach (var cost in groupCostType)
  6603. {
  6604. var List = cost.ToList();
  6605. if (cost.Key == "A")
  6606. {
  6607. foreach (var ListItem in List)
  6608. {
  6609. if (ListItem.number > 0)
  6610. {
  6611. if (ListItem.code.Contains("TBR"))
  6612. {
  6613. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6614. }
  6615. else
  6616. {
  6617. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6618. }
  6619. TotalPrice += (ListItem.number * ListItem.price);
  6620. }
  6621. }
  6622. }
  6623. else
  6624. {
  6625. itemStr = itemStr.Insert(0, "A段\r\n");
  6626. itemStr += "B段\r\n";
  6627. foreach (var ListItem in List)
  6628. {
  6629. if (ListItem.number > 0)
  6630. {
  6631. if (ListItem.code.Contains("TBR"))
  6632. {
  6633. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6634. }
  6635. else
  6636. {
  6637. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6638. }
  6639. TotalPrice += (ListItem.number * ListItem.price);
  6640. }
  6641. }
  6642. }
  6643. }
  6644. #region 替换Word模板书签内容
  6645. Dictionary<string, string> marks = new Dictionary<string, string>();
  6646. marks.Add("To", di.ClientUnit);//付款方
  6647. marks.Add("ToTel", di.TellPhone);//付款方电话
  6648. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6649. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6650. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6651. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6652. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6653. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6654. marks.Add("PayItemContent", itemStr);//详细信息
  6655. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6656. #endregion
  6657. ////注
  6658. //if (doc.Range.Bookmarks["Attention"] != null)
  6659. //{
  6660. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6661. // mark.Text = frList[0].Attention;
  6662. //}
  6663. foreach (var item in marks.Keys)
  6664. {
  6665. if (doc.Range.Bookmarks[item] != null)
  6666. {
  6667. Bookmark mark = doc.Range.Bookmarks[item];
  6668. mark.Text = marks[item];
  6669. }
  6670. }
  6671. byte[] bytes = null;
  6672. using (MemoryStream stream = new MemoryStream())
  6673. {
  6674. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6675. bytes = stream.ToArray();
  6676. }
  6677. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6678. return Ok(JsonView(true, "", new
  6679. {
  6680. Data = bytes,
  6681. strFileName,
  6682. }));
  6683. }
  6684. else
  6685. {
  6686. return Ok(JsonView(false, "团组信息不存在!"));
  6687. }
  6688. }
  6689. /// <summary>
  6690. /// 导出团组成本
  6691. /// </summary>
  6692. /// <param name="dto"></param>
  6693. /// <returns></returns>
  6694. [HttpPost]
  6695. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6696. {
  6697. var jw = JsonView(false);
  6698. if (dto.Diid == 0)
  6699. {
  6700. return Ok(JsonView(false, "请传递团组id"));
  6701. }
  6702. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6703. if (deleInfo.Code != 0)
  6704. {
  6705. return Ok(JsonView(false, "团组信息查询失败!"));
  6706. }
  6707. var di = deleInfo.Data as DelegationInfoWebView;
  6708. if (di == null)
  6709. {
  6710. return Ok(JsonView(false, "团组信息查询失败!"));
  6711. }
  6712. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6713. WorkbookDesigner designer = new WorkbookDesigner();
  6714. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6715. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6716. for (int i = 0; i < List_GC.Count; i++)
  6717. {
  6718. GroupCost_Excel gc = new GroupCost_Excel();
  6719. gc.Id = List_GC[i].Id;
  6720. gc.Diid = List_GC[i].Diid.ToString();
  6721. gc.DAY = List_GC[i].DAY;
  6722. string week = "";
  6723. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6724. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6725. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6726. gc.ITIN = List_GC[i].ITIN;
  6727. gc.CarType = List_GC[i].CarType;
  6728. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6729. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6730. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6731. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6732. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6733. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6734. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6735. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6736. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6737. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6738. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6739. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6740. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6741. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6742. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6743. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6744. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6745. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6746. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6747. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6748. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6749. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6750. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6751. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6752. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6753. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6754. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6755. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6756. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6757. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6758. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6759. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6760. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6761. List_GC1.Add(gc);
  6762. }
  6763. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6764. dt.TableName = "TB";
  6765. //报表标题等不用dt的值
  6766. designer.SetDataSource("TeamName", dto.title.TeamName);
  6767. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6768. designer.SetDataSource("Tax", dto.title.Tax);
  6769. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6770. designer.SetDataSource("Currency", dto.title.Currency);
  6771. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6772. designer.SetDataSource("Rate", dto.title.Rate);
  6773. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6774. var Aparams = hotels.Find(x => x.Type == "Default");
  6775. if (Aparams == null)
  6776. {
  6777. return Ok(jw);
  6778. }
  6779. //酒店数量
  6780. var txtSGRNumber = Aparams.SGR.ToString();
  6781. var txtTBRNumber = Aparams.TBR.ToString();
  6782. var txtJSESNumber = Aparams.JSES.ToString();
  6783. var txtSUITENumbe = Aparams.SUITE.ToString();
  6784. if (dto.costType == "B")
  6785. {
  6786. Aparams = hotels.Find(x => x.Type == "A");
  6787. var Bparams = hotels.Find(x => x.Type == "B");
  6788. if (Aparams == null || Bparams == null)
  6789. {
  6790. return Ok(jw);
  6791. }
  6792. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6793. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6794. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6795. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6796. }
  6797. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6798. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6799. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6800. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6801. var ws = designer.Workbook.Worksheets[0];
  6802. int Row = List_GC.Count;
  6803. int startIndex = 11;
  6804. int HideRows = 0;
  6805. List<int> hideRowsList = new List<int>();
  6806. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6807. #region A段left数据
  6808. var left = dto.leftInfo.Find(x => x.Type == "A");
  6809. if (left == null)
  6810. {
  6811. return Ok(jw);
  6812. }
  6813. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6814. if (leftBindData != null)
  6815. {
  6816. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6817. designer.SetDataSource("VisaRS", leftBindData.rs);
  6818. designer.SetDataSource("VisaXS", leftBindData.xs);
  6819. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6820. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6821. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6822. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6823. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6824. }
  6825. else
  6826. {
  6827. hideRowsList.Add(Row + startIndex + HideRows);
  6828. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6829. }
  6830. HideRows += 2;
  6831. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6832. if (leftBindData != null)
  6833. {
  6834. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6835. designer.SetDataSource("BXRS", leftBindData.rs);
  6836. designer.SetDataSource("BXXS", leftBindData.xs);
  6837. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6838. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6839. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6840. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6841. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6842. }
  6843. else
  6844. {
  6845. hideRowsList.Add(Row + startIndex + HideRows);
  6846. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6847. }
  6848. HideRows += 2;
  6849. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6850. if (leftBindData != null)
  6851. {
  6852. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6853. designer.SetDataSource("HSRS", leftBindData.rs);
  6854. designer.SetDataSource("HSXS", leftBindData.xs);
  6855. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6856. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6857. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6858. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6859. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6860. }
  6861. else
  6862. {
  6863. hideRowsList.Add(Row + startIndex + HideRows);
  6864. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6865. }
  6866. HideRows += 2;
  6867. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6868. if (leftBindData != null)
  6869. {
  6870. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6871. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6872. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6873. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6874. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6875. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6876. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6877. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6878. }
  6879. else
  6880. {
  6881. hideRowsList.Add(Row + startIndex + HideRows);
  6882. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6883. }
  6884. HideRows += 2;
  6885. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6886. if (leftBindData != null)
  6887. {
  6888. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6889. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6890. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6891. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6892. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6893. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6894. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6895. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6896. }
  6897. else
  6898. {
  6899. hideRowsList.Add(Row + startIndex + HideRows);
  6900. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6901. }
  6902. HideRows += 2;
  6903. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6904. if (leftBindData != null)
  6905. {
  6906. ////TBR
  6907. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6908. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6909. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6910. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6911. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6912. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6913. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6914. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6915. }
  6916. else
  6917. {
  6918. hideRowsList.Add(Row + startIndex + HideRows);
  6919. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6920. }
  6921. HideRows += 2;
  6922. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6923. if (leftBindData != null)
  6924. {
  6925. ////SGR
  6926. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6927. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6928. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6929. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6930. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6931. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6932. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6933. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6934. }
  6935. else
  6936. {
  6937. hideRowsList.Add(Row + startIndex + HideRows);
  6938. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6939. }
  6940. HideRows += 2;
  6941. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6942. if (leftBindData != null)
  6943. {
  6944. ////JS/ES
  6945. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6946. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6947. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6948. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6949. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6950. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6951. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6952. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6953. }
  6954. else
  6955. {
  6956. hideRowsList.Add(Row + startIndex + HideRows);
  6957. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6958. }
  6959. HideRows += 2;
  6960. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6961. if (leftBindData != null)
  6962. {
  6963. ////SUITE
  6964. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6965. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6966. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6967. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6968. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6969. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6970. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6971. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6972. }
  6973. else
  6974. {
  6975. hideRowsList.Add(Row + startIndex + HideRows);
  6976. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6977. }
  6978. HideRows += 2;
  6979. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6980. if (leftBindData != null)
  6981. {
  6982. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6983. designer.SetDataSource("DJRS", leftBindData.rs);
  6984. designer.SetDataSource("DJXS", leftBindData.xs);
  6985. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6986. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6987. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6988. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6989. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6990. }
  6991. else
  6992. {
  6993. hideRowsList.Add(Row + startIndex + HideRows);
  6994. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6995. }
  6996. HideRows += 2;
  6997. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6998. if (leftBindData != null)
  6999. {
  7000. designer.SetDataSource("HCPCB", leftBindData.cb);
  7001. designer.SetDataSource("HCPRS", leftBindData.rs);
  7002. designer.SetDataSource("HCPXS", leftBindData.xs);
  7003. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7004. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7005. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7006. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7007. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7008. }
  7009. else
  7010. {
  7011. hideRowsList.Add(Row + startIndex + HideRows);
  7012. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7013. }
  7014. HideRows += 2;
  7015. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7016. if (leftBindData != null)
  7017. {
  7018. designer.SetDataSource("CPCB", leftBindData.cb);
  7019. designer.SetDataSource("CPRS", leftBindData.rs);
  7020. designer.SetDataSource("CPXS", leftBindData.xs);
  7021. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7022. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7023. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7024. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7025. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7026. }
  7027. else
  7028. {
  7029. hideRowsList.Add(Row + startIndex + HideRows);
  7030. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7031. }
  7032. HideRows += 2;
  7033. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7034. if (leftBindData != null)
  7035. {
  7036. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7037. designer.SetDataSource("GWRS", leftBindData.rs);
  7038. designer.SetDataSource("GWXS", leftBindData.xs);
  7039. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7040. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7041. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7042. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7043. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7044. }
  7045. else
  7046. {
  7047. hideRowsList.Add(Row + startIndex + HideRows);
  7048. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7049. }
  7050. HideRows += 2;
  7051. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7052. if (leftBindData != null)
  7053. {
  7054. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7055. designer.SetDataSource("LYJRS", leftBindData.rs);
  7056. designer.SetDataSource("LYJXS", leftBindData.xs);
  7057. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7058. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7059. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7060. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7061. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7062. }
  7063. else
  7064. {
  7065. hideRowsList.Add(Row + startIndex + HideRows);
  7066. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7067. }
  7068. #endregion
  7069. #region A段Right信息
  7070. var right = dto.rightInfo.Find(x => x.Type == "A");
  7071. if (right == null)
  7072. {
  7073. return Ok(jw);
  7074. }
  7075. HideRows += 4;
  7076. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7077. if (rightBindData != null)
  7078. {
  7079. //经济舱 + 双人间 TBR
  7080. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7081. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7082. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7083. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7084. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7085. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7086. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7087. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7088. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7089. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7090. }
  7091. else
  7092. {
  7093. hideRowsList.Add(Row + startIndex + HideRows);
  7094. }
  7095. HideRows += 2;
  7096. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7097. if (rightBindData != null)
  7098. {
  7099. //经济舱 + 单人间 SGR
  7100. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7101. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7102. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7103. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7104. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7105. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7106. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7107. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7108. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7109. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7110. }
  7111. else
  7112. {
  7113. hideRowsList.Add(Row + startIndex + HideRows);
  7114. }
  7115. HideRows += 2;
  7116. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7117. if (rightBindData != null)
  7118. {
  7119. //公务舱 + 单人间 SGR
  7120. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7121. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7122. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7123. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7124. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7125. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7126. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7127. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7128. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7129. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7130. }
  7131. else
  7132. {
  7133. hideRowsList.Add(Row + startIndex + HideRows);
  7134. }
  7135. HideRows += 2;
  7136. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7137. if (rightBindData != null)
  7138. {
  7139. //公务舱 + 小套房 JSES
  7140. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7141. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7142. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7143. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7144. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7145. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7146. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7147. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7148. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7149. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7150. }
  7151. else
  7152. {
  7153. hideRowsList.Add(Row + startIndex + HideRows);
  7154. }
  7155. HideRows += 2;
  7156. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7157. if (rightBindData != null)
  7158. {
  7159. //公务舱 + 小套房 JSES
  7160. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7161. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7162. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7163. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7164. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7165. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7166. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7167. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7168. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7169. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7170. }
  7171. else
  7172. {
  7173. hideRowsList.Add(Row + startIndex + HideRows);
  7174. }
  7175. HideRows += 2;
  7176. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7177. if (rightBindData != null)
  7178. {
  7179. //经济舱 + 大套房
  7180. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7181. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7182. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7183. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7184. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7185. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7186. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7187. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7188. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7189. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7190. }
  7191. else
  7192. {
  7193. hideRowsList.Add(Row + startIndex + HideRows);
  7194. }
  7195. #endregion
  7196. #region B段标题清空
  7197. designer.SetDataSource("CostBDRCB", "");
  7198. designer.SetDataSource("CostBRS", "");
  7199. designer.SetDataSource("CostBXS", "");
  7200. designer.SetDataSource("CostBZCB", "");
  7201. designer.SetDataSource("CostBDRBJ", "");
  7202. designer.SetDataSource("CostBZBJ", "");
  7203. designer.SetDataSource("CostBDRLR", "");
  7204. designer.SetDataSource("CostBZLR", "");
  7205. designer.SetDataSource("CostBDRCBOM", "");
  7206. designer.SetDataSource("CostBRSOM", "");
  7207. designer.SetDataSource("CostBZCBOM", "");
  7208. designer.SetDataSource("CostBDRBJOM", "");
  7209. designer.SetDataSource("CostBZBJOM", "");
  7210. designer.SetDataSource("CostBDRLROM", "");
  7211. designer.SetDataSource("CostBZLROM", "");
  7212. #endregion
  7213. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7214. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7215. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7216. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7217. designer.SetDataSource("DJName", "地接(CNY)");
  7218. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7219. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7220. designer.SetDataSource("GWName", "公务(CNY)");
  7221. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7222. designer.SetDataSource("LYJName", "零用金(CNY)");
  7223. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7224. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7225. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7226. designer.SetDataSource("BXName", "保险(CNY)");
  7227. designer.SetDataSource("VisaName", "签证(CNY)");
  7228. #region B段基本数据
  7229. if (dto.costType == "B")
  7230. {
  7231. left = dto.leftInfo.Find(x => x.Type == "B");
  7232. if (left == null)
  7233. {
  7234. return Ok(jw);
  7235. }
  7236. #region B段left数据
  7237. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7238. if (leftBindData != null)
  7239. {
  7240. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7241. designer.SetDataSource("BHSRS", leftBindData.rs);
  7242. designer.SetDataSource("BHSXS", leftBindData.xs);
  7243. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7244. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7245. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7246. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7247. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7248. }
  7249. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7250. if (leftBindData != null)
  7251. {
  7252. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7253. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7254. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7255. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7256. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7257. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7258. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7259. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7260. }
  7261. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7262. if (leftBindData != null)
  7263. {
  7264. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7265. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7266. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7267. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7268. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7269. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7270. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7271. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7272. }
  7273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7274. if (leftBindData != null)
  7275. {
  7276. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7277. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7278. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7279. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7280. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7281. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7282. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7283. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7284. }
  7285. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7286. if (leftBindData != null)
  7287. {
  7288. designer.SetDataSource("BCPCB", leftBindData.cb);
  7289. designer.SetDataSource("BCPRS", leftBindData.rs);
  7290. designer.SetDataSource("BCPXS", leftBindData.xs);
  7291. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7292. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7293. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7294. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7295. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7296. }
  7297. //TBR
  7298. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7299. if (leftBindData != null)
  7300. {
  7301. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7302. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7303. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7304. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7305. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7306. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7307. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7308. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7309. }
  7310. //SGR
  7311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7312. if (leftBindData != null)
  7313. {
  7314. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7315. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7316. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7317. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7318. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7319. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7320. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7321. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7322. }
  7323. //JS/ES
  7324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7325. if (leftBindData != null)
  7326. {
  7327. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7328. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7329. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7330. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7331. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7332. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7333. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7334. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7335. }
  7336. //SUITE
  7337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7338. if (leftBindData != null)
  7339. {
  7340. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7341. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7342. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7343. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7344. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7345. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7346. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7347. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7348. }
  7349. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7350. if (leftBindData != null)
  7351. {
  7352. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7353. designer.SetDataSource("BDJRS", leftBindData.rs);
  7354. designer.SetDataSource("BDJXS", leftBindData.xs);
  7355. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7356. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7357. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7358. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7359. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7360. }
  7361. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7362. if (leftBindData != null)
  7363. {
  7364. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7365. designer.SetDataSource("BGWRS", leftBindData.rs);
  7366. designer.SetDataSource("BGWXS", leftBindData.xs);
  7367. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7368. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7369. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7370. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7371. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7372. }
  7373. #region 优化方案
  7374. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7375. //excelBind.Add("零用金", new {
  7376. //cb="",
  7377. //rs="",
  7378. //xs ="",
  7379. //zcb = "",
  7380. //});
  7381. #endregion
  7382. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7383. if (leftBindData != null)
  7384. {
  7385. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7386. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7387. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7388. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7389. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7390. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7391. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7392. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7393. }
  7394. #endregion
  7395. #region B段Right信息
  7396. right = dto.rightInfo.Find(x => x.Type == "B");
  7397. if (right == null)
  7398. {
  7399. return Ok(jw);
  7400. }
  7401. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7402. if (rightBindData != null)
  7403. {
  7404. //经济舱 + 双人间 TBR
  7405. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7406. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7407. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7408. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7409. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7410. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7411. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7412. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7413. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7414. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7415. }
  7416. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7417. if (rightBindData != null)
  7418. {
  7419. //经济舱 + 单人间 SGR
  7420. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7421. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7422. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7423. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7424. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7425. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7426. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7430. }
  7431. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7432. if (rightBindData != null)
  7433. {
  7434. //公务舱 + 单人间 SGR
  7435. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7436. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7437. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7438. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7439. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7440. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7441. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7442. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7443. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7444. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7445. }
  7446. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7447. if (rightBindData != null)
  7448. {
  7449. //公务舱 + 小套房 JSES
  7450. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7451. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7452. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7453. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7454. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7455. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7456. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7457. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7458. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7459. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7460. }
  7461. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7462. if (rightBindData != null)
  7463. {
  7464. //公务舱 + 小套房 JSES
  7465. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7466. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7467. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7468. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7469. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7470. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7471. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7472. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7473. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7474. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7475. }
  7476. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7477. if (rightBindData != null)
  7478. {
  7479. //经济舱 + 大套房
  7480. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7481. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7482. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7483. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7484. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7485. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7486. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7487. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7488. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7489. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7490. }
  7491. #endregion
  7492. #region 标题
  7493. designer.SetDataSource("CostBDRCB", "单人成本");
  7494. designer.SetDataSource("CostBRS", "人数");
  7495. designer.SetDataSource("CostBXS", "系数");
  7496. designer.SetDataSource("CostBZCB", "总成本");
  7497. designer.SetDataSource("CostBDRBJ", "单人报价");
  7498. designer.SetDataSource("CostBZBJ", "总报价");
  7499. designer.SetDataSource("CostBDRLR", "单人利润");
  7500. designer.SetDataSource("CostBZLR", "总利润");
  7501. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7502. designer.SetDataSource("CostBRSOM", "人数");
  7503. designer.SetDataSource("CostBZCBOM", "总成本");
  7504. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7505. designer.SetDataSource("CostBZBJOM", "总报价");
  7506. designer.SetDataSource("CostBDRLROM", "单人利润");
  7507. designer.SetDataSource("CostBZLROM", "总利润");
  7508. #endregion
  7509. }
  7510. #endregion
  7511. designer.SetDataSource("TzZCB2", TzZCB2);
  7512. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7513. designer.SetDataSource("TzZLR2", TzZLR2);
  7514. string[] dataSourceKeys = new string[]
  7515. {
  7516. "VF",
  7517. "TGS",
  7518. "TGOF",
  7519. "TGM",
  7520. "TGA",
  7521. "TGTF",
  7522. "TGEF",
  7523. "CFM",
  7524. "CFOF",
  7525. "B",
  7526. "L",
  7527. "D",
  7528. "TBR",
  7529. "SGR",
  7530. "JSES",
  7531. "Suite",
  7532. "TV",
  7533. "1L",
  7534. "IF",
  7535. "EF",
  7536. "BRF",
  7537. "TE",
  7538. "TGT",
  7539. "DRVT",
  7540. "PC",
  7541. "TLF",
  7542. "ECT"
  7543. };
  7544. foreach (var item in dataSourceKeys)
  7545. {
  7546. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7547. if (find != null)
  7548. {
  7549. designer.SetDataSource(item, find.text);
  7550. }
  7551. else
  7552. {
  7553. designer.SetDataSource(item, 0);
  7554. }
  7555. }
  7556. designer.SetDataSource(dt);
  7557. //根据数据源处理生成报表内容
  7558. designer.Process();
  7559. designer.Workbook.Worksheets[0].Name = "清单";
  7560. Worksheet sheet = designer.Workbook.Worksheets[0];
  7561. foreach (var Rowindex in hideRowsList)
  7562. {
  7563. ws.Cells.HideRows(Rowindex, 2);
  7564. }
  7565. byte[] bytes = null;
  7566. string strFileName = di.TeamName + "-团组-成本.xls";
  7567. using (MemoryStream stream = new MemoryStream())
  7568. {
  7569. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7570. bytes = stream.ToArray();
  7571. }
  7572. return Ok(JsonView(true, "", new
  7573. {
  7574. Data = bytes,
  7575. strFileName,
  7576. }));
  7577. }
  7578. /// <summary>
  7579. /// 导出客户报表
  7580. /// </summary>
  7581. /// <returns></returns>
  7582. [HttpPost]
  7583. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7584. {
  7585. var jw = JsonView(false);
  7586. if (dto.Diid == 0)
  7587. {
  7588. return Ok(JsonView(false, "请传递团组id"));
  7589. }
  7590. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7591. if (deleInfo.Code != 0)
  7592. {
  7593. return Ok(JsonView(false, "团组信息查询失败!"));
  7594. }
  7595. var di = deleInfo.Data as DelegationInfoWebView;
  7596. if (di == null)
  7597. {
  7598. return Ok(JsonView(false, "团组信息查询失败!"));
  7599. }
  7600. //文件名
  7601. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7602. //获取模板
  7603. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7604. //载入模板
  7605. Document doc = new Document(tmppath);
  7606. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7607. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7608. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7609. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7610. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7611. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7612. if (AParameter == null)
  7613. {
  7614. return Ok(JsonView(false, "系数不存在!"));
  7615. }
  7616. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7617. , TzAirDesc, TzZCost;
  7618. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7619. = TzAirDesc = TzZCost = string.Empty;
  7620. TzNumber = AParameter.CostTypenumber.ToString();
  7621. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7622. CarGuides1 = dto.CarGuides1;
  7623. Meal = dto.Meal;
  7624. SubsidizedMeals = dto.SubsidizedMeals;
  7625. NightRepair = dto.NightRepair;
  7626. AttractionsTickets = dto.AttractionsTickets;
  7627. MiscellaneousFees = dto.MiscellaneousFees;
  7628. ATip = dto.ATip;
  7629. TzHotelDesc = "";
  7630. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7631. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7632. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7633. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7634. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7635. TzAirDesc = "";
  7636. TzZCost = dto.TzZCost;
  7637. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7638. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7639. var index = 1;
  7640. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7641. foreach (var item in TzHotelDescArr)
  7642. {
  7643. if (AinfoArr != null)
  7644. {
  7645. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7646. if (Ainfo != null)
  7647. {
  7648. if (int.Parse(Ainfo.rs) <= 0)
  7649. {
  7650. continue;
  7651. }
  7652. var hotelText = string.Empty;
  7653. switch (item)
  7654. {
  7655. case "SGR":
  7656. hotelText = "单人间";
  7657. break;
  7658. case "JSES":
  7659. hotelText = "小套房";
  7660. break;
  7661. case "SUITE":
  7662. hotelText = "套房";
  7663. break;
  7664. case "TBR":
  7665. hotelText = "双人间";
  7666. break;
  7667. }
  7668. if (item != "TBR")
  7669. {
  7670. 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";
  7671. }
  7672. else
  7673. {
  7674. 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";
  7675. }
  7676. index++;
  7677. }
  7678. }
  7679. }
  7680. index = 1;
  7681. foreach (var item in TzAirDescArr)
  7682. {
  7683. if (AinfoArr != null)
  7684. {
  7685. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7686. if (Ainfo != null)
  7687. {
  7688. if (int.Parse(Ainfo.rs) <= 0)
  7689. {
  7690. continue;
  7691. }
  7692. 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";
  7693. index++;
  7694. }
  7695. }
  7696. }
  7697. if (dto.costType == "B")
  7698. {
  7699. if (BParameter == null)
  7700. {
  7701. return Ok(JsonView(false, "B段系数不存在!"));
  7702. }
  7703. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7704. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7705. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7706. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7707. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7708. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7709. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7710. foreach (var item in TzHotelDescArr)
  7711. {
  7712. if (AinfoArr != null)
  7713. {
  7714. TzHotelDesc += "B段信息 \r\n";
  7715. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7716. if (Ainfo != null)
  7717. {
  7718. if (int.Parse(Ainfo.rs) <= 0)
  7719. {
  7720. continue;
  7721. }
  7722. var hotelText = string.Empty;
  7723. switch (item)
  7724. {
  7725. case "SGR":
  7726. hotelText = "单人间";
  7727. break;
  7728. case "JSES":
  7729. hotelText = "小套房";
  7730. break;
  7731. case "SUITE":
  7732. hotelText = "套房";
  7733. break;
  7734. case "TBR":
  7735. hotelText = "双人间";
  7736. break;
  7737. }
  7738. if (item != "TBR")
  7739. {
  7740. 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";
  7741. }
  7742. else
  7743. {
  7744. 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";
  7745. }
  7746. index++;
  7747. }
  7748. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7749. }
  7750. }
  7751. index = 1;
  7752. foreach (var item in TzAirDescArr)
  7753. {
  7754. if (AinfoArr != null)
  7755. {
  7756. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7757. if (Ainfo != null)
  7758. {
  7759. if (int.Parse(Ainfo.rs) <= 0)
  7760. {
  7761. continue;
  7762. }
  7763. 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";
  7764. index++;
  7765. }
  7766. }
  7767. }
  7768. }
  7769. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7770. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7771. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7772. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7773. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7774. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7775. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7776. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7777. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7778. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7779. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7780. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7781. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7782. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7783. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7784. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7785. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7786. DickeyValue.Add("TzZCost", TzZCost);
  7787. foreach (var key in DickeyValue.Keys)
  7788. {
  7789. if (doc.Range.Bookmarks[key] != null)
  7790. {
  7791. Bookmark mark = doc.Range.Bookmarks[key];
  7792. mark.Text = DickeyValue[key];
  7793. }
  7794. }
  7795. byte[] bytes = null;
  7796. string strFileName = di.TeamName + "-客户报价.doc";
  7797. using (MemoryStream stream = new MemoryStream())
  7798. {
  7799. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7800. bytes = stream.ToArray();
  7801. }
  7802. return Ok(JsonView(true, "", new
  7803. {
  7804. Data = bytes,
  7805. strFileName,
  7806. }));
  7807. }
  7808. /// <summary>
  7809. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7810. /// </summary>
  7811. /// <param name="dto"></param>
  7812. /// <returns></returns>
  7813. [HttpPost]
  7814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7815. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7816. {
  7817. try
  7818. {
  7819. #region 参数验证
  7820. if (dto.DiId < 0)
  7821. {
  7822. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7823. }
  7824. List<int> cTableIds = new List<int>() {
  7825. 76 ,//酒店预订
  7826. 77 ,//行程
  7827. 79 ,//车/导游地接
  7828. 80 ,//签证
  7829. 81 ,//邀请/公务活
  7830. 82 ,//团组客户保险
  7831. 85 ,//机票预订
  7832. 98 ,//其他款项
  7833. 285 ,//收款退还
  7834. 751 ,//酒店早餐
  7835. 1015 // 超支费用
  7836. };
  7837. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7838. {
  7839. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7840. }
  7841. #endregion
  7842. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7843. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7844. if (_GroupCostParameters.Count <= 0)
  7845. {
  7846. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7847. }
  7848. if (_GroupCostParameters[0].IsShare == 0)
  7849. {
  7850. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7851. }
  7852. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7853. //处理date为空问题
  7854. if (_GroupCosts.Count > 0)
  7855. {
  7856. for (int i = 0; i < _GroupCosts.Count; i++)
  7857. {
  7858. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7859. {
  7860. if (i > 0)
  7861. {
  7862. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7863. }
  7864. }
  7865. }
  7866. }
  7867. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7868. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7869. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7870. string currCode = "";
  7871. #region currCode 验证
  7872. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7873. if (isInt)
  7874. {
  7875. var currData = currDatas.Find(it => it.Id == intCurrency);
  7876. if (currData != null)
  7877. {
  7878. currCode = currData.Name;
  7879. }
  7880. }
  7881. else
  7882. {
  7883. currCode = _GroupCostParameters[0].Currency.Trim();
  7884. }
  7885. #endregion
  7886. //op,酒店单段模式存储
  7887. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7888. {
  7889. CurrencyCode = currCode,
  7890. Rate = _GroupCostParameters[0].Rate,
  7891. CostType = _GroupCostParameters[0].CostType,
  7892. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7893. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7894. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7895. };
  7896. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7897. if (_GroupCostParameters.Count == 2)
  7898. {
  7899. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7900. }
  7901. foreach (var item in _GroupCostParameters)
  7902. {
  7903. decimal _rate = 1;
  7904. decimal _rate1 = item.Rate;
  7905. decimal _scale = 1;
  7906. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7907. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7908. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7909. //if (userInfo != null)
  7910. //{
  7911. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7912. // {
  7913. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7914. // {
  7915. // _scale = 1.00M;
  7916. // }
  7917. // }
  7918. //}
  7919. #endregion
  7920. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7921. {
  7922. CurrencyCode = currCode,
  7923. Rate = _rate1,
  7924. CostType = item.CostType,
  7925. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7926. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7927. CostTypeNumber = item.CostTypenumber
  7928. };
  7929. if (_GroupCostParameters.Count > 1)
  7930. {
  7931. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7932. }
  7933. else
  7934. {
  7935. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7936. }
  7937. if (dto.CTable == 79)//
  7938. {
  7939. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7940. modulePromptInfo.TotalCost = item.DJCB;
  7941. }
  7942. List<string> costTypes = new List<string>() { "A", "B" };
  7943. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7944. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7945. if (_GroupCostsDuplicates.Count() == 1)
  7946. {
  7947. _GroupCostsTypeData = _GroupCosts;
  7948. }
  7949. else
  7950. {
  7951. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7952. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7953. }
  7954. /*
  7955. * 76 酒店预订
  7956. * 77 行程
  7957. * 79 车/导游地接
  7958. * 80 签证
  7959. * 81 邀请/公务活动
  7960. * 82 团组客户保险
  7961. * 85 机票预订
  7962. * 98 其他款项
  7963. * 285 收款退还
  7964. * 751 酒店早餐
  7965. * 1015 超支费用
  7966. */
  7967. switch (dto.CTable)
  7968. {
  7969. case 76: // 酒店预订
  7970. _ModuleSubPromptInfo.AddRange(
  7971. _GroupCostsTypeData.Select(it => new
  7972. {
  7973. it.DAY,
  7974. it.Date,
  7975. it.ACCON,
  7976. it.ITIN,
  7977. it.SGR,
  7978. it.TBR,
  7979. it.JS_ES,
  7980. it.Suite
  7981. })
  7982. );
  7983. break;
  7984. case 79: // 车/导游地接
  7985. _ModuleSubPromptInfo.AddRange(
  7986. _GroupCostsTypeData.Select(it => new
  7987. {
  7988. Date = it.Date, //日期
  7989. CarFee = it.CarCost * _rate * _scale, //车费用
  7990. CarType = it.CarType, //车型
  7991. DriverFee = it.CFS * _rate * _scale, //司机工资
  7992. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  7993. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  7994. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  7995. GuideFee = it.TGS * _rate * _scale, //导游费用
  7996. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  7997. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  7998. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  7999. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8000. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8001. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8002. Breakfast = it.B * _rate * _scale, //早餐费
  8003. Lunch = it.L * _rate * _scale, //午餐费
  8004. Dinner = it.D * _rate * _scale, //晚餐费
  8005. TicketFee = it.EF * _rate * _scale, //门票费
  8006. SpentCash = it.PC * _rate * _scale, //零用金
  8007. LeadersFee = it.TLF * _rate * _scale, //领队费
  8008. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8009. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8010. })
  8011. );
  8012. break;
  8013. case 85: // 机票
  8014. List<dynamic> datas = new List<dynamic>();
  8015. datas.Add(
  8016. new
  8017. {
  8018. AirType = "经济舱",
  8019. AirNum = item.JJCRS,
  8020. AirDRCB = item.JJCCB,
  8021. AirZCB = (item.JJCRS * item.JJCCB)
  8022. }
  8023. );
  8024. datas.Add(
  8025. new
  8026. {
  8027. AirType = "公务舱",
  8028. AirNum = item.GWCRS,
  8029. AirDRCB = item.GWCCB,
  8030. AirZCB = (item.GWCRS * item.GWCCB)
  8031. }
  8032. );
  8033. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8034. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8035. modulePromptInfo.Data = new
  8036. {
  8037. airFeeData = datas,
  8038. airInitData = initDatas
  8039. };
  8040. _ModulePromptInfos.Add(modulePromptInfo);
  8041. break;
  8042. default:
  8043. break;
  8044. }
  8045. }
  8046. if (dto.CTable != 85)
  8047. {
  8048. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8049. _ModulePromptInfos.Add(_ModulePromptInfo);
  8050. }
  8051. _view.ModulePromptInfos = _ModulePromptInfos;
  8052. return Ok(JsonView(true, "操作成功!", _view));
  8053. }
  8054. catch (Exception ex)
  8055. {
  8056. return Ok(JsonView(false, ex.Message));
  8057. }
  8058. }
  8059. /// <summary>
  8060. /// 根据黑屏代码重新生成行程
  8061. /// </summary>
  8062. /// <param name="dto"></param>
  8063. /// <returns></returns>
  8064. [HttpPost]
  8065. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8066. {
  8067. var jw = JsonView(false);
  8068. var Create = _GroupCostRepository.
  8069. CreateGroupCostByBlackCode(dto.Diid);
  8070. jw.Msg = Create.Msg;
  8071. if (Create.Code == 0)
  8072. {
  8073. jw.Code = 200;
  8074. jw.Data = new
  8075. {
  8076. groupCost = Create.Data,
  8077. blackCodeIsTrue = true
  8078. };
  8079. }
  8080. else
  8081. {
  8082. jw.Code = 400;
  8083. jw.Data = new
  8084. {
  8085. groupCost = Create.Data,
  8086. blackCodeIsTrue = false,
  8087. };
  8088. }
  8089. return Ok(jw);
  8090. }
  8091. /// <summary>
  8092. /// 成本获取OP历史车费用
  8093. /// </summary>
  8094. /// <param name="dto"></param>
  8095. /// <returns></returns>
  8096. [HttpPost]
  8097. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8098. {
  8099. var jw = JsonView(false);
  8100. try
  8101. {
  8102. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8103. //获取现有所有车的数据
  8104. if (!dto.Param.IsNullOrWhiteSpace())
  8105. {
  8106. string sql = $@"
  8107. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8108. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8109. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8110. 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
  8111. AND gctggr.ServiceEndTime is not NULL
  8112. ORDER by gctggrc.id DESC
  8113. ";
  8114. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8115. var numeberResult = await Task.Run(() =>
  8116. {
  8117. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8118. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8119. return numberArr;
  8120. });
  8121. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8122. foreach (var item in numeberResult)
  8123. {
  8124. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8125. {
  8126. Country = "数据异常!",
  8127. City = string.Empty,
  8128. };
  8129. item.Area = find.Country + " " + find.City;
  8130. }
  8131. dbResult.AddRange(numeberResult);
  8132. if (dto.Param.Contains("、"))
  8133. {
  8134. var sp = dto.Param.Split("、");
  8135. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8136. .Where(x =>
  8137. {
  8138. return System.Array.Exists(sp, e =>
  8139. {
  8140. bool where = false;
  8141. if (x.Area != null)
  8142. {
  8143. where = x.Area.Contains(e);
  8144. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8145. {
  8146. return false;
  8147. }
  8148. }
  8149. if (x.PriceName != null && !where)
  8150. {
  8151. where = x.PriceName.Contains(e);
  8152. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8153. {
  8154. return false;
  8155. }
  8156. }
  8157. return where;
  8158. });
  8159. }).ToList();
  8160. }
  8161. else
  8162. {
  8163. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8164. .Where(x =>
  8165. {
  8166. bool where = false;
  8167. if (x.Area != null)
  8168. {
  8169. where = x.Area.Contains(dto.Param);
  8170. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8171. {
  8172. return false;
  8173. }
  8174. }
  8175. if (x.PriceName != null && !where)
  8176. {
  8177. where = x.PriceName.Contains(dto.Param);
  8178. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8179. {
  8180. return false;
  8181. }
  8182. }
  8183. return where;
  8184. }
  8185. )
  8186. .ToList();
  8187. }
  8188. }
  8189. var view = dbResult.Select(x =>
  8190. {
  8191. decimal dp = 0.00M;
  8192. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8193. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8194. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8195. {
  8196. if (startB && endB)
  8197. {
  8198. var timesp = endD.Subtract(startD);
  8199. if ((timesp.Days + 1) != 0)
  8200. {
  8201. dp = x.Price / (timesp.Days + 1);
  8202. }
  8203. }
  8204. }
  8205. else
  8206. {
  8207. dp = x.Price;
  8208. }
  8209. return new
  8210. {
  8211. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8212. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8213. x.Area,
  8214. x.id,
  8215. price = x.Price.ToString("F2"),
  8216. x.PriceName,
  8217. x.PriceContent,
  8218. x.TeamName,
  8219. x.DatePrice,
  8220. dayPrice = dp.ToString("F2"),
  8221. };
  8222. }).OrderByDescending(x => x.id).ToList();
  8223. jw = JsonView(true, "获取成功!", view);
  8224. }
  8225. catch (Exception e)
  8226. {
  8227. jw = JsonView(false, e.Message);
  8228. }
  8229. return Ok(jw);
  8230. }
  8231. #endregion
  8232. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8233. /// <summary>
  8234. /// 酒店预订
  8235. /// 酒店费用列表 根据团组Id查询
  8236. /// </summary>
  8237. /// <param name="_dto"></param>
  8238. /// <returns></returns>
  8239. [HttpPost]
  8240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8241. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8242. {
  8243. #region 参数验证
  8244. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8245. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8246. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8247. #region 团组操作权限验证 76 酒店预定模块
  8248. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8249. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8250. #endregion
  8251. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8252. #region 页面操作权限验证
  8253. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8254. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8255. #endregion
  8256. #endregion
  8257. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8258. }
  8259. /// <summary>
  8260. /// 酒店预订
  8261. /// 基础数据
  8262. /// </summary>
  8263. /// <param name="_dto"></param>
  8264. /// <returns></returns>
  8265. [HttpPost]
  8266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8267. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8268. {
  8269. #region 参数验证
  8270. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8271. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8272. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8273. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8274. #region 页面操作权限验证
  8275. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8276. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8277. #endregion
  8278. #region 团组操作权限验证 76 酒店预定模块
  8279. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8280. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8281. #endregion
  8282. #endregion
  8283. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8284. }
  8285. /// <summary>
  8286. /// 酒店预订
  8287. /// 创建 入住卷号码
  8288. /// </summary>
  8289. /// <param name="_dto"></param>
  8290. /// <returns></returns>
  8291. [HttpPost]
  8292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8293. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8294. {
  8295. try
  8296. {
  8297. #region 参数验证
  8298. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8299. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8300. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8301. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8302. #region 页面操作权限验证
  8303. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8304. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8305. #endregion
  8306. #region 团组操作权限验证 76 酒店预定模块
  8307. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8308. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8309. #endregion
  8310. #endregion
  8311. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8312. if (data.Code != 0)
  8313. {
  8314. return Ok(JsonView(false, data.Msg));
  8315. }
  8316. return Ok(JsonView(true, data.Msg, data.Data));
  8317. }
  8318. catch (Exception ex)
  8319. {
  8320. return Ok(JsonView(false, ex.Message));
  8321. }
  8322. }
  8323. /// <summary>
  8324. /// 酒店预订
  8325. /// 详情
  8326. /// </summary>
  8327. /// <param name="_dto"></param>
  8328. /// <returns></returns>
  8329. [HttpPost]
  8330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8331. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8332. {
  8333. #region 参数验证
  8334. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8335. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8336. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8337. #region 团组操作权限验证 76 酒店预定模块
  8338. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8339. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8340. #endregion
  8341. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8342. #region 页面操作权限验证
  8343. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8344. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8345. #endregion
  8346. #endregion
  8347. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8348. }
  8349. /// <summary>
  8350. /// 酒店预订
  8351. /// Add Or Edit
  8352. /// </summary>
  8353. /// <param name="_dto"></param>
  8354. /// <returns></returns>
  8355. [HttpPost]
  8356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8357. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8358. {
  8359. #region 参数验证
  8360. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8361. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8362. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8363. #region 团组操作权限验证 76 酒店预定模块
  8364. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8365. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8366. #endregion
  8367. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8368. #region 页面操作权限验证
  8369. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8370. if (_dto.Id == 0) // Add
  8371. {
  8372. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8373. }
  8374. else if (_dto.Id > 1) // Edit
  8375. {
  8376. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8377. }
  8378. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8379. #endregion
  8380. #endregion
  8381. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8382. if (_view.Code != 200)
  8383. {
  8384. return Ok(_view);
  8385. }
  8386. #region 应用推送
  8387. try
  8388. {
  8389. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8390. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8391. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8392. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8393. //自动审核
  8394. await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8395. }
  8396. catch (Exception ex)
  8397. {
  8398. }
  8399. #endregion
  8400. return Ok(_view);
  8401. }
  8402. /// <summary>
  8403. /// 酒店预订
  8404. /// Del
  8405. /// </summary>
  8406. /// <param name="_dto"></param>
  8407. /// <returns></returns>
  8408. [HttpPost]
  8409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8410. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8411. {
  8412. #region 参数验证
  8413. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8414. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8415. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8416. #region 团组操作权限验证 76 酒店预定模块
  8417. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8418. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8419. #endregion
  8420. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8421. #region 页面操作权限验证
  8422. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8423. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8424. #endregion
  8425. #endregion
  8426. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8427. }
  8428. /// <summary>
  8429. /// 酒店预订
  8430. /// 生成VOUCHER
  8431. /// 2024.05.06 之前版本
  8432. /// </summary>
  8433. /// <param name="_dto"></param>
  8434. /// <returns></returns>
  8435. [HttpPost]
  8436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8437. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8438. {
  8439. try
  8440. {
  8441. #region 参数验证
  8442. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8443. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8444. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8445. #region 团组操作权限验证 76 酒店预定模块
  8446. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8447. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8448. #endregion
  8449. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8450. #region 页面操作权限验证
  8451. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8452. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8453. #endregion
  8454. #endregion
  8455. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8456. //判断数据是否完整
  8457. if (hr != null)
  8458. {
  8459. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8460. {
  8461. string strFileName = "HotelStatement/";
  8462. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8463. if (dele != null)
  8464. strFileName += dele.TourCode;
  8465. //载入模板
  8466. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8467. Document doc = new Document(sss);
  8468. DocumentBuilder builder = new DocumentBuilder(doc);
  8469. #region 替换Word模板书签内容
  8470. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8471. //入住卷预定号码
  8472. if (doc.Range.Bookmarks["VNO"] != null)
  8473. {
  8474. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8475. mark.Text = hr.CheckNumber;
  8476. }
  8477. //酒店时间
  8478. if (doc.Range.Bookmarks["Date"] != null)
  8479. {
  8480. Bookmark mark = doc.Range.Bookmarks["Date"];
  8481. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8482. }
  8483. //团号
  8484. if (doc.Range.Bookmarks["TNo"] != null)
  8485. {
  8486. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8487. mark.Text = dele.TourCode;
  8488. }
  8489. //预定号码
  8490. if (doc.Range.Bookmarks["BookingId"] != null)
  8491. {
  8492. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8493. mark.Text = hr.ReservationsNo;
  8494. }
  8495. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8496. {
  8497. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8498. mark.Text = hr.DetermineNo;
  8499. }
  8500. //酒店城市
  8501. if (doc.Range.Bookmarks["City"] != null)
  8502. {
  8503. Bookmark mark = doc.Range.Bookmarks["City"];
  8504. mark.Text = hr.City;
  8505. }
  8506. //酒店名称
  8507. if (doc.Range.Bookmarks["HName"] != null)
  8508. {
  8509. Bookmark mark = doc.Range.Bookmarks["HName"];
  8510. mark.Text = hr.HotelName;
  8511. }
  8512. //酒店地址
  8513. if (doc.Range.Bookmarks["Address"] != null)
  8514. {
  8515. Bookmark mark = doc.Range.Bookmarks["Address"];
  8516. mark.Text = hr.HotelAddress;
  8517. }
  8518. //酒店电话
  8519. if (doc.Range.Bookmarks["Tel"] != null)
  8520. {
  8521. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8522. mark.Text = hr.HotelTel;
  8523. }
  8524. //酒店传真
  8525. if (doc.Range.Bookmarks["Fax"] != null)
  8526. {
  8527. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8528. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8529. {
  8530. mark.Text = hr.HotelFax;
  8531. }
  8532. }
  8533. //入住时间
  8534. if (doc.Range.Bookmarks["CIn"] != null)
  8535. {
  8536. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8537. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8538. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8539. }
  8540. //退房时间
  8541. if (doc.Range.Bookmarks["COut"] != null)
  8542. {
  8543. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8544. Bookmark mark = doc.Range.Bookmarks["COut"];
  8545. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8546. }
  8547. //客户名称
  8548. if (doc.Range.Bookmarks["GName"] != null)
  8549. {
  8550. string guestName = "";
  8551. string[] clients = new string[] { };
  8552. if (hr.GuestName.Contains(","))
  8553. {
  8554. clients = hr.GuestName.Split(",");
  8555. }
  8556. else
  8557. {
  8558. clients = new string[] { hr.GuestName };
  8559. }
  8560. List<int> clientIds_int = new List<int>();
  8561. if (clients.Length > 0)
  8562. {
  8563. foreach (var item in clients)
  8564. {
  8565. if (item.IsNumeric())
  8566. {
  8567. clientIds_int.Add(int.Parse(item));
  8568. }
  8569. }
  8570. }
  8571. if (clientIds_int.Count > 0)
  8572. {
  8573. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8574. foreach (var client in _clientDatas)
  8575. {
  8576. //男
  8577. if (client.Sex == 0) guestName += $"Mr.";
  8578. //女
  8579. else if (client.Sex == 1) guestName += $"Ms.";
  8580. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8581. {
  8582. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8583. }
  8584. //guestName += $"{client.Pinyin},";
  8585. }
  8586. if (guestName.Length > 0)
  8587. {
  8588. guestName = guestName.Substring(0, guestName.Length - 1);
  8589. }
  8590. }
  8591. else
  8592. {
  8593. guestName = hr.GuestName;
  8594. }
  8595. Bookmark mark = doc.Range.Bookmarks["GName"];
  8596. mark.Text = guestName;
  8597. }
  8598. //房间介绍
  8599. if (doc.Range.Bookmarks["ROOM"] != null)
  8600. {
  8601. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8602. mark.Text = hr.RoomExplanation;
  8603. }
  8604. //报价描述
  8605. if (doc.Range.Bookmarks["NOTE"] != null)
  8606. {
  8607. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8608. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8609. if (ss != null)
  8610. mark.Text = ss.Name;
  8611. }
  8612. //入住时间
  8613. if (doc.Range.Bookmarks["CheckIn"] != null)
  8614. {
  8615. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8616. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8617. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8618. }
  8619. //退房时间
  8620. if (doc.Range.Bookmarks["CheckOut"] != null)
  8621. {
  8622. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8623. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8624. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8625. }
  8626. //日期
  8627. if (doc.Range.Bookmarks["DT"] != null)
  8628. {
  8629. Bookmark mark = doc.Range.Bookmarks["DT"];
  8630. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8631. }
  8632. //名称
  8633. if (doc.Range.Bookmarks["VName"] != null)
  8634. {
  8635. Bookmark mark = doc.Range.Bookmarks["VName"];
  8636. mark.Text = hr.HotelName;
  8637. }
  8638. //号码
  8639. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8640. {
  8641. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8642. mark.Text = hr.CheckNumber;
  8643. }
  8644. #endregion
  8645. strFileName += "VOUCHER.doc";
  8646. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8647. doc.Save(fileDir);
  8648. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8649. return Ok(JsonView(true, "操作成功!", Url));
  8650. }
  8651. else
  8652. {
  8653. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8654. }
  8655. }
  8656. else
  8657. {
  8658. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8659. }
  8660. }
  8661. catch (Exception ex)
  8662. {
  8663. return Ok(JsonView(false, ex.Message));
  8664. }
  8665. }
  8666. /// <summary>
  8667. /// 酒店预订
  8668. /// 生成VOUCHER
  8669. /// 2024.05.06 之后版本
  8670. /// </summary>
  8671. /// <param name="_dto"></param>
  8672. /// <returns></returns>
  8673. [HttpPost]
  8674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8675. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8676. {
  8677. #region 参数验证
  8678. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8679. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8680. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8681. #region 团组操作权限验证 76 酒店预定模块
  8682. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8683. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8684. #endregion
  8685. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8686. #region 页面操作权限验证
  8687. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8688. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8689. #endregion
  8690. #endregion
  8691. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8692. //判断数据是否完整
  8693. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8694. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8695. string strFileName = "HotelStatement/";
  8696. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8697. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8698. #region 数据处理
  8699. List<int> guestIds = new List<int>();
  8700. int index = 0;
  8701. foreach (var item in hrDtas)
  8702. {
  8703. if (item.GuestName.Contains(","))
  8704. {
  8705. string[] guestIdArr = item.GuestName.Split(',');
  8706. foreach (var guestIdStr in guestIdArr)
  8707. {
  8708. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8709. if (guestBool)
  8710. {
  8711. guestIds.Add(guestId);
  8712. }
  8713. }
  8714. }
  8715. else guestNames += item.GuestName;
  8716. var voucherInfo = new HotelVoucherInfoView()
  8717. {
  8718. HotelName = item.HotelName,
  8719. CheckInDate = item.CheckInDate,
  8720. CheckOutDate = item.CheckOutDate,
  8721. ConfirmationNumber = item.DetermineNo.Trim(),
  8722. RoomType = item.RoomExplanation
  8723. };
  8724. vouchers.Add(voucherInfo);
  8725. }
  8726. if (guestIds.Count > 0)
  8727. {
  8728. guestIds = guestIds.Distinct().ToList();
  8729. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8730. if (guestDatas.Count > 0)
  8731. {
  8732. guestNames = "";
  8733. foreach (var guest in guestDatas)
  8734. {
  8735. string guestName = "";
  8736. if (guest.Sex == 0) guestName += @"MR.";
  8737. else if (guest.Sex == 1) guestName += @"MS.";
  8738. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8739. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8740. guestNames += @$"{guestName.Trim()}、";
  8741. }
  8742. if (guestNames.Length > 0)
  8743. {
  8744. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8745. }
  8746. }
  8747. }
  8748. #endregion
  8749. //载入模板
  8750. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8751. Document doc = new Document(sss);
  8752. DocumentBuilder builder = new DocumentBuilder(doc);
  8753. if (doc.Range.Bookmarks["GuestName"] != null)
  8754. {
  8755. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8756. mark.Text = guestNames;
  8757. }
  8758. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8759. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8760. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8761. for (int i = 1; i <= vouchers.Count; i++)
  8762. {
  8763. HotelVoucherInfoView hviv = vouchers[i - 1];
  8764. builder.MoveToCell(0, i, 0, 0);
  8765. builder.Write(hviv.HotelName);
  8766. builder.MoveToCell(0, i, 1, 0);
  8767. builder.Write(hviv.CheckInDate);
  8768. builder.MoveToCell(0, i, 2, 0);
  8769. builder.Write(hviv.CheckOutDate);
  8770. builder.MoveToCell(0, i, 3, 0);
  8771. builder.Write(hviv.RoomType);
  8772. builder.MoveToCell(0, i, 4, 0);
  8773. builder.Write(hviv.ConfirmationNumber);
  8774. }
  8775. //删除多余行
  8776. int currRowIndex = vouchers.Count + 1;
  8777. int delRows = 21 - currRowIndex;
  8778. if (delRows > 0)
  8779. {
  8780. for (int i = 0; i < delRows; i++)
  8781. {
  8782. table.Rows.RemoveAt(currRowIndex);
  8783. //cultivateRowIndex++;
  8784. }
  8785. }
  8786. strFileName += "VOUCHER.docx";
  8787. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8788. doc.Save(fileDir);
  8789. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8790. return Ok(JsonView(true, "操作成功!", Url));
  8791. }
  8792. /// <summary>
  8793. /// 酒店预订
  8794. /// 生成 预定成本 Excel
  8795. /// </summary>
  8796. /// <param name="_dto"></param>
  8797. /// <returns></returns>
  8798. [HttpPost]
  8799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8800. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8801. {
  8802. #region 参数验证
  8803. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8804. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8805. if (!vadalitorRes.IsValid)
  8806. {
  8807. var errors = new StringBuilder();
  8808. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8809. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8810. }
  8811. #region 团组操作权限验证 76 酒店预定模块
  8812. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8813. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8814. #endregion
  8815. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8816. #region 页面操作权限验证
  8817. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8818. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8819. #endregion
  8820. #endregion
  8821. decimal _rate = 1.00M;
  8822. string _currency = "";
  8823. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8824. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8825. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8826. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8827. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8828. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8829. {
  8830. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8831. }
  8832. _currency = _GroupCostParameter.Currency;
  8833. bool isIntType = int.TryParse(_currency, out int currId);
  8834. if (isIntType)
  8835. {
  8836. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8837. }
  8838. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8839. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8840. if (currInfo == null)
  8841. {
  8842. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8843. }
  8844. if (!_currency.ToUpper().Equals("CNY"))
  8845. {
  8846. _rate = _GroupCostParameter.Rate;
  8847. }
  8848. _rate = currInfo.Rate;
  8849. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8850. string strFileName = "HotelStatement/";
  8851. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8852. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8853. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8854. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8855. #region 数据处理
  8856. foreach (var item in hrDtas)
  8857. {
  8858. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8859. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8860. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8861. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8862. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8863. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8864. string singleRoomFeeStr = string.Empty,
  8865. doubleRoomFeeStr = string.Empty,
  8866. suiteRoomFeeStr = string.Empty,
  8867. otherRoomFeeStr = string.Empty,
  8868. payMoneyStr = string.Empty,
  8869. cardPriceStr = string.Empty;
  8870. if (roomCurr.Equals(_currency))
  8871. {
  8872. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8873. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8874. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8875. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8876. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8877. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8878. }
  8879. else
  8880. {
  8881. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8882. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8883. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8884. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8885. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8886. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8887. }
  8888. string breakfastPriceStr = string.Empty,
  8889. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8890. governmentRentStr = string.Empty,
  8891. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8892. cityTaxStrStr = string.Empty,
  8893. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8894. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8895. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8896. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8897. pcfds.Add(new HotelReservations_PCFD_View()
  8898. {
  8899. City = item.City,
  8900. HotelName = item.HotelName,
  8901. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8902. // SingleRoomCount = item.SingleRoomCount,
  8903. SingleRoomPrice = singleRoomFeeStr,
  8904. // DoubleRoomCount = item.DoubleRoomCount,
  8905. DoubleRoomPrice = doubleRoomFeeStr,
  8906. //SuiteRoomCount = item.SuiteRoomCount,
  8907. SuiteRoomPrice = suiteRoomFeeStr,
  8908. OtherRoomPrice = otherRoomFeeStr,
  8909. //OtherRoomCount = item.OtherRoomCount,
  8910. BreakfastPrice = breakfastPriceStr,
  8911. GovernmentRent = governmentRentStr,
  8912. CityTax = cityTaxStrStr,
  8913. RoomExplanation = item.RoomExplanation,
  8914. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8915. PayTime = roomInfo.ConsumptionDate,
  8916. BankNo = roomInfo.BankNo,
  8917. PayMoney = payMoneyStr,
  8918. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8919. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8920. CardPrice = cardPriceStr,
  8921. Remark = ccpInfo.Remark
  8922. });
  8923. }
  8924. #endregion
  8925. //载入模板
  8926. WorkbookDesigner designer = new WorkbookDesigner();
  8927. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8928. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8929. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8930. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8931. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8932. designer.SetDataSource("Opertor", userInfo.CnName);
  8933. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8934. dt.TableName = "ViewMyHotelReservations";
  8935. designer.SetDataSource(dt);
  8936. designer.Process();
  8937. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8938. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8939. designer.Workbook.Save(serverPath);
  8940. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8941. #region 删除指定行
  8942. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8943. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8944. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8945. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8946. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8947. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8948. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8949. cssIndex = dt.Columns["CityTax"].Ordinal,
  8950. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8951. remarkIndex = dt.Columns["Remark"].Ordinal;
  8952. //删除指定列
  8953. foreach (DataRow item in dt.Rows)
  8954. {
  8955. string singleStr = item["SingleRoomPrice"].ToString();
  8956. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8957. if (containsDigitButNotZero1) singleDel = false;
  8958. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8959. string doubleStr = item["DoubleRoomPrice"].ToString();
  8960. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8961. if (containsDigitButNotZero2) doubleDel = false;
  8962. string suiteStr = item["SuiteRoomPrice"].ToString();
  8963. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8964. if (containsDigitButNotZero3) suiteDel = false;
  8965. string otherStr = item["OtherRoomPrice"].ToString();
  8966. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8967. if (containsDigitButNotZero4) otherDel = false;
  8968. string zcStr = item["BreakfastPrice"].ToString();
  8969. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8970. if (containsDigitButNotZero5) zcDel = false;
  8971. string dsStr = item["GovernmentRent"].ToString();
  8972. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8973. if (containsDigitButNotZero6) dsDel = false;
  8974. string cssStr = item["CityTax"].ToString();
  8975. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8976. if (containsDigitButNotZero7) cssDel = false;
  8977. string cpStr = item["ConsumptionPatterns"].ToString();
  8978. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8979. string remarkStr = item["Remark"].ToString();
  8980. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8981. }
  8982. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8983. DeleteColumn(serverPath, cpIndex, cpDel);
  8984. DeleteColumn(serverPath, dsIndex, dsDel);
  8985. DeleteColumn(serverPath, cssIndex, cssDel);
  8986. DeleteColumn(serverPath, zcIndex, zcDel);
  8987. DeleteColumn(serverPath, otherIndex, otherDel);
  8988. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8989. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8990. DeleteColumn(serverPath, singleIndex, singleDel);
  8991. #endregion
  8992. //只保留第一个表格
  8993. DeleteSheet(serverPath);
  8994. return Ok(JsonView(true, "操作成功", url = rst));
  8995. }
  8996. /// <summary>
  8997. /// 删除指定列
  8998. /// </summary>
  8999. /// <param name="file"></param>
  9000. /// <param name="columnIndex"></param>
  9001. /// <param name="isDel"></param>
  9002. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9003. {
  9004. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9005. //wb.Save(file);
  9006. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9007. if (sheet1 != null)
  9008. {
  9009. if (isDel)
  9010. {
  9011. Cells cells = sheet1.Cells;
  9012. cells.DeleteColumn(columnIndex);
  9013. }
  9014. }
  9015. wb.Save(file);
  9016. }
  9017. /// <summary>
  9018. /// 删除sheet
  9019. /// </summary>
  9020. /// <param name="file"></param>
  9021. /// <param name="sheetName"></param>
  9022. private void DeleteSheet(string file, string sheetName = "")
  9023. {
  9024. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9025. //wb.Save(file);
  9026. List<string> sheets = new List<string>();
  9027. foreach (var item in wb.Worksheets)
  9028. {
  9029. sheets.Add(item.Name);
  9030. }
  9031. if (sheets.Count > 0)
  9032. {
  9033. sheets.RemoveAt(0);//不删除第一个sheet
  9034. foreach (var item in sheets)
  9035. {
  9036. wb.Worksheets.RemoveAt(item);
  9037. }
  9038. }
  9039. wb.Save(file);
  9040. }
  9041. /// <summary>
  9042. /// 酒店预订
  9043. /// 确认单
  9044. /// </summary>
  9045. /// <param name="_dto"></param>
  9046. /// <returns></returns>
  9047. [HttpPost]
  9048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9049. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9050. {
  9051. try
  9052. {
  9053. #region 参数验证
  9054. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9055. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9056. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9057. #region 团组操作权限验证 76 酒店预定模块
  9058. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9059. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9060. #endregion
  9061. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9062. #region 页面操作权限验证
  9063. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9064. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9065. #endregion
  9066. #endregion
  9067. //团组信息
  9068. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9069. //酒店数据
  9070. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9071. if (listhoteldata.Count < 0)
  9072. {
  9073. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9074. }
  9075. //利datatable存储
  9076. DataTable dt = new DataTable();
  9077. dt.Columns.Add("CheckInDate", typeof(string));
  9078. dt.Columns.Add("City", typeof(string));
  9079. dt.Columns.Add("Hotel", typeof(string));
  9080. dt.Columns.Add("Room", typeof(string));
  9081. for (int i = 0; i < listhoteldata.Count; i++)
  9082. {
  9083. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9084. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9085. while (dayStart < dayEnd)
  9086. {
  9087. string temp = "";
  9088. DataRow row = dt.NewRow();
  9089. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9090. row["City"] = listhoteldata[i].City;
  9091. row["Hotel"] = listhoteldata[i].HotelName;
  9092. if (listhoteldata[i].SingleRoomCount > 0)
  9093. {
  9094. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9095. }
  9096. if (listhoteldata[i].DoubleRoomCount > 0)
  9097. {
  9098. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9099. }
  9100. if (listhoteldata[i].SuiteRoomCount > 0)
  9101. {
  9102. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9103. }
  9104. if (listhoteldata[i].OtherRoomCount > 0)
  9105. {
  9106. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9107. }
  9108. row["Room"] = temp;
  9109. dt.Rows.Add(row);
  9110. dayStart = dayStart.AddDays(1);
  9111. }
  9112. }
  9113. Dictionary<string, string> dic = new Dictionary<string, string>();
  9114. dic.Add("Dele", di.TeamName);
  9115. dic.Add("City", di.VisitCountry);
  9116. //模板路径
  9117. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9118. //载入模板
  9119. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9120. DocumentBuilder builder = new DocumentBuilder(doc);
  9121. foreach (var key in dic.Keys)
  9122. {
  9123. builder.MoveToBookmark(key);
  9124. builder.Write(dic[key]);
  9125. }
  9126. //获取word里所有表格
  9127. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9128. //获取所填表格的序数
  9129. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9130. var rowStart = tableOne.Rows[0]; //获取第1行
  9131. //循环赋值
  9132. for (int i = 0; i < dt.Rows.Count; i++)
  9133. {
  9134. builder.MoveToCell(0, i + 1, 0, 0);
  9135. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9136. builder.MoveToCell(0, i + 1, 1, 0);
  9137. builder.Write(dt.Rows[i]["City"].ToString());
  9138. builder.MoveToCell(0, i + 1, 2, 0);
  9139. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9140. builder.MoveToCell(0, i + 1, 3, 0);
  9141. builder.Write(dt.Rows[i]["Room"].ToString());
  9142. }
  9143. //删除多余行
  9144. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9145. {
  9146. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9147. }
  9148. string strFileName = di.TeamName + "酒店确认单.doc";
  9149. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9150. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9151. return Ok(JsonView(true, "成功", url));
  9152. }
  9153. catch (Exception ex)
  9154. {
  9155. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9156. }
  9157. }
  9158. #endregion
  9159. #region 团组状态
  9160. /// <summary>
  9161. /// 团组状态列表 Page
  9162. /// </summary>
  9163. /// <param name="dto">团组列表请求dto</param>
  9164. /// <returns></returns>
  9165. [HttpPost]
  9166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9167. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9168. {
  9169. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9170. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9171. {
  9172. string sqlWhere = string.Empty;
  9173. if (dto.IsSure == 0) //未完成
  9174. {
  9175. sqlWhere += string.Format(@" And IsSure = 0");
  9176. }
  9177. else if (dto.IsSure == 1) //已完成
  9178. {
  9179. sqlWhere += string.Format(@" And IsSure = 1");
  9180. }
  9181. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9182. {
  9183. string tj = dto.SearchCriteria;
  9184. 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}%')",
  9185. tj, tj, tj, tj, tj);
  9186. }
  9187. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9188. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9189. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9190. From (
  9191. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9192. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9193. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9194. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9195. From Grp_DelegationInfo gdi
  9196. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9197. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9198. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9199. Where gdi.IsDel = 0 {0}
  9200. ) temp ", sqlWhere);
  9201. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9202. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9203. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9204. }
  9205. else
  9206. {
  9207. return Ok(JsonView(false, "查询失败"));
  9208. }
  9209. }
  9210. /// <summary>
  9211. /// 团组状态
  9212. /// 设置操作完成
  9213. /// </summary>
  9214. /// <param name="dto">团组列表请求dto</param>
  9215. /// <returns></returns>
  9216. [HttpPost]
  9217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9218. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9219. {
  9220. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9221. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9222. {
  9223. Id = dto.Id,
  9224. IsSure = 1
  9225. };
  9226. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9227. .UpdateColumns(it => new { it.IsSure })
  9228. .WhereColumns(it => new { it.Id })
  9229. .ExecuteCommandAsync();
  9230. if (result > 0)
  9231. {
  9232. return Ok(JsonView(true, "操作完成!"));
  9233. }
  9234. return Ok(JsonView(false, "操作失败!"));
  9235. }
  9236. #endregion
  9237. #region 保险费用录入
  9238. /// <summary>
  9239. /// 根据团组Id查询保险费用列表
  9240. /// </summary>
  9241. /// <param name="dto"></param>
  9242. /// <returns></returns>
  9243. [HttpPost]
  9244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9245. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9246. {
  9247. try
  9248. {
  9249. Result groupData = await _customersRep.CustomersByDiId(dto);
  9250. if (groupData.Code != 0)
  9251. {
  9252. return Ok(JsonView(false, groupData.Msg));
  9253. }
  9254. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9255. }
  9256. catch (Exception ex)
  9257. {
  9258. return Ok(JsonView(false, ex.Message));
  9259. }
  9260. }
  9261. /// <summary>
  9262. /// 根据保险费用Id查询保险费用详细
  9263. /// </summary>
  9264. /// <param name="dto"></param>
  9265. /// <returns></returns>
  9266. [HttpPost]
  9267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9268. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9269. {
  9270. try
  9271. {
  9272. Result groupData = await _customersRep.CustomersById(dto);
  9273. if (groupData.Code != 0)
  9274. {
  9275. return Ok(JsonView(false, groupData.Msg));
  9276. }
  9277. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9278. }
  9279. catch (Exception ex)
  9280. {
  9281. return Ok(JsonView(false, ex.Message));
  9282. }
  9283. }
  9284. /// <summary>
  9285. /// 保险费用录入页面初始化绑定
  9286. /// </summary>
  9287. /// <param name="dto"></param>
  9288. /// <returns></returns>
  9289. [HttpPost]
  9290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9291. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9292. {
  9293. try
  9294. {
  9295. Result groupData = await _customersRep.CustomersInitialize(dto);
  9296. if (groupData.Code != 0)
  9297. {
  9298. return Ok(JsonView(false, groupData.Msg));
  9299. }
  9300. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9301. }
  9302. catch (Exception ex)
  9303. {
  9304. return Ok(JsonView(false, ex.Message));
  9305. }
  9306. }
  9307. /// <summary>
  9308. /// 保险费用操作(Status:1.新增,2.修改)
  9309. /// </summary>
  9310. /// <param name="dto"></param>
  9311. /// <returns></returns>
  9312. [HttpPost]
  9313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9314. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9315. {
  9316. try
  9317. {
  9318. Result groupData = await _customersRep.OpCustomers(dto);
  9319. if (groupData.Code != 0)
  9320. {
  9321. return Ok(JsonView(false, groupData.Msg));
  9322. }
  9323. #region 应用推送
  9324. try
  9325. {
  9326. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9327. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9328. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9329. }
  9330. catch (Exception ex)
  9331. {
  9332. }
  9333. #endregion
  9334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9335. }
  9336. catch (Exception ex)
  9337. {
  9338. return Ok(JsonView(false, ex.Message));
  9339. }
  9340. }
  9341. /// <summary>
  9342. /// 保险文件上传
  9343. /// </summary>
  9344. /// <param name="file"></param>
  9345. /// <returns></returns>
  9346. [HttpPost]
  9347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9348. public async Task<IActionResult> UploadCus(IFormFile file)
  9349. {
  9350. try
  9351. {
  9352. if (file != null)
  9353. {
  9354. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9355. //文件名称
  9356. string projectFileName = file.FileName;
  9357. //上传的文件的路径
  9358. string filePath = "";
  9359. if (!Directory.Exists(fileDir))
  9360. {
  9361. Directory.CreateDirectory(fileDir);
  9362. }
  9363. //上传的文件的路径
  9364. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9365. using (FileStream fs = System.IO.File.Create(filePath))
  9366. {
  9367. file.CopyTo(fs);
  9368. fs.Flush();
  9369. }
  9370. return Ok(JsonView(true, "上传成功!", projectFileName));
  9371. }
  9372. else
  9373. {
  9374. return Ok(JsonView(false, "上传失败!"));
  9375. }
  9376. }
  9377. catch (Exception ex)
  9378. {
  9379. return Ok(JsonView(false, "程序错误!"));
  9380. throw;
  9381. }
  9382. }
  9383. /// <summary>
  9384. /// 保险删除指定文件
  9385. /// </summary>
  9386. /// <param name="dto"></param>
  9387. /// <returns></returns>
  9388. [HttpPost]
  9389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9390. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9391. {
  9392. try
  9393. {
  9394. string filePath = "";
  9395. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9396. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9397. //int id = 0;
  9398. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9399. // 删除该文件
  9400. try
  9401. {
  9402. System.IO.File.Delete(filePath);
  9403. 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()
  9404. {
  9405. Attachment = "",
  9406. }).ExecuteCommandAsync();
  9407. if (result != 0)
  9408. {
  9409. return Ok(JsonView(true, "成功!"));
  9410. }
  9411. else
  9412. {
  9413. return Ok(JsonView(false, "失败!"));
  9414. }
  9415. }
  9416. catch (Exception)
  9417. {
  9418. 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()
  9419. {
  9420. Attachment = "",
  9421. }).ExecuteCommandAsync();
  9422. if (result != 0)
  9423. {
  9424. return Ok(JsonView(true, "成功!"));
  9425. }
  9426. else
  9427. {
  9428. return Ok(JsonView(false, "失败!"));
  9429. }
  9430. }
  9431. }
  9432. catch (Exception ex)
  9433. {
  9434. return Ok(JsonView(false, "程序错误!"));
  9435. throw;
  9436. }
  9437. }
  9438. /// <summary>
  9439. /// 保险费用操作(删除)
  9440. /// </summary>
  9441. /// <param name="dto"></param>
  9442. /// <returns></returns>
  9443. [HttpPost]
  9444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9445. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9446. {
  9447. try
  9448. {
  9449. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9450. if (!res)
  9451. {
  9452. return Ok(JsonView(false, "删除失败"));
  9453. }
  9454. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9455. {
  9456. IsDel = 1,
  9457. DeleteUserId = dto.DeleteUserId,
  9458. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9459. }).ExecuteCommandAsync();
  9460. return Ok(JsonView(true, "删除成功!"));
  9461. }
  9462. catch (Exception ex)
  9463. {
  9464. return Ok(JsonView(false, "程序错误!"));
  9465. throw;
  9466. }
  9467. }
  9468. #endregion
  9469. #region 接团客户名单 PageId 104
  9470. /// <summary>
  9471. /// 接团客户名单
  9472. /// 迁移数据(慎用!)
  9473. /// </summary>
  9474. /// <param name="dto"></param>
  9475. /// <returns></returns>
  9476. [HttpPost]
  9477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9478. public async Task<IActionResult> PostTourClientListChange()
  9479. {
  9480. try
  9481. {
  9482. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9483. //var groupClinetData1
  9484. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9485. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9486. int updateCount = 0;
  9487. if (oldOAClientList.Count > 0)
  9488. {
  9489. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9490. _sqlSugar.BeginTran();
  9491. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9492. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9493. foreach (var item in oldOAClientList)
  9494. {
  9495. int comId = 0;
  9496. string format = "yyyy-MM-dd HH:mm:ss";
  9497. string data11 = "1990-01-01 00:00";
  9498. var data1 = IsValidDate(item.OPdate, format);
  9499. if (data1) data11 = item.OPdate;
  9500. //客户公司验证
  9501. if (!string.IsNullOrEmpty(item.Company))
  9502. {
  9503. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9504. if (clientComInfo == null) // add
  9505. {
  9506. var addInfo = new Crm_CustomerCompany()
  9507. {
  9508. CompanyAbbreviation = "",
  9509. CompanyFullName = item.Company,
  9510. Address = "",
  9511. PostCodes = "",
  9512. LastedOpUserId = item.OPer,
  9513. LastedOpDt = Convert.ToDateTime(data11),
  9514. CreateUserId = item.OPer,
  9515. CreateTime = Convert.ToDateTime(data11),
  9516. IsDel = 0
  9517. };
  9518. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9519. if (comId1 > 0) comId = comId1;
  9520. }
  9521. else comId = clientComInfo.Id;
  9522. }
  9523. //客户人员验证
  9524. int clientId = 0;
  9525. string name = item.LastName + item.Name;
  9526. if (!string.IsNullOrEmpty(name))
  9527. {
  9528. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9529. if (clientInfo == null)
  9530. {
  9531. DateTime? dateTime = null;
  9532. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9533. if (isDt) dateTime = birthDayDt;
  9534. var addInfo1 = new Crm_DeleClient()
  9535. {
  9536. CrmCompanyId = comId,
  9537. DiId = -1,
  9538. LastName = item.LastName,
  9539. FirstName = item.Name,
  9540. OldName = "",
  9541. Pinyin = item.Pinyin,
  9542. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9543. Marriage = 0,
  9544. Phone = item.Phone,
  9545. Job = item.Job,
  9546. BirthDay = dateTime
  9547. };
  9548. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9549. if (clientId1 > 0) clientId = clientId1;
  9550. }
  9551. else clientId = clientInfo.Id;
  9552. }
  9553. if (clientId < 1)
  9554. {
  9555. continue;
  9556. }
  9557. int airType = 0;
  9558. if (item.AirType == "超经舱") airType = 459;
  9559. else if (item.AirType == "公务舱") airType = 458;
  9560. else if (item.AirType == "经济舱") airType = 460;
  9561. else if (item.AirType == "其他") airType = 565;
  9562. else if (item.AirType == "头等舱") airType = 457;
  9563. var _TourClientListEntity = new Grp_TourClientList()
  9564. {
  9565. DiId = item.Diid,
  9566. ClientId = clientId,
  9567. CreateUserId = item.OPer,
  9568. CreateTime = Convert.ToDateTime(data11),
  9569. Remark = item.Remark,
  9570. IsDel = item.Isdel,
  9571. ShippingSpaceTypeId = airType,
  9572. ShippingSpaceSpecialNeeds = item.AirRemark,
  9573. HotelSpecialNeeds = item.RoomType
  9574. };
  9575. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9576. if (_TourClientList > 0)
  9577. {
  9578. updateCount++;
  9579. }
  9580. }
  9581. _sqlSugar.CommitTran();
  9582. }
  9583. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9584. }
  9585. catch (Exception ex)
  9586. {
  9587. _sqlSugar.RollbackTran();
  9588. return Ok(JsonView(false, ex.Message));
  9589. }
  9590. return Ok(JsonView(true));
  9591. }
  9592. private bool IsValidDate(string dateString, string format)
  9593. {
  9594. DateTime dateValue;
  9595. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9596. return valid;
  9597. }
  9598. /// <summary>
  9599. /// 接团客户名单
  9600. /// 根据团组Id查询List
  9601. /// </summary>
  9602. /// <param name="dto"></param>
  9603. /// <returns></returns>
  9604. [HttpPost]
  9605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9606. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9607. {
  9608. #region 参数验证
  9609. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9610. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9611. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9612. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9613. #region 页面操作权限验证
  9614. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9615. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9616. #endregion
  9617. #endregion
  9618. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9619. if (viewData.Code != 0)
  9620. {
  9621. return Ok(JsonView(false, viewData.Msg));
  9622. }
  9623. return Ok(JsonView(viewData.Data));
  9624. }
  9625. /// <summary>
  9626. /// 接团客户名单
  9627. /// 基础数据 Init
  9628. /// </summary>
  9629. /// <param name="_dto"></param>
  9630. /// <returns></returns>
  9631. [HttpPost]
  9632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9633. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9634. {
  9635. #region 参数验证
  9636. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9637. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9638. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9639. #region 页面操作权限验证
  9640. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9641. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9642. #endregion
  9643. #endregion
  9644. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9645. if (viewData.Code != 0)
  9646. {
  9647. return Ok(JsonView(false, viewData.Msg));
  9648. }
  9649. return Ok(JsonView(viewData.Data));
  9650. }
  9651. /// <summary>
  9652. /// 接团客户名单
  9653. /// 根据 Id查询 Details
  9654. /// </summary>
  9655. /// <param name="_dto"></param>
  9656. /// <returns></returns>
  9657. [HttpPost]
  9658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9659. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9660. {
  9661. #region 参数验证
  9662. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9663. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9664. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9665. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9666. #region 页面操作权限验证
  9667. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9668. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9669. #endregion
  9670. #endregion
  9671. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9672. if (viewData.Code != 0)
  9673. {
  9674. return Ok(JsonView(false, viewData.Msg));
  9675. }
  9676. return Ok(JsonView(viewData.Data));
  9677. }
  9678. /// <summary>
  9679. /// 接团客户名单
  9680. /// Add Or Edit
  9681. /// </summary>
  9682. /// <param name="_dto"></param>
  9683. /// <returns></returns>
  9684. [HttpPost]
  9685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9686. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9687. {
  9688. #region 参数验证
  9689. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9690. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9691. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9692. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9693. #region 页面操作权限验证
  9694. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9695. if (_dto.Id == 0) //添加
  9696. {
  9697. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9698. }
  9699. else if (_dto.Id >= 0) //修改
  9700. {
  9701. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9702. }
  9703. #endregion
  9704. #endregion
  9705. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9706. if (viewData.Code != 0)
  9707. {
  9708. return Ok(JsonView(false, viewData.Msg));
  9709. }
  9710. return Ok(JsonView(true));
  9711. }
  9712. /// <summary>
  9713. /// 接团客户名单
  9714. /// AddMultiple(添加多个)
  9715. /// </summary>
  9716. /// <param name="_dto"></param>
  9717. /// <returns></returns>
  9718. [HttpPost]
  9719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9720. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9721. {
  9722. #region 参数验证
  9723. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9724. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9725. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9726. #region 页面操作权限验证
  9727. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9728. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9729. #endregion
  9730. #endregion
  9731. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9732. if (viewData.Code != 0)
  9733. {
  9734. return Ok(JsonView(false, viewData.Msg));
  9735. }
  9736. return Ok(JsonView(true));
  9737. }
  9738. /// <summary>
  9739. /// 接团客户名单
  9740. /// Del
  9741. /// </summary>
  9742. /// <param name="_dto"></param>
  9743. /// <returns></returns>
  9744. [HttpPost]
  9745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9746. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9747. {
  9748. #region 参数验证
  9749. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9750. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9752. #region 页面操作权限验证
  9753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9754. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9755. #endregion
  9756. #endregion
  9757. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9758. if (viewData.Code != 0)
  9759. {
  9760. return Ok(JsonView(false, viewData.Msg));
  9761. }
  9762. return Ok(JsonView(true));
  9763. }
  9764. /// <summary>
  9765. /// 接团客户名单
  9766. /// 文件下载 客户名单
  9767. /// </summary>
  9768. /// <param name="_dto"></param>
  9769. /// <returns></returns>
  9770. [HttpPost]
  9771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9772. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9773. {
  9774. #region 参数验证
  9775. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9776. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9777. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9778. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9779. #region 页面操作权限验证
  9780. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9781. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9782. #endregion
  9783. #endregion
  9784. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9785. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9786. From Grp_TourClientList tcl
  9787. Left Join
  9788. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9789. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9790. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9791. From Crm_DeleClient dc
  9792. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9793. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9794. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9795. Where dc.IsDel = 0) temp
  9796. On temp.DcId =tcl.ClientId
  9797. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9798. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9799. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9800. //载入模板
  9801. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9802. if (_dto.Language == 1)
  9803. {
  9804. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9805. }
  9806. //载入模板
  9807. var doc = new Document(tempPath);
  9808. DocumentBuilder builder = new DocumentBuilder(doc);
  9809. //获取word里所有表格
  9810. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9811. //获取所填表格的序数
  9812. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9813. var rowStart = tableOne.Rows[0]; //获取第1行
  9814. if (_dto.Language == 0)
  9815. {
  9816. //循环赋值
  9817. for (int i = 0; i < DcList.Count; i++)
  9818. {
  9819. builder.MoveToCell(0, i + 1, 0, 0);
  9820. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9821. builder.MoveToCell(0, i + 1, 1, 0);
  9822. int sex = DcList[i].Sex;
  9823. string sexStr = string.Empty;
  9824. if (sex == 0) sexStr = "男";
  9825. else if (sex == 1) sexStr = "女";
  9826. else sexStr = "未设置";
  9827. builder.Write(sexStr);
  9828. builder.MoveToCell(0, i + 1, 2, 0);
  9829. string birthDay = DcList[i].BirthDay;
  9830. string birthDayStr = string.Empty;
  9831. if (!string.IsNullOrEmpty(birthDay))
  9832. {
  9833. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9834. }
  9835. builder.Write(birthDayStr);
  9836. builder.MoveToCell(0, i + 1, 3, 0);
  9837. string company = "";
  9838. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9839. {
  9840. company = DcList[i].CompanyFullName.ToString();
  9841. }
  9842. builder.Write(company);
  9843. builder.MoveToCell(0, i + 1, 4, 0);
  9844. builder.Write(DcList[i].Job);
  9845. }
  9846. }
  9847. else if (_dto.Language == 1)
  9848. {
  9849. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9850. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9851. List<string> transArrayStr = new List<string>();
  9852. string transStrRes1 = "";
  9853. for (int i = 0; i < DcList.Count; i++)
  9854. {
  9855. var dc = DcList[i];
  9856. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  9857. if (dc.Job.Equals("暂无")) dc.Job = "-";
  9858. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  9859. if (DcList.Count - 1 == i) transStrRes1 += str1;
  9860. else transStrRes1 += $"{str1}|";
  9861. }
  9862. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  9863. string transStrRes = "";
  9864. if (transStrRes1.Length > 0 )
  9865. {
  9866. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  9867. }
  9868. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  9869. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  9870. //List<string> transArray = new List<string> { };
  9871. List<TranslateInfo> transArray = new List<TranslateInfo>();
  9872. if (transStrRes.Contains("|"))
  9873. {
  9874. string[] transArray1 = transStrRes.Split('|');
  9875. if (transArray1.Length > 0)
  9876. {
  9877. foreach (var item in transArray1)
  9878. {
  9879. if (item.Contains("&"))
  9880. {
  9881. string[] transArray2 = item.Split('&');
  9882. int index = 0;
  9883. string companyName = "", job = "";
  9884. if (transArray2.Length > 0)
  9885. {
  9886. bool success = int.TryParse(transArray2[0].Trim(), out index);
  9887. if (1 < transArray2.Length) companyName = transArray2[1];
  9888. if (2 < transArray2.Length) job = transArray2[2];
  9889. }
  9890. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  9891. }
  9892. }
  9893. }
  9894. }
  9895. //循环赋值
  9896. for (int i = 0; i < DcList.Count; i++)
  9897. {
  9898. string PYName = "";
  9899. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9900. {
  9901. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9902. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9903. PYName = PY_First + " " + PY_Last;
  9904. }
  9905. else
  9906. {
  9907. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9908. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9909. PYName = PY_First + " " + PY_Last;
  9910. }
  9911. builder.MoveToCell(0, i + 1, 0, 0);
  9912. builder.Write(PYName);
  9913. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9914. builder.MoveToCell(0, i + 1, 1, 0);
  9915. builder.Write(sex);
  9916. DateTime birthDt;
  9917. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9918. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  9919. builder.MoveToCell(0, i + 1, 2, 0);
  9920. builder.Write(birthday);
  9921. string company = string.Empty,job = string.Empty;
  9922. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  9923. if (dcTransInfo != null)
  9924. {
  9925. company = dcTransInfo.CompanyName;
  9926. job = dcTransInfo.Job;
  9927. }
  9928. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9929. {
  9930. //查询对照表
  9931. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9932. if (tempCec != null)
  9933. {
  9934. company = tempCec.enName;
  9935. }
  9936. //翻译
  9937. else
  9938. {
  9939. }
  9940. }
  9941. builder.MoveToCell(0, i + 1, 3, 0);
  9942. builder.Write(company);
  9943. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9944. {
  9945. //查询对照表
  9946. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9947. if (tempPec != null)
  9948. {
  9949. job = tempPec.enName;
  9950. }
  9951. //翻译
  9952. else
  9953. {
  9954. }
  9955. }
  9956. builder.MoveToCell(0, i + 1, 4, 0);
  9957. builder.Write(job);
  9958. }
  9959. }
  9960. //删除多余行
  9961. while (tableOne.Rows.Count > DcList.Count + 1)
  9962. {
  9963. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9964. }
  9965. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9966. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9967. doc.Save(fileDir);
  9968. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9969. return Ok(JsonView(true, "操作成功!", Url));
  9970. }
  9971. private class TranslateInfo
  9972. {
  9973. public int Index { get; set; }
  9974. public string CompanyName { get; set; }
  9975. public string Job { get; set; }
  9976. }
  9977. #endregion
  9978. #region 团组倒推表
  9979. /// <summary>
  9980. /// 倒推表基础数据
  9981. /// Init
  9982. /// </summary>
  9983. /// <param name="dto"></param>
  9984. /// <returns></returns>
  9985. [HttpPost]
  9986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9987. public async Task<IActionResult> PostInvertedListInit()
  9988. {
  9989. var viewData = await _invertedListRep._Init();
  9990. if (viewData.Code != 0)
  9991. {
  9992. return Ok(JsonView(false, viewData.Msg));
  9993. }
  9994. return Ok(JsonView(viewData.Data));
  9995. }
  9996. /// <summary>
  9997. /// 倒推表
  9998. /// Info
  9999. /// </summary>
  10000. /// <param name="dto"></param>
  10001. /// <returns></returns>
  10002. [HttpPost]
  10003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10004. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10005. {
  10006. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10007. if (viewData.Code != 0)
  10008. {
  10009. return Ok(JsonView(false, viewData.Msg));
  10010. }
  10011. return Ok(JsonView(viewData.Data));
  10012. }
  10013. /// <summary>
  10014. /// 倒推表
  10015. /// Create
  10016. /// </summary>
  10017. /// <param name="dto"></param>
  10018. /// <returns></returns>
  10019. [HttpPost]
  10020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10021. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10022. {
  10023. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10024. if (viewData.Code != 0)
  10025. {
  10026. return Ok(JsonView(false, viewData.Msg));
  10027. }
  10028. return Ok(JsonView(viewData.Data));
  10029. }
  10030. /// <summary>
  10031. /// 倒推表
  10032. /// Update
  10033. /// </summary>
  10034. /// <param name="dto"></param>
  10035. /// <returns></returns>
  10036. [HttpPost]
  10037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10038. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10039. {
  10040. var viewData = await _invertedListRep._Update(dto);
  10041. if (viewData.Code != 0)
  10042. {
  10043. return Ok(JsonView(false, viewData.Msg));
  10044. }
  10045. return Ok(JsonView(viewData.Data));
  10046. }
  10047. /// <summary>
  10048. /// 倒推表
  10049. /// File Download
  10050. /// </summary>
  10051. /// <param name="dto"></param>
  10052. /// <returns></returns>
  10053. [HttpPost]
  10054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10055. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10056. {
  10057. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10058. if (info2.Code != 0)
  10059. {
  10060. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10061. }
  10062. var info1 = info2.Data as InvertedListInfoView;
  10063. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10064. string teamName = "";
  10065. if (info != null) teamName = info.TeamName;
  10066. //载入模板
  10067. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10068. DocumentBuilder builder = new DocumentBuilder(doc);
  10069. //利用键值对存放数据
  10070. Dictionary<string, string> dic = new Dictionary<string, string>();
  10071. dic.Add("TeamName", teamName);
  10072. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10073. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10074. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10075. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10076. dic.Add("SQRemark", info1.ApprovalRemark);
  10077. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10078. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10079. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10080. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10081. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10082. dic.Add("QZRemark", info1.VisaInformationRemark);
  10083. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10084. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10085. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10086. dic.Add("CQRemark", info1.IssueVisaRemark);
  10087. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10088. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10089. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10090. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10091. #region 填充word模板书签内容
  10092. foreach (var key in dic.Keys)
  10093. {
  10094. builder.MoveToBookmark(key);
  10095. builder.Write(dic[key]);
  10096. }
  10097. #endregion
  10098. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10099. string fileName = $"{teamName}团出行准备流程表.doc";
  10100. string filePath = fileDir + $@"InvertedList/{fileName}";
  10101. doc.Save(filePath);
  10102. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10103. return Ok(JsonView(true, "操作成功!", Url));
  10104. }
  10105. #endregion
  10106. #region 三公签证费用(签证费、代办费)
  10107. /// <summary>
  10108. /// 三公签证费用(签证费、代办费)
  10109. /// List
  10110. /// </summary>
  10111. /// <returns></returns>
  10112. [HttpPost]
  10113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10114. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10115. {
  10116. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10117. if (_view.Code != 0)
  10118. {
  10119. return Ok(JsonView(false, _view.Msg));
  10120. }
  10121. return Ok(JsonView(true, "操作成功!", _view.Data));
  10122. }
  10123. /// <summary>
  10124. /// 三公签证费用(签证费、代办费)
  10125. /// Add Or Update
  10126. /// </summary>
  10127. /// <returns></returns>
  10128. [HttpPost]
  10129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10130. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10131. {
  10132. var _view = await _visaFeeInfoRep._Update(_dto);
  10133. if (_view.Code != 0)
  10134. {
  10135. return Ok(JsonView(false, _view.Msg));
  10136. }
  10137. return Ok(JsonView(true, _view.Msg));
  10138. }
  10139. #endregion
  10140. #region 酒店询价
  10141. /// <summary>
  10142. /// 酒店询价
  10143. /// Init
  10144. /// </summary>
  10145. /// <param name="dto"></param>
  10146. /// <returns></returns>
  10147. [HttpPost]
  10148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10149. public async Task<IActionResult> PostHotelInquiryInit()
  10150. {
  10151. var res = await _hotelInquiryRep._Init();
  10152. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10153. return Ok(JsonView(true, res.Msg, res.Data));
  10154. }
  10155. /// <summary>
  10156. /// 酒店询价
  10157. /// page Item
  10158. /// </summary>
  10159. /// <param name="_dto"></param>
  10160. /// <returns></returns>
  10161. [HttpPost]
  10162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10163. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10164. {
  10165. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10166. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10167. var view = res.Data as PageDataViewBase;
  10168. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10169. }
  10170. /// <summary>
  10171. /// 酒店询价
  10172. /// info
  10173. /// </summary>
  10174. /// <param name="_dto"></param>
  10175. /// <returns></returns>
  10176. [HttpPost]
  10177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10178. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10179. {
  10180. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10181. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10182. return Ok(JsonView(true, res.Msg, res.Data));
  10183. }
  10184. /// <summary>
  10185. /// 酒店询价
  10186. /// Add Or Edit
  10187. /// </summary>
  10188. /// <param name="_dto"></param>
  10189. /// <returns></returns>
  10190. [HttpPost]
  10191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10192. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10193. {
  10194. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10195. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10196. return Ok(JsonView(true, res.Msg, res.Data));
  10197. }
  10198. /// <summary>
  10199. /// 酒店询价
  10200. /// Del
  10201. /// </summary>
  10202. /// <param name="_dto"></param>
  10203. /// <returns></returns>
  10204. [HttpPost]
  10205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10206. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10207. {
  10208. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10209. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10210. return Ok(JsonView(true, res.Msg, res.Data));
  10211. }
  10212. #endregion
  10213. #region 下载匹配op行程单
  10214. /// <summary>
  10215. /// 匹配op行程单
  10216. /// Init
  10217. /// </summary>
  10218. /// <param name="dto">团组列表请求dto</param>
  10219. /// <returns></returns>
  10220. [HttpPost]
  10221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10222. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10223. {
  10224. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10225. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10226. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10227. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10228. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10229. .Where(it => it.IsDel == 0)
  10230. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10231. .OrderByDescending(it => it.CreateUserId)
  10232. .ToList();
  10233. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10234. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10235. var diids = groupInfos.Select(it => it.Id).ToList();
  10236. List<string> countrys = new List<string>();
  10237. foreach (var item in country)
  10238. {
  10239. var data = _groupRepository.FormartTeamName(item);
  10240. var dataArray = _groupRepository.GroupSplitCountry(data);
  10241. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10242. }
  10243. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10244. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10245. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10246. foreach (var item in areaItem)
  10247. {
  10248. string areaStr = item.Value;
  10249. if (!string.IsNullOrEmpty(areaStr))
  10250. {
  10251. string[] str1 = areaStr.Split("-");
  10252. if (str1.Length > 0)
  10253. {
  10254. areaArray.AddRange(str1);
  10255. }
  10256. }
  10257. }
  10258. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10259. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10260. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10261. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10262. .ToList();
  10263. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10264. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10265. .Where(it => countriesIds.Contains(it.Id))
  10266. .Select(it => new { it.Id, Name = it.Name_CN })
  10267. .ToList();
  10268. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10269. .Select(it => it.TeamName).ToList();
  10270. stopwatch.Stop();
  10271. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10272. }
  10273. ///// <summary>
  10274. ///// 匹配op行程单
  10275. ///// Init 查询区域数据
  10276. ///// </summary>
  10277. ///// <param name="dto">团组列表请求dto</param>
  10278. ///// <returns></returns>
  10279. //[HttpPost]
  10280. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10281. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10282. //{
  10283. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10284. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10285. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10286. // if (string.IsNullOrEmpty(countriesDataStr))
  10287. // {
  10288. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10289. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10290. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10291. // }
  10292. // else
  10293. // {
  10294. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10295. // }
  10296. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10297. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10298. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10299. // List<dynamic> childList = new List<dynamic>();
  10300. // int parentId = dto.CountriesId;
  10301. // if (provinceData.Count > 1)
  10302. // {
  10303. // foreach (var item1 in provinceData)
  10304. // {
  10305. // List<dynamic> childList1 = new List<dynamic>();
  10306. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10307. // foreach (var item2 in citiesData1)
  10308. // {
  10309. // List<dynamic> childList2 = new List<dynamic>();
  10310. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10311. // foreach (var item3 in countiesData1)
  10312. // {
  10313. // childList2.Add(new
  10314. // {
  10315. // id = item3.Id,
  10316. // parentId = item2.Id,
  10317. // level = "district",
  10318. // name = item3.Name_CN,
  10319. // });
  10320. // }
  10321. // childList1.Add(new
  10322. // {
  10323. // id = item2.Id,
  10324. // parentId = item1.Id,
  10325. // level = "city",
  10326. // name = item2.Name_CN,
  10327. // childList = childList2
  10328. // });
  10329. // }
  10330. // childList.Add(new
  10331. // {
  10332. // id = item1.Id,
  10333. // parentId = parentId,
  10334. // level = "province",
  10335. // name = item1.Name_CN,
  10336. // childList = childList1
  10337. // });
  10338. // }
  10339. // //城市
  10340. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10341. // foreach (var item2 in citiesData2)
  10342. // {
  10343. // List<dynamic> childList22 = new List<dynamic>();
  10344. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10345. // foreach (var item3 in countiesData1)
  10346. // {
  10347. // childList22.Add(new
  10348. // {
  10349. // id = item3.Id,
  10350. // parentId = item2.Id,
  10351. // level = "district",
  10352. // name = item3.Name_CN,
  10353. // });
  10354. // }
  10355. // childList.Add(new
  10356. // {
  10357. // id = item2.Id,
  10358. // parentId = parentId,
  10359. // level = "city",
  10360. // name = item2.Name_CN,
  10361. // childList = childList22
  10362. // });
  10363. // }
  10364. // }
  10365. // else
  10366. // {
  10367. // foreach (var item2 in citiesData)
  10368. // {
  10369. // string cname = item2.Name_CN;
  10370. // List<dynamic> childList1 = new List<dynamic>();
  10371. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10372. // foreach (var item3 in countiesData1)
  10373. // {
  10374. // childList1.Add(new
  10375. // {
  10376. // Id = item3.Id,
  10377. // parentId = item2.Id,
  10378. // level = "district",
  10379. // name = item3.Name_CN
  10380. // });
  10381. // }
  10382. // childList.Add(new
  10383. // {
  10384. // id = item2.Id,
  10385. // parentId = parentId,
  10386. // level = "city",
  10387. // name = item2.Name_CN,
  10388. // childList = childList1
  10389. // });
  10390. // }
  10391. // }
  10392. // stopwatch.Stop();
  10393. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10394. //}
  10395. /// <summary>
  10396. /// 匹配op行程单
  10397. /// 接团信息列表 Page
  10398. /// </summary>
  10399. /// <param name="dto">团组列表请求dto</param>
  10400. /// <returns></returns>
  10401. [HttpPost]
  10402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10403. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10404. {
  10405. var swatch = new Stopwatch();
  10406. swatch.Start();
  10407. #region 参数验证
  10408. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10409. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10410. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10411. #region 页面操作权限验证
  10412. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10413. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10414. #endregion
  10415. #endregion
  10416. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10417. {
  10418. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10419. string sqlWhere = "";
  10420. if (!string.IsNullOrEmpty(dto.Country))
  10421. {
  10422. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10423. }
  10424. if (!string.IsNullOrEmpty(dto.Area))
  10425. {
  10426. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10427. }
  10428. if (!string.IsNullOrEmpty(dto.TeamName))
  10429. {
  10430. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10431. }
  10432. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10433. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10434. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10435. swatch.Stop();
  10436. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10437. }
  10438. else
  10439. {
  10440. return Ok(JsonView(false, "查询失败"));
  10441. }
  10442. }
  10443. /// <summary>
  10444. /// 匹配op行程单
  10445. /// 行程单下载
  10446. /// </summary>
  10447. /// <param name="dto">团组列表请求dto</param>
  10448. /// <returns></returns>
  10449. [HttpPost]
  10450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10451. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10452. {
  10453. #region 参数验证
  10454. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10455. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10456. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10457. #region 页面操作权限验证
  10458. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10459. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10460. #endregion
  10461. #endregion
  10462. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10463. {
  10464. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10465. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10466. }
  10467. else
  10468. {
  10469. return Ok(JsonView(false, "下载失败!"));
  10470. }
  10471. }
  10472. #endregion
  10473. #region 国家信息 数据 注释
  10474. //[HttpPost]
  10475. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10476. //{
  10477. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10478. // foreach (var item in dto)
  10479. // {
  10480. // infos.Add(new Grp_GroupsTaskAssignment()
  10481. // {
  10482. // DIId = item,
  10483. // CTId = 82,
  10484. // UId = 248,
  10485. // IsEnable = 1,
  10486. // CreateUserId = 233,
  10487. // CreateTime = DateTime.Now,
  10488. // IsDel = 0
  10489. // });
  10490. // infos.Add(new Grp_GroupsTaskAssignment()
  10491. // {
  10492. // DIId = item,
  10493. // CTId = 82,
  10494. // UId = 286,
  10495. // IsEnable = 1,
  10496. // CreateUserId = 233,
  10497. // CreateTime = DateTime.Now,
  10498. // IsDel = 0
  10499. // });
  10500. // }
  10501. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10502. // return Ok("操作成功");
  10503. //}
  10504. //public class paramJsonDto
  10505. //{
  10506. // public List<CountriesInfo> str { get; set; }
  10507. //}
  10508. //[HttpPost]
  10509. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10510. //{
  10511. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10512. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10513. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10514. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10515. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10516. // _sqlSugar.BeginTran();
  10517. // int countitiesIndex = 0;
  10518. // foreach (var item in dto.str)
  10519. // {
  10520. // dynamic data = item.c;
  10521. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10522. // if (data != null)
  10523. // {
  10524. // countitiesIndex++;
  10525. // foreach (var item1 in data)
  10526. // {
  10527. // string cnname = item1.cn;
  10528. // string enname = item1.en;
  10529. // Sys_Cities provinceInfo = new Sys_Cities()
  10530. // {
  10531. // CountriesId = countriesId,
  10532. // Name_CN = cnname,
  10533. // Name_EN = enname,
  10534. // ParentId = 0,
  10535. // IsCapital = 1,
  10536. // CreateUserId = 208,
  10537. // CreateTime = DateTime.Now,
  10538. // IsDel = 0
  10539. // };
  10540. // if (item1.lv == "province") //省份
  10541. // {
  10542. // provinceInfo.Level = 1;
  10543. // int provinceId = 0;
  10544. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10545. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10546. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10547. // var data1 = item1.c;
  10548. // foreach (var item2 in data1)
  10549. // {
  10550. // if (item2.lv == "city")
  10551. // {
  10552. // string citycnname = item2.cn;
  10553. // string cityenname = item2.en;
  10554. // Sys_Cities cityInfo = new Sys_Cities()
  10555. // {
  10556. // CountriesId = countriesId,
  10557. // ParentId = provinceId,
  10558. // Level = 2,
  10559. // Name_CN = citycnname,
  10560. // Name_EN = cityenname,
  10561. // IsCapital = 1,
  10562. // CreateUserId = 208,
  10563. // CreateTime = DateTime.Now,
  10564. // IsDel = 0
  10565. // };
  10566. // if (item2.c != null)
  10567. // {
  10568. // int cityId = 0;
  10569. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10570. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10571. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10572. // foreach (var item3 in item2.c)
  10573. // {
  10574. // if (item3.lv == "district")
  10575. // {
  10576. // var districtInfo = new Sys_Cities()
  10577. // {
  10578. // CountriesId = countriesId,
  10579. // Name_CN = item3.cn,
  10580. // Name_EN = item3.en,
  10581. // Level = 3,
  10582. // ParentId = cityId,
  10583. // IsCapital = 1,
  10584. // CreateUserId = 208,
  10585. // CreateTime = DateTime.Now,
  10586. // IsDel = 0
  10587. // };
  10588. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10589. // //{
  10590. // districts.Add(districtInfo);
  10591. // //}
  10592. // }
  10593. // }
  10594. // }
  10595. // else
  10596. // {
  10597. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10598. // //{
  10599. // cities.Add(cityInfo);
  10600. // //}
  10601. // }
  10602. // }
  10603. // }
  10604. // }
  10605. // else if (item1.lv == "city")//城市
  10606. // {
  10607. // provinceInfo.Level = 2;
  10608. // if (item1.c != null)
  10609. // {
  10610. // int cityId = 0;
  10611. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10612. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10613. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10614. // foreach (var item3 in item1.c)
  10615. // {
  10616. // if (item3.lv == "district")
  10617. // {
  10618. // var districtInfo = new Sys_Cities()
  10619. // {
  10620. // CountriesId = countriesId,
  10621. // Name_CN = item3.cn,
  10622. // Name_EN = item3.en,
  10623. // Level = 3,
  10624. // ParentId = cityId,
  10625. // IsCapital = 1,
  10626. // CreateUserId = 208,
  10627. // CreateTime = DateTime.Now,
  10628. // IsDel = 0
  10629. // };
  10630. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10631. // //{
  10632. // districts.Add(districtInfo);
  10633. // //}
  10634. // }
  10635. // }
  10636. // }
  10637. // else
  10638. // {
  10639. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10640. // //{
  10641. // cities.Add(provinceInfo);
  10642. // //}
  10643. // }
  10644. // }
  10645. // }
  10646. // }
  10647. // }
  10648. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10649. // cities = cities.Distinct().ToList();
  10650. // districts = districts.Distinct().ToList();
  10651. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10652. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10653. // cities.AddRange(districts);
  10654. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10655. // //_sqlSugar.RollbackTran();
  10656. // _sqlSugar.CommitTran();
  10657. // return Ok(JsonView(false, "操作成功!"));
  10658. //}
  10659. //[HttpPost]
  10660. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10661. //{
  10662. // List<CountitiesInfo> infos = dto.MyProperty;
  10663. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10664. // _sqlSugar.BeginTran();
  10665. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10666. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10667. // foreach (var item in infos)
  10668. // {
  10669. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10670. // if (countryInfo != null)
  10671. // {
  10672. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10673. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10674. // if (cityInfo1 != null)
  10675. // {
  10676. // cityInfo1.IsCapital = 0;
  10677. // cityInfos.Add(cityInfo1);
  10678. // }
  10679. // }
  10680. // }
  10681. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10682. // .UpdateColumns(it => it.IsCapital)
  10683. // .WhereColumns(it => it.Id)
  10684. // .ExecuteCommand();
  10685. // //_sqlSugar.RollbackTran();
  10686. // _sqlSugar.CommitTran();
  10687. // return Ok(JsonView(false, "操作成功!"));
  10688. //}
  10689. //public class CounrtiesDto
  10690. //{
  10691. // public List<CountitiesInfo> MyProperty { get; set; }
  10692. //}
  10693. //public class CountitiesInfo
  10694. //{
  10695. // /// <summary>
  10696. // /// 圣约翰
  10697. // /// </summary>
  10698. // public string capital_name_chinese { get; set; }
  10699. // /// <summary>
  10700. // ///
  10701. // /// </summary>
  10702. // public string capital_name { get; set; }
  10703. // /// <summary>
  10704. // ///
  10705. // /// </summary>
  10706. // public string country_type { get; set; }
  10707. // /// <summary>
  10708. // /// 安提瓜和巴布达
  10709. // /// </summary>
  10710. // public string country_name_chinese { get; set; }
  10711. // /// <summary>
  10712. // /// 安提瓜和巴布达
  10713. // /// </summary>
  10714. // public string country_name_chinese_short { get; set; }
  10715. // /// <summary>
  10716. // /// 安提瓜和巴布达
  10717. // /// </summary>
  10718. // public string country_name_chinese_UN { get; set; }
  10719. // /// <summary>
  10720. // ///
  10721. // /// </summary>
  10722. // public string country_name_english_abbreviation { get; set; }
  10723. // /// <summary>
  10724. // ///
  10725. // /// </summary>
  10726. // public string country_name_english_formal { get; set; }
  10727. // /// <summary>
  10728. // ///
  10729. // /// </summary>
  10730. // public string country_name_english_UN { get; set; }
  10731. // /// <summary>
  10732. // ///
  10733. // /// </summary>
  10734. // public string continent_name { get; set; }
  10735. // /// <summary>
  10736. // ///
  10737. // /// </summary>
  10738. // public string subregion_name { get; set; }
  10739. // /// <summary>
  10740. // ///
  10741. // /// </summary>
  10742. // public string country_code2 { get; set; }
  10743. // /// <summary>
  10744. // ///
  10745. // /// </summary>
  10746. // public string country_code3 { get; set; }
  10747. // /// <summary>
  10748. // ///
  10749. // /// </summary>
  10750. // public string phone_code { get; set; }
  10751. //}
  10752. //public class CountriesInfo : BasicInfo
  10753. //{
  10754. // public List<CitiesInfo> c { get; set; }
  10755. //}
  10756. //public class CitiesInfo : BasicInfo
  10757. //{
  10758. // public List<AreaInfo> c { get; set; }
  10759. //}
  10760. //public class AreaInfo : BasicInfo
  10761. //{
  10762. // public List<AreaInfo> c { get; set; }
  10763. //}
  10764. //public class BasicInfo
  10765. //{
  10766. // public string code { get; set; }
  10767. // public string cn { get; set; }
  10768. // public string lv { get; set; }
  10769. // public string en { get; set; }
  10770. //}
  10771. #endregion
  10772. #region 查看邀请方
  10773. /// <summary>
  10774. /// 查看邀请方
  10775. /// 邀请方信息 Init
  10776. /// </summary>
  10777. /// <param name="dto"></param>
  10778. /// <returns></returns>
  10779. [HttpPost]
  10780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10781. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10782. {
  10783. string sqlWhere = string.Empty;
  10784. if (!string.IsNullOrEmpty(dto.Search))
  10785. {
  10786. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10787. }
  10788. string sql = string.Format($@"Select
  10789. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10790. Id,
  10791. UnitName
  10792. From Res_InvitationOfficialActivityData
  10793. Where IsDel = 0
  10794. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10795. RefAsync<int> total = 0;
  10796. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10797. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10798. }
  10799. /// <summary>
  10800. /// 查看邀请方
  10801. /// 国家信息 Init
  10802. /// </summary>
  10803. /// <param name="dto"></param>
  10804. /// <returns></returns>
  10805. [HttpPost]
  10806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10807. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10808. {
  10809. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10810. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10811. var diids = groupInfos.Select(it => it.Id).ToList();
  10812. List<string> countrys = new List<string>();
  10813. foreach (var item in country)
  10814. {
  10815. var data = _groupRepository.FormartTeamName(item);
  10816. var dataArray = _groupRepository.GroupSplitCountry(data);
  10817. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10818. }
  10819. countrys = countrys.Distinct().ToList();
  10820. for (int i = 0; i < countrys.Count; i++)
  10821. {
  10822. string item = countrys[i];
  10823. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10824. {
  10825. countrys.Remove(item);
  10826. i--;
  10827. }
  10828. }
  10829. RefAsync<int> total = 0;
  10830. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10831. .Where(it => countrys.Contains(it.Name_CN))
  10832. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10833. .Select(it => new { id = it.Id, name = it.Name_CN })
  10834. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10835. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10836. }
  10837. /// <summary>
  10838. /// 查看邀请方
  10839. /// 城市信息 Init
  10840. /// </summary>
  10841. /// <param name="dto"></param>
  10842. /// <returns></returns>
  10843. [HttpPost]
  10844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10845. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10846. {
  10847. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10848. RefAsync<int> total = 0;
  10849. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10850. .Where(it => it.CountriesId == dto.CountiesId)
  10851. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10852. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10853. .Select(it => new { id = it.Id, name = it.Name_CN })
  10854. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10855. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10856. }
  10857. /// <summary>
  10858. /// 查看邀请方
  10859. /// 团组名称 Init
  10860. /// </summary>
  10861. /// <param name="dto"></param>
  10862. /// <returns></returns>
  10863. [HttpPost]
  10864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10865. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10866. {
  10867. var watch = new Stopwatch();
  10868. watch.Start();
  10869. RefAsync<int> total = 0;
  10870. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10871. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  10872. .Where((oa, di) => oa.IsDel == 0)
  10873. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10874. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10875. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10876. .Distinct()
  10877. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10878. watch.Stop();
  10879. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10880. }
  10881. /// <summary>
  10882. /// 查看邀请方
  10883. /// 团组 & 邀请方信息
  10884. /// </summary>
  10885. /// <param name="dto"></param>
  10886. /// <returns></returns>
  10887. [HttpPost]
  10888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10889. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10890. {
  10891. var watch = new Stopwatch();
  10892. watch.Start();
  10893. RefAsync<int> total = 0;
  10894. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10895. .AS("Grp_DelegationInfo")
  10896. .Includes(x => x.InvitingInfos)
  10897. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10898. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10899. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10900. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10901. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10902. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10903. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10904. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10905. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10906. infos.ForEach(x =>
  10907. {
  10908. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10909. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10910. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10911. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10912. });
  10913. watch.Stop();
  10914. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10915. }
  10916. #endregion
  10917. #region 报批行程
  10918. /// <summary>
  10919. /// 报批行程初始化
  10920. /// </summary>
  10921. /// <param name="dto"></param>
  10922. /// <returns></returns>
  10923. [HttpPost]
  10924. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10925. {
  10926. const int chiNumber = 5;
  10927. var jw = JsonView(false);
  10928. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10929. var group = groupList.First();
  10930. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10931. group = groupList.First(x => x.Id == diid);
  10932. if (group == null)
  10933. {
  10934. jw.Msg = "暂无团组!";
  10935. return Ok(jw);
  10936. }
  10937. var data = new
  10938. {
  10939. groupList = groupList.Select(x => new
  10940. {
  10941. x.TeamName,
  10942. x.Id
  10943. }),
  10944. content = new ArrayList(),
  10945. groupInfo = new
  10946. {
  10947. group.VisitDays,
  10948. group.TourCode,
  10949. group.VisitPNumber,
  10950. group.TeamName,
  10951. group.Id,
  10952. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10953. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10954. },
  10955. };
  10956. var resultArr = new ArrayList();
  10957. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10958. if (content.Count == 0)
  10959. {
  10960. var stay = "-";
  10961. var cityPath = "-";
  10962. //添加城市路径以及住宿地
  10963. //黑屏代码数据
  10964. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10965. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10966. {
  10967. jw = JsonView(true, "黑屏代码有误!", data);
  10968. return Ok(jw);
  10969. }
  10970. foreach (DataRow row in dtBlack.Rows)
  10971. {
  10972. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10973. {
  10974. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10975. return Ok(jw);
  10976. }
  10977. }
  10978. //黑屏代码获取时间区间
  10979. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10980. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10981. _sqlSugar.BeginTran();
  10982. for (int i = 0; i < timeArr.Count; i++)
  10983. {
  10984. stay = "-";
  10985. cityPath = "-";
  10986. DateTime NewData = DateTime.Parse(timeArr[i]);
  10987. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10988. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10989. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10990. if (tbSelect.Length > 0)
  10991. {
  10992. List<string> threeCodeStr = new List<string>();
  10993. foreach (var item in tbSelect)
  10994. {
  10995. var threeCode = item["Three"].ToString() ?? "";
  10996. if (threeCode.Length == 6)
  10997. {
  10998. var start = threeCode.Substring(0, 3);
  10999. var end = threeCode.Substring(3, 3);
  11000. if (threeCodeStr.Count == 0)
  11001. {
  11002. threeCodeStr.Add(start);
  11003. threeCodeStr.Add(end);
  11004. }
  11005. else
  11006. {
  11007. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11008. {
  11009. threeCodeStr.Add(end);
  11010. }
  11011. else
  11012. {
  11013. threeCodeStr.Add(start);
  11014. threeCodeStr.Add(end);
  11015. }
  11016. }
  11017. }
  11018. }
  11019. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11020. var last = threeCodeStr.Last();
  11021. foreach (var item in threeCodeStr)
  11022. {
  11023. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11024. if (item.Equals(last))
  11025. {
  11026. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11027. }
  11028. }
  11029. cityPath = cityPath.Trim('-');
  11030. }
  11031. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11032. appro.Diid = diid ?? -1;
  11033. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11034. appro.Id = thisId;
  11035. appro.CreateUserId = dto.UserId;
  11036. appro.CreateTime = DateTime.Now;
  11037. content.Add(appro);
  11038. }
  11039. _sqlSugar.CommitTran();
  11040. }
  11041. foreach (var x in content)
  11042. {
  11043. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11044. if (chiList.Count < chiNumber)
  11045. {
  11046. for (int i = chiList.Count; i < chiNumber; i++)
  11047. {
  11048. chiList.Add(new Grp_ApprovalTravelDetails());
  11049. }
  11050. }
  11051. resultArr.Add(new
  11052. {
  11053. x.Id,
  11054. x.Date,
  11055. x.Diid,
  11056. chiList = chiList.Select(x1 => new
  11057. {
  11058. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11059. x1.Details,
  11060. x1.ParentId,
  11061. x1.Id
  11062. })
  11063. });
  11064. }
  11065. data = data with
  11066. {
  11067. content = resultArr,
  11068. };
  11069. jw = JsonView(true, "获取成功!", data);
  11070. return Ok(jw);
  11071. }
  11072. /// <summary>
  11073. /// 报批行程删除
  11074. /// </summary>
  11075. /// <param name="dto"></param>
  11076. /// <returns></returns>
  11077. [HttpPost]
  11078. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11079. {
  11080. var jw = JsonView(false);
  11081. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11082. if (group == null)
  11083. {
  11084. jw.Msg = "团组参数有误!";
  11085. return Ok(jw);
  11086. }
  11087. try
  11088. {
  11089. _sqlSugar.BeginTran();
  11090. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  11091. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11092. {
  11093. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11094. DeleteUserId = dto.uesrId,
  11095. IsDel = 1
  11096. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11097. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11098. {
  11099. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11100. DeleteUserId = dto.uesrId,
  11101. IsDel = 1
  11102. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11103. _sqlSugar.CommitTran();
  11104. jw = JsonView(true, "删除成功");
  11105. }
  11106. catch (Exception ex)
  11107. {
  11108. jw = JsonView(false, ex.Message);
  11109. }
  11110. return Ok(jw);
  11111. }
  11112. /// <summary>
  11113. /// 报批行程保存
  11114. /// </summary>
  11115. /// <param name="dto"></param>
  11116. /// <returns></returns>
  11117. [HttpPost]
  11118. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11119. {
  11120. var jw = JsonView(false);
  11121. var Find = dto.Arr.Find(x => x.id == 0);
  11122. if (Find != null)
  11123. {
  11124. jw.Msg = "生成的ID为0!";
  11125. return Ok(jw);
  11126. }
  11127. foreach (var item in dto.Arr)
  11128. {
  11129. foreach (var chi in item.chiList)
  11130. {
  11131. if (chi.parentId == 0)
  11132. {
  11133. chi.parentId = item.id;
  11134. }
  11135. }
  11136. }
  11137. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11138. _sqlSugar.BeginTran();
  11139. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  11140. {
  11141. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11142. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  11143. {
  11144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11145. DeleteUserId = dto.UserId,
  11146. IsDel = 1
  11147. }).ExecuteCommand();
  11148. }
  11149. try
  11150. {
  11151. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11152. {
  11153. CreateTime = DateTime.Now,
  11154. CreateUserId = dto.UserId,
  11155. Details = x.details,
  11156. ParentId = x.parentId,
  11157. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11158. Remark = "",
  11159. IsDel = 0
  11160. }).ToList()).ExecuteCommand();
  11161. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11162. {
  11163. Id = x.id,
  11164. Details = x.details,
  11165. ParentId = x.parentId,
  11166. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11167. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11168. {
  11169. Details = x.Details,
  11170. ParentId = x.ParentId,
  11171. Time = x.Time
  11172. }).ExecuteCommand();
  11173. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11174. {
  11175. Id = x.id,
  11176. Date = x.date,
  11177. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11178. {
  11179. Date = x.Date
  11180. }).ExecuteCommand();
  11181. _sqlSugar.CommitTran();
  11182. jw = JsonView(true, "保存成功!");
  11183. }
  11184. catch (Exception ex)
  11185. {
  11186. _sqlSugar.RollbackTran();
  11187. jw = JsonView(false, "保存失败!" + ex.Message);
  11188. }
  11189. return Ok(jw);
  11190. }
  11191. /// <summary>
  11192. /// 报批行程生成
  11193. /// </summary>
  11194. /// <param name="dto"></param>
  11195. /// <returns></returns>
  11196. [HttpPost]
  11197. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11198. {
  11199. var jw = JsonView(false);
  11200. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11201. if (group == null)
  11202. {
  11203. jw.Msg = "暂无该团组!";
  11204. return Ok(jw);
  11205. }
  11206. //黑屏代码数据
  11207. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11208. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11209. {
  11210. jw.Msg = "黑屏代码有误!";
  11211. return Ok(jw);
  11212. }
  11213. foreach (DataRow row in dtBlack.Rows)
  11214. {
  11215. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11216. {
  11217. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11218. return Ok(jw);
  11219. }
  11220. }
  11221. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11222. var resultArr = new ArrayList();
  11223. if (officialActivitiesArr.Count == 0)
  11224. {
  11225. jw.Msg = "暂无公务出访信息!";
  11226. return Ok(jw);
  11227. }
  11228. try
  11229. {
  11230. _sqlSugar.BeginTran();
  11231. DeleteApprovalJourney(new
  11232. Domain.Dtos.Groups.DeleteApprovalJourney
  11233. {
  11234. Diid = dto.Diid,
  11235. uesrId = dto.Userid
  11236. });
  11237. var stay = "-";
  11238. var cityPath = "-";
  11239. //添加城市路径以及住宿地
  11240. //黑屏代码获取时间区间
  11241. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11242. var empty = "【未收入该三字码!请机票同事录入】";
  11243. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11244. for (int i = 0; i < timeArr.Count; i++)
  11245. {
  11246. stay = "-";
  11247. cityPath = "-";
  11248. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11249. DateTime NewData = DateTime.Parse(timeArr[i]);
  11250. 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();
  11251. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11252. if (tbSelect.Length > 0)
  11253. {
  11254. List<string> threeCodeStr = new List<string>();
  11255. bool isTrade = false;
  11256. string trip = string.Empty;
  11257. var rowLast = tbSelect.Last();
  11258. var rowFirst = tbSelect.First();
  11259. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11260. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11261. var takeOffTime = DateTime.Parse(timeArr[i]);
  11262. var fallToTime = DateTime.Parse(timeArr[i]);
  11263. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11264. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11265. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11266. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11267. foreach (var item in tbSelect)
  11268. {
  11269. var start = string.Empty;
  11270. var end = string.Empty;
  11271. var threeCode = item["Three"].ToString() ?? "";
  11272. if (threeCode.Length == 6)
  11273. {
  11274. start = threeCode.Substring(0, 3);
  11275. end = threeCode.Substring(3, 3);
  11276. if (threeCodeStr.Count == 0)
  11277. {
  11278. threeCodeStr.Add(start);
  11279. threeCodeStr.Add(end);
  11280. }
  11281. else
  11282. {
  11283. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11284. {
  11285. threeCodeStr.Add(end);
  11286. }
  11287. else
  11288. {
  11289. threeCodeStr.Add(start);
  11290. threeCodeStr.Add(end);
  11291. }
  11292. }
  11293. }
  11294. //处理机票信息
  11295. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11296. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11297. if (start_Object == null)
  11298. {
  11299. start_Object = new Res_ThreeCode()
  11300. {
  11301. AirPort = empty,
  11302. AirPort_En = empty,
  11303. City = empty,
  11304. Country = empty,
  11305. Four = empty,
  11306. Three = empty,
  11307. };
  11308. }
  11309. if (end_Object == null)
  11310. {
  11311. end_Object = new Res_ThreeCode()
  11312. {
  11313. AirPort = empty,
  11314. AirPort_En = empty,
  11315. City = empty,
  11316. Country = empty,
  11317. Four = empty,
  11318. Three = empty,
  11319. };
  11320. }
  11321. //机型判断
  11322. string airModel = item["AirModel"].ToString();
  11323. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11324. string flightTime = item["FlightTime"].ToString();
  11325. if (flightTime!.Contains(":"))
  11326. {
  11327. flightTime = flightTime.Replace(":", "小时");
  11328. flightTime += "分钟";
  11329. }
  11330. if (flightTime.Contains("H"))
  11331. {
  11332. flightTime = flightTime.Replace("H", "小时");
  11333. }
  11334. if (flightTime.Contains("M"))
  11335. {
  11336. flightTime = flightTime.Replace("M", "分钟");
  11337. }
  11338. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11339. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11340. {
  11341. flightTime = flightDataTime.Hour > 0
  11342. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11343. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11344. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11345. }
  11346. //航班号
  11347. string flightcode = item["Fliagtcode"].ToString();
  11348. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11349. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11350. if (aircompany == null)
  11351. {
  11352. aircompany = new Res_AirCompany
  11353. {
  11354. CnName = hsEmpty,
  11355. EnName = hsEmpty,
  11356. ShortCode = hsEmpty,
  11357. };
  11358. }
  11359. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11360. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11361. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11362. if (isTrade)
  11363. {
  11364. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11365. }
  11366. else
  11367. {
  11368. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11369. }
  11370. }
  11371. chiarr.Add(new Grp_ApprovalTravelDetails
  11372. {
  11373. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11374. CreateTime = DateTime.Now,
  11375. CreateUserId = dto.Userid,
  11376. ParentId = 0,
  11377. Details = trip
  11378. });
  11379. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11380. var last = threeCodeStr.Last();
  11381. foreach (var item in threeCodeStr)
  11382. {
  11383. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11384. if (item.Equals(last))
  11385. {
  11386. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11387. }
  11388. }
  11389. cityPath = cityPath.Trim('-');
  11390. }
  11391. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11392. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11393. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11394. appro.Diid = dto.Diid;
  11395. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11396. appro.Id = thisId;
  11397. appro.CreateUserId = dto.Userid;
  11398. appro.CreateTime = DateTime.Now;
  11399. foreach (var item in gwinfo)
  11400. {
  11401. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11402. chi.Details = "拜访" + item.Client;
  11403. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11404. {
  11405. chi.Details += "," + item.ReqSample;
  11406. }
  11407. chi.ParentId = thisId;
  11408. chi.Time = item.Time;
  11409. chiarr.Add(chi);
  11410. }
  11411. if (chiarr.Count < 5)
  11412. {
  11413. for (int j = chiarr.Count; j < 5; j++)
  11414. {
  11415. chiarr.Add(new
  11416. Grp_ApprovalTravelDetails());
  11417. }
  11418. }
  11419. resultArr.Add(new
  11420. {
  11421. appro.Id,
  11422. appro.Date,
  11423. appro.Diid,
  11424. chiList = chiarr.Select(x1 => new
  11425. {
  11426. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11427. x1.Details,
  11428. x1.ParentId,
  11429. x1.Id
  11430. })
  11431. });
  11432. }
  11433. _sqlSugar.CommitTran();
  11434. jw = JsonView(true, "生成成功!", resultArr);
  11435. }
  11436. catch (Exception ex)
  11437. {
  11438. jw.Code = 400;
  11439. jw.Msg = "生成失败!" + ex.Message;
  11440. }
  11441. return Ok(jw);
  11442. }
  11443. /// <summary>
  11444. /// 报批行程word导出
  11445. /// </summary>
  11446. /// <param name="dto"></param>
  11447. /// <returns></returns>
  11448. [HttpPost]
  11449. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11450. {
  11451. var jw = JsonView(false);
  11452. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11453. if (group == null)
  11454. {
  11455. jw.Msg = "暂无该团组!";
  11456. return Ok(jw);
  11457. }
  11458. //模板路径
  11459. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  11460. //载入模板
  11461. Document doc = new Document(tempPath);
  11462. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11463. //获取所填表格的序数
  11464. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11465. Aspose.Words.Tables.Row titleRowClone = null;
  11466. Aspose.Words.Tables.Row CenterRowClone = null;
  11467. int index = 0;
  11468. int indexChi = 0;
  11469. int SetIndex = 0;
  11470. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11471. //获取数据,放到datatable
  11472. foreach (var item in ApprovalTravelArr)
  11473. {
  11474. if (index > 0)
  11475. {
  11476. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11477. tableOne.AppendChild(titleRowClone);
  11478. }
  11479. var textTime = item.Date;
  11480. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11481. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11482. SetIndex++;
  11483. if (ChiRep.Count > 0)
  11484. {
  11485. foreach (var itemChi in ChiRep)
  11486. {
  11487. var txtTime = itemChi.Time;
  11488. var txtDetail = itemChi.Details;
  11489. if (indexChi > 0)
  11490. {
  11491. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11492. tableOne.AppendChild(CenterRowClone);
  11493. }
  11494. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11495. {
  11496. SetCells(tableOne, doc, SetIndex, 0, "");
  11497. SetCells(tableOne, doc, SetIndex, 1, "");
  11498. indexChi++;
  11499. SetIndex++;
  11500. break;
  11501. }
  11502. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11503. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11504. indexChi++;
  11505. SetIndex++;
  11506. }
  11507. }
  11508. else
  11509. {
  11510. if (indexChi > 0)
  11511. {
  11512. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11513. tableOne.AppendChild(CenterRowClone);
  11514. }
  11515. SetCells(tableOne, doc, SetIndex, 0, "");
  11516. SetCells(tableOne, doc, SetIndex, 1, "");
  11517. indexChi++;
  11518. SetIndex++;
  11519. }
  11520. index++;
  11521. }
  11522. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11523. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11524. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11525. jw.Code = 200;
  11526. jw.Msg = "";
  11527. return Ok(jw);
  11528. }
  11529. private string intToString(int numberVal)
  11530. {
  11531. string numberval = numberVal.ToString();
  11532. Dictionary<char, string> Number = new Dictionary<char, string>();
  11533. Number.Add('1', "一");
  11534. Number.Add('2', "二");
  11535. Number.Add('3', "三");
  11536. Number.Add('4', "四");
  11537. Number.Add('5', "五");
  11538. Number.Add('6', "六");
  11539. Number.Add('7', "七");
  11540. Number.Add('8', "八");
  11541. Number.Add('9', "九");
  11542. string stringNumberVal = string.Empty;
  11543. for (int i = 0; i < numberval.Length; i++)
  11544. {
  11545. if (i == 0)
  11546. {
  11547. stringNumberVal += Number[numberval[i]];
  11548. }
  11549. else if (i >= 1)
  11550. {
  11551. if (numberval[i] == '0')
  11552. {
  11553. stringNumberVal = "十";
  11554. }
  11555. else
  11556. {
  11557. stringNumberVal += "十" + Number[numberval[i]];
  11558. }
  11559. }
  11560. }
  11561. return stringNumberVal;
  11562. }
  11563. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11564. {
  11565. //获取table中的某个单元格,从0开始
  11566. Cell lshCell = table.Rows[rows].Cells[cells];
  11567. //将单元格中段落移除
  11568. foreach (Node item in lshCell.Paragraphs)
  11569. {
  11570. lshCell.Paragraphs.Remove(item);
  11571. }
  11572. if (val.Contains("\r\n"))
  11573. {
  11574. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  11575. foreach (var item in spArr)
  11576. {
  11577. //新建一个段落
  11578. Paragraph p = new Paragraph(doc);
  11579. var r = new Run(doc, item);
  11580. //把设置的值赋给之前新建的段落
  11581. p.AppendChild(r);
  11582. //将此段落加到单元格内
  11583. lshCell.AppendChild(p);
  11584. }
  11585. }
  11586. else
  11587. {
  11588. //新建一个段落
  11589. Paragraph p = new Paragraph(doc);
  11590. var r = new Run(doc, val);
  11591. //把设置的值赋给之前新建的段落
  11592. p.AppendChild(r);
  11593. //将此段落加到单元格内
  11594. lshCell.AppendChild(p);
  11595. }
  11596. }
  11597. [HttpPost]
  11598. public async Task<IActionResult> ServerHttp(string paramStr)
  11599. {
  11600. paramStr = paramStr.TrimEnd('\'');
  11601. paramStr = paramStr.TrimStart('\'');
  11602. JsonView jw = JsonView(false);
  11603. JObject param = JObject.Parse(paramStr);
  11604. if (!param.ContainsKey("url"))
  11605. {
  11606. jw.Msg = "url null";
  11607. return Ok(jw);
  11608. }
  11609. string url = param["url"]!.ToString();
  11610. var methon = "get";
  11611. Dictionary<string, string> bodyValues = null;
  11612. Dictionary<string, string> headValues = null;
  11613. if (param.ContainsKey("methon"))
  11614. {
  11615. methon = param["methon"]!.ToString();
  11616. }
  11617. if (param.ContainsKey("header"))
  11618. {
  11619. var header = param["header"]!.ToString();
  11620. JObject headerJobject = JObject.Parse(header);
  11621. headValues = new Dictionary<string, string>();
  11622. foreach (JProperty item in headerJobject.Properties())
  11623. {
  11624. var value = item.Value.ToString();
  11625. var head = item.Path;
  11626. headValues.Add(head, value);
  11627. }
  11628. }
  11629. if (param.ContainsKey("body"))
  11630. {
  11631. var body = param["body"]!.ToString();
  11632. bodyValues = new Dictionary<string, string>();
  11633. JObject bodyJobject = JObject.Parse(body);
  11634. foreach (JProperty item in bodyJobject.Properties())
  11635. {
  11636. var value = item.Value.ToString();
  11637. var head = item.Path;
  11638. bodyValues.Add(head, value);
  11639. }
  11640. }
  11641. HttpClient client = new HttpClient();
  11642. string responseString = string.Empty;
  11643. if (param.ContainsKey("isJson"))
  11644. {
  11645. }
  11646. if (headValues != null)
  11647. {
  11648. foreach (var item in headValues.Keys)
  11649. {
  11650. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11651. }
  11652. }
  11653. try
  11654. {
  11655. if (methon == "get")
  11656. {
  11657. responseString = await client.GetStringAsync(url);
  11658. }
  11659. else if (methon == "post")
  11660. {
  11661. if (bodyValues == null)
  11662. {
  11663. jw.Msg = "methon post body null";
  11664. return Ok(jw);
  11665. }
  11666. // 数据转化为 key=val 格式
  11667. var content = new FormUrlEncodedContent(bodyValues);
  11668. var response = await client.PostAsync(url, content);
  11669. // 获取数据
  11670. responseString = await response.Content.ReadAsStringAsync();
  11671. }
  11672. else
  11673. {
  11674. jw.Msg = "methon error";
  11675. }
  11676. jw = JsonView(true, "success", responseString);
  11677. }
  11678. catch (Exception ex)
  11679. {
  11680. jw.Msg = "error " + ex.Message;
  11681. jw.Data = ex.StackTrace;
  11682. }
  11683. finally
  11684. {
  11685. client.Dispose();
  11686. }
  11687. return Ok(jw);
  11688. }
  11689. #endregion
  11690. // /// <summary>
  11691. // ///
  11692. // /// </summary>
  11693. // /// <param name="_dto"></param>
  11694. // /// <returns></returns>
  11695. // [HttpPost]
  11696. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11697. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11698. // {
  11699. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11700. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11701. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11702. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11703. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11704. // dic_psg.Add("客人", 974);
  11705. // dic_psg.Add("司机", 975);
  11706. // dic_psg.Add("导游", 976);
  11707. // dic_psg.Add("公司内部人员", 977);
  11708. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11709. // foreach (var item in list_visa)
  11710. // {
  11711. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11712. // temp.Id = item.Id;
  11713. // temp.DIId = item.DIId;
  11714. // temp.VisaClient = item.VisaClient;
  11715. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11716. // temp.VisaCurrency = item.VisaCurrency;
  11717. // temp.IsThird = item.IsThird;
  11718. // if (dic_psg.ContainsKey(item.PassengerType))
  11719. // {
  11720. // temp.PassengerType = dic_psg[item.PassengerType];
  11721. // }
  11722. // else {
  11723. // temp.PassengerType = -1;
  11724. // }
  11725. // temp.VisaNumber = item.VisaNumber;
  11726. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11727. // temp.CreateUserId = item.Operators;
  11728. // DateTime dt_ct;
  11729. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11730. // if (b_ct)
  11731. // {
  11732. // temp.CreateTime = dt_ct;
  11733. // }
  11734. // else
  11735. // {
  11736. // temp.CreateTime = DateTime.Now;
  11737. // }
  11738. // temp.DeleteTime = "";
  11739. // temp.DeleteUserId = 0;
  11740. // temp.Remark = item.Remark;
  11741. // if (string.IsNullOrEmpty(temp.Remark)) {
  11742. // temp.Remark = "";
  11743. // }
  11744. // temp.IsDel = item.IsDel;
  11745. // temp.VisaDescription = item.VisaAttachment;
  11746. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11747. //([Id]
  11748. // ,[DIId]
  11749. // ,[VisaClient]
  11750. // ,[VisaPrice]
  11751. // ,[VisaCurrency]
  11752. // ,[IsThird]
  11753. // ,[PassengerType]
  11754. // ,[VisaNumber]
  11755. // ,[VisaFreeNumber]
  11756. // ,[CreateUserId]
  11757. // ,[CreateTime]
  11758. // ,[DeleteTime]
  11759. // ,[DeleteUserId]
  11760. // ,[Remark]
  11761. // ,[IsDel]
  11762. // ,[visaDescription])
  11763. // VALUES
  11764. // ({0},{1},'{2}',{3},{4}
  11765. //,{5},{6},{7},{8},{9}
  11766. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11767. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11768. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11769. //);
  11770. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11771. // }
  11772. // return Ok(JsonView(true, "操作成功!"));
  11773. // }
  11774. /// <summary>
  11775. /// 123132123
  11776. /// </summary>
  11777. /// <param name="_dto"></param>
  11778. /// <returns></returns>
  11779. [HttpPost]
  11780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11781. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11782. {
  11783. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11784. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11785. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11786. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11787. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11788. dicDetail.Add(789, 1034);
  11789. dicDetail.Add(790, 1035);
  11790. dicDetail.Add(791, 1036);
  11791. dicDetail.Add(792, 1037);
  11792. dicDetail.Add(793, 1038);
  11793. dicDetail.Add(794, 1039);
  11794. dicDetail.Add(795, 1040);
  11795. dicDetail.Add(796, 1041);
  11796. dicDetail.Add(797, 1042);
  11797. dicDetail.Add(798, 1043);
  11798. dicDetail.Add(801, 1044);
  11799. dicDetail.Add(802, 1045);
  11800. dicDetail.Add(803, 1046);
  11801. Dictionary<int, int> dic = new Dictionary<int, int>();
  11802. dic.Add(806, 1027);
  11803. dic.Add(807, 1028);
  11804. dic.Add(808, 1029);
  11805. dic.Add(809, 1030);
  11806. dic.Add(810, 1031);
  11807. dic.Add(811, 1032);
  11808. dic.Add(812, 1033);
  11809. foreach (var item in list_visa)
  11810. {
  11811. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11812. temp.Coefficient = item.coefficient;
  11813. DateTime dtCrt;
  11814. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11815. if (b1)
  11816. {
  11817. temp.CreateTime = dtCrt;
  11818. }
  11819. else
  11820. {
  11821. temp.CreateTime = DateTime.Now;
  11822. }
  11823. temp.CreateUserId = item.Operators;
  11824. temp.DeleteTime = "";
  11825. temp.DeleteUserId = 0;
  11826. temp.DiId = int.Parse(item.DIID);
  11827. temp.FilePath = item.FilePath;
  11828. temp.IsDel = item.IsDel;
  11829. temp.Price = item.Price;
  11830. temp.PriceCount = 1;
  11831. temp.PriceCurrency = item.Currency;
  11832. int detailId = 0;
  11833. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11834. {
  11835. detailId = dicDetail[item.PriceTypeDetail];
  11836. }
  11837. temp.PriceDetailType = detailId;
  11838. temp.PriceDt = DateTime.Now;
  11839. temp.PriceName = item.PriceName;
  11840. temp.PriceSum = item.Price;
  11841. int tid = 0;
  11842. if (dic.ContainsKey(item.PriceType))
  11843. {
  11844. tid = dic[item.PriceType];
  11845. }
  11846. temp.PriceType = tid;
  11847. temp.Remark = item.Remark;
  11848. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11849. }
  11850. return Ok(JsonView(true, "操作成功!"));
  11851. }
  11852. }
  11853. }