GroupsController.cs 615 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484
  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. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly ThreeCodeRepository _threeCodeRepository;
  135. private readonly HotelInquiryRepository _hotelInquiryRep;
  136. private readonly FeeAuditRepository _feeAuditRep;
  137. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  138. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  139. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  140. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  141. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  142. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  143. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  144. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  145. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  146. {
  147. _mapper = mapper;
  148. _grpScheduleRep = grpScheduleRep;
  149. _groupRepository = groupRepository;
  150. _taskAssignmentRep = taskAssignmentRep;
  151. _airTicketResRep = airTicketResRep;
  152. _sqlSugar = sqlSugar;
  153. url = AppSettingsHelper.Get("ExcelBaseUrl");
  154. path = AppSettingsHelper.Get("ExcelBasePath");
  155. if (!System.IO.Directory.Exists(path))
  156. {
  157. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  158. }
  159. _decreasePaymentsRep = decreasePaymentsRep;
  160. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  161. _delegationEnDataRep = delegationEnDataRep;
  162. _enterExitCostRep = enterExitCostRep;
  163. _delegationVisaRep = delegationVisaRep;
  164. _message = message;
  165. _visaPriceRep = visaPriceRep;
  166. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  167. _checkBoxs = checkBoxs;
  168. _GroupCostRepository = GroupCostRepository;
  169. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  170. _GroupCostParameterRepository = GroupCostParameterRepository;
  171. _hotelPriceRep = hotelPriceRep;
  172. _customersRep = customersRep;
  173. _setDataRep = setDataRep;
  174. _tourClientListRep = tourClientListRep;
  175. _teamRateRep = teamRateRep;
  176. _hubContext = hubContext;
  177. _usersRep = usersRep;
  178. _juHeApi = juHeApi;
  179. _invertedListRep = invertedListRep;
  180. _visaFeeInfoRep = visaFeeInfoRep;
  181. _ticketBlackCodeRep = ticketBlackCodeRep;
  182. _hotelInquiryRep = hotelInquiryRep;
  183. _threeCodeRepository = threeCodeRepository;
  184. _feeAuditRep = feeAuditRep;
  185. }
  186. #region 流程管控
  187. /// <summary>
  188. /// 获取团组流程管控信息
  189. /// </summary>
  190. /// <param name="paras">参数Json字符串</param>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  195. {
  196. if (string.IsNullOrEmpty(_jsonDto.Paras))
  197. {
  198. return Ok(JsonView(false, "参数为空"));
  199. }
  200. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  201. if (_ScheduleDto != null)
  202. {
  203. if (_ScheduleDto.SearchType == 2)//获取列表
  204. {
  205. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  206. return Ok(JsonView(_grpScheduleViewList));
  207. }
  208. else//获取对象
  209. {
  210. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  211. if (_grpScheduleView != null)
  212. {
  213. return Ok(JsonView(_grpScheduleView));
  214. }
  215. }
  216. }
  217. else
  218. {
  219. return Ok(JsonView(false, "参数反序列化失败"));
  220. }
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. /// <summary>
  224. /// 修改团组流程管控详细表数据
  225. /// </summary>
  226. /// <param name="paras"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  230. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  231. {
  232. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  233. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  234. .SetColumns(it => it.Duty == _detail.Duty)
  235. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  236. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  237. .SetColumns(it => it.JobContent == _detail.JobContent)
  238. .SetColumns(it => it.Remark == _detail.Remark)
  239. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  240. .Where(s => s.Id == dto.Id)
  241. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  242. .ExecuteCommandAsync();
  243. if (result > 0)
  244. {
  245. return Ok(JsonView(true, "保存成功!"));
  246. }
  247. return Ok(JsonView(false, "保存失败!"));
  248. }
  249. /// <summary>
  250. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  257. {
  258. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  259. _detail.IsDel = 1;
  260. _detail.DeleteUserId = dto.Duty;
  261. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  262. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  263. .SetColumns(it => it.IsDel == _detail.IsDel)
  264. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  265. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  266. .Where(it => it.Id == dto.Id)
  267. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  268. //.WhereColumns(s => s.Id == dto.Id)
  269. .ExecuteCommandAsync();
  270. if (result > 0)
  271. {
  272. return Ok(JsonView(true, "删除成功!"));
  273. }
  274. return Ok(JsonView(false, "删除失败!"));
  275. }
  276. /// <summary>
  277. /// 增加团组流程管控详细表数据
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  284. {
  285. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  286. if (DateTime.Now < _detail.ExpectBeginDt)
  287. {
  288. _detail.StepStatus = 0;
  289. }
  290. else
  291. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  292. _detail.StepStatus = 1;
  293. }
  294. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  295. if (result > 0)
  296. {
  297. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  298. return Ok(JsonView(true, "添加成功!", _result));
  299. }
  300. return Ok(JsonView(false, "添加失败!"));
  301. }
  302. #endregion
  303. #region 团组基本信息
  304. /// <summary>
  305. /// 接团信息列表
  306. /// </summary>
  307. /// <param name="dto">团组列表请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupList(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 接团信息列表 Page
  322. /// </summary>
  323. /// <param name="dto">团组列表请求dto</param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  328. {
  329. #region 参数验证
  330. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  331. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  333. #region 页面操作权限验证
  334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  335. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  336. #endregion
  337. #endregion
  338. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  339. {
  340. string sqlWhere = string.Empty;
  341. if (dto.IsSure == 0) //未完成
  342. {
  343. sqlWhere += string.Format(@" And IsSure = 0");
  344. }
  345. else if (dto.IsSure == 1) //已完成
  346. {
  347. sqlWhere += string.Format(@" And IsSure = 1");
  348. }
  349. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  350. {
  351. string tj = dto.SearchCriteria;
  352. 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}%')",
  353. tj, tj, tj, tj, tj);
  354. }
  355. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  356. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  358. JietuanOperator,IsSure,CreateTime
  359. From (
  360. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  361. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  362. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  363. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  364. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  365. From Grp_DelegationInfo gdi
  366. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  367. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  368. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  369. Where gdi.IsDel = 0 {0}
  370. ) temp", sqlWhere);
  371. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  372. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  373. #region 处理所属部门
  374. /*
  375. * 1.sq 和 gyy 等显示 市场部
  376. * 2.王鸽和主管及张总还有管理员号统一国交部
  377. * 2-1. 4 管理员 ,21 张海麟
  378. */
  379. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  380. List<int> userIds1 = new List<int>() { 4, 21 };
  381. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  382. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  383. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  384. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  385. .ToList();
  386. foreach (var item in _DelegationList)
  387. {
  388. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  389. }
  390. #endregion
  391. var _view = new
  392. {
  393. PageFuncAuth = pageFunAuthView,
  394. Data = _DelegationList
  395. };
  396. return Ok(JsonView(true, "查询成功!", _view, total));
  397. }
  398. else
  399. {
  400. return Ok(JsonView(false, "查询失败"));
  401. }
  402. }
  403. /// <summary>
  404. /// 团组列表
  405. /// </summary>
  406. /// <returns></returns>
  407. [HttpPost]
  408. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  409. {
  410. #region 参数验证
  411. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  412. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  413. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  414. #region 页面操作权限验证
  415. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  416. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  417. #endregion
  418. #endregion
  419. if (dto.PortType != 1 && dto.PortType != 2)
  420. {
  421. return Ok(JsonView(false, "查询失败!"));
  422. }
  423. string orderbyStr = "order by gdi.CreateTime Desc";
  424. string sqlWhere = string.Empty;
  425. if (dto.IsSure == 0) //未完成
  426. {
  427. sqlWhere += string.Format(@" And IsSure = 0");
  428. }
  429. else if (dto.IsSure == 1) //已完成
  430. {
  431. sqlWhere += string.Format(@" And IsSure = 1");
  432. }
  433. //团组类型
  434. if (dto.TeamDid > 0)
  435. {
  436. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  437. }
  438. //团组名称
  439. if (!string.IsNullOrEmpty(dto.TeamName))
  440. {
  441. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  442. }
  443. //客户名称
  444. if (!string.IsNullOrEmpty(dto.ClientName))
  445. {
  446. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  447. }
  448. //客户单位
  449. if (!string.IsNullOrEmpty(dto.ClientUnit))
  450. {
  451. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  452. }
  453. //出访时间
  454. if (!string.IsNullOrEmpty(dto.visitDataTime))
  455. {
  456. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  457. orderbyStr = "order by gdi.VisitDate";
  458. }
  459. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  460. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  462. JietuanOperator,IsSure,CreateTime
  463. From (
  464. Select row_number() over({0}) as Row_Number,
  465. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  466. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  467. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  468. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  469. From Grp_DelegationInfo gdi
  470. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  471. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  472. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  473. Where gdi.IsDel = 0 {1}
  474. ) temp ", orderbyStr, sqlWhere);
  475. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  476. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  477. #region 处理所属部门
  478. /*
  479. * 1.sq 和 gyy 等显示 市场部
  480. * 2.王鸽和主管及张总还有管理员号统一国交部
  481. * 2-1. 4 管理员 ,21 张海麟
  482. */
  483. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  484. List<int> userIds1 = new List<int>() { 4, 21 };
  485. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  486. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  487. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  488. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  489. .ToList();
  490. foreach (var item in _DelegationList)
  491. {
  492. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  493. }
  494. #endregion
  495. var _view = new
  496. {
  497. PageFuncAuth = pageFunAuthView,
  498. Data = _DelegationList
  499. };
  500. return Ok(JsonView(true, "查询成功!", _view, total));
  501. }
  502. /// <summary>
  503. /// 接团信息详情
  504. /// </summary>
  505. /// <param name="dto">团组info请求dto</param>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  510. {
  511. var groupData = await _groupRepository.GetGroupInfo(dto);
  512. if (groupData.Code != 0)
  513. {
  514. return Ok(JsonView(false, groupData.Msg));
  515. }
  516. return Ok(JsonView(groupData.Data));
  517. }
  518. /// <summary>
  519. /// 接团信息 编辑添加
  520. /// 基础信息数据源
  521. /// </summary>
  522. /// <param name="dto"></param>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  527. {
  528. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  529. if (groupData.Code != 0)
  530. {
  531. return Ok(JsonView(false, groupData.Msg));
  532. }
  533. return Ok(JsonView(groupData.Data));
  534. }
  535. /// <summary>
  536. /// 接团信息 操作(增改)
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  543. {
  544. try
  545. {
  546. var groupData = await _groupRepository.GroupOperation(dto);
  547. if (groupData.Code != 0)
  548. {
  549. return Ok(JsonView(false, groupData.Msg));
  550. }
  551. int diId = 0;
  552. //添加时 默认加入团组汇率
  553. if (dto.Status == 1) //添加
  554. {
  555. diId = groupData.Data;
  556. //添加默认币种
  557. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  558. //默认分配权限
  559. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  560. //消息提示 王鸽 主管号
  561. List<int> _managerIds = new List<int>() { 22, 32 };
  562. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  563. if (userIds.Count > 0)
  564. {
  565. userIds.Add(208);
  566. //创建团组管控
  567. GroupStepForDelegation.CreateWorkStep(diId);
  568. //发送消息
  569. string groupName = dto.TeamName;
  570. string createGroupUser = string.Empty;
  571. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  572. if (userInfo != null) createGroupUser = userInfo.CnName;
  573. string title = $"系统通知";
  574. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  575. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  576. }
  577. //默认创建倒推表
  578. await _invertedListRep._Create(dto.UserId, diId);
  579. }
  580. else if (dto.Status == 2)
  581. {
  582. diId = dto.Id;
  583. }
  584. return Ok(JsonView(true, "操作成功!", diId));
  585. }
  586. catch (Exception ex)
  587. {
  588. Logs("[response]" + JsonConvert.SerializeObject(dto));
  589. Logs(ex.Message);
  590. return Ok(JsonView(false, ex.Message));
  591. }
  592. }
  593. /// <summary>
  594. /// 接团流程操作(增改)
  595. /// 安卓端使用 建团时添加客户名单
  596. /// </summary>
  597. /// <param name="dto"></param>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  602. {
  603. try
  604. {
  605. #region 参数验证
  606. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  608. #region 页面操作权限验证
  609. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  610. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  611. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  612. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  613. #endregion
  614. #endregion
  615. _sqlSugar.BeginTran();
  616. var _dto = new GroupOperationDto();
  617. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  618. var groupData = await _groupRepository.GroupOperation(_dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  622. }
  623. int diId = 0;
  624. //添加时 默认加入团组汇率
  625. if (dto.Status == 1) //添加
  626. {
  627. diId = groupData.Data;
  628. //添加默认币种
  629. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  630. //默认分配权限
  631. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  632. //消息提示 王鸽 主管号
  633. List<int> _managerIds = new List<int>() { 22, 32 };
  634. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  635. if (userIds.Count > 0)
  636. {
  637. userIds.Add(208);
  638. //创建团组管控
  639. GroupStepForDelegation.CreateWorkStep(diId);
  640. //发送消息
  641. string groupName = dto.TeamName;
  642. string createGroupUser = string.Empty;
  643. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  644. if (userInfo != null) createGroupUser = userInfo.CnName;
  645. string title = $"系统通知";
  646. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  647. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  648. }
  649. }
  650. if (dto.Status == 2)
  651. {
  652. diId = dto.Id;
  653. if (diId == 0)
  654. {
  655. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  656. }
  657. }
  658. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  659. if (viewData.Code != 0)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  663. }
  664. _sqlSugar.CommitTran();
  665. return Ok(JsonView(true, "添加成功"));
  666. }
  667. catch (Exception ex)
  668. {
  669. _sqlSugar.RollbackTran();
  670. return Ok(JsonView(false, ex.Message));
  671. }
  672. }
  673. /// <summary>
  674. /// 接团信息 操作(删除)
  675. /// </summary>
  676. /// <param name="dto"></param>
  677. /// <returns></returns>
  678. [HttpPost]
  679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  680. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  681. {
  682. try
  683. {
  684. var groupData = await _groupRepository.GroupDel(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(true));
  690. }
  691. catch (Exception ex)
  692. {
  693. Logs("[response]" + JsonConvert.SerializeObject(dto));
  694. Logs(ex.Message);
  695. return Ok(JsonView(false, ex.Message));
  696. }
  697. }
  698. /// <summary>
  699. /// 获取团组销售报价号
  700. /// 团组添加时 使用
  701. /// </summary>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupSalesQuoteNo()
  706. {
  707. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. object salesQuoteNo = new
  713. {
  714. SalesQuoteNo = groupData.Data
  715. };
  716. return Ok(JsonView(salesQuoteNo));
  717. }
  718. /// <summary>
  719. /// 设置确认出团
  720. /// </summary>
  721. /// <param name="dto"></param>
  722. /// <returns></returns>
  723. [HttpPost]
  724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  725. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  726. {
  727. var groupData = await _groupRepository.ConfirmationGroup(dto);
  728. if (groupData.Code != 0)
  729. {
  730. return Ok(JsonView(false, groupData.Msg));
  731. }
  732. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  733. #region OA消息推送
  734. try
  735. {
  736. string groupName = groupInfo.TeamName;
  737. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  738. List<int> userIds = new List<int>();
  739. listUser.ForEach(s => userIds.Add(s.Id));
  740. string title = $"系统通知";
  741. string content = $"团组[{groupName}]已确认出团!";
  742. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  743. }
  744. catch (Exception ex)
  745. {
  746. }
  747. #endregion
  748. #region 应用推送
  749. try
  750. {
  751. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  752. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  753. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  754. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  755. {
  756. List<string> userList = new List<string>() { users.QiyeChatUserId };
  757. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  758. }
  759. }
  760. catch (Exception ex)
  761. {
  762. }
  763. #endregion
  764. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  765. return Ok(JsonView(true, "操作成功!", groupData.Data));
  766. }
  767. /// <summary>
  768. /// 获取团组名称data And 签证国别Data
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  775. {
  776. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  777. if (groupData.Code != 0)
  778. {
  779. return Ok(JsonView(false, groupData.Msg));
  780. }
  781. return Ok(JsonView(groupData.Data));
  782. }
  783. /// <summary>
  784. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  785. /// </summary>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  790. {
  791. try
  792. {
  793. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  794. if (groupData.Code != 0)
  795. {
  796. return Ok(JsonView(false, groupData.Msg));
  797. }
  798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  799. }
  800. catch (Exception ex)
  801. {
  802. return Ok(JsonView(false, "程序错误!"));
  803. throw;
  804. }
  805. }
  806. #endregion
  807. #region 团组&签证
  808. /// <summary>
  809. /// 根据团组Id获取签证客户信息List
  810. /// </summary>
  811. /// <param name="dto">请求dto</param>
  812. /// <returns></returns>
  813. [HttpPost]
  814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  815. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  816. {
  817. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  818. if (groupData.Code != 0)
  819. {
  820. return Ok(JsonView(false, groupData.Msg));
  821. }
  822. return Ok(JsonView(groupData.Data));
  823. }
  824. /// <summary>
  825. /// IOS获取团组签证拍照上传进度01(团组列表)
  826. /// </summary>
  827. /// <param name="dto">请求dto</param>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "参数为空"));
  836. }
  837. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  838. return Ok(JsonView(visaList));
  839. }
  840. /// <summary>
  841. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  842. /// </summary>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  847. {
  848. if (dto == null)
  849. {
  850. return Ok(JsonView(false, "请求错误:"));
  851. }
  852. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  853. return Ok(JsonView(list));
  854. }
  855. /// <summary>
  856. /// IOS获取团组签证拍照上传进度03(相册)
  857. /// </summary>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  862. {
  863. if (dto == null)
  864. {
  865. return Ok(JsonView(false, "请求错误:"));
  866. }
  867. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  868. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  869. list.ForEach(s => s.url = url);
  870. return Ok(JsonView(list));
  871. }
  872. /// <summary>
  873. /// IOS获取团组签证拍照上传进度04(图片上传)
  874. /// </summary>
  875. /// <param name="dto"></param>
  876. /// <returns></returns>
  877. [HttpPost]
  878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  879. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  880. {
  881. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  882. //if (!string.IsNullOrEmpty(result))
  883. //{
  884. //}
  885. //else {
  886. // return Ok(JsonView(false, "上传失败"));
  887. //}
  888. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  889. int sucNum = 0;
  890. try
  891. {
  892. foreach (var item in dto.base64DataList)
  893. {
  894. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  895. string result = decodeBase64ToImage(item, imageName);
  896. if (!string.IsNullOrEmpty(result))
  897. {
  898. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  899. pic.CreateUserId = dto.CreateUserId;
  900. pic.PicName = imageName;
  901. pic.PicPath = result;
  902. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  903. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  904. if (insertResult > 0)
  905. {
  906. sucNum++;
  907. }
  908. }
  909. }
  910. }
  911. catch (Exception ex)
  912. {
  913. return Ok(JsonView(false, ex.Message));
  914. }
  915. string msg = string.Format(@"成功上传{0}张", sucNum);
  916. return Ok(JsonView(true, msg));
  917. }
  918. private string decodeBase64ToImage(string base64DataURL, string imgName)
  919. {
  920. string filename = "";//声明一个string类型的相对路径
  921. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  922. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  923. try//会有异常抛出,try,catch一下
  924. {
  925. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  926. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  927. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  928. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  929. //文件名称
  930. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  931. //上传的文件的路径
  932. string filePath = "";
  933. if (!Directory.Exists(fileDir))
  934. {
  935. Directory.CreateDirectory(fileDir);
  936. }
  937. //上传的文件的路径
  938. filePath = fileDir + filename;
  939. //string url = HttpRuntime.AppDomainAppPath.ToString();
  940. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  941. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  942. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  943. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  944. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  945. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  946. ms.Close();//关闭当前流,并释放所有与之关联的资源
  947. bitmap.Dispose();
  948. }
  949. catch (Exception e)
  950. {
  951. string massage = e.Message;
  952. Logs("IOS图片上传Error:" + massage);
  953. //filename = e.Message;
  954. }
  955. return filename;//返回相对路径
  956. }
  957. /// <summary>
  958. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  965. {
  966. if (dto == null)
  967. {
  968. return Ok(JsonView(false, "请求错误:"));
  969. }
  970. string msg = "参数错误";
  971. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  972. {
  973. try
  974. {
  975. //_delegationVisaRep.BeginTran();
  976. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  977. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  978. .Where(s => s.Id == dto.visaProgressCustomerId)
  979. .ExecuteCommandAsync();
  980. if (updCount > 0 && dto.publishCode == 1)
  981. {
  982. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  983. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  984. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  985. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  986. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  987. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  988. if (groupData == null)
  989. {
  990. _delegationVisaRep.RollbackTran();
  991. }
  992. string title = string.Format(@"[签证进度更新]");
  993. string content = string.Format(@"测试文本");
  994. bool rst = await _message.AddMsg(new MessageDto()
  995. {
  996. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  997. IssuerId = dto.publisher,
  998. Title = title,
  999. Content = content,
  1000. ReleaseTime = DateTime.Now,
  1001. UIdList = new List<int> {
  1002. 234
  1003. }
  1004. });
  1005. if (rst)
  1006. {
  1007. return Ok(JsonView(true, "发送通知成功"));
  1008. }
  1009. }
  1010. //_delegationVisaRep.CommitTran();
  1011. }
  1012. catch (Exception)
  1013. {
  1014. //_delegationVisaRep.RollbackTran();
  1015. }
  1016. }
  1017. return Ok(JsonView(true, msg));
  1018. }
  1019. #endregion
  1020. #region 团组任务分配
  1021. /// <summary>
  1022. /// 团组任务分配初始化
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GetTaskAssignmen()
  1029. {
  1030. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1031. if (groupData.Code != 0)
  1032. {
  1033. return Ok(JsonView(false, groupData.Msg));
  1034. }
  1035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1036. }
  1037. /// <summary>
  1038. /// 团组任务分配查询
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1045. {
  1046. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1047. if (groupData.Code != 0)
  1048. {
  1049. return Ok(JsonView(false, groupData.Msg));
  1050. }
  1051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1052. }
  1053. /// <summary>
  1054. /// 团组任务分配操作
  1055. /// </summary>
  1056. /// <param name="dto"></param>
  1057. /// <returns></returns>
  1058. [HttpPost]
  1059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1060. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1061. {
  1062. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1063. if (groupData.Code != 0)
  1064. {
  1065. return Ok(JsonView(false, groupData.Msg));
  1066. }
  1067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1068. }
  1069. #endregion
  1070. #region 团组费用审核
  1071. /// <summary>
  1072. /// 费用审核
  1073. /// 团组列表 Page
  1074. /// </summary>
  1075. /// <param name="_dto">团组列表请求dto</param>
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1080. {
  1081. #region 参数验证
  1082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1083. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1085. #region 页面操作权限验证
  1086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1087. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1088. #endregion
  1089. #endregion
  1090. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1091. {
  1092. string sqlWhere = string.Empty;
  1093. if (_dto.IsSure == 0) //未完成
  1094. {
  1095. sqlWhere += string.Format(@" And IsSure = 0");
  1096. }
  1097. else if (_dto.IsSure == 1) //已完成
  1098. {
  1099. sqlWhere += string.Format(@" And IsSure = 1");
  1100. }
  1101. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1102. {
  1103. string tj = _dto.SearchCriteria;
  1104. 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}%')",
  1105. tj, tj, tj, tj, tj);
  1106. }
  1107. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1108. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1109. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1110. From (
  1111. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1112. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1113. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1114. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1115. From Grp_DelegationInfo gdi
  1116. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1117. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1118. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1119. Where gdi.IsDel = 0 {0}
  1120. ) temp ", sqlWhere);
  1121. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1122. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1123. var _view = new
  1124. {
  1125. PageFuncAuth = pageFunAuthView,
  1126. Data = _DelegationList
  1127. };
  1128. return Ok(JsonView(true, "查询成功!", _view, total));
  1129. }
  1130. else
  1131. {
  1132. return Ok(JsonView(false, "查询失败"));
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 获取团组费用审核
  1137. /// </summary>
  1138. /// <param name="paras">参数Json字符串</param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1143. {
  1144. try
  1145. {
  1146. #region 参数验证
  1147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1148. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1154. #endregion
  1155. #endregion
  1156. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1157. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1158. #region 费用清单
  1159. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1160. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1161. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1162. List<Grp_CreditCardPayment> entityList = _groupRepository
  1163. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1164. .Where(exp.ToExpression())
  1165. .ToList();
  1166. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1167. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1168. /*
  1169. * 76://酒店预订
  1170. */
  1171. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1172. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1175. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. /*
  1178. * 79://车/导游地接
  1179. */
  1180. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 80: //签证
  1188. */
  1189. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1190. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. *81: //邀请/公务活动
  1194. */
  1195. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1196. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1197. .ToListAsync();
  1198. /*
  1199. * 82: //团组客户保险
  1200. */
  1201. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1202. /*
  1203. * Lable = 85 机票预订
  1204. */
  1205. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1206. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1207. .ToListAsync();
  1208. /*
  1209. * 85 机票预定
  1210. */
  1211. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1212. /*
  1213. * 98 其他款项
  1214. */
  1215. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1216. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 285:收款退还
  1220. */
  1221. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1222. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1223. .ToListAsync();
  1224. /*
  1225. * 1015: //超支费用
  1226. */
  1227. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 币种信息
  1230. */
  1231. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1232. /*
  1233. * 车/导游地接 费用类型
  1234. */
  1235. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 车/导游地接 费用类型
  1238. */
  1239. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1240. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1241. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1242. /*
  1243. * 用户信息
  1244. */
  1245. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1246. /*
  1247. * 费用模块
  1248. */
  1249. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1250. string priceModule = string.Empty;
  1251. if (sdPriceName != null)
  1252. {
  1253. priceModule = sdPriceName.Name;
  1254. }
  1255. /*
  1256. * 成本信息
  1257. */
  1258. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1259. decimal _groupRate = 0.0000M;
  1260. string _groupCurrencyCode = "-";
  1261. if (groupCost != null)
  1262. {
  1263. _groupRate = groupCost.Rate;
  1264. if (int.TryParse(groupCost.Currency, out int _currency))
  1265. {
  1266. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1267. }
  1268. else _groupCurrencyCode = groupCost.Currency;
  1269. }
  1270. string costContentSql = $"Select * From Grp_GroupCost";
  1271. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1272. //处理日期为空的天数
  1273. for (int i = 0; i < groupCostDetails.Count; i++)
  1274. if (i != 0)
  1275. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1276. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1277. /*
  1278. * 处理详情数据
  1279. */
  1280. foreach (var entity in entityList)
  1281. {
  1282. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1283. _detail.Id = entity.Id;
  1284. _detail.PriceName = priceModule;
  1285. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1286. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1287. /*
  1288. * 应付款金额
  1289. */
  1290. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1291. string PaymentCurrency_WaitPay = "Unknown";
  1292. string hotelCurrncyCode = "Unknown";
  1293. string hotelCurrncyName = "Unknown";
  1294. if (sdPaymentCurrency_WaitPay != null)
  1295. {
  1296. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1297. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1298. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1299. if (hotelCurrncyCode.Equals("CNY"))
  1300. {
  1301. entity.DayRate = 1.0000M;
  1302. }
  1303. }
  1304. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1305. /*
  1306. * 此次付款金额
  1307. */
  1308. decimal CurrPayStr = 0;
  1309. if (entity.PayPercentage == 0)
  1310. {
  1311. if (entity.PayThenMoney != 0)
  1312. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1313. }
  1314. else
  1315. {
  1316. if (entity.PayMoney != 0)
  1317. {
  1318. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1319. }
  1320. }
  1321. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1322. /*
  1323. * 剩余尾款
  1324. */
  1325. decimal BalanceStr = 0;
  1326. if (CurrPayStr != 0)
  1327. {
  1328. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1329. BalanceStr = 0;
  1330. else
  1331. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1332. }
  1333. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1334. /*
  1335. * Bus名称
  1336. */
  1337. _detail.BusName = "待增加";
  1338. /*
  1339. *费用所属
  1340. */
  1341. switch (entity.CTable)
  1342. {
  1343. case 76://酒店预订
  1344. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1345. if (hotelReservations != null)
  1346. {
  1347. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1348. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1349. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1350. string roomFeeStr = "", roomFeestr1 = "";
  1351. //是否比较房型价格
  1352. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1353. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1354. if (hotelReservations.SingleRoomPrice > 0)
  1355. { roomFeestr1 += $"单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}"; __isSingle = true; }
  1356. if (hotelReservations.DoubleRoomPrice > 0)
  1357. { roomFeestr1 += $"双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}"; __isDouble = true; }
  1358. if (hotelReservations.SuiteRoomPrice > 0)
  1359. { roomFeestr1 += $"套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}"; __isSuite = true; }
  1360. if (hotelReservations.OtherRoomPrice > 0)
  1361. { roomFeestr1 += $"其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}"; __isOther = true; }
  1362. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1363. else roomFeeStr += " 0.00 * 0";
  1364. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1365. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1366. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1367. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1368. /*
  1369. * 费用类型
  1370. * 1:房费
  1371. * 2:早餐
  1372. * 3:地税
  1373. * 4:城市税
  1374. * </summary>
  1375. */
  1376. //地税
  1377. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1378. if (governmentRentData != null)
  1379. {
  1380. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1381. governmentRentFee = governmentRentData.Price;
  1382. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1383. if (governmentRentCurrData != null)
  1384. {
  1385. governmentRentCode = governmentRentCurrData.Name;
  1386. governmentRentName = $"({governmentRentCurrData.Remark})";
  1387. }
  1388. }
  1389. //城市税
  1390. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1391. if (cityTaxData != null)
  1392. {
  1393. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1394. cityTaxFee = cityTaxData.Price;
  1395. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1396. if (cityTaxCurrData != null)
  1397. {
  1398. cityTaxCode = cityTaxCurrData.Name;
  1399. cityTaxName = $"({cityTaxCurrData.Remark})";
  1400. }
  1401. }
  1402. //酒店早餐
  1403. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1404. if (breakfastData != null)
  1405. {
  1406. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1407. breakfastFee = breakfastData.Price;
  1408. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1409. if (breakfastCurrData != null)
  1410. {
  1411. breakfastCode = breakfastCurrData.Name;
  1412. breakfastName = $"({breakfastCurrData.Remark})";
  1413. }
  1414. }
  1415. //房间费用
  1416. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1417. if (roomData != null)
  1418. {
  1419. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1420. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1421. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1422. roomFee = roomData.Price;
  1423. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1424. if (roomCurrData != null)
  1425. {
  1426. roomCode = roomCurrData.Name;
  1427. roomName = $"({roomCurrData.Remark})";
  1428. }
  1429. }
  1430. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1431. string hotelCostStr = "";
  1432. decimal hotelCsotTotal = 0.00M;
  1433. if (groupCost != null)
  1434. {
  1435. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1436. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1437. }
  1438. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1439. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1440. string hotelCost_day = "";
  1441. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1442. foreach (var item in hotelCostDetails1)
  1443. {
  1444. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1445. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1446. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1447. else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1448. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1449. else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1450. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1451. else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1452. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1453. else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1454. hotelCost_day += @$"</br>";
  1455. }
  1456. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1457. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1458. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1459. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1460. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1461. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1462. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1463. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1464. $"房间说明: {hotelReservations.Remark} <br/>" +
  1465. $"房间费用: {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接代付:{roomBool}<br/><br/>" +
  1466. $"{hotelBreakfastStr}" +
  1467. $"{hotelGovernmentRentStr}" +
  1468. $"{hotelCityTaxStr}";
  1469. _detail.PriceNameContent = hotelReservations.HotelName;
  1470. }
  1471. break;
  1472. case 79://车/导游地接
  1473. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1474. if (touristGuideGroundReservations != null)
  1475. {
  1476. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1477. {
  1478. _detail.BusName = touristGuideGroundReservations.BusName;
  1479. }
  1480. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1481. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1482. //if (isInt)
  1483. //{
  1484. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1485. // if (cityInfo != null)
  1486. // {
  1487. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1488. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1489. // if (carFeeItem != null)
  1490. // {
  1491. // nameContent += $@"({carFeeItem.Name})";
  1492. // }
  1493. // _detail.PriceNameContent = nameContent;
  1494. // }
  1495. //}
  1496. //else
  1497. //{
  1498. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1499. //}
  1500. var touristGuideGroundReservationsContents =
  1501. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1502. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1503. foreach (var item in touristGuideGroundReservationsContents)
  1504. {
  1505. string typeName = "Unknown";
  1506. string carCurrencyCode = "Unknown";
  1507. string carCurrencyName = "Unknown";
  1508. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1509. if (carTypeData != null) typeName = carTypeData.Name;
  1510. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1511. if (currencyData != null)
  1512. {
  1513. carCurrencyCode = currencyData.Name;
  1514. carCurrencyName = currencyData.Remark;
  1515. }
  1516. string opCostStr = string.Empty;
  1517. decimal opCostTypePrice = 0.00M;
  1518. #region 处理成本各项费用
  1519. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1520. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1521. if (opCost.Count > 0)
  1522. {
  1523. switch (item.SId)
  1524. {
  1525. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1526. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1527. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1528. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1529. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1530. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1531. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1532. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1533. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1534. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1535. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1536. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1537. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1538. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1539. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1540. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1541. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1542. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1543. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1544. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1545. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1546. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1547. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1548. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1549. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1550. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1551. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1552. }
  1553. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1554. }
  1555. #endregion
  1556. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1557. $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1558. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1559. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1560. }
  1561. _detail.PriceMsgContent = priceMsg;
  1562. }
  1563. break;
  1564. case 80: //签证
  1565. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1566. if (visaInfo != null)
  1567. {
  1568. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1569. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1570. }
  1571. break;
  1572. case 81: //邀请/公务活动
  1573. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1574. if (_ioa != null)
  1575. {
  1576. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1577. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1578. sendCurrName = "Unknown", //快递费用币种 Name
  1579. sendCurrCode = "Unknown", //快递费用币种 Code
  1580. eventsCurrName = "Unknown", //公务活动费币种 Name
  1581. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1582. translateCurrName = "Unknown", //公务翻译费 Name
  1583. translateCurrCode = "Unknown"; //公务翻译费 Code
  1584. #region 处理费用币种
  1585. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1586. if (inviteCurrData != null)
  1587. {
  1588. inviteCurrName = inviteCurrData.Remark;
  1589. inviteCurrCode = inviteCurrData.Name;
  1590. }
  1591. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1592. if (sendCurrData != null)
  1593. {
  1594. sendCurrName = sendCurrData.Remark;
  1595. sendCurrCode = sendCurrData.Name;
  1596. }
  1597. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1598. if (eventsCurrData != null)
  1599. {
  1600. eventsCurrName = eventsCurrData.Remark;
  1601. eventsCurrCode = eventsCurrData.Name;
  1602. }
  1603. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1604. if (translateCurrData != null)
  1605. {
  1606. translateCurrName = translateCurrData.Remark;
  1607. translateCurrCode = translateCurrData.Name;
  1608. }
  1609. #endregion
  1610. _detail.PriceNameContent = _ioa.InviterArea;
  1611. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1612. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1613. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1614. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1615. $@"备注:" + _ioa.Remark + "<br/>";
  1616. }
  1617. break;
  1618. case 82: //团组客户保险
  1619. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1620. if (customers != null)
  1621. {
  1622. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1623. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1624. }
  1625. break;
  1626. case 85: //机票预订
  1627. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1628. if (jpRes != null)
  1629. {
  1630. string FlightsDescription = jpRes.FlightsDescription;
  1631. string PriceDescription = jpRes.PriceDescription;
  1632. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1633. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1634. }
  1635. break;
  1636. case 98://其他款项
  1637. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1638. if (gdpRes != null)
  1639. {
  1640. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1641. _detail.PriceNameContent = gdpRes.PriceName;
  1642. }
  1643. break;
  1644. case 285://收款退还
  1645. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1646. if (refundAndOtherMoney != null)
  1647. {
  1648. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1649. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1650. }
  1651. break;
  1652. case 751://酒店早餐
  1653. break;
  1654. case 1015://超支费用
  1655. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1656. if (groupExtraCost != null)
  1657. {
  1658. _detail.PriceNameContent = groupExtraCost.PriceName;
  1659. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1660. }
  1661. break;
  1662. default:
  1663. break;
  1664. }
  1665. /*
  1666. * 申请人
  1667. */
  1668. string operatorName = " - ";
  1669. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1670. if (_opUser != null)
  1671. {
  1672. operatorName = _opUser.CnName;
  1673. }
  1674. _detail.OperatorName = operatorName;
  1675. /*
  1676. * 审核人
  1677. */
  1678. string auditOperatorName = "Unknown";
  1679. if (entity.AuditGMOperate == 0)
  1680. auditOperatorName = " - ";
  1681. else if (entity.AuditGMOperate == 4)
  1682. auditOperatorName = "自动审核";
  1683. else
  1684. {
  1685. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1686. if (_adUser != null)
  1687. {
  1688. auditOperatorName = _adUser.CnName;
  1689. }
  1690. }
  1691. _detail.AuditOperatorName = auditOperatorName;
  1692. /*
  1693. * 超预算比例
  1694. */
  1695. string overBudgetStr = "";
  1696. if (entity.ExceedBudget == -1)
  1697. overBudgetStr = sdPriceName.Name + "尚无预算";
  1698. else if (entity.ExceedBudget == 0)
  1699. {
  1700. if (entity.CTable == 76 || entity.CTable == 79)
  1701. {
  1702. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1703. else overBudgetStr = "超预算";
  1704. }
  1705. else
  1706. {
  1707. overBudgetStr = "未超预算";
  1708. }
  1709. }
  1710. else
  1711. overBudgetStr = entity.ExceedBudget.ToString("P");
  1712. _detail.OverBudget = overBudgetStr;
  1713. /*
  1714. * 费用总计
  1715. */
  1716. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1717. {
  1718. CurrencyId = entity.PaymentCurrency,
  1719. CurrencyName = PaymentCurrency_WaitPay,
  1720. AmountPayable = entity.PayMoney,
  1721. ThisPayment = CurrPayStr,
  1722. BalancePayment = BalanceStr,
  1723. AuditedFunds = CurrPayStr
  1724. });
  1725. _detail.IsAuditGM = entity.IsAuditGM;
  1726. detailList.Add(_detail);
  1727. }
  1728. #endregion
  1729. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1730. /*
  1731. * 下方描述处理
  1732. */
  1733. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1734. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1735. if (ccpCurrencyPrice != null)
  1736. {
  1737. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1738. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1739. }
  1740. else
  1741. {
  1742. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1743. }
  1744. string amountPayableStr = string.Format(@"应付款总金额: ");
  1745. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1746. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1747. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1748. foreach (var item in nonDuplicat)
  1749. {
  1750. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1751. if (strs.Count > 0)
  1752. {
  1753. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1754. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1755. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1756. //单独处理此次付款金额
  1757. if (item.CurrencyId == 836) //人民币
  1758. {
  1759. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1760. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1761. }
  1762. else
  1763. {
  1764. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1765. }
  1766. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1767. //单独处理已审核费用
  1768. if (item.CurrencyId == 836) //人民币
  1769. {
  1770. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1771. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1772. }
  1773. else
  1774. {
  1775. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1776. }
  1777. }
  1778. }
  1779. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1780. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1781. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1782. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1783. var _view1 = new
  1784. {
  1785. PageFuncAuth = pageFunAuthView,
  1786. Data = _view
  1787. };
  1788. return Ok(JsonView(_view1));
  1789. }
  1790. catch (Exception ex)
  1791. {
  1792. return Ok(JsonView(false, ex.Message));
  1793. }
  1794. }
  1795. /// <summary>
  1796. /// 费用审核
  1797. /// 修改团组费用审核状态
  1798. /// </summary>
  1799. /// <param name="_dto">参数Json字符串</param>
  1800. /// <returns></returns>
  1801. [HttpPost]
  1802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1803. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1804. {
  1805. #region 参数验证
  1806. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1807. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1808. #endregion
  1809. #region 页面操作权限验证
  1810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1812. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1813. #endregion
  1814. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1815. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1816. DateTime dtNow = DateTime.Now;
  1817. _groupRepository.BeginTran();
  1818. int rst = 0;
  1819. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1820. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1821. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1822. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1823. List<dynamic> msgDatas = new List<dynamic>();
  1824. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1825. foreach (var item in idList)
  1826. {
  1827. int CreditId = int.Parse(item);
  1828. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1829. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1830. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1831. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1832. .Where(s => s.Id == CreditId)
  1833. .ExecuteCommandAsync();
  1834. if (result < 1)
  1835. {
  1836. rst = -1;
  1837. _groupRepository.RollbackTran();
  1838. return Ok(JsonView(false, "操作失败并回滚!"));
  1839. }
  1840. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1841. if (creditData != null)
  1842. {
  1843. #region 应用通知配置
  1844. try
  1845. {
  1846. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1847. }
  1848. catch (Exception ex)
  1849. {
  1850. }
  1851. #endregion
  1852. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1853. string groupNameStr = string.Empty;
  1854. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1855. if (groupData != null) groupNameStr = groupData.TeamName;
  1856. string creditTypeStr = string.Empty;
  1857. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1858. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1859. string creditCurrency = string.Empty;
  1860. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1861. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1862. if (creditCurrency.Equals("CNY"))
  1863. {
  1864. creditData.DayRate = 1.0000M;
  1865. }
  1866. if (creditData.PayPercentage == 0.00M)
  1867. {
  1868. creditData.PayPercentage = 100M;
  1869. }
  1870. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1871. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1872. string msgContent = "";
  1873. if (creditCurrency.Equals("CNY"))
  1874. {
  1875. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1876. }
  1877. else
  1878. {
  1879. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1880. }
  1881. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1882. }
  1883. }
  1884. if (rst == 0)
  1885. {
  1886. _groupRepository.CommitTran();
  1887. foreach (var item in msgDatas)
  1888. {
  1889. //发送消息
  1890. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1891. }
  1892. #region 应用推送
  1893. try
  1894. {
  1895. foreach (var ccpId in dic_ccp_user.Keys)
  1896. {
  1897. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1898. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1899. }
  1900. }
  1901. catch (Exception)
  1902. {
  1903. }
  1904. #endregion
  1905. return Ok(JsonView(true, "操作成功!"));
  1906. }
  1907. return Ok(JsonView(false, "操作失败!"));
  1908. }
  1909. #endregion
  1910. #region 机票费用录入
  1911. /// <summary>
  1912. /// 机票录入当前登录人可操作团组
  1913. /// </summary>
  1914. /// <param name="dto"></param>
  1915. /// <returns></returns>
  1916. [HttpPost]
  1917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1918. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1919. {
  1920. try
  1921. {
  1922. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1923. if (groupData.Code != 0)
  1924. {
  1925. return Ok(JsonView(false, groupData.Msg));
  1926. }
  1927. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1928. }
  1929. catch (Exception ex)
  1930. {
  1931. return Ok(JsonView(false, "程序错误!"));
  1932. throw;
  1933. }
  1934. }
  1935. /// <summary>
  1936. /// 机票费用录入列表
  1937. /// </summary>
  1938. /// <param name="dto"></param>
  1939. /// <returns></returns>
  1940. [HttpPost]
  1941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1942. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1943. {
  1944. try
  1945. {
  1946. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1947. if (groupData.Code != 0)
  1948. {
  1949. return Ok(JsonView(false, groupData.Msg));
  1950. }
  1951. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1952. }
  1953. catch (Exception ex)
  1954. {
  1955. return Ok(JsonView(false, ex.Message));
  1956. throw;
  1957. }
  1958. }
  1959. /// <summary>
  1960. /// 根据id查询费用录入信息
  1961. /// </summary>
  1962. /// <param name="dto"></param>
  1963. /// <returns></returns>
  1964. [HttpPost]
  1965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1966. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1967. {
  1968. try
  1969. {
  1970. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1971. if (groupData.Code != 0)
  1972. {
  1973. return Ok(JsonView(false, groupData.Msg));
  1974. }
  1975. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1976. }
  1977. catch (Exception ex)
  1978. {
  1979. return Ok(JsonView(false, "程序错误!"));
  1980. throw;
  1981. }
  1982. }
  1983. /// <summary>
  1984. /// 机票费用录入操作(Status:1.新增,2.修改)
  1985. /// </summary>
  1986. /// <param name="dto"></param>
  1987. /// <returns></returns>
  1988. [HttpPost]
  1989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1990. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1991. {
  1992. try
  1993. {
  1994. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1995. if (groupData.Code != 0)
  1996. {
  1997. return Ok(JsonView(false, groupData.Msg));
  1998. }
  1999. #region 应用推送
  2000. try
  2001. {
  2002. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2003. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2004. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2005. }
  2006. catch (Exception ex)
  2007. {
  2008. }
  2009. #endregion
  2010. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2011. }
  2012. catch (Exception ex)
  2013. {
  2014. return Ok(JsonView(false, "程序错误!"));
  2015. throw;
  2016. }
  2017. }
  2018. /// <summary>
  2019. /// 根据舱位类型查询接团客户名单信息
  2020. /// </summary>
  2021. /// <param name="dto"></param>
  2022. /// <returns></returns>
  2023. [HttpPost]
  2024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2025. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2026. {
  2027. try
  2028. {
  2029. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2030. if (crm_Groups.Count != 0)
  2031. {
  2032. List<dynamic> Customer = new List<dynamic>();
  2033. foreach (var item in crm_Groups)
  2034. {
  2035. var data = new
  2036. {
  2037. Id = item.Id,
  2038. Pinyin = item.Pinyin,
  2039. Name = item.LastName + item.FirstName
  2040. };
  2041. Customer.Add(data);
  2042. }
  2043. return Ok(JsonView(true, "查询成功!", Customer));
  2044. }
  2045. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2046. }
  2047. catch (Exception ex)
  2048. {
  2049. return Ok(JsonView(false, "程序错误!"));
  2050. throw;
  2051. }
  2052. }
  2053. /// <summary>
  2054. /// 根据团号获取客户信息
  2055. /// </summary>
  2056. /// <param name="dto"></param>
  2057. /// <returns></returns>
  2058. [HttpPost]
  2059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2060. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2061. {
  2062. var jw = JsonView(false);
  2063. if (dto.DIID < 1)
  2064. {
  2065. jw.Msg += "请输入正确的diid";
  2066. return Ok(jw);
  2067. }
  2068. var arr = getSimplClientList(dto.DIID);
  2069. jw = JsonView(true, "获取成功!", arr);
  2070. return Ok(jw);
  2071. }
  2072. private List<SimplClientInfo> getSimplClientList(int diId)
  2073. {
  2074. 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);
  2075. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2076. return arr;
  2077. }
  2078. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2079. {
  2080. string result = origin;
  2081. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2082. {
  2083. string[] temparr = origin.Split(',');
  2084. string fistrStr = temparr[0];
  2085. int count = temparr.Count();
  2086. int tempId;
  2087. bool success = int.TryParse(fistrStr, out tempId);
  2088. if (success)
  2089. {
  2090. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2091. if (tempInfo != null)
  2092. {
  2093. if (count > 1)
  2094. {
  2095. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2096. }
  2097. else
  2098. {
  2099. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2100. }
  2101. }
  2102. }
  2103. }
  2104. return result;
  2105. }
  2106. /// <summary>
  2107. /// 机票费用录入,删除
  2108. /// </summary>
  2109. /// <param name="dto"></param>
  2110. /// <returns></returns>
  2111. [HttpPost]
  2112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2113. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2114. {
  2115. try
  2116. {
  2117. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2118. if (res)
  2119. {
  2120. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2121. {
  2122. IsDel = 1,
  2123. DeleteUserId = dto.DeleteUserId,
  2124. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2125. }).ExecuteCommandAsync();
  2126. return Ok(JsonView(true, "删除成功!"));
  2127. }
  2128. return Ok(JsonView(false, "删除失败!"));
  2129. }
  2130. catch (Exception ex)
  2131. {
  2132. return Ok(JsonView(false, "程序错误!"));
  2133. throw;
  2134. }
  2135. }
  2136. /// <summary>
  2137. /// 导出机票录入报表
  2138. /// </summary>
  2139. /// <param name="dto"></param>
  2140. /// <returns></returns>
  2141. [HttpPost]
  2142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2143. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2144. {
  2145. try
  2146. {
  2147. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2148. if (groupData.Code != 0)
  2149. {
  2150. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2151. }
  2152. else
  2153. {
  2154. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2155. if (AirTicketReservations.Count != 0)
  2156. {
  2157. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2158. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2159. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2160. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2161. WorkbookDesigner designer = new WorkbookDesigner();
  2162. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2163. decimal countCost = 0;
  2164. foreach (var item in AirTicketReservations)
  2165. {
  2166. #region 处理客人姓名
  2167. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2168. item.ClientName = clientNames;
  2169. #endregion
  2170. if (item.BankType == "其他")
  2171. {
  2172. item.BankNo = "--";
  2173. }
  2174. else
  2175. {
  2176. if (!string.IsNullOrEmpty(item.BankType))
  2177. {
  2178. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2179. }
  2180. }
  2181. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2182. item.Price = System.Decimal.Round(item.Price, 2);
  2183. countCost += Convert.ToDecimal(item.Price);
  2184. }
  2185. designer.SetDataSource("Export", AirTicketReservations);
  2186. designer.SetDataSource("ExportDiCode", diCode);
  2187. designer.SetDataSource("ExportDiName", diName);
  2188. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2189. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2190. designer.Process();
  2191. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2192. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2193. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2194. return Ok(JsonView(true, "成功", url = rst));
  2195. }
  2196. else
  2197. {
  2198. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2199. }
  2200. }
  2201. }
  2202. catch (Exception ex)
  2203. {
  2204. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2205. throw;
  2206. }
  2207. }
  2208. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2209. /// <summary>
  2210. /// 行程单导出
  2211. /// </summary>
  2212. /// <param name="dto"></param>
  2213. /// <returns></returns>
  2214. [HttpPost]
  2215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2216. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2217. {
  2218. try
  2219. {
  2220. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2221. if (groupData.Code != 0)
  2222. {
  2223. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2224. }
  2225. else
  2226. {
  2227. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2228. if (dto.Language == "CN")
  2229. {
  2230. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2231. DocumentBuilder builder = new DocumentBuilder(doc);
  2232. int tableIndex = 0;//表格索引
  2233. //得到文档中的第一个表格
  2234. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2235. foreach (var item in _AirTicketReservations)
  2236. {
  2237. #region 处理固定数据
  2238. string[] FlightsCode = item.FlightsCode.Split('/');
  2239. if (FlightsCode.Length != 0)
  2240. {
  2241. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2242. if (_AirCompany != null)
  2243. {
  2244. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2245. }
  2246. else
  2247. {
  2248. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2249. }
  2250. }
  2251. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2252. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2253. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2254. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2255. string name = "";
  2256. foreach (string clientName in nameArray)
  2257. {
  2258. if (!name.Contains(clientName))
  2259. {
  2260. name += clientName + ",";
  2261. }
  2262. }
  2263. if (!string.IsNullOrWhiteSpace(name))
  2264. {
  2265. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2266. }
  2267. else
  2268. {
  2269. table.Range.Bookmarks["ClientName"].Text = "--";
  2270. }
  2271. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2272. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2273. table.Range.Bookmarks["JointTicket"].Text = "--";
  2274. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2275. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2276. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2277. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2278. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2279. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2280. #endregion
  2281. #region 循环数据处理
  2282. List<AirInfo> airs = new List<AirInfo>();
  2283. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2284. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2285. for (int i = 0; i < FlightsCode.Length; i++)
  2286. {
  2287. AirInfo air = new AirInfo();
  2288. string[] tempstr = DayArray[i]
  2289. .Replace("\r\n", string.Empty)
  2290. .Replace("\\r\\n", string.Empty)
  2291. .TrimStart().TrimEnd()
  2292. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2293. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2294. string starCity = "";
  2295. if (star_Three != null)
  2296. {
  2297. starCity = star_Three.AirPort;
  2298. }
  2299. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2300. string EndCity = "";
  2301. if (End_Three != null)
  2302. {
  2303. EndCity = End_Three.AirPort;
  2304. }
  2305. air.Destination = starCity + "/" + EndCity;
  2306. air.Flight = FlightsCode[i];
  2307. air.SeatingClass = item.CTypeName;
  2308. string dateTime = tempstr[2];
  2309. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2310. air.FlightDate = DateTemp;
  2311. air.DepartureTime = tempstr[5];
  2312. air.LandingTime = tempstr[6];
  2313. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2314. air.TicketStatus = "--";
  2315. air.Luggage = "--";
  2316. air.DepartureTerminal = "--";
  2317. air.LandingTerminal = "--";
  2318. airs.Add(air);
  2319. }
  2320. int row = 13;
  2321. for (int i = 0; i < airs.Count; i++)
  2322. {
  2323. if (airs.Count > 2)
  2324. {
  2325. for (int j = 0; j < airs.Count - 2; j++)
  2326. {
  2327. var CopyRow = table.Rows[12].Clone(true);
  2328. table.Rows.Add(CopyRow);
  2329. }
  2330. }
  2331. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2332. int index = 0;
  2333. foreach (PropertyInfo property in properties)
  2334. {
  2335. string value = property.GetValue(airs[i]).ToString();
  2336. Cell ishcel0 = table.Rows[row].Cells[index];
  2337. Paragraph p = new Paragraph(doc);
  2338. string s = value;
  2339. p.AppendChild(new Run(doc, s));
  2340. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2341. ishcel0.AppendChild(p);
  2342. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2343. index++;
  2344. }
  2345. row++;
  2346. }
  2347. #endregion
  2348. Paragraph lastParagraph = new Paragraph(doc);
  2349. //第一个表格末尾加段落
  2350. table.ParentNode.InsertAfter(lastParagraph, table);
  2351. //复制第一个表格
  2352. Table cloneTable = (Table)table.Clone(true);
  2353. //在文档末尾段落后面加入复制的表格
  2354. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2355. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2356. {
  2357. int rownewsIndex = 13;
  2358. for (int i = 0; i < 2; i++)
  2359. {
  2360. var CopyRow = table.Rows[12].Clone(true);
  2361. table.Rows.RemoveAt(13);
  2362. table.Rows.Add(CopyRow);
  2363. rownewsIndex++;
  2364. }
  2365. }
  2366. else
  2367. {
  2368. table.Rows.RemoveAt(12);
  2369. }
  2370. cloneTable.Rows.RemoveAt(12);
  2371. }
  2372. if (_AirTicketReservations.Count != 0)
  2373. {
  2374. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2375. if (FlightsCode.Length != 0)
  2376. {
  2377. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2378. if (_AirCompany != null)
  2379. {
  2380. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2381. }
  2382. else
  2383. {
  2384. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2385. }
  2386. }
  2387. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2388. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2389. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2390. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2391. string name = "";
  2392. foreach (string clientName in nameArray)
  2393. {
  2394. if (!name.Contains(clientName))
  2395. {
  2396. name += clientName + ",";
  2397. }
  2398. }
  2399. if (!string.IsNullOrWhiteSpace(name))
  2400. {
  2401. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2402. }
  2403. else
  2404. {
  2405. table.Range.Bookmarks["ClientName"].Text = "--";
  2406. }
  2407. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2408. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2409. table.Range.Bookmarks["JointTicket"].Text = "--";
  2410. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2411. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2412. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2413. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2414. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2415. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2416. }
  2417. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2418. //保存合并后的文档
  2419. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2420. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2421. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2422. return Ok(JsonView(true, "成功!", rst));
  2423. }
  2424. else
  2425. {
  2426. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2427. DocumentBuilder builder = new DocumentBuilder(doc);
  2428. int tableIndex = 0;//表格索引
  2429. //得到文档中的第一个表格
  2430. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2431. List<string> texts = new List<string>();
  2432. foreach (var item in _AirTicketReservations)
  2433. {
  2434. string[] FlightsCode = item.FlightsCode.Split('/');
  2435. if (FlightsCode.Length != 0)
  2436. {
  2437. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2438. if (_AirCompany != null)
  2439. {
  2440. if (!transDic.ContainsKey(_AirCompany.CnName))
  2441. {
  2442. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2443. }
  2444. }
  2445. else
  2446. {
  2447. if (!transDic.ContainsKey("--"))
  2448. {
  2449. transDic.Add("--", "--");
  2450. }
  2451. }
  2452. }
  2453. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2454. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2455. string name = "";
  2456. foreach (string clientName in nameArray)
  2457. {
  2458. name += clientName + ",";
  2459. }
  2460. if (!texts.Contains(name))
  2461. {
  2462. texts.Add(name);
  2463. }
  2464. List<AirInfo> airs = new List<AirInfo>();
  2465. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2466. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2467. for (int i = 0; i < FlightsCode.Length; i++)
  2468. {
  2469. AirInfo air = new AirInfo();
  2470. string[] tempstr = DayArray[i]
  2471. .Replace("\r\n", string.Empty)
  2472. .Replace("\\r\\n", string.Empty)
  2473. .TrimStart().TrimEnd()
  2474. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2475. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2476. if (star_Three != null)
  2477. {
  2478. if (!transDic.ContainsKey(star_Three.AirPort))
  2479. {
  2480. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2481. }
  2482. }
  2483. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2484. if (End_Three != null)
  2485. {
  2486. if (!transDic.ContainsKey(End_Three.AirPort))
  2487. {
  2488. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2489. }
  2490. }
  2491. if (!texts.Contains(item.CTypeName))
  2492. {
  2493. texts.Add(item.CTypeName);
  2494. }
  2495. }
  2496. }
  2497. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2498. if (transData.Count > 0)
  2499. {
  2500. foreach (TranslateResult item in transData)
  2501. {
  2502. if (!transDic.ContainsKey(item.Query))
  2503. {
  2504. transDic.Add(item.Query, item.Translation);
  2505. }
  2506. }
  2507. }
  2508. foreach (var item in _AirTicketReservations)
  2509. {
  2510. #region 处理固定数据
  2511. string[] FlightsCode = item.FlightsCode.Split('/');
  2512. if (FlightsCode.Length != 0)
  2513. {
  2514. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2515. if (_AirCompany != null)
  2516. {
  2517. string str = "--";
  2518. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2519. if (!string.IsNullOrEmpty(translateResult))
  2520. {
  2521. str = translateResult;
  2522. str = _airTicketResRep.Processing(str);
  2523. }
  2524. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2525. }
  2526. else
  2527. {
  2528. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2529. }
  2530. }
  2531. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2532. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2533. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2534. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2535. string names = "";
  2536. foreach (string clientName in nameArray)
  2537. {
  2538. names += clientName + ",";
  2539. }
  2540. if (!string.IsNullOrWhiteSpace(names))
  2541. {
  2542. string str = "--";
  2543. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2544. if (!string.IsNullOrEmpty(translateResult))
  2545. {
  2546. str = translateResult;
  2547. str = _airTicketResRep.Processing(str);
  2548. }
  2549. table.Range.Bookmarks["ClientName"].Text = str;
  2550. }
  2551. else
  2552. {
  2553. table.Range.Bookmarks["ClientName"].Text = "--";
  2554. }
  2555. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2556. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2557. table.Range.Bookmarks["JointTicket"].Text = "--";
  2558. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2559. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2560. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2561. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2562. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2563. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2564. #endregion
  2565. #region 循环数据处理
  2566. List<AirInfo> airs = new List<AirInfo>();
  2567. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2568. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2569. for (int i = 0; i < FlightsCode.Length; i++)
  2570. {
  2571. AirInfo air = new AirInfo();
  2572. string[] tempstr = DayArray[i]
  2573. .Replace("\r\n", string.Empty)
  2574. .Replace("\\r\\n", string.Empty)
  2575. .TrimStart().TrimEnd()
  2576. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2577. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2578. string starCity = "";
  2579. if (star_Three != null)
  2580. {
  2581. string str2 = "--";
  2582. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2583. if (!string.IsNullOrEmpty(translateResult2))
  2584. {
  2585. str2 = translateResult2;
  2586. str2 = _airTicketResRep.Processing(str2);
  2587. }
  2588. starCity = str2;
  2589. }
  2590. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2591. string EndCity = "";
  2592. if (End_Three != null)
  2593. {
  2594. string str1 = "--";
  2595. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2596. if (!string.IsNullOrEmpty(translateResult1))
  2597. {
  2598. str1 = translateResult1;
  2599. str1 = _airTicketResRep.Processing(str1);
  2600. }
  2601. EndCity = str1;
  2602. }
  2603. air.Destination = starCity + "/" + EndCity;
  2604. air.Flight = FlightsCode[i];
  2605. string str = "--";
  2606. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2607. if (!string.IsNullOrEmpty(translateResult))
  2608. {
  2609. str = translateResult;
  2610. str = _airTicketResRep.Processing(str);
  2611. }
  2612. air.SeatingClass = str;
  2613. string dateTime = tempstr[2];
  2614. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2615. air.FlightDate = DateTemp;
  2616. air.DepartureTime = tempstr[5];
  2617. air.LandingTime = tempstr[6];
  2618. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2619. air.TicketStatus = "--";
  2620. air.Luggage = "--";
  2621. air.DepartureTerminal = "--";
  2622. air.LandingTerminal = "--";
  2623. airs.Add(air);
  2624. }
  2625. int row = 13;
  2626. for (int i = 0; i < airs.Count; i++)
  2627. {
  2628. if (airs.Count > 2)
  2629. {
  2630. for (int j = 0; j < airs.Count - 2; j++)
  2631. {
  2632. var CopyRow = table.Rows[12].Clone(true);
  2633. table.Rows.Add(CopyRow);
  2634. }
  2635. }
  2636. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2637. int index = 0;
  2638. foreach (PropertyInfo property in properties)
  2639. {
  2640. string value = property.GetValue(airs[i]).ToString();
  2641. Cell ishcel0 = table.Rows[row].Cells[index];
  2642. Paragraph p = new Paragraph(doc);
  2643. string s = value;
  2644. p.AppendChild(new Run(doc, s));
  2645. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2646. ishcel0.AppendChild(p);
  2647. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2648. //ishcel0.CellFormat.VerticalAlignment=
  2649. index++;
  2650. }
  2651. row++;
  2652. }
  2653. #endregion
  2654. Paragraph lastParagraph = new Paragraph(doc);
  2655. //第一个表格末尾加段落
  2656. table.ParentNode.InsertAfter(lastParagraph, table);
  2657. //复制第一个表格
  2658. Table cloneTable = (Table)table.Clone(true);
  2659. //在文档末尾段落后面加入复制的表格
  2660. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2661. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2662. {
  2663. int rownewsIndex = 13;
  2664. for (int i = 0; i < 2; i++)
  2665. {
  2666. var CopyRow = table.Rows[12].Clone(true);
  2667. table.Rows.RemoveAt(13);
  2668. table.Rows.Add(CopyRow);
  2669. rownewsIndex++;
  2670. }
  2671. }
  2672. else
  2673. {
  2674. table.Rows.RemoveAt(12);
  2675. }
  2676. cloneTable.Rows.RemoveAt(12);
  2677. }
  2678. if (_AirTicketReservations.Count != 0)
  2679. {
  2680. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2681. if (FlightsCode.Length != 0)
  2682. {
  2683. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2684. if (_AirCompany != null)
  2685. {
  2686. string str = "--";
  2687. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2688. if (!string.IsNullOrEmpty(translateResult))
  2689. {
  2690. str = translateResult;
  2691. str = _airTicketResRep.Processing(str);
  2692. }
  2693. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2694. }
  2695. else
  2696. {
  2697. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2698. }
  2699. }
  2700. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2701. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2702. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2703. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2704. string names = "";
  2705. foreach (string clientName in nameArray)
  2706. {
  2707. names += clientName + ",";
  2708. }
  2709. if (!string.IsNullOrWhiteSpace(names))
  2710. {
  2711. string str = "--";
  2712. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2713. if (!string.IsNullOrEmpty(translateResult))
  2714. {
  2715. str = translateResult;
  2716. str = _airTicketResRep.Processing(str);
  2717. }
  2718. table.Range.Bookmarks["ClientName"].Text = str;
  2719. }
  2720. else
  2721. {
  2722. table.Range.Bookmarks["ClientName"].Text = "--";
  2723. }
  2724. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2725. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2726. table.Range.Bookmarks["JointTicket"].Text = "--";
  2727. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2728. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2729. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2730. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2731. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2732. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2733. }
  2734. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2735. //保存合并后的文档
  2736. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2737. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2738. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2739. return Ok(JsonView(true, "成功!", rst));
  2740. }
  2741. }
  2742. }
  2743. catch (Exception ex)
  2744. {
  2745. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2746. throw;
  2747. }
  2748. }
  2749. #endregion
  2750. #region 团组增减款项 --> 其他款项
  2751. /// <summary>
  2752. /// 团组增减款项下拉框绑定
  2753. /// </summary>
  2754. /// <param name="dto"></param>
  2755. /// <returns></returns>
  2756. [HttpPost]
  2757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2758. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2759. {
  2760. #region 参数验证
  2761. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2762. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2763. #endregion
  2764. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2765. }
  2766. /// <summary>
  2767. /// 根据团组Id查询团组增减款项
  2768. /// </summary>
  2769. /// <param name="dto"></param>
  2770. /// <returns></returns>
  2771. [HttpPost]
  2772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2773. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2774. {
  2775. #region 参数验证
  2776. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2777. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2778. #endregion
  2779. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2780. }
  2781. /// <summary>
  2782. /// 团组增减款项操作(Status:1.新增,2.修改)
  2783. /// </summary>
  2784. /// <param name="dto"></param>
  2785. /// <returns></returns>
  2786. [HttpPost]
  2787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2788. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2789. {
  2790. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2791. if (groupData.Code != 200)
  2792. {
  2793. return Ok(JsonView(false, groupData.Msg));
  2794. }
  2795. #region 应用推送
  2796. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2797. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2798. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2799. #endregion
  2800. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2801. }
  2802. /// <summary>
  2803. /// 团组增减款项操作 删除
  2804. /// </summary>
  2805. /// <param name="dto"></param>
  2806. /// <returns></returns>
  2807. [HttpPost]
  2808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2809. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2810. {
  2811. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2812. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2813. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2814. if (res.Code == 0)
  2815. {
  2816. return Ok(JsonView(true, "删除成功!"));
  2817. }
  2818. return Ok(JsonView(false, "删除失败!"));
  2819. }
  2820. /// <summary>
  2821. /// 根据团组增减款项Id查询
  2822. /// </summary>
  2823. /// <param name="dto"></param>
  2824. /// <returns></returns>
  2825. [HttpPost]
  2826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2827. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2828. {
  2829. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2830. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2831. }
  2832. /// <summary>
  2833. /// 查询供应商名称
  2834. /// </summary>
  2835. /// <param name="dto"></param>
  2836. /// <returns></returns>
  2837. [HttpPost]
  2838. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2839. {
  2840. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2841. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2842. ?? new List<Grp_DecreasePayments>();
  2843. dbResult = dbResult.Distinct(new
  2844. ProductComparer()).ToList();
  2845. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2846. {
  2847. x.Id,
  2848. x.SupplierAddress,
  2849. x.SupplierArea,
  2850. x.SupplierContact,
  2851. x.SupplierContactNumber,
  2852. x.SupplierEmail,
  2853. x.SupplierName,
  2854. x.SupplierSocialAccount,
  2855. x.SupplierTypeId,
  2856. }).ToList());
  2857. return Ok(jw);
  2858. }
  2859. #endregion
  2860. #region 文件上传、删除
  2861. /// <summary>
  2862. /// region 文件上传 可以带参数
  2863. /// </summary>
  2864. /// <param name="file"></param>
  2865. /// <returns></returns>
  2866. [HttpPost]
  2867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2868. public async Task<IActionResult> UploadProject(IFormFile file)
  2869. {
  2870. try
  2871. {
  2872. var TypeName = Request.Headers["TypeName"].ToString();
  2873. if (file != null)
  2874. {
  2875. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2876. //文件名称
  2877. string projectFileName = file.FileName;
  2878. //上传的文件的路径
  2879. string filePath = "";
  2880. if (TypeName == "A")//A代表团组增减款项
  2881. {
  2882. if (!Directory.Exists(fileDir))
  2883. {
  2884. Directory.CreateDirectory(fileDir);
  2885. }
  2886. //上传的文件的路径
  2887. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2888. }
  2889. else if (TypeName == "B")//B代表商邀相关文件
  2890. {
  2891. if (!Directory.Exists(fileDir))
  2892. {
  2893. Directory.CreateDirectory(fileDir);
  2894. }
  2895. //上传的文件的路径
  2896. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2897. }
  2898. using (FileStream fs = System.IO.File.Create(filePath))
  2899. {
  2900. file.CopyTo(fs);
  2901. fs.Flush();
  2902. }
  2903. return Ok(JsonView(true, "上传成功!", projectFileName));
  2904. }
  2905. else
  2906. {
  2907. return Ok(JsonView(false, "上传失败!"));
  2908. }
  2909. }
  2910. catch (Exception ex)
  2911. {
  2912. return Ok(JsonView(false, "程序错误!"));
  2913. throw;
  2914. }
  2915. }
  2916. /// <summary>
  2917. /// 删除指定文件
  2918. /// </summary>
  2919. /// <param name="dto"></param>
  2920. /// <returns></returns>
  2921. [HttpPost]
  2922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2923. public async Task<IActionResult> DelFile(DelFileDto dto)
  2924. {
  2925. try
  2926. {
  2927. var TypeName = Request.Headers["TypeName"].ToString();
  2928. string filePath = "";
  2929. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2930. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2931. int id = 0;
  2932. if (TypeName == "A")
  2933. {
  2934. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2935. // 删除该文件
  2936. System.IO.File.Delete(filePath);
  2937. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2938. }
  2939. else if (TypeName == "B")
  2940. {
  2941. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2942. // 删除该文件
  2943. System.IO.File.Delete(filePath);
  2944. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2945. }
  2946. if (id != 0)
  2947. {
  2948. return Ok(JsonView(true, "成功!"));
  2949. }
  2950. else
  2951. {
  2952. return Ok(JsonView(false, "失败!"));
  2953. }
  2954. }
  2955. catch (Exception ex)
  2956. {
  2957. return Ok(JsonView(false, "程序错误!"));
  2958. throw;
  2959. }
  2960. }
  2961. #endregion
  2962. #region 商邀费用录入
  2963. /// <summary>
  2964. /// 根据团组Id查询商邀费用列表
  2965. /// </summary>
  2966. /// <param name="dto"></param>
  2967. /// <returns></returns>
  2968. [HttpPost]
  2969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2970. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2971. {
  2972. try
  2973. {
  2974. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2975. if (groupData.Code != 0)
  2976. {
  2977. return Ok(JsonView(false, groupData.Msg));
  2978. }
  2979. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2980. }
  2981. catch (Exception ex)
  2982. {
  2983. return Ok(JsonView(false, "程序错误!"));
  2984. throw;
  2985. }
  2986. }
  2987. //
  2988. /// <summary>
  2989. /// 商邀费用 Info Page 基础数据源
  2990. /// </summary>
  2991. /// <param name="dto"></param>
  2992. /// <returns></returns>
  2993. [HttpPost]
  2994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2995. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2996. {
  2997. try
  2998. {
  2999. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3000. if (groupData.Code != 0)
  3001. {
  3002. return Ok(JsonView(false, groupData.Msg));
  3003. }
  3004. return Ok(JsonView(true, "操作成功", groupData.Data));
  3005. }
  3006. catch (Exception ex)
  3007. {
  3008. return Ok(JsonView(false, ex.Message));
  3009. throw;
  3010. }
  3011. }
  3012. /// <summary>
  3013. /// 根据商邀费用ID查询C表和商邀费用数据
  3014. /// </summary>
  3015. /// <param name="dto"></param>
  3016. /// <returns></returns>
  3017. [HttpPost]
  3018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3019. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3020. {
  3021. try
  3022. {
  3023. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3024. if (groupData.Code != 0)
  3025. {
  3026. return Ok(JsonView(false, groupData.Msg));
  3027. }
  3028. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3029. }
  3030. catch (Exception ex)
  3031. {
  3032. return Ok(JsonView(false, ex.Message));
  3033. throw;
  3034. }
  3035. }
  3036. /// <summary>
  3037. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3038. /// </summary>
  3039. /// <param name="dto"></param>
  3040. /// <returns></returns>
  3041. [HttpPost]
  3042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3043. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3044. {
  3045. try
  3046. {
  3047. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3048. if (groupData.Code != 0)
  3049. {
  3050. return Ok(JsonView(false, groupData.Msg));
  3051. }
  3052. #region 应用推送
  3053. try
  3054. {
  3055. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3056. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3057. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3058. }
  3059. catch (Exception ex)
  3060. {
  3061. }
  3062. #endregion
  3063. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3064. }
  3065. catch (Exception ex)
  3066. {
  3067. return Ok(JsonView(false, "程序错误!"));
  3068. throw;
  3069. }
  3070. }
  3071. /// <summary>
  3072. /// 商邀删除
  3073. /// </summary>
  3074. /// <param name="dto"></param>
  3075. /// <returns></returns>
  3076. [HttpPost]
  3077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3078. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3079. {
  3080. try
  3081. {
  3082. _sqlSugar.BeginTran();
  3083. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3084. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3085. {
  3086. IsDel = 1,
  3087. DeleteUserId = dto.DeleteUserId,
  3088. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3089. })
  3090. .Where(it => it.Id == dto.Id)
  3091. .ExecuteCommand();
  3092. if (res1 > 0)
  3093. {
  3094. int _diId = 0;
  3095. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3096. if (_ioaInfo != null)
  3097. {
  3098. _diId = _ioaInfo.DiId;
  3099. }
  3100. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3101. .SetColumns(a => new Grp_CreditCardPayment()
  3102. {
  3103. IsDel = 1,
  3104. DeleteUserId = dto.DeleteUserId,
  3105. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3106. })
  3107. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3108. .ExecuteCommand();
  3109. if (res2 > 0)
  3110. {
  3111. _sqlSugar.CommitTran();
  3112. return Ok(JsonView(true, "删除成功!"));
  3113. }
  3114. }
  3115. _sqlSugar.RollbackTran();
  3116. return Ok(JsonView(false, "删除失败"));
  3117. }
  3118. catch (Exception ex)
  3119. {
  3120. _sqlSugar.RollbackTran();
  3121. return Ok(JsonView(false, ex.Message));
  3122. }
  3123. }
  3124. #endregion
  3125. #region 团组英文资料
  3126. /// <summary>
  3127. /// 查询团组英文所有资料
  3128. /// </summary>
  3129. /// <param name="dto"></param>
  3130. /// <returns></returns>
  3131. [HttpPost]
  3132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3133. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3134. {
  3135. try
  3136. {
  3137. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3138. if (groupData.Code != 0)
  3139. {
  3140. return Ok(JsonView(false, groupData.Msg));
  3141. }
  3142. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3143. }
  3144. catch (Exception ex)
  3145. {
  3146. return Ok(JsonView(false, "程序错误!"));
  3147. throw;
  3148. }
  3149. }
  3150. /// <summary>
  3151. /// 团组英文资料操作(Status:1.新增,2.修改)
  3152. /// </summary>
  3153. /// <param name="dto"></param>
  3154. /// <returns></returns>
  3155. [HttpPost]
  3156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3157. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3158. {
  3159. try
  3160. {
  3161. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3162. if (groupData.Code != 0)
  3163. {
  3164. return Ok(JsonView(false, groupData.Msg));
  3165. }
  3166. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3167. }
  3168. catch (Exception ex)
  3169. {
  3170. return Ok(JsonView(false, "程序错误!"));
  3171. throw;
  3172. }
  3173. }
  3174. /// <summary>
  3175. /// 团组英文资料Id查询数据
  3176. /// </summary>
  3177. /// <param name="dto"></param>
  3178. /// <returns></returns>
  3179. [HttpPost]
  3180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3181. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3182. {
  3183. try
  3184. {
  3185. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3186. if (_DelegationEnData != null)
  3187. {
  3188. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3189. }
  3190. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3191. }
  3192. catch (Exception ex)
  3193. {
  3194. return Ok(JsonView(false, "程序错误!"));
  3195. throw;
  3196. }
  3197. }
  3198. /// <summary>
  3199. /// 团组英文资料删除
  3200. /// </summary>
  3201. /// <param name="dto"></param>
  3202. /// <returns></returns>
  3203. [HttpPost]
  3204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3205. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3206. {
  3207. try
  3208. {
  3209. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3210. if (!res)
  3211. {
  3212. return Ok(JsonView(false, "删除失败"));
  3213. }
  3214. return Ok(JsonView(true, "删除成功!"));
  3215. }
  3216. catch (Exception ex)
  3217. {
  3218. return Ok(JsonView(false, "程序错误!"));
  3219. throw;
  3220. }
  3221. }
  3222. #endregion
  3223. #region 导出邀请函
  3224. /// <summary>
  3225. /// 导出邀请函页面初始化
  3226. /// </summary>
  3227. /// <param name="dto"></param>
  3228. /// <returns></returns>
  3229. [HttpPost]
  3230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3231. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3232. {
  3233. try
  3234. {
  3235. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3236. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3237. if (dto.DiId == 0)
  3238. {
  3239. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3240. }
  3241. else
  3242. {
  3243. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3244. }
  3245. return Ok(JsonView(true, "查询成功!", new
  3246. {
  3247. deleClient = crm_Deles,
  3248. delegations = grp_Delegations
  3249. }));
  3250. }
  3251. catch (Exception ex)
  3252. {
  3253. return Ok(JsonView(false, "程序错误!"));
  3254. throw;
  3255. }
  3256. }
  3257. /// <summary>
  3258. /// 导出邀请函
  3259. /// </summary>
  3260. /// <param name="dto"></param>
  3261. /// <returns></returns>
  3262. [HttpPost]
  3263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3264. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3265. {
  3266. #region 参数验证
  3267. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3268. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3269. #endregion
  3270. try
  3271. {
  3272. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3273. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3274. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3275. From Grp_TourClientList tcl
  3276. Left Join
  3277. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3278. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3279. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3280. From Crm_DeleClient dc
  3281. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3282. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3283. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3284. Where dc.IsDel = 0) temp
  3285. On temp.DcId =tcl.ClientId
  3286. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3287. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3288. List<string> texts = new List<string>();
  3289. if (datas.Count != 0)
  3290. {
  3291. foreach (TourClientListDetailsView item in datas)
  3292. {
  3293. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3294. {
  3295. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3296. }
  3297. else
  3298. {
  3299. string name = item.LastName + item.FirstName;
  3300. texts.Add(name);
  3301. }
  3302. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3303. {
  3304. if (!transDic.ContainsKey(item.Job))
  3305. {
  3306. texts.Add(item.Job);
  3307. }
  3308. }
  3309. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3310. {
  3311. texts.Add(item.CompanyFullName);
  3312. }
  3313. }
  3314. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3315. if (transData.Count > 0)
  3316. {
  3317. foreach (TranslateResult item in transData)
  3318. {
  3319. if (!transDic.ContainsKey(item.Query))
  3320. {
  3321. transDic.Add(item.Query, item.Translation);
  3322. }
  3323. }
  3324. }
  3325. List<GuestList> list = new List<GuestList>();
  3326. foreach (TourClientListDetailsView dele in datas)
  3327. {
  3328. GuestList guestList = new GuestList();
  3329. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3330. {
  3331. guestList.Name = dele.Pinyin;
  3332. }
  3333. else
  3334. {
  3335. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3336. guestList.Name = Name;
  3337. }
  3338. if (dele.Sex == 0)
  3339. {
  3340. guestList.Sex = "Male";
  3341. }
  3342. else if (dele.Sex == 1)
  3343. {
  3344. guestList.Sex = "Female";
  3345. }
  3346. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3347. if (!string.IsNullOrEmpty(dele.Job))
  3348. {
  3349. guestList.Job = dele.Job;
  3350. }
  3351. list.Add(guestList);
  3352. }
  3353. //载入模板
  3354. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3355. DocumentBuilder builder = new DocumentBuilder(doc);
  3356. //获取word里所有表格
  3357. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3358. //获取所填表格的序数
  3359. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3360. var rowStart = tableOne.Rows[0]; //获取第1行
  3361. //循环赋值
  3362. for (int i = 0; i < list.Count; i++)
  3363. {
  3364. builder.MoveToCell(0, i + 1, 0, 0);
  3365. builder.Write(list[i].Name.ToString());
  3366. builder.MoveToCell(0, i + 1, 1, 0);
  3367. builder.Write(list[i].Sex.ToString());
  3368. builder.MoveToCell(0, i + 1, 2, 0);
  3369. builder.Write(list[i].DOB.ToString());
  3370. builder.MoveToCell(0, i + 1, 3, 0);
  3371. builder.Write(list[i].Job.ToString());
  3372. }
  3373. //删除多余行
  3374. while (tableOne.Rows.Count > list.Count + 1)
  3375. {
  3376. tableOne.Rows.RemoveAt(list.Count + 1);
  3377. }
  3378. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3379. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3380. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3381. doc.Save(filePath);
  3382. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3383. return Ok(JsonView(true, "操作成功!", Url));
  3384. }
  3385. else
  3386. {
  3387. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3388. }
  3389. }
  3390. catch (Exception ex)
  3391. {
  3392. return Ok(JsonView(false, ex.Message));
  3393. throw;
  3394. }
  3395. }
  3396. #endregion
  3397. #region 团组经理模块 出入境费用
  3398. ///// <summary>
  3399. ///// 团组模块 - 出入境费用
  3400. ///// </summary>
  3401. ///// <returns></returns>
  3402. //[HttpPost]
  3403. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3404. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3405. //{
  3406. // try
  3407. // {
  3408. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3409. // if (data.Code != 0)
  3410. // {
  3411. // return Ok(JsonView(false, data.Msg));
  3412. // }
  3413. // return Ok(JsonView(true, "查询成功!"));
  3414. // }
  3415. // catch (Exception ex)
  3416. // {
  3417. // return Ok(JsonView(false, ex.Message));
  3418. // throw;
  3419. // }
  3420. //}
  3421. /// <summary>
  3422. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3423. /// </summary>
  3424. /// <returns></returns>
  3425. [HttpPost]
  3426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3427. public async Task<IActionResult> SetDayAndCostAreaChange()
  3428. {
  3429. try
  3430. {
  3431. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3432. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3433. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3434. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3435. foreach (var item in unite) //处理交集数据
  3436. {
  3437. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3438. }
  3439. foreach (var item in merge) //处理差集数据
  3440. {
  3441. int nationalTravelFeeId = 0;
  3442. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3443. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3444. else
  3445. {
  3446. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3447. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3448. }
  3449. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3450. }
  3451. //只更新dayAndCost 的 nationalTravelFeeId;
  3452. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3453. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3454. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3455. }
  3456. catch (Exception ex)
  3457. {
  3458. return Ok(JsonView(false, ex.Message));
  3459. throw;
  3460. }
  3461. }
  3462. /// <summary>
  3463. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3464. /// </summary>
  3465. /// <returns></returns>
  3466. [HttpPost]
  3467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3468. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3469. {
  3470. try
  3471. {
  3472. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3473. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3474. //SetDataInfoView
  3475. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3476. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3477. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3478. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3479. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3480. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3481. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3482. //默认币种显示
  3483. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3484. {
  3485. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3486. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3487. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3488. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3489. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3490. };
  3491. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3492. if (_currencyRate.Count > 0)
  3493. {
  3494. foreach (var item in _currencyInfos)
  3495. {
  3496. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3497. if (rateInfo != null)
  3498. {
  3499. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3500. rate1 *= 1.035M;
  3501. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3502. }
  3503. }
  3504. }
  3505. return Ok(JsonView(true, "查询成功!", new
  3506. {
  3507. GroupNameData = groupNameData.Data,
  3508. CurrencyData = _CurrencyData,
  3509. WordTypeData = _WordTypeData,
  3510. ExcelTypeData = _ExcelTypeData,
  3511. CurrencyInit = _currencyInfos
  3512. }));
  3513. }
  3514. catch (Exception ex)
  3515. {
  3516. return Ok(JsonView(false, ex.Message));
  3517. throw;
  3518. }
  3519. }
  3520. /// <summary>
  3521. /// 团组模块 - 出入境费用
  3522. /// 实时汇率 tips
  3523. /// 签证费用 tips
  3524. /// </summary>
  3525. /// <returns></returns>
  3526. [HttpPost]
  3527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3528. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3529. {
  3530. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3531. //默认币种显示
  3532. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3533. {
  3534. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3535. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3536. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3537. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3538. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3539. };
  3540. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3541. List<dynamic> reteInfos = new List<dynamic>();
  3542. if (_currencyRate.Count > 0)
  3543. {
  3544. foreach (var item in _currencyInfos)
  3545. {
  3546. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3547. if (rateInfo != null)
  3548. {
  3549. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3550. decimal rate1 = item.Rate;
  3551. rate1 *= 1.03M;
  3552. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3553. reteInfos.Add(new
  3554. {
  3555. currCode = item.CurrencyCode,
  3556. currName = item.CurrencyName,
  3557. rate = rate2,
  3558. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3559. });
  3560. }
  3561. }
  3562. }
  3563. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3564. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3565. return Ok(JsonView(true, "查询成功!", new
  3566. {
  3567. //GroupNameData = groupNameData.Data,
  3568. visaData = visaData.Data,
  3569. airData = airData.Data,
  3570. reteInfos = reteInfos
  3571. }));
  3572. }
  3573. /// <summary>
  3574. /// 团组模块 - 出入境费用 - Info
  3575. /// </summary>
  3576. /// <returns></returns>
  3577. [HttpPost]
  3578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3579. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3580. {
  3581. try
  3582. {
  3583. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3584. if (data.Code != 0)
  3585. {
  3586. return Ok(JsonView(false, data.Msg));
  3587. }
  3588. return Ok(JsonView(true, "查询成功!", data.Data));
  3589. }
  3590. catch (Exception ex)
  3591. {
  3592. return Ok(JsonView(false, ex.Message));
  3593. }
  3594. }
  3595. /// <summary>
  3596. /// 团组模块 - 出入境费用 - Add And Update
  3597. /// </summary>
  3598. /// <returns></returns>
  3599. [HttpPost]
  3600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3601. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3602. {
  3603. try
  3604. {
  3605. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3606. if (data.Code != 0)
  3607. {
  3608. return Ok(JsonView(false, data.Msg));
  3609. }
  3610. //生成默认文件pdf并且通知人员
  3611. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3612. {
  3613. DiId = dto.DiId,
  3614. ExportType = 1,
  3615. SubTypeId = 1005
  3616. }, "pdf");
  3617. //发送通知
  3618. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3619. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3620. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3621. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3622. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","5","233" }, dto.UserId, url);
  3623. return Ok(JsonView(true, data.Msg, data.Data));
  3624. }
  3625. catch (Exception ex)
  3626. {
  3627. return Ok(JsonView(false, ex.Message));
  3628. }
  3629. }
  3630. /// <summary>
  3631. /// 团组模块 - 出入境费用 - Confirm 费用
  3632. /// </summary>
  3633. /// <returns></returns>
  3634. [HttpPost]
  3635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3636. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3637. {
  3638. //TODO:测试完毕需把对应的用户ID更改
  3639. //1、数据表添加字段
  3640. //2、更改字段接口()
  3641. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3642. //3、确认成功 给财务发送消息
  3643. if (_view.Code == 200)
  3644. {
  3645. if (dto.Type == 1)
  3646. {
  3647. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3648. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3649. }
  3650. }
  3651. return Ok(_view);
  3652. }
  3653. /// <summary>
  3654. /// 团组模块 - 出入境费用 - File downlaod
  3655. /// </summary>
  3656. /// <param name="dto"></param>
  3657. /// <returns></returns>
  3658. [HttpPost]
  3659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3660. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3661. {
  3662. try
  3663. {
  3664. if (dto.DiId < 1)
  3665. {
  3666. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3667. }
  3668. if (dto.ExportType < 1)
  3669. {
  3670. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3671. }
  3672. if (dto.SubTypeId < 1)
  3673. {
  3674. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3675. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3676. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3677. 3 团组成员名单 1 团组成员名单"));
  3678. }
  3679. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3680. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3681. if (_EnterExitCosts == null)
  3682. {
  3683. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3684. }
  3685. //数据源
  3686. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3687. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3688. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3689. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3690. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3691. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3692. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3693. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3694. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3695. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3696. .Select((tcl, dc, cc) => new
  3697. {
  3698. Name = dc.LastName + dc.FirstName,
  3699. Sex = dc.Sex,
  3700. Birthday = dc.BirthDay,
  3701. Company = cc.CompanyFullName,
  3702. Job = dc.Job
  3703. })
  3704. .ToList();
  3705. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3706. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3707. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3708. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3709. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3710. if (dto.ExportType == 1) //明细表
  3711. {
  3712. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3713. {
  3714. //获取模板
  3715. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3716. //载入模板
  3717. Document doc = new Document(tempPath);
  3718. DocumentBuilder builder = new DocumentBuilder(doc);
  3719. //利用键值对存放数据
  3720. Dictionary<string, string> dic = new Dictionary<string, string>();
  3721. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3722. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3723. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3724. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3725. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3726. string row1_1 = "";
  3727. if (_EnterExitCosts.Visa > 0)
  3728. {
  3729. //insidePayTotal += _EnterExitCosts.Visa;
  3730. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3731. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3732. {
  3733. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3734. }
  3735. }
  3736. string row1_2 = "";
  3737. if (_EnterExitCosts.YiMiao > 0)
  3738. {
  3739. //insidePayTotal += _EnterExitCosts.YiMiao;
  3740. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3741. }
  3742. if (_EnterExitCosts.HeSuan > 0)
  3743. {
  3744. //insidePayTotal += _EnterExitCosts.HeSuan;
  3745. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3746. }
  3747. if (_EnterExitCosts.Service > 0)
  3748. {
  3749. //insidePayTotal += _EnterExitCosts.Service;
  3750. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3751. }
  3752. string row1_3 = "";
  3753. if (_EnterExitCosts.Safe > 0)
  3754. {
  3755. //insidePayTotal += _EnterExitCosts.Safe;
  3756. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3757. }
  3758. if (_EnterExitCosts.Ticket > 0)
  3759. {
  3760. //insidePayTotal += _EnterExitCosts.Ticket;
  3761. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3762. }
  3763. string row1 = "";
  3764. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3765. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3766. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3767. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3768. dic.Add("Row1Str", row1);
  3769. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3770. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3771. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3772. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3773. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3774. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3775. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3776. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3777. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3778. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3779. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3780. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3781. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3782. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3783. #region 填充word模板书签内容
  3784. foreach (var key in dic.Keys)
  3785. {
  3786. builder.MoveToBookmark(key);
  3787. builder.Write(dic[key]);
  3788. }
  3789. #endregion
  3790. #region 填充word表格内容
  3791. ////获读取指定表格方法二
  3792. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3793. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3794. for (int i = 0; i < dac1.Count; i++)
  3795. {
  3796. Grp_DayAndCost dac = dac1[i];
  3797. if (dac == null) continue;
  3798. builder.MoveToCell(0, i, 0, 0);
  3799. builder.Write("第" + dac.Days.ToString() + "晚:");
  3800. builder.MoveToCell(0, i, 1, 0);
  3801. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3802. //builder.Write(dac.Place == null ? "" : dac.Place);
  3803. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3804. builder.MoveToCell(0, i, 2, 0);
  3805. builder.Write("费用标准:");
  3806. string curr = "";
  3807. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3808. if (currData != null)
  3809. {
  3810. curr = currData.Name;
  3811. }
  3812. builder.MoveToCell(0, i, 3, 0);
  3813. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3814. builder.MoveToCell(0, i, 4, 0);
  3815. builder.Write("费用小计:");
  3816. builder.MoveToCell(0, i, 5, 0);
  3817. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3818. }
  3819. //删除多余行
  3820. while (table1.Rows.Count > dac1.Count)
  3821. {
  3822. table1.Rows.RemoveAt(dac1.Count);
  3823. }
  3824. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3825. for (int i = 0; i < dac2.Count; i++)
  3826. {
  3827. Grp_DayAndCost dac = dac2[i];
  3828. if (dac == null) continue;
  3829. builder.MoveToCell(1, i, 0, 0);
  3830. builder.Write("第" + dac.Days.ToString() + "天:");
  3831. builder.MoveToCell(1, i, 1, 0);
  3832. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3833. builder.MoveToCell(1, i, 2, 0);
  3834. builder.Write("费用标准:");
  3835. string curr = "";
  3836. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3837. if (currData != null)
  3838. {
  3839. curr = currData.Name;
  3840. }
  3841. builder.MoveToCell(1, i, 3, 0);
  3842. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3843. builder.MoveToCell(1, i, 4, 0);
  3844. builder.Write("费用小计:");
  3845. builder.MoveToCell(1, i, 5, 0);
  3846. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3847. }
  3848. //删除多余行
  3849. while (table2.Rows.Count > dac2.Count)
  3850. {
  3851. table2.Rows.RemoveAt(dac2.Count);
  3852. }
  3853. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3854. for (int i = 0; i < dac3.Count; i++)
  3855. {
  3856. Grp_DayAndCost dac = dac3[i];
  3857. if (dac == null) continue;
  3858. builder.MoveToCell(2, i, 0, 0);
  3859. builder.Write("第" + dac.Days.ToString() + "天:");
  3860. builder.MoveToCell(2, i, 1, 0);
  3861. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3862. builder.MoveToCell(2, i, 2, 0);
  3863. builder.Write("费用标准:");
  3864. string curr = "";
  3865. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3866. if (currData != null)
  3867. {
  3868. curr = currData.Name;
  3869. }
  3870. builder.MoveToCell(2, i, 3, 0);
  3871. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3872. builder.MoveToCell(2, i, 4, 0);
  3873. builder.Write("费用小计:");
  3874. builder.MoveToCell(2, i, 5, 0);
  3875. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3876. }
  3877. //删除多余行
  3878. while (table3.Rows.Count > dac3.Count)
  3879. {
  3880. table3.Rows.RemoveAt(dac3.Count);
  3881. }
  3882. #endregion
  3883. //文件名
  3884. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3885. AsposeHelper.removewatermark_v2180();
  3886. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3887. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3888. return Ok(JsonView(true, "成功", new { Url = url }));
  3889. }
  3890. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3891. {
  3892. //获取模板
  3893. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3894. //载入模板
  3895. Document doc = new Document(tempPath);
  3896. DocumentBuilder builder = new DocumentBuilder(doc);
  3897. Dictionary<string, string> dic = new Dictionary<string, string>();
  3898. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3899. {
  3900. List<string> list = new List<string>();
  3901. try
  3902. {
  3903. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3904. foreach (var item in spilitArr)
  3905. {
  3906. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3907. var depCode = spDotandEmpty[2].Substring(0, 3);
  3908. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3909. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3910. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3911. list.Add(depName);
  3912. list.Add(arrName);
  3913. }
  3914. list = list.Distinct().ToList();
  3915. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3916. }
  3917. catch (Exception)
  3918. {
  3919. dic.Add("ReturnCode", "行程录入不正确!");
  3920. }
  3921. }
  3922. else
  3923. {
  3924. dic.Add("ReturnCode", "未录入行程!");
  3925. }
  3926. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3927. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3928. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3929. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3930. {
  3931. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3932. dic.Add("Day", sp.Days.ToString());
  3933. }
  3934. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3935. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3936. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3937. //dic.Add("Names", Names);
  3938. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3939. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3940. decimal dac1totalPrice = 0.00M;
  3941. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3942. foreach (var dac in dac1)
  3943. {
  3944. if (dac.SubTotal == 0.00M)
  3945. {
  3946. continue;
  3947. }
  3948. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3949. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3950. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3951. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3952. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3953. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3954. builder.Write(currency);//币种
  3955. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3956. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3957. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3958. builder.Write("");//人数
  3959. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3960. builder.Write("");//天数
  3961. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3962. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3963. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3964. decimal rate = 0.00M;
  3965. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3966. builder.Write(rate.ToString("#0.0000"));//汇率
  3967. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3968. decimal rbmPrice = dac.SubTotal;
  3969. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3970. accommodationStartIndex++;
  3971. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3972. }
  3973. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3974. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3975. {
  3976. table1.Rows.RemoveAt(i - 1);
  3977. foodandotherStartIndex--;
  3978. }
  3979. if (dac2.Count == dac3.Count)//国家 币种 金额
  3980. {
  3981. for (int i = 0; i < dac2.Count; i++)
  3982. {
  3983. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3984. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3985. }
  3986. }
  3987. decimal dac2totalPrice = 0.00M;
  3988. foreach (var dac in dac2)
  3989. {
  3990. if (dac.SubTotal == 0)
  3991. {
  3992. continue;
  3993. }
  3994. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3995. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3996. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3997. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3998. builder.Write(currency);//币种
  3999. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4000. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4001. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4002. builder.Write("");//人数
  4003. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4004. builder.Write("");//天数
  4005. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4006. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4007. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4008. decimal rate = 0.00M;
  4009. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4010. builder.Write(rate.ToString("#0.0000"));//汇率
  4011. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4012. decimal rbmPrice = dac.SubTotal;
  4013. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4014. foodandotherStartIndex++;
  4015. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4016. }
  4017. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4018. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4019. {
  4020. table1.Rows.RemoveAt(i - 1);
  4021. }
  4022. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4023. string otherFeeStr = "";
  4024. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4025. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4026. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4027. if (otherFeeStr.Length > 0)
  4028. {
  4029. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4030. otherFeeStr = $"({otherFeeStr})";
  4031. dic.Add("OtherFeeStr", otherFeeStr);
  4032. }
  4033. //总计
  4034. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4035. //国际旅费
  4036. string outsideJJ = "";
  4037. string allPriceJJ = "";
  4038. if (_EnterExitCosts.SumJJC == 1)
  4039. {
  4040. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4041. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4042. }
  4043. string outsideGW = "";
  4044. string allPriceGW = "";
  4045. if (_EnterExitCosts.SumGWC == 1)
  4046. {
  4047. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  4048. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4049. }
  4050. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  4051. {
  4052. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4053. dic.Add("InTravelPrice", InTravelPriceStr);
  4054. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4055. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4056. }
  4057. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4058. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4059. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4060. foreach (var key in dic.Keys)
  4061. {
  4062. builder.MoveToBookmark(key);
  4063. builder.Write(dic[key]);
  4064. }
  4065. //模板文件名
  4066. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4067. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4068. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4069. return Ok(JsonView(true, "成功", new { Url = url }));
  4070. }
  4071. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4072. {
  4073. //获取模板
  4074. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4075. //载入模板
  4076. WorkbookDesigner designer = new WorkbookDesigner();
  4077. designer.Workbook = new Workbook(tempPath);
  4078. Dictionary<string, string> dic = new Dictionary<string, string>();
  4079. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4080. {
  4081. List<string> list = new List<string>();
  4082. try
  4083. {
  4084. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4085. foreach (var item in spilitArr)
  4086. {
  4087. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4088. var depCode = spDotandEmpty[2].Substring(0, 3);
  4089. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4090. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4091. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4092. list.Add(depName);
  4093. list.Add(arrName);
  4094. }
  4095. list = list.Distinct().ToList();
  4096. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4097. }
  4098. catch (Exception)
  4099. {
  4100. dic.Add("ReturnCode", "行程录入不正确!");
  4101. }
  4102. }
  4103. else
  4104. {
  4105. dic.Add("ReturnCode", "未录入行程!");
  4106. }
  4107. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4108. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4109. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4110. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4111. {
  4112. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4113. dic.Add("Day", sp.Days.ToString());
  4114. }
  4115. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4116. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4117. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4118. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4119. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4120. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4121. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4122. designer.SetDataSource("Name", Names);
  4123. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4124. designer.SetDataSource("Day", dic["Day"] + "天");
  4125. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4126. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4127. int startIndex = 10;
  4128. const int startIndexcopy = 10;
  4129. if (dac2.Count == dac3.Count)//国家 币种 金额
  4130. {
  4131. for (int i = 0; i < dac2.Count; i++)
  4132. {
  4133. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4134. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4135. }
  4136. }
  4137. DataTable dtdac1 = new DataTable();
  4138. List<string> place = new List<string>();
  4139. dtdac1.Columns.AddRange(new DataColumn[] {
  4140. new DataColumn(){ ColumnName = "city"},
  4141. new DataColumn(){ ColumnName = "curr"},
  4142. new DataColumn(){ ColumnName = "criterion"},
  4143. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4144. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4145. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4146. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4147. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4148. });
  4149. DataTable dtdac2 = new DataTable();
  4150. dtdac2.Columns.AddRange(new DataColumn[] {
  4151. new DataColumn(){ ColumnName = "city"},
  4152. new DataColumn(){ ColumnName = "curr"},
  4153. new DataColumn(){ ColumnName = "criterion"},
  4154. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4155. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4156. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4157. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4158. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4159. });
  4160. dtdac1.TableName = "tb1";
  4161. dtdac2.TableName = "tb2";
  4162. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4163. foreach (var item in dac1)
  4164. {
  4165. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4166. if (place.Contains(item.Place))
  4167. {
  4168. continue;
  4169. }
  4170. DataRow row = dtdac1.NewRow();
  4171. row["city"] = item.Place;
  4172. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4173. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4174. row["curr"] = currency;
  4175. row["rate"] = rate.ToString("#0.0000");
  4176. row["criterion"] = item.Cost.ToString("#0.00");
  4177. row["number"] = 1;
  4178. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4179. //row["costRMB"] = rbmPrice;
  4180. dtdac1.Rows.Add(row);
  4181. place.Add(item.Place);
  4182. }
  4183. place = new List<string>();
  4184. foreach (var item in dac2)
  4185. {
  4186. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4187. if (place.Contains(item.Place))
  4188. {
  4189. continue;
  4190. }
  4191. DataRow row = dtdac2.NewRow();
  4192. row["city"] = item.Place;
  4193. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4194. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4195. row["curr"] = currency;
  4196. row["rate"] = rate.ToString("#0.0000");
  4197. row["criterion"] = item.Cost.ToString("#0.00");
  4198. row["number"] = 1;
  4199. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4200. //row["cost"] = item.SubTotal;
  4201. //row["costRMB"] = rbmPrice;
  4202. dtdac2.Rows.Add(row);
  4203. place.Add(item.Place);
  4204. //dac2totalPrice += rbmPrice;
  4205. }
  4206. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4207. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4208. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4209. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4210. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4211. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4212. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4213. string cellStr = $" 5.其他费用(";
  4214. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4215. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4216. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4217. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4218. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4219. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4220. if (cellStr.Length > 8)
  4221. {
  4222. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4223. }
  4224. cellStr += ")";
  4225. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4226. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4227. decimal pxFee = dac4.Sum(it => it.Cost);
  4228. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4229. string celllastStr1 = "";
  4230. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4231. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4232. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4233. celllastStr1 += $",国际旅费 元";
  4234. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4235. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4236. designer.SetDataSource("cell4Str", cell4Str);
  4237. designer.SetDataSource("cellStr", cellStr);
  4238. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4239. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4240. designer.SetDataSource("celllastStr", celllastStr);
  4241. Workbook wb = designer.Workbook;
  4242. var sheet = wb.Worksheets[0];
  4243. //绑定datatable数据集
  4244. designer.SetDataSource(dtdac1);
  4245. designer.SetDataSource(dtdac2);
  4246. designer.Process();
  4247. var rowStart = dtdac1.Rows.Count;
  4248. while (rowStart > 0)
  4249. {
  4250. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4251. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4252. startIndex++;
  4253. rowStart--;
  4254. }
  4255. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4256. startIndex += 1; //总计行
  4257. rowStart = dtdac2.Rows.Count;
  4258. while (rowStart > 0)
  4259. {
  4260. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4261. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4262. startIndex++;
  4263. rowStart--;
  4264. }
  4265. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4266. wb.CalculateFormula(true);
  4267. //模板文件名
  4268. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4269. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4270. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4271. return Ok(JsonView(true, "成功", new { Url = url }));
  4272. }
  4273. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4274. {
  4275. //获取模板
  4276. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4277. //载入模板
  4278. Document doc = new Document(tempPath);
  4279. DocumentBuilder builder = new DocumentBuilder(doc);
  4280. Dictionary<string, string> dic = new Dictionary<string, string>();
  4281. dic.Add("GroupName", _DelegationInfo.TeamName);
  4282. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4283. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4284. string missionLeaderJob = "";//负责人job
  4285. int groupNumber = 0; //团人数
  4286. if (DeleClientList.Count > 0)
  4287. {
  4288. missionLeader = DeleClientList[0]?.Name ?? "";
  4289. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4290. }
  4291. dic.Add("MissionLeader", missionLeader); //团负责人
  4292. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4293. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4294. #region MyRegion
  4295. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4296. //{
  4297. // List<string> list = new List<string>();
  4298. // try
  4299. // {
  4300. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4301. // foreach (var item in spilitArr)
  4302. // {
  4303. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4304. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4305. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4306. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4307. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4308. // list.Add(depName);
  4309. // list.Add(arrName);
  4310. // }
  4311. // list = list.Distinct().ToList();
  4312. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4313. // }
  4314. // catch (Exception)
  4315. // {
  4316. // dic.Add("ReturnCode", "行程录入不正确!");
  4317. // }
  4318. //}
  4319. //else
  4320. //{
  4321. // dic.Add("ReturnCode", "未录入行程!");
  4322. //}
  4323. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4324. dic.Add("ReturnCode", string.Join("、", countrys));
  4325. #endregion
  4326. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4327. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4328. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4329. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4330. //{
  4331. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4332. // dic.Add("Day", sp.Days.ToString());
  4333. //}
  4334. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4335. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4336. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4337. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4338. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4339. //培训人员名单
  4340. int cultivateRowIndex = 7;
  4341. foreach (var item in DeleClientList)
  4342. {
  4343. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4344. builder.Write(item.Name);
  4345. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4346. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4347. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4348. string birthDay = "";
  4349. if (item.Birthday != null)
  4350. {
  4351. DateTime dt = Convert.ToDateTime(item.Birthday);
  4352. birthDay = $"{dt.Year}.{dt.Month}";
  4353. }
  4354. builder.Write(birthDay);
  4355. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4356. builder.Write(item.Company);
  4357. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4358. builder.Write(item.Job);
  4359. cultivateRowIndex++;
  4360. }
  4361. //删除多余行
  4362. //cultivateRowIndex -= 2;
  4363. int delRows = 10 + 7 - cultivateRowIndex;
  4364. if (delRows > 0)
  4365. {
  4366. for (int i = 0; i < delRows; i++)
  4367. {
  4368. table1.Rows.RemoveAt(cultivateRowIndex);
  4369. //cultivateRowIndex++;
  4370. }
  4371. }
  4372. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4373. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4374. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4375. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4376. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4377. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4378. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4379. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4380. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4381. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4382. //其他费用
  4383. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4384. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4385. //其他费用合计
  4386. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4387. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4388. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4389. //公务舱合计
  4390. //国际旅费
  4391. string outsideJJ = "";
  4392. string allPriceJJ = "";
  4393. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4394. {
  4395. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4396. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4397. }
  4398. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4399. {
  4400. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4401. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4402. }
  4403. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4404. {
  4405. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4406. dic.Add("AirFeeTotal", airFeeTotalStr);
  4407. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4408. dic.Add("FeeTotal", feeTotalStr);
  4409. }
  4410. foreach (var key in dic.Keys)
  4411. {
  4412. builder.MoveToBookmark(key);
  4413. builder.Write(dic[key]);
  4414. }
  4415. //模板文件名
  4416. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4417. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4418. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4419. return Ok(JsonView(true, "成功", new { Url = url }));
  4420. }
  4421. }
  4422. else if (dto.ExportType == 2) //表格
  4423. {
  4424. //利用键值对存放数据
  4425. Dictionary<string, string> dic = new Dictionary<string, string>();
  4426. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4427. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4428. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4429. dic.Add("Day", sp.Days.ToString());
  4430. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4431. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4432. {
  4433. //获取模板
  4434. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4435. //载入模板
  4436. Document doc = new Document(tempPath);
  4437. DocumentBuilder builder = new DocumentBuilder(doc);
  4438. dic.Add("TeamName", _DelegationInfo.TeamName);
  4439. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4440. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4441. string missionLeaderName = "",
  4442. missionLeaderJob = "";
  4443. if (DeleClientList.Count > 0)
  4444. {
  4445. missionLeaderName = DeleClientList[0].Name;
  4446. missionLeaderJob = DeleClientList[0].Job;
  4447. }
  4448. dic.Add("MissionLeaderName", missionLeaderName);
  4449. dic.Add("MissionLeaderJob", missionLeaderJob);
  4450. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4451. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4452. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4453. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4454. int rowCount = 10;//总人数行
  4455. int startRowIndex = 7; //起始行
  4456. for (int i = 0; i < DeleClientList.Count; i++)
  4457. {
  4458. builder.MoveToCell(0, startRowIndex, 0, 0);
  4459. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4460. builder.MoveToCell(0, startRowIndex, 1, 0);
  4461. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4462. builder.Write(sex);//性别
  4463. builder.MoveToCell(0, startRowIndex, 2, 0);
  4464. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4465. builder.MoveToCell(0, startRowIndex, 3, 0);
  4466. builder.Write(DeleClientList[i].Company);//工作单位
  4467. builder.MoveToCell(0, startRowIndex, 4, 0);
  4468. builder.Write(DeleClientList[i].Job);//职务及级别
  4469. builder.MoveToCell(0, startRowIndex, 5, 0);
  4470. builder.Write("");//人员属性
  4471. builder.MoveToCell(0, startRowIndex, 6, 0);
  4472. builder.Write("");//上次出国时间
  4473. startRowIndex++;
  4474. }
  4475. int nullRow = rowCount - DeleClientList.Count;//空行
  4476. for (int i = 0; i < nullRow; i++)
  4477. {
  4478. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4479. }
  4480. foreach (var key in dic.Keys)
  4481. {
  4482. builder.MoveToBookmark(key);
  4483. builder.Write(dic[key]);
  4484. }
  4485. //模板文件名
  4486. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4487. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4488. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4489. return Ok(JsonView(true, "成功", new { Url = url }));
  4490. }
  4491. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4492. {
  4493. //获取模板
  4494. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4495. //载入模板
  4496. Document doc = new Document(tempPath);
  4497. DocumentBuilder builder = new DocumentBuilder(doc);
  4498. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4499. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4500. dic.Add("Names", Names);
  4501. int accommodationRows = 12, foodandotherRows = 12;
  4502. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4503. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4504. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4505. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4506. int accommodationStartIndex = 6;
  4507. decimal dac1totalPrice = 0.00M;
  4508. foreach (var dac in dac1)
  4509. {
  4510. if (dac.SubTotal == 0)
  4511. {
  4512. continue;
  4513. }
  4514. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4515. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4516. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4517. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4518. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4519. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4520. builder.Write(currency);//币种
  4521. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4522. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4523. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4524. builder.Write("");//人数
  4525. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4526. builder.Write("");//天数
  4527. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4528. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4529. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4530. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4531. builder.Write(rate.ToString("#0.0000"));//汇率
  4532. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4533. decimal rbmPrice = rate * dac.SubTotal;
  4534. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4535. accommodationStartIndex++;
  4536. dac1totalPrice += rbmPrice;
  4537. }
  4538. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4539. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4540. builder.Write("小计");
  4541. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4542. builder.Write(dac1totalPrice.ToString("#0.00"));
  4543. accommodationStartIndex++;
  4544. int nullRow = accommodationRows - dac1.Count;
  4545. //删除空行
  4546. //if (nullRow > 0)
  4547. //{
  4548. // int rowIndex = accommodationStartIndex;
  4549. // for (int i = 0; i < nullRow; i++)
  4550. // {
  4551. // Row row = table1.Rows[rowIndex];
  4552. // row.Remove();
  4553. // rowIndex++;
  4554. // }
  4555. //}
  4556. if (dac2.Count == dac3.Count)//国家 币种 金额
  4557. {
  4558. for (int i = 0; i < dac2.Count; i++)
  4559. {
  4560. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4561. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4562. }
  4563. }
  4564. int foodandotherStartIndex = 19;//
  4565. decimal dac2totalPrice = 0.00M;
  4566. foreach (var dac in dac2)
  4567. {
  4568. if (dac.SubTotal == 0)
  4569. {
  4570. continue;
  4571. }
  4572. //foodandotherStartIndex = 12;
  4573. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4574. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4575. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4576. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4577. builder.Write(currency);//币种
  4578. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4579. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4580. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4581. builder.Write("");//人数
  4582. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4583. builder.Write("");//天数
  4584. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4585. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4586. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4587. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4588. builder.Write(rate.ToString("#0.0000"));//汇率
  4589. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4590. decimal rbmPrice = rate * dac.SubTotal;
  4591. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4592. foodandotherStartIndex++;
  4593. dac2totalPrice += rbmPrice;
  4594. }
  4595. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4596. //删除空行
  4597. if (dac2.Count < foodandotherRows)
  4598. {
  4599. //int nullRow = accommodationRows - dac2.Count;
  4600. //while (table2.Rows.Count > dac2.Count)
  4601. //{
  4602. // table2.Rows.RemoveAt(dac2.Count);
  4603. //}
  4604. }
  4605. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4606. string otherFeeStr = "";
  4607. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4608. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4609. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4610. if (otherFeeStr.Length > 0)
  4611. {
  4612. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4613. otherFeeStr = $"({otherFeeStr})";
  4614. dic.Add("OtherFeeStr", otherFeeStr);
  4615. }
  4616. foreach (var key in dic.Keys)
  4617. {
  4618. builder.MoveToBookmark(key);
  4619. builder.Write(dic[key]);
  4620. }
  4621. //模板文件名
  4622. string strFileName = $"省级单位出(境)经费报销单.docx";
  4623. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4624. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4625. return Ok(JsonView(true, "成功", new { Url = url }));
  4626. }
  4627. }
  4628. else if (dto.ExportType == 3)
  4629. {
  4630. if (dto.SubTypeId == 1) //团组成员名单
  4631. {
  4632. if (DeleClientList.Count < 1)
  4633. {
  4634. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4635. }
  4636. //获取模板
  4637. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4638. //载入模板
  4639. Document doc = new Document(tempPath);
  4640. DocumentBuilder builder = new DocumentBuilder(doc);
  4641. //获取word里所有表格
  4642. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4643. //获取所填表格的序数
  4644. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4645. var rowStart = tableOne.Rows[0]; //获取第1行
  4646. //循环赋值
  4647. for (int i = 0; i < DeleClientList.Count; i++)
  4648. {
  4649. builder.MoveToCell(0, i + 1, 0, 0);
  4650. builder.Write(DeleClientList[i].Name);
  4651. builder.MoveToCell(0, i + 1, 1, 0);
  4652. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4653. builder.Write(sex);
  4654. builder.MoveToCell(0, i + 1, 2, 0);
  4655. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4656. builder.MoveToCell(0, i + 1, 3, 0);
  4657. builder.Write(DeleClientList[i].Company);
  4658. builder.MoveToCell(0, i + 1, 4, 0);
  4659. builder.Write(DeleClientList[i].Job);
  4660. }
  4661. //删除多余行
  4662. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4663. {
  4664. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4665. }
  4666. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4667. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4668. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4669. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4670. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4671. return Ok(JsonView(true, "成功", new { Url = url }));
  4672. }
  4673. }
  4674. return Ok(JsonView(false, "操作失败!"));
  4675. }
  4676. catch (Exception ex)
  4677. {
  4678. return Ok(JsonView(false, ex.Message));
  4679. }
  4680. }
  4681. /// <summary>
  4682. /// 获取三公费用标准city
  4683. /// </summary>
  4684. /// <param name="placeData"></param>
  4685. /// <param name="nationalTravelFeeId"></param>
  4686. /// <returns></returns>
  4687. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4688. {
  4689. string _city = string.Empty;
  4690. if (placeData.Count < 1) return _city;
  4691. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4692. if (data == null) return _city;
  4693. string country = data.Country;
  4694. string city = data.City;
  4695. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4696. else _city = city;
  4697. return _city;
  4698. }
  4699. /// <summary>
  4700. /// 团组模块 - 出入境费用 - 明细表导出
  4701. /// </summary>
  4702. /// <returns></returns>
  4703. [HttpPost]
  4704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4705. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4706. {
  4707. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4708. if (data.Code != 0)
  4709. {
  4710. return Ok(JsonView(false, data.Msg));
  4711. }
  4712. return Ok(JsonView(true, data.Msg, data.Data));
  4713. }
  4714. /// <summary>
  4715. /// 团组模块 - 出入境费用 - 一键清空
  4716. /// </summary>
  4717. /// <returns></returns>
  4718. [HttpPost]
  4719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4720. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4721. {
  4722. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4723. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4724. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4725. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4726. if (_view.Code == 0)
  4727. {
  4728. return Ok(JsonView(true, "操作成功"));
  4729. }
  4730. return Ok(JsonView(false, "操作失败"));
  4731. }
  4732. /// <summary>
  4733. /// 团组模块 - 出入境费用 - 子项删除
  4734. /// </summary>
  4735. /// <returns></returns>
  4736. [HttpPost]
  4737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4738. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4739. {
  4740. try
  4741. {
  4742. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4743. if (data.Code != 0)
  4744. {
  4745. return Ok(JsonView(false, data.Msg));
  4746. }
  4747. return Ok(JsonView(true, "操作成功!", data.Data));
  4748. }
  4749. catch (Exception ex)
  4750. {
  4751. return Ok(JsonView(false, ex.Message));
  4752. }
  4753. }
  4754. /// <summary>
  4755. /// 团组模块 - 出入境国家费用标准 List
  4756. /// </summary>
  4757. /// <returns></returns>
  4758. [HttpPost]
  4759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4760. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4761. {
  4762. try
  4763. {
  4764. Stopwatch sw = new Stopwatch();
  4765. sw.Start();
  4766. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4767. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4768. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4769. Where gntf.Isdel = 0");
  4770. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4771. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4772. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4773. //foreach (var item in nationalTravel)
  4774. //{
  4775. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4776. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4777. // if (otherData != null)
  4778. // {
  4779. // cityData.Remove(otherData);
  4780. // cityData.Add(otherData);
  4781. // }
  4782. // nationalTravelFeeData1.Add(new
  4783. // {
  4784. // Country = item.Country,
  4785. // CityData = cityData
  4786. // });
  4787. //}
  4788. sw.Stop();
  4789. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4790. }
  4791. catch (Exception ex)
  4792. {
  4793. return Ok(JsonView(false, ex.Message));
  4794. throw;
  4795. }
  4796. }
  4797. /// <summary>
  4798. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4799. /// </summary>
  4800. /// <returns></returns>
  4801. [HttpPost]
  4802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4803. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4804. {
  4805. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4806. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4807. List<string> countryData = new List<string>();
  4808. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4809. countryData = countryData.Distinct().ToList();
  4810. List<dynamic> dataSource = new List<dynamic>();
  4811. foreach (var item in countryData)
  4812. {
  4813. List<string> cityData1 = new List<string>();
  4814. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4815. var countryData2 = new
  4816. {
  4817. CountryName = item,
  4818. CityData = cityData1
  4819. };
  4820. dataSource.Add(countryData2);
  4821. }
  4822. return Ok(JsonView(true, "查询成功!", dataSource));
  4823. }
  4824. /// <summary>
  4825. /// 团组模块 - 出入境国家费用标准 Page List
  4826. /// </summary>
  4827. /// <returns></returns>
  4828. [HttpPost]
  4829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4830. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4831. {
  4832. int portId = dto.PortType;
  4833. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4834. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4835. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4836. string whereSql = string.Empty;
  4837. if (!string.IsNullOrEmpty(dto.Country))
  4838. {
  4839. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4840. }
  4841. if (!string.IsNullOrEmpty(dto.City))
  4842. {
  4843. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4844. }
  4845. string pageSql = string.Format(@"Select * From (
  4846. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4847. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4848. From Grp_NationalTravelFee gntf
  4849. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4850. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4851. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4852. RefAsync<int> total = 0;
  4853. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4854. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4855. }
  4856. /// <summary>
  4857. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4858. /// </summary>
  4859. /// <returns></returns>
  4860. [HttpPost]
  4861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4862. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4863. {
  4864. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4865. int portId = dto.PortType;
  4866. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4867. string whereSql = string.Empty;
  4868. if (!string.IsNullOrEmpty(dto.Country))
  4869. {
  4870. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4871. }
  4872. if (!string.IsNullOrEmpty(dto.City))
  4873. {
  4874. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4875. }
  4876. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4877. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4878. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4879. From Grp_NationalTravelFee gntf
  4880. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4881. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4882. Where gntf.Isdel = 0 {0} ", whereSql);
  4883. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4884. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4885. }
  4886. /// <summary>
  4887. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4888. /// </summary>
  4889. /// <returns></returns>
  4890. [HttpPost]
  4891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4892. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4893. {
  4894. try
  4895. {
  4896. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4897. if (data.Code != 0)
  4898. {
  4899. return Ok(JsonView(false, data.Msg));
  4900. }
  4901. return Ok(JsonView(true, "操作成功!", data.Data));
  4902. }
  4903. catch (Exception ex)
  4904. {
  4905. return Ok(JsonView(false, ex.Message));
  4906. }
  4907. }
  4908. /// <summary>
  4909. /// 团组模块 - 出入境国家费用标准 - Del
  4910. /// </summary>
  4911. /// <returns></returns>
  4912. [HttpPost]
  4913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4914. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4915. {
  4916. try
  4917. {
  4918. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4919. {
  4920. Id = dto.Id,
  4921. DeleteUserId = dto.DeleteUserId,
  4922. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4923. IsDel = 1
  4924. };
  4925. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4926. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4927. .WhereColumns(it => new { it.Id })
  4928. .ExecuteCommandAsync();
  4929. if (delStatus <= 0)
  4930. {
  4931. return Ok(JsonView(false, "删除失败!"));
  4932. }
  4933. return Ok(JsonView(true, "操作成功!"));
  4934. }
  4935. catch (Exception ex)
  4936. {
  4937. return Ok(JsonView(false, ex.Message));
  4938. }
  4939. }
  4940. #endregion
  4941. #region 签证费用录入
  4942. /// <summary>
  4943. /// 根据diid查询签证费用列表
  4944. /// </summary>
  4945. /// <param name="dto"></param>
  4946. /// <returns></returns>
  4947. [HttpPost]
  4948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4949. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4950. {
  4951. try
  4952. {
  4953. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4954. if (groupData.Code != 0)
  4955. {
  4956. return Ok(JsonView(false, groupData.Msg));
  4957. }
  4958. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4959. }
  4960. catch (Exception ex)
  4961. {
  4962. return Ok(JsonView(false, ex.Message));
  4963. }
  4964. }
  4965. /// <summary>
  4966. /// 根据签证费用Id查询单条数据及c表数据
  4967. /// </summary>
  4968. /// <param name="dto"></param>
  4969. /// <returns></returns>
  4970. [HttpPost]
  4971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4972. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4973. {
  4974. try
  4975. {
  4976. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4977. if (groupData.Code != 0)
  4978. {
  4979. return Ok(JsonView(false, groupData.Msg));
  4980. }
  4981. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4982. }
  4983. catch (Exception ex)
  4984. {
  4985. return Ok(JsonView(false, ex.Message));
  4986. }
  4987. }
  4988. /// <summary>
  4989. /// 签证费用删除
  4990. /// </summary>
  4991. /// <param name="dto"></param>
  4992. /// <returns></returns>
  4993. [HttpPost]
  4994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4995. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4996. {
  4997. _sqlSugar.BeginTran();
  4998. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4999. if (!res)
  5000. {
  5001. _sqlSugar.RollbackTran();
  5002. return Ok(JsonView(false, "删除失败"));
  5003. }
  5004. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5005. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5006. .SetColumns(a => new Grp_CreditCardPayment()
  5007. {
  5008. IsDel = 1,
  5009. DeleteUserId = dto.DeleteUserId,
  5010. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5011. }).ExecuteCommand();
  5012. if (resSub < 1)
  5013. {
  5014. _sqlSugar.RollbackTran();
  5015. return Ok(JsonView(false, "删除失败"));
  5016. }
  5017. _sqlSugar.CommitTran();
  5018. return Ok(JsonView(true, "删除成功!"));
  5019. }
  5020. /// <summary>
  5021. /// 签证费用录入下拉框初始化
  5022. /// </summary>
  5023. /// <returns></returns>
  5024. [HttpPost]
  5025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5026. public async Task<IActionResult> VisaPriceAddSelect()
  5027. {
  5028. try
  5029. {
  5030. //支付方式
  5031. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5032. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5033. //币种
  5034. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5035. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5036. //乘客类型
  5037. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5038. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5039. //卡类型
  5040. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5041. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5042. var data = new
  5043. {
  5044. Payment = _Payment,
  5045. CurrencyList = _CurrencyList,
  5046. PassengerType = _PassengerType,
  5047. BankCard = _BankCard
  5048. };
  5049. return Ok(JsonView(true, "查询成功!", data));
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. return Ok(JsonView(false, "程序错误!"));
  5054. throw;
  5055. }
  5056. }
  5057. /// <summary>
  5058. /// 签证费用录入操作(Status:1.新增,2.修改)
  5059. /// </summary>
  5060. /// <param name="dto"></param>
  5061. /// <returns></returns>
  5062. [HttpPost]
  5063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5064. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5065. {
  5066. try
  5067. {
  5068. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5069. if (groupData.Code != 0)
  5070. {
  5071. return Ok(JsonView(false, groupData.Msg));
  5072. }
  5073. #region 应用推送
  5074. try
  5075. {
  5076. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5077. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5078. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5079. }
  5080. catch (Exception ex)
  5081. {
  5082. }
  5083. #endregion
  5084. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5085. }
  5086. catch (Exception ex)
  5087. {
  5088. return Ok(JsonView(false, ex.Message));
  5089. }
  5090. }
  5091. #endregion
  5092. #region op费用录入
  5093. /// <summary>
  5094. /// 根据diid查询op费用列表
  5095. /// </summary>
  5096. /// <param name="dto"></param>
  5097. /// <returns></returns>
  5098. [HttpPost]
  5099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5100. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5101. {
  5102. try
  5103. {
  5104. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5105. if (groupData.Code != 0)
  5106. {
  5107. return Ok(JsonView(false, groupData.Msg));
  5108. }
  5109. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5110. }
  5111. catch (Exception ex)
  5112. {
  5113. return Ok(JsonView(false, ex.Message));
  5114. }
  5115. }
  5116. /// <summary>
  5117. /// 根据op费用Id查询单条数据及c表数据
  5118. /// </summary>
  5119. /// <param name="dto"></param>
  5120. /// <returns></returns>
  5121. [HttpPost]
  5122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5123. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5124. {
  5125. try
  5126. {
  5127. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5128. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5129. var data = new
  5130. {
  5131. CarTouristGuideGround = _groupData,
  5132. CreditCardPayment = _creditCardPayment
  5133. };
  5134. return Ok(JsonView(true, "查询成功!", data));
  5135. }
  5136. catch (Exception ex)
  5137. {
  5138. return Ok(JsonView(false, "程序错误!"));
  5139. }
  5140. }
  5141. /// <summary>
  5142. /// op费用删除
  5143. /// </summary>
  5144. /// <param name="dto"></param>
  5145. /// <returns></returns>
  5146. [HttpPost]
  5147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5148. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5149. {
  5150. try
  5151. {
  5152. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5153. if (!res)
  5154. {
  5155. return Ok(JsonView(false, "删除失败"));
  5156. }
  5157. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5158. {
  5159. IsDel = 1,
  5160. DeleteUserId = dto.DeleteUserId,
  5161. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5162. }).ExecuteCommandAsync();
  5163. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5164. {
  5165. IsDel = 1,
  5166. DeleteUserId = dto.DeleteUserId,
  5167. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5168. }).ExecuteCommandAsync();
  5169. return Ok(JsonView(true, "删除成功!"));
  5170. }
  5171. catch (Exception ex)
  5172. {
  5173. return Ok(JsonView(false, "程序错误!"));
  5174. throw;
  5175. }
  5176. }
  5177. /// <summary>
  5178. /// op费用录入操作(Status:1.新增,2.修改)
  5179. /// </summary>
  5180. /// <param name="dto"></param>
  5181. /// <returns></returns>
  5182. [HttpPost]
  5183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5184. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5185. {
  5186. try
  5187. {
  5188. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5189. if (groupData.Code != 0)
  5190. {
  5191. return Ok(JsonView(false, groupData.Msg));
  5192. }
  5193. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5194. }
  5195. catch (Exception ex)
  5196. {
  5197. return Ok(JsonView(false, ex.Message));
  5198. }
  5199. }
  5200. /// <summary>
  5201. /// 填写费用详细页面初始化绑定
  5202. /// </summary>
  5203. /// <param name="dto"></param>
  5204. /// <returns></returns>
  5205. [HttpPost]
  5206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5207. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5208. {
  5209. try
  5210. {
  5211. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5212. if (groupData.Code != 0)
  5213. {
  5214. return Ok(JsonView(false, groupData.Msg));
  5215. }
  5216. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5217. }
  5218. catch (Exception ex)
  5219. {
  5220. return Ok(JsonView(false, ex.Message));
  5221. }
  5222. }
  5223. /// <summary>
  5224. /// 根据op费用Id查询详细数据
  5225. /// </summary>
  5226. /// <param name="dto"></param>
  5227. /// <returns></returns>
  5228. [HttpPost]
  5229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5230. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5231. {
  5232. try
  5233. {
  5234. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5235. if (groupData.Code != 0)
  5236. {
  5237. return Ok(JsonView(false, groupData.Msg));
  5238. }
  5239. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5240. }
  5241. catch (Exception ex)
  5242. {
  5243. return Ok(JsonView(false, ex.Message));
  5244. }
  5245. }
  5246. /// <summary>
  5247. /// OP费用录入填写详情
  5248. /// </summary>
  5249. /// <param name="dto"></param>
  5250. /// <returns></returns>
  5251. [HttpPost]
  5252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5253. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5254. {
  5255. try
  5256. {
  5257. #region 参数校验
  5258. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5259. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5260. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5261. #endregion
  5262. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5263. if (groupData.Code != 0)
  5264. {
  5265. return Ok(JsonView(false, groupData.Msg));
  5266. }
  5267. //自动审核
  5268. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5269. #region 应用推送
  5270. try
  5271. {
  5272. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5273. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5274. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5275. }
  5276. catch (Exception ex)
  5277. {
  5278. }
  5279. #endregion
  5280. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5281. }
  5282. catch (Exception ex)
  5283. {
  5284. return Ok(JsonView(false, ex.Message));
  5285. }
  5286. }
  5287. /// <summary>
  5288. /// 获取三公详细所有城市
  5289. /// </summary>
  5290. /// <returns></returns>
  5291. [HttpGet]
  5292. public IActionResult OpCarCityResult()
  5293. {
  5294. var jw = JsonView(false);
  5295. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5296. {
  5297. x.Id,
  5298. x.Country,
  5299. x.City,
  5300. }).ToList();
  5301. if (data.Count > 0)
  5302. {
  5303. jw = JsonView(true, "获取成功!", data);
  5304. }
  5305. else
  5306. {
  5307. jw.Msg = "城市数据为空!";
  5308. jw.Data = new string[0];
  5309. }
  5310. return Ok(jw);
  5311. }
  5312. /// <summary>
  5313. /// 导出地接费用明细
  5314. /// </summary>
  5315. /// <param name="dto"></param>
  5316. /// <returns></returns>
  5317. [HttpPost]
  5318. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5319. {
  5320. var jw = JsonView(false);
  5321. if (dto.Diid < 1)
  5322. {
  5323. jw.Msg = "请输入正确的diid!";
  5324. return Ok(jw);
  5325. }
  5326. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5327. if (group == null)
  5328. {
  5329. jw.Msg = "未找到团组信息!";
  5330. return Ok(jw);
  5331. }
  5332. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5333. if (localGuideArr.Count == 0)
  5334. {
  5335. jw.Msg = "该团组暂无地接信息!";
  5336. return Ok(jw);
  5337. }
  5338. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5339. var overspendSoure = new Dictionary<int, int>
  5340. {
  5341. { 91, 982 }, //车
  5342. { 92 , 1059} ,//导游
  5343. { 994 , 1073}, //翻译
  5344. { 988 , 1074 }, //早餐
  5345. { 93 , 1075 }, //午餐
  5346. { 989 , 1076 }, //晚餐
  5347. };
  5348. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5349. foreach (var groupArr in localGroup)
  5350. {
  5351. var keyValue = groupArr.Key;
  5352. if (int.TryParse(keyValue, out int cityid))
  5353. {
  5354. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5355. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5356. }
  5357. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5358. foreach (var item in groupArr)
  5359. {
  5360. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5361. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5362. new Grp_CarTouristGuideGroundReservationsContentExtend
  5363. {
  5364. Count = a.Count,
  5365. CreateTime = a.CreateTime,
  5366. CreateUserId = a.CreateUserId,
  5367. CTGGRId = a.CTGGRId,
  5368. Currency = a.Currency,
  5369. DatePrice = a.DatePrice,
  5370. DeleteTime = a.DeleteTime,
  5371. DeleteUserId = a.DeleteUserId,
  5372. DiId = a.DiId,
  5373. Id = a.Id,
  5374. IsDel = a.IsDel,
  5375. Price = a.Price,
  5376. PriceContent = a.PriceContent,
  5377. Remark = a.Remark,
  5378. SId = a.SId,
  5379. SidName = b.Name,
  5380. Units = a.Units,
  5381. }
  5382. ).ToList();
  5383. if (content.Count > 0)
  5384. {
  5385. contentArr.Add(content);
  5386. }
  5387. }
  5388. //open excel
  5389. //set excel
  5390. //save excel
  5391. try
  5392. {
  5393. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5394. IWorkbook workbook;
  5395. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5396. {
  5397. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5398. }
  5399. else
  5400. {
  5401. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5402. }
  5403. ISheet sheet = workbook.GetSheetAt(0);
  5404. var rowStartIndex = 2;
  5405. var clounmCount = 10;
  5406. var initStyleRow = sheet.GetRow(2);
  5407. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5408. //var overspendArrDetail =
  5409. var existsId = new List<CarCompare>();
  5410. var lastElem = arr.Last();
  5411. var thisSid = -1;
  5412. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5413. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5414. {
  5415. Name = "未知币种!",
  5416. Remark = "未知币种!",
  5417. };
  5418. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5419. Action cloneRowFn = () =>
  5420. {
  5421. rowStartIndex++;
  5422. var cloneRow = sheet.CreateRow(rowStartIndex);
  5423. // 复制样式
  5424. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5425. {
  5426. ICell sourceCell = initStyleRow.GetCell(i);
  5427. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5428. // 确保单元格存在样式
  5429. if (sourceCell.CellStyle != null)
  5430. {
  5431. targetCell.CellStyle = sourceCell.CellStyle;
  5432. }
  5433. }
  5434. };
  5435. var mergeRow = () =>
  5436. {
  5437. for (int i = 2; i < sheet.LastRowNum; i++)
  5438. {
  5439. var row = sheet.GetRow(i);
  5440. var cellFirst = row.GetCell(0);
  5441. var thisIndex = i + 1;
  5442. while (thisIndex < sheet.LastRowNum)
  5443. {
  5444. var nextRow = sheet.GetRow(thisIndex);
  5445. var nextCellFirst = nextRow.GetCell(0);
  5446. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5447. {
  5448. thisIndex++;
  5449. }
  5450. else
  5451. {
  5452. break;
  5453. }
  5454. }
  5455. thisIndex--;
  5456. if (thisIndex != i)
  5457. {
  5458. //合并row
  5459. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5460. i, // 起始行索引(0-based)
  5461. thisIndex, // 结束行索引(0-based)
  5462. 0, // 起始列索引(0-based)
  5463. 0 // 结束列索引(0-based)
  5464. );
  5465. sheet.AddMergedRegion(cellRangeAddress);
  5466. i = thisIndex;
  5467. }
  5468. }
  5469. };
  5470. var chaoshiNumber = 0;
  5471. var totalNumber = 0.00M;
  5472. string lastStr = "";
  5473. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5474. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5475. {
  5476. b.IsAuditGM,
  5477. x.Id,
  5478. x.Area,
  5479. b.PayPercentage,
  5480. b.PayMoney,
  5481. }).ToList();
  5482. string yesPayment = "", noPayment = "";
  5483. foreach (var item in queryCarArrByCityAndDiid)
  5484. {
  5485. if (item.IsAuditGM == 1)
  5486. {
  5487. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5488. }
  5489. else
  5490. {
  5491. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5492. }
  5493. }
  5494. lastStr = yesPayment + noPayment;
  5495. foreach (var item in arr)
  5496. {
  5497. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5498. {
  5499. if (thisSid != item.SId)
  5500. {
  5501. if (thisSid == -1)
  5502. {
  5503. thisSid = item.SId;
  5504. }
  5505. else
  5506. {
  5507. //合并小计行
  5508. //创建合并区域的实例
  5509. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5510. rowStartIndex, // 起始行索引(0-based)
  5511. rowStartIndex, // 结束行索引(0-based)
  5512. 0, // 起始列索引(0-based)
  5513. 3 // 结束列索引(0-based)
  5514. );
  5515. sheet.AddMergedRegion(cellRangeAddress);
  5516. var CellStyle = workbook.CreateCellStyle();
  5517. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5518. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5519. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5520. for (int i = 0; i <= clounmCount; i++)
  5521. {
  5522. if (i > 6)
  5523. {
  5524. var CellStyle1 = workbook.CreateCellStyle();
  5525. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5526. IFont Font = workbook.CreateFont(); // 创建字体
  5527. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5528. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5529. CellStyle1.SetFont(Font);
  5530. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5531. }
  5532. else
  5533. {
  5534. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5535. }
  5536. }
  5537. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5538. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5539. //超时合计
  5540. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5541. //超时数
  5542. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5543. //超时合计费用
  5544. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5545. thisSid = item.SId;
  5546. cloneRowFn();
  5547. chaoshiNumber = 0;
  5548. totalNumber = 0;
  5549. }
  5550. }
  5551. IRow row = sheet.GetRow(rowStartIndex);
  5552. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5553. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5554. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5555. if (isOpenOverspendSoure)
  5556. {
  5557. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5558. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5559. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5560. }
  5561. for (int i = 0; i <= clounmCount; i++)
  5562. {
  5563. var cell = row.GetCell(i);
  5564. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5565. if (cell == null)
  5566. {
  5567. cell = row.CreateCell(i);
  5568. }
  5569. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5570. fontRed.CloneStyleFrom(cell.CellStyle);
  5571. IFont Font = workbook.CreateFont(); // 创建字体
  5572. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5573. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5574. fontRed.SetFont(Font);
  5575. byte[] rgb = new byte[3] { 255, 242, 204 };
  5576. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5577. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5578. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5579. if (workbook is XSSFWorkbook)
  5580. {
  5581. BackgroundColor255_242_204.FillForegroundColor = 0;
  5582. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5583. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5584. }
  5585. else
  5586. {
  5587. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5588. }
  5589. if (i == 1 || i > 6)
  5590. {
  5591. if (i > 6)
  5592. {
  5593. fontRed.FillForegroundColor = 0;
  5594. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5595. fontRed.FillPattern = FillPattern.SolidForeground;
  5596. }
  5597. cell.CellStyle = fontRed;
  5598. }
  5599. if (i > 2 && i < 7)
  5600. {
  5601. cell.CellStyle = BackgroundColor255_242_204;
  5602. }
  5603. cell.SetCellValue(setCellValue); //写入单元格
  5604. }
  5605. if (overspendSoure.ContainsKey(thisSid))
  5606. {
  5607. var overspendId = overspendSoure[thisSid];
  5608. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5609. }
  5610. cloneRowFn();
  5611. existsId.Add(new CarCompare
  5612. {
  5613. DataPrice = item.DatePrice.ObjToDate(),
  5614. Sid = item.SId
  5615. });
  5616. }
  5617. if (item.Equals(lastElem))
  5618. {
  5619. //合并小计行
  5620. //创建合并区域的实例
  5621. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5622. rowStartIndex, // 起始行索引(0-based)
  5623. rowStartIndex, // 结束行索引(0-based)
  5624. 0, // 起始列索引(0-based)
  5625. 3 // 结束列索引(0-based)
  5626. );
  5627. sheet.AddMergedRegion(cellRangeAddress);
  5628. var CellStyle = workbook.CreateCellStyle();
  5629. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5630. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5631. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5632. for (int i = 0; i <= clounmCount; i++)
  5633. {
  5634. if (i > 6)
  5635. {
  5636. var CellStyle1 = workbook.CreateCellStyle();
  5637. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5638. IFont Font = workbook.CreateFont(); // 创建字体
  5639. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5640. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5641. CellStyle1.SetFont(Font);
  5642. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5643. }
  5644. else
  5645. {
  5646. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5647. }
  5648. }
  5649. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5650. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5651. //超时合计
  5652. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5653. //超时数
  5654. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5655. //超时合计费用
  5656. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5657. cloneRowFn();
  5658. // 创建合并区域的实例
  5659. cellRangeAddress = new CellRangeAddress(
  5660. rowStartIndex, // 起始行索引(0-based)
  5661. rowStartIndex, // 结束行索引(0-based)
  5662. 0, // 起始列索引(0-based)
  5663. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5664. );
  5665. // 添加合并区域
  5666. sheet.AddMergedRegion(cellRangeAddress);
  5667. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5668. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5669. }
  5670. }
  5671. mergeRow();
  5672. // 保存修改后的Excel文件到新文件
  5673. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5674. // new FileStream(newFilePath, FileMode.CreateNew)
  5675. using (var stream = new MemoryStream())
  5676. {
  5677. workbook.Write(stream, true);
  5678. stream.Flush();
  5679. stream.Seek(0, SeekOrigin.Begin);
  5680. MemoryStream memoryStream = new MemoryStream();
  5681. stream.CopyTo(memoryStream);
  5682. memoryStream.Seek(0, SeekOrigin.Begin);
  5683. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5684. }
  5685. workbook.Close();
  5686. workbook.Dispose();
  5687. }
  5688. catch (Exception ex)
  5689. {
  5690. jw.Msg = "出现异常!" + ex.Message;
  5691. return Ok(jw);
  5692. }
  5693. }
  5694. if (Zips.Count > 0)
  5695. {
  5696. IOOperatorHelper io = new IOOperatorHelper();
  5697. var byts = io.ConvertZipStream(Zips);
  5698. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5699. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5700. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5701. }
  5702. else
  5703. {
  5704. jw.Msg = "暂无生成文件!";
  5705. }
  5706. return Ok(jw);
  5707. }
  5708. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5709. {
  5710. string outStr = string.Empty;
  5711. switch (i)
  5712. {
  5713. case 0:
  5714. outStr = arr[0].SidName;
  5715. break;
  5716. case 1:
  5717. outStr = arr[0].DataPriceStr;
  5718. break;
  5719. case 2:
  5720. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5721. break;
  5722. case 4:
  5723. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5724. break;
  5725. case 7:
  5726. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5727. {
  5728. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5729. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5730. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5731. }
  5732. break;
  5733. case 8:
  5734. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5735. {
  5736. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5737. }
  5738. break;
  5739. case 9:
  5740. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5741. {
  5742. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5743. }
  5744. break;
  5745. case 10:
  5746. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5747. {
  5748. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5749. }
  5750. break;
  5751. }
  5752. return outStr;
  5753. }
  5754. #region OP行程单
  5755. /// <summary>
  5756. /// OP行程单初始化
  5757. /// </summary>
  5758. /// <param name="dto"></param>
  5759. /// <returns></returns>
  5760. [HttpPost]
  5761. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5762. {
  5763. var jw = JsonView(false);
  5764. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5765. var group = groupList.First();
  5766. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5767. if (group == null)
  5768. {
  5769. jw.Msg = "暂无团组!";
  5770. return Ok(jw);
  5771. }
  5772. group = groupList.Find(x => x.Id == diid);
  5773. if (group == null)
  5774. {
  5775. jw.Msg = "请输入正确的团组ID!";
  5776. return Ok(jw);
  5777. }
  5778. string city = string.Empty;
  5779. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5780. if (blackCode.Count > 0)
  5781. {
  5782. var black = blackCode.First();
  5783. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5784. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5785. if (blackSp.Length > 0)
  5786. {
  5787. try
  5788. {
  5789. var cityArrCode = new List<string>(20);
  5790. foreach (var item in blackSp)
  5791. {
  5792. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5793. var IndexSelect = itemSp[2];
  5794. var cityArrCodeLength = cityArrCode.Count - 1;
  5795. var startCity = IndexSelect.Substring(0, 3);
  5796. if (cityArrCodeLength > 0)
  5797. {
  5798. var arrEndCity = cityArrCode[cityArrCodeLength];
  5799. if (arrEndCity != startCity)
  5800. {
  5801. cityArrCode.Add(startCity.ToUpper());
  5802. }
  5803. }
  5804. else
  5805. {
  5806. cityArrCode.Add(startCity.ToUpper());
  5807. }
  5808. var endCity = IndexSelect.Substring(3, 3);
  5809. cityArrCode.Add(endCity.ToUpper());
  5810. }
  5811. var cityThree = string.Empty;
  5812. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5813. cityThree = cityThree.TrimEnd(',');
  5814. if (string.IsNullOrWhiteSpace(cityThree))
  5815. {
  5816. throw new
  5817. Exception("error");
  5818. }
  5819. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5820. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5821. foreach (var item in cityArrCode)
  5822. {
  5823. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5824. if (find != null)
  5825. {
  5826. city += find.City + "/";
  5827. }
  5828. else
  5829. {
  5830. city += item + "三字码未收入/";
  5831. }
  5832. }
  5833. city = city.TrimEnd('/');
  5834. }
  5835. catch (Exception e)
  5836. {
  5837. city = "黑屏代码格式不正确!";
  5838. }
  5839. }
  5840. }
  5841. else
  5842. {
  5843. city = "未录入黑屏代码";
  5844. }
  5845. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5846. {
  5847. Date = x.Date,
  5848. Days = x.Days,
  5849. Diffgroup = x.Diffgroup,
  5850. Diid = x.Diid,
  5851. Traffic_First = x.Traffic_First,
  5852. Traffic_Second = x.Traffic_Second,
  5853. Trip = x.Trip,
  5854. WeekDay = x.WeekDay,
  5855. Id = x.Id
  5856. }).ToList();
  5857. jw.Data = new
  5858. {
  5859. groupList = groupList.Select(x => new
  5860. {
  5861. x.Id,
  5862. x.TeamName,
  5863. x.TourCode
  5864. }).ToList(),
  5865. groupInfo = new
  5866. {
  5867. group.VisitDays,
  5868. group.TourCode,
  5869. group.VisitPNumber,
  5870. group.TeamName,
  5871. city
  5872. },
  5873. OpTravelList
  5874. };
  5875. jw.Code = 200;
  5876. jw.Msg = "操作成功!";
  5877. return Ok(jw);
  5878. }
  5879. /// <summary>
  5880. /// 删除团组行程单
  5881. /// </summary>
  5882. /// <returns></returns>
  5883. [HttpPost]
  5884. public IActionResult DelTravel(DelOpTravelDto dto)
  5885. {
  5886. var jw = JsonView(false);
  5887. if (dto.UserId <= 0 || dto.Diid <= 0)
  5888. {
  5889. jw.Msg = "请输入正确的参数!";
  5890. return Ok(jw);
  5891. }
  5892. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5893. .SetColumns(x => new Grp_TravelList
  5894. {
  5895. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5896. DeleteUserId = dto.UserId,
  5897. IsDel = 1,
  5898. }).ExecuteCommand();
  5899. jw = JsonView(true);
  5900. return Ok(jw);
  5901. }
  5902. /// <summary>
  5903. /// 行程单保存
  5904. /// </summary>
  5905. /// <returns></returns>
  5906. [HttpPost]
  5907. public IActionResult TravelSave(TravelSaveDto dto)
  5908. {
  5909. var jw = JsonView(false);
  5910. if (dto.Arr.Count > 0)
  5911. {
  5912. try
  5913. {
  5914. _sqlSugar.BeginTran();
  5915. foreach (var item in dto.Arr)
  5916. {
  5917. if (item.Id == 0)
  5918. {
  5919. throw new Exception("请传入正确的Id");
  5920. }
  5921. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5922. .SetColumns(x => new Grp_TravelList
  5923. {
  5924. Trip = item.Trip
  5925. }).ExecuteCommand();
  5926. }
  5927. _sqlSugar.CommitTran();
  5928. jw = JsonView(true);
  5929. }
  5930. catch (Exception ex)
  5931. {
  5932. _sqlSugar.RollbackTran();
  5933. jw.Msg = "程序异常!" + ex.Message;
  5934. }
  5935. }
  5936. else
  5937. {
  5938. jw.Msg = "请传入正确的参数!";
  5939. }
  5940. return Ok(jw);
  5941. }
  5942. /// <summary>
  5943. /// 导出行程单
  5944. /// </summary>
  5945. /// <param name="dto"></param>
  5946. /// <returns></returns>
  5947. [HttpPost]
  5948. public IActionResult ExportTravel(ExportTravelDto dto)
  5949. {
  5950. var jw = JsonView(false);
  5951. jw.Data = "";
  5952. int diid = 0;
  5953. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5954. if (Find == null)
  5955. {
  5956. jw.Msg = "请选择正确的团组!";
  5957. return Ok(jw);
  5958. }
  5959. else
  5960. {
  5961. diid = Find.Id;
  5962. }
  5963. //数据源
  5964. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5965. DataTable dtBlack = null;
  5966. try
  5967. {
  5968. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  5969. }
  5970. catch (Exception)
  5971. {
  5972. jw.Msg = "机票黑屏代码有误!";
  5973. return Ok(jw);
  5974. }
  5975. string CityStr = string.Empty;
  5976. if (dtBlack.Rows.Count == 0)
  5977. {
  5978. jw.Msg = "机票黑屏代码有误!";
  5979. return Ok(jw);
  5980. }
  5981. else
  5982. {
  5983. foreach (DataRow row in dtBlack.Rows)
  5984. {
  5985. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  5986. {
  5987. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  5988. return Ok(jw);
  5989. }
  5990. }
  5991. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  5992. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  5993. }
  5994. //创建数据源Table
  5995. DataTable dtSource = new DataTable();
  5996. dtSource.Columns.Add("Days", typeof(string));
  5997. dtSource.Columns.Add("Date", typeof(string));
  5998. dtSource.Columns.Add("Week", typeof(string));
  5999. dtSource.Columns.Add("Traffic", typeof(string));
  6000. dtSource.Columns.Add("Trip", typeof(string));
  6001. //获取数据,放到datatable
  6002. foreach (var item in _travelList)
  6003. {
  6004. DataRow dr = dtSource.NewRow();
  6005. dr["Days"] = item.Days;
  6006. dr["Date"] = item.Date;
  6007. dr["Week"] = item.WeekDay;
  6008. dr["Traffic"] = item.Traffic_First
  6009. + "\r\n"
  6010. + item.Traffic_Second;
  6011. dr["Trip"] = item.Trip;
  6012. dtSource.Rows.Add(dr);
  6013. }
  6014. Dictionary<string, string> dic = new Dictionary<string, string>();
  6015. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6016. dic.Add("City", CityStr);
  6017. dic.Add("Days", Find.VisitDays.ToString());
  6018. dic.Add("DeleCode", Find.TourCode);
  6019. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6020. //模板路径
  6021. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6022. //载入模板
  6023. Document doc = null;
  6024. DocumentBuilder builder = null;
  6025. try
  6026. {
  6027. //载入模板
  6028. doc = new Document(tempPath);
  6029. builder = new DocumentBuilder(doc);
  6030. }
  6031. catch (Exception)
  6032. {
  6033. jw.Msg = "模板位置不存在!";
  6034. return Ok(jw);
  6035. }
  6036. foreach (var key in dic.Keys)
  6037. {
  6038. Bookmark bookmark = doc.Range.Bookmarks[key];
  6039. if (bookmark != null)
  6040. {
  6041. builder.MoveToBookmark(key);
  6042. builder.Write(dic[key]);
  6043. }
  6044. }
  6045. //获取word里所有表格
  6046. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6047. //获取所填表格的序数
  6048. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6049. try
  6050. {
  6051. //循环赋值
  6052. for (int i = 0; i < dtSource.Rows.Count; i++)
  6053. {
  6054. builder.MoveToCell(0, i + 1, 0, 0);
  6055. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6056. builder.MoveToCell(0, i + 1, 1, 0);
  6057. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6058. builder.MoveToCell(0, i + 1, 2, 0);
  6059. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6060. var trip = dtSource.Rows[i]["Trip"].ToString();
  6061. builder.MoveToCell(0, i + 1, 3, 0);
  6062. builder.Write(trip);
  6063. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6064. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6065. // 获取特定索引的段落
  6066. Paragraph paragraph = (Paragraph)paragraphs[0];
  6067. Run run = paragraph.Runs[0];
  6068. Aspose.Words.Font font = run.Font;
  6069. font.Name = "黑体";
  6070. //设置双休红色
  6071. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6072. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6073. paragraph = (Paragraph)paragraphs[1];
  6074. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6075. {
  6076. run = paragraph.Runs[0];
  6077. font = run.Font;
  6078. font.Color = Color.Red;
  6079. }
  6080. }
  6081. }
  6082. catch (Exception ex)
  6083. {
  6084. }
  6085. //删除多余行
  6086. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6087. {
  6088. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6089. }
  6090. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6091. if (!Directory.Exists(savePath))
  6092. {
  6093. try
  6094. {
  6095. Directory.CreateDirectory(savePath);
  6096. }
  6097. catch
  6098. {
  6099. }
  6100. }
  6101. string path = savePath + Find.TeamName + "出访日程";
  6102. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6103. try
  6104. {
  6105. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6106. string postfix = ".docx";
  6107. if (dto.IsPDF == 1)
  6108. {
  6109. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6110. postfix = ".pdf";
  6111. }
  6112. doc.Save(path + postfix, saveFormat);
  6113. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6114. }
  6115. catch (Exception)
  6116. {
  6117. jw = JsonView(false);
  6118. }
  6119. return Ok(jw);
  6120. }
  6121. /// <summary>
  6122. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6123. /// </summary>
  6124. /// <param name="num"></param>
  6125. /// <returns></returns>
  6126. string GetNum(string num)
  6127. {
  6128. string str = "";
  6129. switch (num)
  6130. {
  6131. case "1":
  6132. str = "一";
  6133. break;
  6134. case "2":
  6135. str = "二";
  6136. break;
  6137. case "3":
  6138. str = "三";
  6139. break;
  6140. case "4":
  6141. str = "四";
  6142. break;
  6143. case "5":
  6144. str = "五";
  6145. break;
  6146. case "6":
  6147. str = "六";
  6148. break;
  6149. case "7":
  6150. str = "七";
  6151. break;
  6152. case "8":
  6153. str = "八";
  6154. break;
  6155. case "9":
  6156. str = "九";
  6157. break;
  6158. case "10":
  6159. str = "十";
  6160. break;
  6161. case "11":
  6162. str = "十一";
  6163. break;
  6164. case "12":
  6165. str = "十二";
  6166. break;
  6167. case "一":
  6168. str = "1";
  6169. break;
  6170. case "二":
  6171. str = "2";
  6172. break;
  6173. case "三":
  6174. str = "3";
  6175. break;
  6176. case "四":
  6177. str = "4";
  6178. break;
  6179. case "五":
  6180. str = "5";
  6181. break;
  6182. case "六":
  6183. str = "6";
  6184. break;
  6185. case "七":
  6186. str = "7";
  6187. break;
  6188. case "八":
  6189. str = "8";
  6190. break;
  6191. case "九":
  6192. str = "9";
  6193. break;
  6194. case "十":
  6195. str = "10";
  6196. break;
  6197. case "十一":
  6198. str = "11";
  6199. break;
  6200. case "十二":
  6201. str = "12";
  6202. break;
  6203. }
  6204. return str;
  6205. }
  6206. #endregion
  6207. #endregion
  6208. #region 团组成本
  6209. /// <summary>
  6210. /// 团组成本数据初始化
  6211. /// </summary>
  6212. /// <param name="dto"></param>
  6213. /// <returns></returns>
  6214. [HttpPost]
  6215. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6216. {
  6217. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6218. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6219. WHEN COUNT(*) >= 0 THEN 'True'
  6220. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6221. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6222. ").ToList(); //团组列表
  6223. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6224. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6225. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6226. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6227. if (groupinfoValue != null)
  6228. {
  6229. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6230. var spArr = new string[1] { countryArr };
  6231. if (countryArr.Contains("|"))
  6232. {
  6233. spArr = countryArr.Split("|");
  6234. }
  6235. else if (countryArr.Contains("、"))
  6236. {
  6237. spArr = countryArr.Split("、");
  6238. }
  6239. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6240. {
  6241. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6242. if (dbQueryCountry != null)
  6243. {
  6244. visaCountryInfoArr.Add(dbQueryCountry);
  6245. }
  6246. }
  6247. }
  6248. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6249. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6250. var create = _GroupCostRepository.
  6251. CreateGroupCostByBlackCode(dto.Diid);
  6252. if (groupCost.Count == 0 && create.Code == 0)
  6253. {
  6254. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6255. }
  6256. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6257. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6258. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6259. groupCostMap = groupCostMap.Select(x =>
  6260. {
  6261. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6262. {
  6263. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6264. }
  6265. return x;
  6266. }).ToList();
  6267. //GroupCostParameter.Add(new
  6268. // Grp_GroupCostParameter());
  6269. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6270. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6271. return Ok(JsonView(new
  6272. {
  6273. groupList,
  6274. groupInfo,
  6275. groupChecks,
  6276. groupCost = groupCostMap,
  6277. hotelNumber,
  6278. GroupCostParameter = GroupCostParameterMap,
  6279. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6280. {
  6281. x.VisaCountry,
  6282. x.VisaPrice,
  6283. x.Id,
  6284. }).ToList(),
  6285. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6286. blackCodeIsTrue = create.Code == 0 ? true : false,
  6287. hotelIsTrue = hotelIsTrue,
  6288. }));
  6289. }
  6290. /// <summary>
  6291. /// 团组成本信息保存
  6292. /// </summary>
  6293. /// <param name="dto"></param>
  6294. /// <returns></returns>
  6295. [HttpPost]
  6296. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6297. {
  6298. if (dto.Diid <= 0 || dto.Userid <= 0)
  6299. {
  6300. return Ok(JsonView(false));
  6301. }
  6302. JsonView jw = null;
  6303. bool isTrue = false;
  6304. #region 复制团组成本
  6305. //if (dto.Diid == 2581)
  6306. //{
  6307. // dto.Diid = 2599;
  6308. // dto.CheckBoxs.ForEach(x =>
  6309. // {
  6310. // x.Diid = 2599;
  6311. // });
  6312. // dto.GroupCosts.ForEach(x =>
  6313. // {
  6314. // x.Diid = 2599;
  6315. // });
  6316. // dto.CostTypeHotelNumbers.ForEach(x =>
  6317. // {
  6318. // x.Diid = 2599;
  6319. // });
  6320. // dto.GroupCostParameters.ForEach(x =>
  6321. // {
  6322. // x.DiId = 2599;
  6323. // });
  6324. //}
  6325. #endregion
  6326. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6327. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6328. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6329. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6330. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6331. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6332. try
  6333. {
  6334. _sqlSugar.BeginTran();
  6335. isTrue = await _GroupCostRepository.
  6336. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6337. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6338. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6339. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6340. _sqlSugar.CommitTran();
  6341. jw = JsonView(true, "保存成功!", isTrue);
  6342. }
  6343. catch (Exception)
  6344. {
  6345. _sqlSugar.RollbackTran();
  6346. jw = JsonView(false);
  6347. }
  6348. return Ok(jw);
  6349. }
  6350. /// <summary>
  6351. /// 司兼导数据
  6352. /// </summary>
  6353. /// <param name="dto"></param>
  6354. /// <returns></returns>
  6355. [HttpPost]
  6356. public IActionResult GetCarGuides(CarGuidesDto dto)
  6357. {
  6358. JsonView jw = null;
  6359. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6360. jw = JsonView(true, "获取成功!", Data);
  6361. return Ok(jw);
  6362. }
  6363. /// <summary>
  6364. /// 导游数据
  6365. /// </summary>
  6366. /// <param name="dto"></param>
  6367. /// <returns></returns>
  6368. [HttpPost]
  6369. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6370. {
  6371. JsonView jw = null;
  6372. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6373. // 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
  6374. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6375. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6376. jw = JsonView(true, "获取成功!", Data);
  6377. return Ok(jw);
  6378. }
  6379. /// <summary>
  6380. /// 成本车数据
  6381. /// </summary>
  6382. /// <param name="dto"></param>
  6383. /// <returns></returns>
  6384. [HttpPost]
  6385. public IActionResult GetCarInfo(CarGuidesDto dto)
  6386. {
  6387. JsonView jw = null;
  6388. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6389. jw = JsonView(true, "获取成功!", Data);
  6390. return Ok(jw);
  6391. }
  6392. /// <summary>
  6393. /// 景点数据
  6394. /// </summary>
  6395. /// <param name="dto"></param>
  6396. /// <returns></returns>
  6397. [HttpPost]
  6398. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6399. {
  6400. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6401. return Ok(JsonView(true, "获取成功!", Data));
  6402. }
  6403. /// <summary>
  6404. /// 成本通知
  6405. /// </summary>
  6406. /// <param name="dto"></param>
  6407. /// <returns></returns>
  6408. [HttpPost]
  6409. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6410. {
  6411. if (dto.Diid < 0)
  6412. {
  6413. return Ok(JsonView(false));
  6414. }
  6415. JsonView jw = null;
  6416. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6417. if (GroupCostParameter != null)
  6418. {
  6419. int IsShare = 0;
  6420. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6421. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6422. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6423. string msg = string.Empty;
  6424. if (isTrue)
  6425. {
  6426. if (IsShare == 0)
  6427. {
  6428. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6429. }
  6430. else
  6431. {
  6432. #region 企微通知对应岗位用户
  6433. try
  6434. {
  6435. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6436. }
  6437. catch (Exception ex)
  6438. {
  6439. }
  6440. #endregion
  6441. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6442. }
  6443. jw = JsonView(isTrue, msg, new { IsShare });
  6444. }
  6445. else
  6446. {
  6447. msg = "修改失败!";
  6448. jw = JsonView(isTrue, msg);
  6449. }
  6450. }
  6451. else
  6452. {
  6453. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6454. }
  6455. return Ok(jw);
  6456. }
  6457. /// <summary>
  6458. /// 导出报价单
  6459. /// </summary>
  6460. /// <param name="dto"></param>
  6461. /// <returns></returns>
  6462. [HttpPost]
  6463. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6464. {
  6465. if (dto.Diid == 0)
  6466. {
  6467. return Ok(JsonView(false, "请传递团组id"));
  6468. }
  6469. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6470. if (deleInfo.Code != 0)
  6471. {
  6472. return Ok(JsonView(false, "团组信息查询失败!"));
  6473. }
  6474. var di = deleInfo.Data as DelegationInfoWebView;
  6475. if (di != null)
  6476. {
  6477. //文件名
  6478. string strFileName = di.TeamName + "-收款账单.doc";
  6479. //获取模板
  6480. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6481. //载入模板
  6482. Document doc = new Document(tmppath);
  6483. decimal TotalPrice = 0.00M;
  6484. string itemStr = string.Empty;
  6485. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6486. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6487. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6488. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6489. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6490. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6491. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6492. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6493. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6494. foreach (var cost in groupCostType)
  6495. {
  6496. var List = cost.ToList();
  6497. if (cost.Key == "A")
  6498. {
  6499. foreach (var ListItem in List)
  6500. {
  6501. if (ListItem.number > 0)
  6502. {
  6503. if (ListItem.code.Contains("TBR"))
  6504. {
  6505. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6506. }
  6507. else
  6508. {
  6509. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6510. }
  6511. TotalPrice += (ListItem.number * ListItem.price);
  6512. }
  6513. }
  6514. }
  6515. else
  6516. {
  6517. itemStr = itemStr.Insert(0, "A段\r\n");
  6518. itemStr += "B段\r\n";
  6519. foreach (var ListItem in List)
  6520. {
  6521. if (ListItem.number > 0)
  6522. {
  6523. if (ListItem.code.Contains("TBR"))
  6524. {
  6525. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6526. }
  6527. else
  6528. {
  6529. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6530. }
  6531. TotalPrice += (ListItem.number * ListItem.price);
  6532. }
  6533. }
  6534. }
  6535. }
  6536. #region 替换Word模板书签内容
  6537. Dictionary<string, string> marks = new Dictionary<string, string>();
  6538. marks.Add("To", di.ClientUnit);//付款方
  6539. marks.Add("ToTel", di.TellPhone);//付款方电话
  6540. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6541. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6542. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6543. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6544. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6545. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6546. marks.Add("PayItemContent", itemStr);//详细信息
  6547. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6548. #endregion
  6549. ////注
  6550. //if (doc.Range.Bookmarks["Attention"] != null)
  6551. //{
  6552. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6553. // mark.Text = frList[0].Attention;
  6554. //}
  6555. foreach (var item in marks.Keys)
  6556. {
  6557. if (doc.Range.Bookmarks[item] != null)
  6558. {
  6559. Bookmark mark = doc.Range.Bookmarks[item];
  6560. mark.Text = marks[item];
  6561. }
  6562. }
  6563. byte[] bytes = null;
  6564. using (MemoryStream stream = new MemoryStream())
  6565. {
  6566. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6567. bytes = stream.ToArray();
  6568. }
  6569. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6570. return Ok(JsonView(true, "", new
  6571. {
  6572. Data = bytes,
  6573. strFileName,
  6574. }));
  6575. }
  6576. else
  6577. {
  6578. return Ok(JsonView(false, "团组信息不存在!"));
  6579. }
  6580. }
  6581. /// <summary>
  6582. /// 导出团组成本
  6583. /// </summary>
  6584. /// <param name="dto"></param>
  6585. /// <returns></returns>
  6586. [HttpPost]
  6587. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6588. {
  6589. var jw = JsonView(false);
  6590. if (dto.Diid == 0)
  6591. {
  6592. return Ok(JsonView(false, "请传递团组id"));
  6593. }
  6594. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6595. if (deleInfo.Code != 0)
  6596. {
  6597. return Ok(JsonView(false, "团组信息查询失败!"));
  6598. }
  6599. var di = deleInfo.Data as DelegationInfoWebView;
  6600. if (di == null)
  6601. {
  6602. return Ok(JsonView(false, "团组信息查询失败!"));
  6603. }
  6604. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6605. WorkbookDesigner designer = new WorkbookDesigner();
  6606. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6607. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6608. for (int i = 0; i < List_GC.Count; i++)
  6609. {
  6610. GroupCost_Excel gc = new GroupCost_Excel();
  6611. gc.Id = List_GC[i].Id;
  6612. gc.Diid = List_GC[i].Diid.ToString();
  6613. gc.DAY = List_GC[i].DAY;
  6614. string week = "";
  6615. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6616. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6617. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6618. gc.ITIN = List_GC[i].ITIN;
  6619. gc.CarType = List_GC[i].CarType;
  6620. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6621. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6622. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6623. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6624. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6625. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6626. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6627. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6628. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6629. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6630. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6631. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6632. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6633. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6634. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6635. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6636. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6637. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6638. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6639. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6640. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6641. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6642. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6643. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6644. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6645. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6646. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6647. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6648. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6649. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6650. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6651. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6652. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6653. List_GC1.Add(gc);
  6654. }
  6655. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6656. dt.TableName = "TB";
  6657. //报表标题等不用dt的值
  6658. designer.SetDataSource("TeamName", dto.title.TeamName);
  6659. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6660. designer.SetDataSource("Tax", dto.title.Tax);
  6661. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6662. designer.SetDataSource("Currency", dto.title.Currency);
  6663. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6664. designer.SetDataSource("Rate", dto.title.Rate);
  6665. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6666. var Aparams = hotels.Find(x => x.Type == "Default");
  6667. if (Aparams == null)
  6668. {
  6669. return Ok(jw);
  6670. }
  6671. //酒店数量
  6672. var txtSGRNumber = Aparams.SGR.ToString();
  6673. var txtTBRNumber = Aparams.TBR.ToString();
  6674. var txtJSESNumber = Aparams.JSES.ToString();
  6675. var txtSUITENumbe = Aparams.SUITE.ToString();
  6676. if (dto.costType == "B")
  6677. {
  6678. Aparams = hotels.Find(x => x.Type == "A");
  6679. var Bparams = hotels.Find(x => x.Type == "B");
  6680. if (Aparams == null || Bparams == null)
  6681. {
  6682. return Ok(jw);
  6683. }
  6684. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6685. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6686. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6687. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6688. }
  6689. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6690. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6691. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6692. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6693. var ws = designer.Workbook.Worksheets[0];
  6694. int Row = List_GC.Count;
  6695. int startIndex = 11;
  6696. int HideRows = 0;
  6697. List<int> hideRowsList = new List<int>();
  6698. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6699. #region A段left数据
  6700. var left = dto.leftInfo.Find(x => x.Type == "A");
  6701. if (left == null)
  6702. {
  6703. return Ok(jw);
  6704. }
  6705. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6706. if (leftBindData != null)
  6707. {
  6708. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6709. designer.SetDataSource("VisaRS", leftBindData.rs);
  6710. designer.SetDataSource("VisaXS", leftBindData.xs);
  6711. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6712. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6713. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6714. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6715. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6716. }
  6717. else
  6718. {
  6719. hideRowsList.Add(Row + startIndex + HideRows);
  6720. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6721. }
  6722. HideRows += 2;
  6723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6724. if (leftBindData != null)
  6725. {
  6726. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6727. designer.SetDataSource("BXRS", leftBindData.rs);
  6728. designer.SetDataSource("BXXS", leftBindData.xs);
  6729. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6730. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6731. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6732. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6733. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6734. }
  6735. else
  6736. {
  6737. hideRowsList.Add(Row + startIndex + HideRows);
  6738. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6739. }
  6740. HideRows += 2;
  6741. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6742. if (leftBindData != null)
  6743. {
  6744. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6745. designer.SetDataSource("HSRS", leftBindData.rs);
  6746. designer.SetDataSource("HSXS", leftBindData.xs);
  6747. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6748. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6749. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6750. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6751. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6752. }
  6753. else
  6754. {
  6755. hideRowsList.Add(Row + startIndex + HideRows);
  6756. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6757. }
  6758. HideRows += 2;
  6759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6760. if (leftBindData != null)
  6761. {
  6762. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6763. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6764. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6765. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6766. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6767. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6768. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6769. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6770. }
  6771. else
  6772. {
  6773. hideRowsList.Add(Row + startIndex + HideRows);
  6774. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6775. }
  6776. HideRows += 2;
  6777. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6778. if (leftBindData != null)
  6779. {
  6780. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6781. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6782. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6783. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6784. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6785. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6786. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6787. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6788. }
  6789. else
  6790. {
  6791. hideRowsList.Add(Row + startIndex + HideRows);
  6792. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6793. }
  6794. HideRows += 2;
  6795. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6796. if (leftBindData != null)
  6797. {
  6798. ////TBR
  6799. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6800. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6801. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6802. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6803. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6804. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6805. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6806. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6807. }
  6808. else
  6809. {
  6810. hideRowsList.Add(Row + startIndex + HideRows);
  6811. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6812. }
  6813. HideRows += 2;
  6814. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6815. if (leftBindData != null)
  6816. {
  6817. ////SGR
  6818. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6819. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6820. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6821. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6822. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6823. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6824. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6825. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6826. }
  6827. else
  6828. {
  6829. hideRowsList.Add(Row + startIndex + HideRows);
  6830. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6831. }
  6832. HideRows += 2;
  6833. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6834. if (leftBindData != null)
  6835. {
  6836. ////JS/ES
  6837. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6838. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6839. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6840. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6841. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6842. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6843. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6844. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6845. }
  6846. else
  6847. {
  6848. hideRowsList.Add(Row + startIndex + HideRows);
  6849. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6850. }
  6851. HideRows += 2;
  6852. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6853. if (leftBindData != null)
  6854. {
  6855. ////SUITE
  6856. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6857. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6858. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6859. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6860. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6861. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6862. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6863. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6864. }
  6865. else
  6866. {
  6867. hideRowsList.Add(Row + startIndex + HideRows);
  6868. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6869. }
  6870. HideRows += 2;
  6871. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6872. if (leftBindData != null)
  6873. {
  6874. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6875. designer.SetDataSource("DJRS", leftBindData.rs);
  6876. designer.SetDataSource("DJXS", leftBindData.xs);
  6877. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6878. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6879. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6880. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6881. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6882. }
  6883. else
  6884. {
  6885. hideRowsList.Add(Row + startIndex + HideRows);
  6886. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6887. }
  6888. HideRows += 2;
  6889. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6890. if (leftBindData != null)
  6891. {
  6892. designer.SetDataSource("HCPCB", leftBindData.cb);
  6893. designer.SetDataSource("HCPRS", leftBindData.rs);
  6894. designer.SetDataSource("HCPXS", leftBindData.xs);
  6895. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6896. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6897. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6898. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6899. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6900. }
  6901. else
  6902. {
  6903. hideRowsList.Add(Row + startIndex + HideRows);
  6904. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6905. }
  6906. HideRows += 2;
  6907. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6908. if (leftBindData != null)
  6909. {
  6910. designer.SetDataSource("CPCB", leftBindData.cb);
  6911. designer.SetDataSource("CPRS", leftBindData.rs);
  6912. designer.SetDataSource("CPXS", leftBindData.xs);
  6913. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6914. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6915. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6916. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6917. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6918. }
  6919. else
  6920. {
  6921. hideRowsList.Add(Row + startIndex + HideRows);
  6922. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6923. }
  6924. HideRows += 2;
  6925. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  6926. if (leftBindData != null)
  6927. {
  6928. designer.SetDataSource("GWDRCD", leftBindData.cb);
  6929. designer.SetDataSource("GWRS", leftBindData.rs);
  6930. designer.SetDataSource("GWXS", leftBindData.xs);
  6931. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6932. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6933. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6934. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6935. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6936. }
  6937. else
  6938. {
  6939. hideRowsList.Add(Row + startIndex + HideRows);
  6940. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6941. }
  6942. HideRows += 2;
  6943. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  6944. if (leftBindData != null)
  6945. {
  6946. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  6947. designer.SetDataSource("LYJRS", leftBindData.rs);
  6948. designer.SetDataSource("LYJXS", leftBindData.xs);
  6949. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6950. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6951. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6952. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6953. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6954. }
  6955. else
  6956. {
  6957. hideRowsList.Add(Row + startIndex + HideRows);
  6958. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6959. }
  6960. #endregion
  6961. #region A段Right信息
  6962. var right = dto.rightInfo.Find(x => x.Type == "A");
  6963. if (right == null)
  6964. {
  6965. return Ok(jw);
  6966. }
  6967. HideRows += 4;
  6968. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  6969. if (rightBindData != null)
  6970. {
  6971. //经济舱 + 双人间 TBR
  6972. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  6973. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  6974. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6975. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  6976. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6977. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6978. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6979. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6980. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6981. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6982. }
  6983. else
  6984. {
  6985. hideRowsList.Add(Row + startIndex + HideRows);
  6986. }
  6987. HideRows += 2;
  6988. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  6989. if (rightBindData != null)
  6990. {
  6991. //经济舱 + 单人间 SGR
  6992. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  6993. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  6994. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6995. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  6996. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6997. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6998. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7002. }
  7003. else
  7004. {
  7005. hideRowsList.Add(Row + startIndex + HideRows);
  7006. }
  7007. HideRows += 2;
  7008. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7009. if (rightBindData != null)
  7010. {
  7011. //公务舱 + 单人间 SGR
  7012. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7013. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7014. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7015. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7016. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7017. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7018. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7022. }
  7023. else
  7024. {
  7025. hideRowsList.Add(Row + startIndex + HideRows);
  7026. }
  7027. HideRows += 2;
  7028. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7029. if (rightBindData != null)
  7030. {
  7031. //公务舱 + 小套房 JSES
  7032. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7033. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7034. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7035. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7036. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7037. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7038. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7039. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7040. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7041. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7042. }
  7043. else
  7044. {
  7045. hideRowsList.Add(Row + startIndex + HideRows);
  7046. }
  7047. HideRows += 2;
  7048. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7049. if (rightBindData != null)
  7050. {
  7051. //公务舱 + 小套房 JSES
  7052. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7053. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7054. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7055. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7056. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7057. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7058. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7059. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7060. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7061. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7062. }
  7063. else
  7064. {
  7065. hideRowsList.Add(Row + startIndex + HideRows);
  7066. }
  7067. HideRows += 2;
  7068. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7069. if (rightBindData != null)
  7070. {
  7071. //经济舱 + 大套房
  7072. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7073. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7074. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7075. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7076. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7077. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7078. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7079. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7080. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7081. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7082. }
  7083. else
  7084. {
  7085. hideRowsList.Add(Row + startIndex + HideRows);
  7086. }
  7087. #endregion
  7088. #region B段标题清空
  7089. designer.SetDataSource("CostBDRCB", "");
  7090. designer.SetDataSource("CostBRS", "");
  7091. designer.SetDataSource("CostBXS", "");
  7092. designer.SetDataSource("CostBZCB", "");
  7093. designer.SetDataSource("CostBDRBJ", "");
  7094. designer.SetDataSource("CostBZBJ", "");
  7095. designer.SetDataSource("CostBDRLR", "");
  7096. designer.SetDataSource("CostBZLR", "");
  7097. designer.SetDataSource("CostBDRCBOM", "");
  7098. designer.SetDataSource("CostBRSOM", "");
  7099. designer.SetDataSource("CostBZCBOM", "");
  7100. designer.SetDataSource("CostBDRBJOM", "");
  7101. designer.SetDataSource("CostBZBJOM", "");
  7102. designer.SetDataSource("CostBDRLROM", "");
  7103. designer.SetDataSource("CostBZLROM", "");
  7104. #endregion
  7105. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7106. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7107. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7108. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7109. designer.SetDataSource("DJName", "地接(CNY)");
  7110. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7111. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7112. designer.SetDataSource("GWName", "公务(CNY)");
  7113. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7114. designer.SetDataSource("LYJName", "零用金(CNY)");
  7115. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7116. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7117. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7118. designer.SetDataSource("BXName", "保险(CNY)");
  7119. designer.SetDataSource("VisaName", "签证(CNY)");
  7120. #region B段基本数据
  7121. if (dto.costType == "B")
  7122. {
  7123. left = dto.leftInfo.Find(x => x.Type == "B");
  7124. if (left == null)
  7125. {
  7126. return Ok(jw);
  7127. }
  7128. #region B段left数据
  7129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7130. if (leftBindData != null)
  7131. {
  7132. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7133. designer.SetDataSource("BHSRS", leftBindData.rs);
  7134. designer.SetDataSource("BHSXS", leftBindData.xs);
  7135. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7136. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7137. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7138. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7139. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7140. }
  7141. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7142. if (leftBindData != null)
  7143. {
  7144. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7145. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7146. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7147. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7148. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7149. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7150. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7151. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7152. }
  7153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7154. if (leftBindData != null)
  7155. {
  7156. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7157. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7158. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7159. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7160. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7161. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7162. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7163. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7164. }
  7165. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7166. if (leftBindData != null)
  7167. {
  7168. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7169. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7170. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7171. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7172. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7173. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7174. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7175. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7176. }
  7177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7178. if (leftBindData != null)
  7179. {
  7180. designer.SetDataSource("BCPCB", leftBindData.cb);
  7181. designer.SetDataSource("BCPRS", leftBindData.rs);
  7182. designer.SetDataSource("BCPXS", leftBindData.xs);
  7183. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7184. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7185. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7186. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7187. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7188. }
  7189. //TBR
  7190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7191. if (leftBindData != null)
  7192. {
  7193. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7194. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7195. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7196. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7197. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7198. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7199. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7200. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7201. }
  7202. //SGR
  7203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7204. if (leftBindData != null)
  7205. {
  7206. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7207. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7208. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7209. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7210. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7211. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7212. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7213. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7214. }
  7215. //JS/ES
  7216. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7217. if (leftBindData != null)
  7218. {
  7219. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7220. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7221. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7222. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7223. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7224. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7226. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7227. }
  7228. //SUITE
  7229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7230. if (leftBindData != null)
  7231. {
  7232. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7233. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7234. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7235. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7236. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7237. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7238. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7239. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7240. }
  7241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7242. if (leftBindData != null)
  7243. {
  7244. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7245. designer.SetDataSource("BDJRS", leftBindData.rs);
  7246. designer.SetDataSource("BDJXS", leftBindData.xs);
  7247. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7248. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7249. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7250. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7251. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7252. }
  7253. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7254. if (leftBindData != null)
  7255. {
  7256. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7257. designer.SetDataSource("BGWRS", leftBindData.rs);
  7258. designer.SetDataSource("BGWXS", leftBindData.xs);
  7259. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7260. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7261. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7262. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7263. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7264. }
  7265. #region 优化方案
  7266. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7267. //excelBind.Add("零用金", new {
  7268. //cb="",
  7269. //rs="",
  7270. //xs ="",
  7271. //zcb = "",
  7272. //});
  7273. #endregion
  7274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7275. if (leftBindData != null)
  7276. {
  7277. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7278. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7279. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7280. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7281. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7282. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7283. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7284. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7285. }
  7286. #endregion
  7287. #region B段Right信息
  7288. right = dto.rightInfo.Find(x => x.Type == "B");
  7289. if (right == null)
  7290. {
  7291. return Ok(jw);
  7292. }
  7293. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7294. if (rightBindData != null)
  7295. {
  7296. //经济舱 + 双人间 TBR
  7297. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7298. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7299. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7300. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7301. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7302. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7303. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7304. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7305. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7306. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7307. }
  7308. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7309. if (rightBindData != null)
  7310. {
  7311. //经济舱 + 单人间 SGR
  7312. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7313. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7314. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7315. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7316. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7317. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7318. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7319. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7320. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7321. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7322. }
  7323. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7324. if (rightBindData != null)
  7325. {
  7326. //公务舱 + 单人间 SGR
  7327. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7328. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7329. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7330. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7331. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7332. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7333. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7334. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7335. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7336. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7337. }
  7338. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7339. if (rightBindData != null)
  7340. {
  7341. //公务舱 + 小套房 JSES
  7342. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7343. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7344. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7345. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7346. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7347. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7348. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7349. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7350. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7351. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7352. }
  7353. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7354. if (rightBindData != null)
  7355. {
  7356. //公务舱 + 小套房 JSES
  7357. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7358. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7359. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7360. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7361. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7362. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7363. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7364. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7365. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7366. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7367. }
  7368. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7369. if (rightBindData != null)
  7370. {
  7371. //经济舱 + 大套房
  7372. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7373. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7374. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7375. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7376. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7377. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7378. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7379. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7380. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7381. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7382. }
  7383. #endregion
  7384. #region 标题
  7385. designer.SetDataSource("CostBDRCB", "单人成本");
  7386. designer.SetDataSource("CostBRS", "人数");
  7387. designer.SetDataSource("CostBXS", "系数");
  7388. designer.SetDataSource("CostBZCB", "总成本");
  7389. designer.SetDataSource("CostBDRBJ", "单人报价");
  7390. designer.SetDataSource("CostBZBJ", "总报价");
  7391. designer.SetDataSource("CostBDRLR", "单人利润");
  7392. designer.SetDataSource("CostBZLR", "总利润");
  7393. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7394. designer.SetDataSource("CostBRSOM", "人数");
  7395. designer.SetDataSource("CostBZCBOM", "总成本");
  7396. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7397. designer.SetDataSource("CostBZBJOM", "总报价");
  7398. designer.SetDataSource("CostBDRLROM", "单人利润");
  7399. designer.SetDataSource("CostBZLROM", "总利润");
  7400. #endregion
  7401. }
  7402. #endregion
  7403. designer.SetDataSource("TzZCB2", TzZCB2);
  7404. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7405. designer.SetDataSource("TzZLR2", TzZLR2);
  7406. string[] dataSourceKeys = new string[]
  7407. {
  7408. "VF",
  7409. "TGS",
  7410. "TGOF",
  7411. "TGM",
  7412. "TGA",
  7413. "TGTF",
  7414. "TGEF",
  7415. "CFM",
  7416. "CFOF",
  7417. "B",
  7418. "L",
  7419. "D",
  7420. "TBR",
  7421. "SGR",
  7422. "JSES",
  7423. "Suite",
  7424. "TV",
  7425. "1L",
  7426. "IF",
  7427. "EF",
  7428. "BRF",
  7429. "TE",
  7430. "TGT",
  7431. "DRVT",
  7432. "PC",
  7433. "TLF",
  7434. "ECT"
  7435. };
  7436. foreach (var item in dataSourceKeys)
  7437. {
  7438. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7439. if (find != null)
  7440. {
  7441. designer.SetDataSource(item, find.text);
  7442. }
  7443. else
  7444. {
  7445. designer.SetDataSource(item, 0);
  7446. }
  7447. }
  7448. designer.SetDataSource(dt);
  7449. //根据数据源处理生成报表内容
  7450. designer.Process();
  7451. designer.Workbook.Worksheets[0].Name = "清单";
  7452. Worksheet sheet = designer.Workbook.Worksheets[0];
  7453. foreach (var Rowindex in hideRowsList)
  7454. {
  7455. ws.Cells.HideRows(Rowindex, 2);
  7456. }
  7457. byte[] bytes = null;
  7458. string strFileName = di.TeamName + "-团组-成本.xls";
  7459. using (MemoryStream stream = new MemoryStream())
  7460. {
  7461. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7462. bytes = stream.ToArray();
  7463. }
  7464. return Ok(JsonView(true, "", new
  7465. {
  7466. Data = bytes,
  7467. strFileName,
  7468. }));
  7469. }
  7470. /// <summary>
  7471. /// 导出客户报表
  7472. /// </summary>
  7473. /// <returns></returns>
  7474. [HttpPost]
  7475. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7476. {
  7477. var jw = JsonView(false);
  7478. if (dto.Diid == 0)
  7479. {
  7480. return Ok(JsonView(false, "请传递团组id"));
  7481. }
  7482. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7483. if (deleInfo.Code != 0)
  7484. {
  7485. return Ok(JsonView(false, "团组信息查询失败!"));
  7486. }
  7487. var di = deleInfo.Data as DelegationInfoWebView;
  7488. if (di == null)
  7489. {
  7490. return Ok(JsonView(false, "团组信息查询失败!"));
  7491. }
  7492. //文件名
  7493. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7494. //获取模板
  7495. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7496. //载入模板
  7497. Document doc = new Document(tmppath);
  7498. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7499. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7500. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7501. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7502. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7503. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7504. if (AParameter == null)
  7505. {
  7506. return Ok(JsonView(false, "系数不存在!"));
  7507. }
  7508. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7509. , TzAirDesc, TzZCost;
  7510. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7511. = TzAirDesc = TzZCost = string.Empty;
  7512. TzNumber = AParameter.CostTypenumber.ToString();
  7513. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7514. CarGuides1 = dto.CarGuides1;
  7515. Meal = dto.Meal;
  7516. SubsidizedMeals = dto.SubsidizedMeals;
  7517. NightRepair = dto.NightRepair;
  7518. AttractionsTickets = dto.AttractionsTickets;
  7519. MiscellaneousFees = dto.MiscellaneousFees;
  7520. ATip = dto.ATip;
  7521. TzHotelDesc = "";
  7522. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7523. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7524. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7525. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7526. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7527. TzAirDesc = "";
  7528. TzZCost = dto.TzZCost;
  7529. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7530. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7531. var index = 1;
  7532. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7533. foreach (var item in TzHotelDescArr)
  7534. {
  7535. if (AinfoArr != null)
  7536. {
  7537. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7538. if (Ainfo != null)
  7539. {
  7540. if (int.Parse(Ainfo.rs) <= 0)
  7541. {
  7542. continue;
  7543. }
  7544. var hotelText = string.Empty;
  7545. switch (item)
  7546. {
  7547. case "SGR":
  7548. hotelText = "单人间";
  7549. break;
  7550. case "JSES":
  7551. hotelText = "小套房";
  7552. break;
  7553. case "SUITE":
  7554. hotelText = "套房";
  7555. break;
  7556. case "TBR":
  7557. hotelText = "双人间";
  7558. break;
  7559. }
  7560. if (item != "TBR")
  7561. {
  7562. 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";
  7563. }
  7564. else
  7565. {
  7566. 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";
  7567. }
  7568. index++;
  7569. }
  7570. }
  7571. }
  7572. index = 1;
  7573. foreach (var item in TzAirDescArr)
  7574. {
  7575. if (AinfoArr != null)
  7576. {
  7577. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7578. if (Ainfo != null)
  7579. {
  7580. if (int.Parse(Ainfo.rs) <= 0)
  7581. {
  7582. continue;
  7583. }
  7584. 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";
  7585. index++;
  7586. }
  7587. }
  7588. }
  7589. if (dto.costType == "B")
  7590. {
  7591. if (BParameter == null)
  7592. {
  7593. return Ok(JsonView(false, "B段系数不存在!"));
  7594. }
  7595. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7596. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7597. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7598. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7599. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7600. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7601. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7602. foreach (var item in TzHotelDescArr)
  7603. {
  7604. if (AinfoArr != null)
  7605. {
  7606. TzHotelDesc += "B段信息 \r\n";
  7607. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7608. if (Ainfo != null)
  7609. {
  7610. if (int.Parse(Ainfo.rs) <= 0)
  7611. {
  7612. continue;
  7613. }
  7614. var hotelText = string.Empty;
  7615. switch (item)
  7616. {
  7617. case "SGR":
  7618. hotelText = "单人间";
  7619. break;
  7620. case "JSES":
  7621. hotelText = "小套房";
  7622. break;
  7623. case "SUITE":
  7624. hotelText = "套房";
  7625. break;
  7626. case "TBR":
  7627. hotelText = "双人间";
  7628. break;
  7629. }
  7630. if (item != "TBR")
  7631. {
  7632. 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";
  7633. }
  7634. else
  7635. {
  7636. 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";
  7637. }
  7638. index++;
  7639. }
  7640. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7641. }
  7642. }
  7643. index = 1;
  7644. foreach (var item in TzAirDescArr)
  7645. {
  7646. if (AinfoArr != null)
  7647. {
  7648. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7649. if (Ainfo != null)
  7650. {
  7651. if (int.Parse(Ainfo.rs) <= 0)
  7652. {
  7653. continue;
  7654. }
  7655. 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";
  7656. index++;
  7657. }
  7658. }
  7659. }
  7660. }
  7661. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7662. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7663. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7664. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7665. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7666. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7667. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7668. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7669. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7670. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7671. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7672. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7673. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7674. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7675. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7676. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7677. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7678. DickeyValue.Add("TzZCost", TzZCost);
  7679. foreach (var key in DickeyValue.Keys)
  7680. {
  7681. if (doc.Range.Bookmarks[key] != null)
  7682. {
  7683. Bookmark mark = doc.Range.Bookmarks[key];
  7684. mark.Text = DickeyValue[key];
  7685. }
  7686. }
  7687. byte[] bytes = null;
  7688. string strFileName = di.TeamName + "-客户报价.doc";
  7689. using (MemoryStream stream = new MemoryStream())
  7690. {
  7691. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7692. bytes = stream.ToArray();
  7693. }
  7694. return Ok(JsonView(true, "", new
  7695. {
  7696. Data = bytes,
  7697. strFileName,
  7698. }));
  7699. }
  7700. /// <summary>
  7701. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7702. /// </summary>
  7703. /// <param name="dto"></param>
  7704. /// <returns></returns>
  7705. [HttpPost]
  7706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7707. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7708. {
  7709. try
  7710. {
  7711. #region 参数验证
  7712. if (dto.DiId < 0)
  7713. {
  7714. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7715. }
  7716. List<int> cTableIds = new List<int>() {
  7717. 76 ,//酒店预订
  7718. 77 ,//行程
  7719. 79 ,//车/导游地接
  7720. 80 ,//签证
  7721. 81 ,//邀请/公务活
  7722. 82 ,//团组客户保险
  7723. 85 ,//机票预订
  7724. 98 ,//其他款项
  7725. 285 ,//收款退还
  7726. 751 ,//酒店早餐
  7727. 1015 // 超支费用
  7728. };
  7729. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7730. {
  7731. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7732. }
  7733. #endregion
  7734. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7735. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7736. if (_GroupCostParameters.Count <= 0)
  7737. {
  7738. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7739. }
  7740. if (_GroupCostParameters[0].IsShare == 0)
  7741. {
  7742. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7743. }
  7744. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7745. //处理date为空问题
  7746. if (_GroupCosts.Count > 0)
  7747. {
  7748. for (int i = 0; i < _GroupCosts.Count; i++)
  7749. {
  7750. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7751. {
  7752. if (i > 0)
  7753. {
  7754. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7755. }
  7756. }
  7757. }
  7758. }
  7759. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7760. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7761. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7762. string currCode = "";
  7763. #region currCode 验证
  7764. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7765. if (isInt)
  7766. {
  7767. var currData = currDatas.Find(it => it.Id == intCurrency);
  7768. if (currData != null)
  7769. {
  7770. currCode = currData.Name;
  7771. }
  7772. }
  7773. else
  7774. {
  7775. currCode = _GroupCostParameters[0].Currency.Trim();
  7776. }
  7777. #endregion
  7778. //op,酒店单段模式存储
  7779. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7780. {
  7781. CurrencyCode = currCode,
  7782. Rate = _GroupCostParameters[0].Rate,
  7783. CostType = _GroupCostParameters[0].CostType,
  7784. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7785. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7786. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7787. };
  7788. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7789. if (_GroupCostParameters.Count == 2)
  7790. {
  7791. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7792. }
  7793. foreach (var item in _GroupCostParameters)
  7794. {
  7795. decimal _rate = 1;
  7796. decimal _rate1 = item.Rate;
  7797. decimal _scale = 1;
  7798. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7799. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7800. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7801. //if (userInfo != null)
  7802. //{
  7803. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7804. // {
  7805. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7806. // {
  7807. // _scale = 1.00M;
  7808. // }
  7809. // }
  7810. //}
  7811. #endregion
  7812. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7813. {
  7814. CurrencyCode = currCode,
  7815. Rate = _rate1,
  7816. CostType = item.CostType,
  7817. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7818. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7819. CostTypeNumber = item.CostTypenumber
  7820. };
  7821. if (_GroupCostParameters.Count > 1)
  7822. {
  7823. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7824. }
  7825. else
  7826. {
  7827. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7828. }
  7829. if (dto.CTable == 79)//
  7830. {
  7831. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7832. modulePromptInfo.TotalCost = item.DJCB;
  7833. }
  7834. List<string> costTypes = new List<string>() { "A", "B" };
  7835. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7836. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7837. if (_GroupCostsDuplicates.Count() == 1)
  7838. {
  7839. _GroupCostsTypeData = _GroupCosts;
  7840. }
  7841. else
  7842. {
  7843. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7844. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7845. }
  7846. /*
  7847. * 76 酒店预订
  7848. * 77 行程
  7849. * 79 车/导游地接
  7850. * 80 签证
  7851. * 81 邀请/公务活动
  7852. * 82 团组客户保险
  7853. * 85 机票预订
  7854. * 98 其他款项
  7855. * 285 收款退还
  7856. * 751 酒店早餐
  7857. * 1015 超支费用
  7858. */
  7859. switch (dto.CTable)
  7860. {
  7861. case 76: // 酒店预订
  7862. _ModuleSubPromptInfo.AddRange(
  7863. _GroupCostsTypeData.Select(it => new
  7864. {
  7865. it.DAY,
  7866. it.Date,
  7867. it.ACCON,
  7868. it.ITIN,
  7869. it.SGR,
  7870. it.TBR,
  7871. it.JS_ES,
  7872. it.Suite
  7873. })
  7874. );
  7875. break;
  7876. case 79: // 车/导游地接
  7877. _ModuleSubPromptInfo.AddRange(
  7878. _GroupCostsTypeData.Select(it => new
  7879. {
  7880. Date = it.Date, //日期
  7881. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  7882. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  7883. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  7884. TicketFee = it.EF * _rate * _scale, //门票费
  7885. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  7886. AirportTransferFee = 0.00M,
  7887. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7888. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7889. LeadersFee = it.TLF * _rate * _scale, //领队费
  7890. CarFee1 = it.CarCost * _rate * _scale,
  7891. CarType = it.CarType, //车型
  7892. SpentCash = it.PC * _rate * _scale, //零用金
  7893. })
  7894. );
  7895. break;
  7896. case 85: // 机票
  7897. List<dynamic> datas = new List<dynamic>();
  7898. datas.Add(
  7899. new
  7900. {
  7901. AirType = "经济舱",
  7902. AirNum = item.JJCRS,
  7903. AirDRCB = item.JJCCB,
  7904. AirZCB = (item.JJCRS * item.JJCCB)
  7905. }
  7906. );
  7907. datas.Add(
  7908. new
  7909. {
  7910. AirType = "公务舱",
  7911. AirNum = item.GWCRS,
  7912. AirDRCB = item.GWCCB,
  7913. AirZCB = (item.GWCRS * item.GWCCB)
  7914. }
  7915. );
  7916. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7917. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  7918. modulePromptInfo.Data = new
  7919. {
  7920. airFeeData = datas,
  7921. airInitData = initDatas
  7922. };
  7923. _ModulePromptInfos.Add(modulePromptInfo);
  7924. break;
  7925. default:
  7926. break;
  7927. }
  7928. }
  7929. if (dto.CTable != 85)
  7930. {
  7931. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  7932. _ModulePromptInfos.Add(_ModulePromptInfo);
  7933. }
  7934. _view.ModulePromptInfos = _ModulePromptInfos;
  7935. return Ok(JsonView(true, "操作成功!", _view));
  7936. }
  7937. catch (Exception ex)
  7938. {
  7939. return Ok(JsonView(false, ex.Message));
  7940. }
  7941. }
  7942. /// <summary>
  7943. /// 根据黑屏代码重新生成行程
  7944. /// </summary>
  7945. /// <param name="dto"></param>
  7946. /// <returns></returns>
  7947. [HttpPost]
  7948. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  7949. {
  7950. var jw = JsonView(false);
  7951. var Create = _GroupCostRepository.
  7952. CreateGroupCostByBlackCode(dto.Diid);
  7953. jw.Msg = Create.Msg;
  7954. if (Create.Code == 0)
  7955. {
  7956. jw.Code = 200;
  7957. jw.Data = new
  7958. {
  7959. groupCost = Create.Data,
  7960. blackCodeIsTrue = true
  7961. };
  7962. }
  7963. else
  7964. {
  7965. jw.Code = 400;
  7966. jw.Data = new
  7967. {
  7968. groupCost = Create.Data,
  7969. blackCodeIsTrue = false,
  7970. };
  7971. }
  7972. return Ok(jw);
  7973. }
  7974. /// <summary>
  7975. /// 成本获取OP历史车费用
  7976. /// </summary>
  7977. /// <param name="dto"></param>
  7978. /// <returns></returns>
  7979. [HttpPost]
  7980. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  7981. {
  7982. var jw = JsonView(false);
  7983. try
  7984. {
  7985. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  7986. //获取现有所有车的数据
  7987. if (!dto.Param.IsNullOrWhiteSpace())
  7988. {
  7989. string sql = $@"
  7990. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  7991. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  7992. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  7993. 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
  7994. AND gctggr.ServiceEndTime is not NULL
  7995. ORDER by gctggrc.id DESC
  7996. ";
  7997. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  7998. var numeberResult = await Task.Run(() =>
  7999. {
  8000. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8001. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8002. return numberArr;
  8003. });
  8004. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8005. foreach (var item in numeberResult)
  8006. {
  8007. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8008. {
  8009. Country = "数据异常!",
  8010. City = string.Empty,
  8011. };
  8012. item.Area = find.Country + " " + find.City;
  8013. }
  8014. dbResult.AddRange(numeberResult);
  8015. if (dto.Param.Contains("、"))
  8016. {
  8017. var sp = dto.Param.Split("、");
  8018. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8019. .Where(x =>
  8020. {
  8021. return System.Array.Exists(sp, e =>
  8022. {
  8023. bool where = false;
  8024. if (x.Area != null)
  8025. {
  8026. where = x.Area.Contains(e);
  8027. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8028. {
  8029. return false;
  8030. }
  8031. }
  8032. if (x.PriceName != null && !where)
  8033. {
  8034. where = x.PriceName.Contains(e);
  8035. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8036. {
  8037. return false;
  8038. }
  8039. }
  8040. return where;
  8041. });
  8042. }).ToList();
  8043. }
  8044. else
  8045. {
  8046. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8047. .Where(x =>
  8048. {
  8049. bool where = false;
  8050. if (x.Area != null)
  8051. {
  8052. where = x.Area.Contains(dto.Param);
  8053. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8054. {
  8055. return false;
  8056. }
  8057. }
  8058. if (x.PriceName != null && !where)
  8059. {
  8060. where = x.PriceName.Contains(dto.Param);
  8061. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8062. {
  8063. return false;
  8064. }
  8065. }
  8066. return where;
  8067. }
  8068. )
  8069. .ToList();
  8070. }
  8071. }
  8072. var view = dbResult.Select(x =>
  8073. {
  8074. decimal dp = 0.00M;
  8075. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8076. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8077. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8078. {
  8079. if (startB && endB)
  8080. {
  8081. var timesp = endD.Subtract(startD);
  8082. if ((timesp.Days + 1) != 0)
  8083. {
  8084. dp = x.Price / (timesp.Days + 1);
  8085. }
  8086. }
  8087. }
  8088. else
  8089. {
  8090. dp = x.Price;
  8091. }
  8092. return new
  8093. {
  8094. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8095. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8096. x.Area,
  8097. x.id,
  8098. price = x.Price.ToString("F2"),
  8099. x.PriceName,
  8100. x.PriceContent,
  8101. x.TeamName,
  8102. x.DatePrice,
  8103. dayPrice = dp.ToString("F2"),
  8104. };
  8105. }).OrderByDescending(x => x.id).ToList();
  8106. jw = JsonView(true, "获取成功!", view);
  8107. }
  8108. catch (Exception e)
  8109. {
  8110. jw = JsonView(false, e.Message);
  8111. }
  8112. return Ok(jw);
  8113. }
  8114. #endregion
  8115. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8116. /// <summary>
  8117. /// 酒店预订
  8118. /// 酒店费用列表 根据团组Id查询
  8119. /// </summary>
  8120. /// <param name="_dto"></param>
  8121. /// <returns></returns>
  8122. [HttpPost]
  8123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8124. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8125. {
  8126. #region 参数验证
  8127. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8128. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8129. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8130. #region 团组操作权限验证 76 酒店预定模块
  8131. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8132. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8133. #endregion
  8134. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8135. #region 页面操作权限验证
  8136. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8137. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8138. #endregion
  8139. #endregion
  8140. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8141. }
  8142. /// <summary>
  8143. /// 酒店预订
  8144. /// 基础数据
  8145. /// </summary>
  8146. /// <param name="_dto"></param>
  8147. /// <returns></returns>
  8148. [HttpPost]
  8149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8150. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8151. {
  8152. #region 参数验证
  8153. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8154. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8155. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8156. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8157. #region 页面操作权限验证
  8158. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8159. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8160. #endregion
  8161. #region 团组操作权限验证 76 酒店预定模块
  8162. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8163. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8164. #endregion
  8165. #endregion
  8166. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8167. }
  8168. /// <summary>
  8169. /// 酒店预订
  8170. /// 创建 入住卷号码
  8171. /// </summary>
  8172. /// <param name="_dto"></param>
  8173. /// <returns></returns>
  8174. [HttpPost]
  8175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8176. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8177. {
  8178. try
  8179. {
  8180. #region 参数验证
  8181. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8182. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8183. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8184. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8185. #region 页面操作权限验证
  8186. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8187. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8188. #endregion
  8189. #region 团组操作权限验证 76 酒店预定模块
  8190. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8191. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8192. #endregion
  8193. #endregion
  8194. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8195. if (data.Code != 0)
  8196. {
  8197. return Ok(JsonView(false, data.Msg));
  8198. }
  8199. return Ok(JsonView(true, data.Msg, data.Data));
  8200. }
  8201. catch (Exception ex)
  8202. {
  8203. return Ok(JsonView(false, ex.Message));
  8204. }
  8205. }
  8206. /// <summary>
  8207. /// 酒店预订
  8208. /// 详情
  8209. /// </summary>
  8210. /// <param name="_dto"></param>
  8211. /// <returns></returns>
  8212. [HttpPost]
  8213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8214. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8215. {
  8216. #region 参数验证
  8217. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8218. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8219. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8220. #region 团组操作权限验证 76 酒店预定模块
  8221. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8222. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8223. #endregion
  8224. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8225. #region 页面操作权限验证
  8226. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8227. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8228. #endregion
  8229. #endregion
  8230. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8231. }
  8232. /// <summary>
  8233. /// 酒店预订
  8234. /// Add Or Edit
  8235. /// </summary>
  8236. /// <param name="_dto"></param>
  8237. /// <returns></returns>
  8238. [HttpPost]
  8239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8240. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8241. {
  8242. #region 参数验证
  8243. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8244. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8245. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8246. #region 团组操作权限验证 76 酒店预定模块
  8247. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8248. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8249. #endregion
  8250. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8251. #region 页面操作权限验证
  8252. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8253. if (_dto.Id == 0) // Add
  8254. {
  8255. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8256. }
  8257. else if (_dto.Id > 1) // Edit
  8258. {
  8259. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8260. }
  8261. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8262. #endregion
  8263. #endregion
  8264. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8265. if (_view.Code != 200)
  8266. {
  8267. return Ok(_view);
  8268. }
  8269. #region 应用推送
  8270. try
  8271. {
  8272. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8273. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8274. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8275. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8276. //自动审核
  8277. await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8278. }
  8279. catch (Exception ex)
  8280. {
  8281. }
  8282. #endregion
  8283. return Ok(_view);
  8284. }
  8285. /// <summary>
  8286. /// 酒店预订
  8287. /// Del
  8288. /// </summary>
  8289. /// <param name="_dto"></param>
  8290. /// <returns></returns>
  8291. [HttpPost]
  8292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8293. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8294. {
  8295. #region 参数验证
  8296. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8297. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8298. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8299. #region 团组操作权限验证 76 酒店预定模块
  8300. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8301. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8302. #endregion
  8303. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8304. #region 页面操作权限验证
  8305. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8306. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8307. #endregion
  8308. #endregion
  8309. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8310. }
  8311. /// <summary>
  8312. /// 酒店预订
  8313. /// 生成VOUCHER
  8314. /// 2024.05.06 之前版本
  8315. /// </summary>
  8316. /// <param name="_dto"></param>
  8317. /// <returns></returns>
  8318. [HttpPost]
  8319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8320. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8321. {
  8322. try
  8323. {
  8324. #region 参数验证
  8325. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8326. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8327. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8328. #region 团组操作权限验证 76 酒店预定模块
  8329. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8330. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8331. #endregion
  8332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8333. #region 页面操作权限验证
  8334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8335. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8336. #endregion
  8337. #endregion
  8338. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8339. //判断数据是否完整
  8340. if (hr != null)
  8341. {
  8342. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8343. {
  8344. string strFileName = "HotelStatement/";
  8345. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8346. if (dele != null)
  8347. strFileName += dele.TourCode;
  8348. //载入模板
  8349. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8350. Document doc = new Document(sss);
  8351. DocumentBuilder builder = new DocumentBuilder(doc);
  8352. #region 替换Word模板书签内容
  8353. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8354. //入住卷预定号码
  8355. if (doc.Range.Bookmarks["VNO"] != null)
  8356. {
  8357. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8358. mark.Text = hr.CheckNumber;
  8359. }
  8360. //酒店时间
  8361. if (doc.Range.Bookmarks["Date"] != null)
  8362. {
  8363. Bookmark mark = doc.Range.Bookmarks["Date"];
  8364. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8365. }
  8366. //团号
  8367. if (doc.Range.Bookmarks["TNo"] != null)
  8368. {
  8369. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8370. mark.Text = dele.TourCode;
  8371. }
  8372. //预定号码
  8373. if (doc.Range.Bookmarks["BookingId"] != null)
  8374. {
  8375. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8376. mark.Text = hr.ReservationsNo;
  8377. }
  8378. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8379. {
  8380. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8381. mark.Text = hr.DetermineNo;
  8382. }
  8383. //酒店城市
  8384. if (doc.Range.Bookmarks["City"] != null)
  8385. {
  8386. Bookmark mark = doc.Range.Bookmarks["City"];
  8387. mark.Text = hr.City;
  8388. }
  8389. //酒店名称
  8390. if (doc.Range.Bookmarks["HName"] != null)
  8391. {
  8392. Bookmark mark = doc.Range.Bookmarks["HName"];
  8393. mark.Text = hr.HotelName;
  8394. }
  8395. //酒店地址
  8396. if (doc.Range.Bookmarks["Address"] != null)
  8397. {
  8398. Bookmark mark = doc.Range.Bookmarks["Address"];
  8399. mark.Text = hr.HotelAddress;
  8400. }
  8401. //酒店电话
  8402. if (doc.Range.Bookmarks["Tel"] != null)
  8403. {
  8404. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8405. mark.Text = hr.HotelTel;
  8406. }
  8407. //酒店传真
  8408. if (doc.Range.Bookmarks["Fax"] != null)
  8409. {
  8410. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8411. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8412. {
  8413. mark.Text = hr.HotelFax;
  8414. }
  8415. }
  8416. //入住时间
  8417. if (doc.Range.Bookmarks["CIn"] != null)
  8418. {
  8419. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8420. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8421. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8422. }
  8423. //退房时间
  8424. if (doc.Range.Bookmarks["COut"] != null)
  8425. {
  8426. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8427. Bookmark mark = doc.Range.Bookmarks["COut"];
  8428. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8429. }
  8430. //客户名称
  8431. if (doc.Range.Bookmarks["GName"] != null)
  8432. {
  8433. string guestName = "";
  8434. string[] clients = new string[] { };
  8435. if (hr.GuestName.Contains(","))
  8436. {
  8437. clients = hr.GuestName.Split(",");
  8438. }
  8439. else
  8440. {
  8441. clients = new string[] { hr.GuestName };
  8442. }
  8443. List<int> clientIds_int = new List<int>();
  8444. if (clients.Length > 0)
  8445. {
  8446. foreach (var item in clients)
  8447. {
  8448. if (item.IsNumeric())
  8449. {
  8450. clientIds_int.Add(int.Parse(item));
  8451. }
  8452. }
  8453. }
  8454. if (clientIds_int.Count > 0)
  8455. {
  8456. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8457. foreach (var client in _clientDatas)
  8458. {
  8459. //男
  8460. if (client.Sex == 0) guestName += $"Mr.";
  8461. //女
  8462. else if (client.Sex == 1) guestName += $"Ms.";
  8463. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8464. {
  8465. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8466. }
  8467. //guestName += $"{client.Pinyin},";
  8468. }
  8469. if (guestName.Length > 0)
  8470. {
  8471. guestName = guestName.Substring(0, guestName.Length - 1);
  8472. }
  8473. }
  8474. else
  8475. {
  8476. guestName = hr.GuestName;
  8477. }
  8478. Bookmark mark = doc.Range.Bookmarks["GName"];
  8479. mark.Text = guestName;
  8480. }
  8481. //房间介绍
  8482. if (doc.Range.Bookmarks["ROOM"] != null)
  8483. {
  8484. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8485. mark.Text = hr.RoomExplanation;
  8486. }
  8487. //报价描述
  8488. if (doc.Range.Bookmarks["NOTE"] != null)
  8489. {
  8490. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8491. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8492. if (ss != null)
  8493. mark.Text = ss.Name;
  8494. }
  8495. //入住时间
  8496. if (doc.Range.Bookmarks["CheckIn"] != null)
  8497. {
  8498. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8499. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8500. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8501. }
  8502. //退房时间
  8503. if (doc.Range.Bookmarks["CheckOut"] != null)
  8504. {
  8505. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8506. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8507. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8508. }
  8509. //日期
  8510. if (doc.Range.Bookmarks["DT"] != null)
  8511. {
  8512. Bookmark mark = doc.Range.Bookmarks["DT"];
  8513. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8514. }
  8515. //名称
  8516. if (doc.Range.Bookmarks["VName"] != null)
  8517. {
  8518. Bookmark mark = doc.Range.Bookmarks["VName"];
  8519. mark.Text = hr.HotelName;
  8520. }
  8521. //号码
  8522. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8523. {
  8524. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8525. mark.Text = hr.CheckNumber;
  8526. }
  8527. #endregion
  8528. strFileName += "VOUCHER.doc";
  8529. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8530. doc.Save(fileDir);
  8531. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8532. return Ok(JsonView(true, "操作成功!", Url));
  8533. }
  8534. else
  8535. {
  8536. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8537. }
  8538. }
  8539. else
  8540. {
  8541. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8542. }
  8543. }
  8544. catch (Exception ex)
  8545. {
  8546. return Ok(JsonView(false, ex.Message));
  8547. }
  8548. }
  8549. /// <summary>
  8550. /// 酒店预订
  8551. /// 生成VOUCHER
  8552. /// 2024.05.06 之后版本
  8553. /// </summary>
  8554. /// <param name="_dto"></param>
  8555. /// <returns></returns>
  8556. [HttpPost]
  8557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8558. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8559. {
  8560. #region 参数验证
  8561. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8562. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8563. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8564. #region 团组操作权限验证 76 酒店预定模块
  8565. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8566. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8567. #endregion
  8568. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8569. #region 页面操作权限验证
  8570. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8571. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8572. #endregion
  8573. #endregion
  8574. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8575. //判断数据是否完整
  8576. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8577. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8578. string strFileName = "HotelStatement/";
  8579. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8580. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8581. #region 数据处理
  8582. List<int> guestIds = new List<int>();
  8583. int index = 0;
  8584. foreach (var item in hrDtas)
  8585. {
  8586. if (item.GuestName.Contains(","))
  8587. {
  8588. string[] guestIdArr = item.GuestName.Split(',');
  8589. foreach (var guestIdStr in guestIdArr)
  8590. {
  8591. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8592. if (guestBool)
  8593. {
  8594. guestIds.Add(guestId);
  8595. }
  8596. }
  8597. }
  8598. else guestNames += item.GuestName;
  8599. var voucherInfo = new HotelVoucherInfoView()
  8600. {
  8601. HotelName = item.HotelName,
  8602. CheckInDate = item.CheckInDate,
  8603. CheckOutDate = item.CheckOutDate,
  8604. ConfirmationNumber = item.DetermineNo.Trim(),
  8605. RoomType = item.RoomExplanation
  8606. };
  8607. vouchers.Add(voucherInfo);
  8608. }
  8609. if (guestIds.Count > 0)
  8610. {
  8611. guestIds = guestIds.Distinct().ToList();
  8612. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8613. if (guestDatas.Count > 0)
  8614. {
  8615. guestNames = "";
  8616. foreach (var guest in guestDatas)
  8617. {
  8618. string guestName = "";
  8619. if (guest.Sex == 0) guestName += @"MR.";
  8620. else if (guest.Sex == 1) guestName += @"MS.";
  8621. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8622. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8623. guestNames += @$"{guestName.Trim()}、";
  8624. }
  8625. if (guestNames.Length > 0)
  8626. {
  8627. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8628. }
  8629. }
  8630. }
  8631. #endregion
  8632. //载入模板
  8633. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8634. Document doc = new Document(sss);
  8635. DocumentBuilder builder = new DocumentBuilder(doc);
  8636. if (doc.Range.Bookmarks["GuestName"] != null)
  8637. {
  8638. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8639. mark.Text = guestNames;
  8640. }
  8641. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8642. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8643. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8644. for (int i = 1; i <= vouchers.Count; i++)
  8645. {
  8646. HotelVoucherInfoView hviv = vouchers[i - 1];
  8647. builder.MoveToCell(0, i, 0, 0);
  8648. builder.Write(hviv.HotelName);
  8649. builder.MoveToCell(0, i, 1, 0);
  8650. builder.Write(hviv.CheckInDate);
  8651. builder.MoveToCell(0, i, 2, 0);
  8652. builder.Write(hviv.CheckOutDate);
  8653. builder.MoveToCell(0, i, 3, 0);
  8654. builder.Write(hviv.RoomType);
  8655. builder.MoveToCell(0, i, 4, 0);
  8656. builder.Write(hviv.ConfirmationNumber);
  8657. }
  8658. //删除多余行
  8659. int currRowIndex = vouchers.Count + 1;
  8660. int delRows = 21 - currRowIndex;
  8661. if (delRows > 0)
  8662. {
  8663. for (int i = 0; i < delRows; i++)
  8664. {
  8665. table.Rows.RemoveAt(currRowIndex);
  8666. //cultivateRowIndex++;
  8667. }
  8668. }
  8669. strFileName += "VOUCHER.docx";
  8670. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8671. doc.Save(fileDir);
  8672. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8673. return Ok(JsonView(true, "操作成功!", Url));
  8674. }
  8675. /// <summary>
  8676. /// 酒店预订
  8677. /// 生成 预定成本 Excel
  8678. /// </summary>
  8679. /// <param name="_dto"></param>
  8680. /// <returns></returns>
  8681. [HttpPost]
  8682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8683. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8684. {
  8685. #region 参数验证
  8686. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8687. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8688. if (!vadalitorRes.IsValid)
  8689. {
  8690. var errors = new StringBuilder();
  8691. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8692. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8693. }
  8694. #region 团组操作权限验证 76 酒店预定模块
  8695. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8696. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8697. #endregion
  8698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8699. #region 页面操作权限验证
  8700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8701. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8702. #endregion
  8703. #endregion
  8704. decimal _rate = 1.00M;
  8705. string _currency = "";
  8706. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8707. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8708. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8709. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8710. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8711. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8712. {
  8713. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8714. }
  8715. _currency = _GroupCostParameter.Currency;
  8716. bool isIntType = int.TryParse(_currency, out int currId);
  8717. if (isIntType)
  8718. {
  8719. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8720. }
  8721. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8722. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8723. if (currInfo == null)
  8724. {
  8725. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8726. }
  8727. if (!_currency.ToUpper().Equals("CNY"))
  8728. {
  8729. _rate = _GroupCostParameter.Rate;
  8730. }
  8731. _rate = currInfo.Rate;
  8732. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8733. string strFileName = "HotelStatement/";
  8734. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8735. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8736. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8737. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8738. #region 数据处理
  8739. foreach (var item in hrDtas)
  8740. {
  8741. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8742. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8743. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8744. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8745. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8746. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8747. string singleRoomFeeStr = string.Empty,
  8748. doubleRoomFeeStr = string.Empty,
  8749. suiteRoomFeeStr = string.Empty,
  8750. otherRoomFeeStr = string.Empty,
  8751. payMoneyStr = string.Empty,
  8752. cardPriceStr = string.Empty;
  8753. if (roomCurr.Equals(_currency))
  8754. {
  8755. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8756. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8757. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8758. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8759. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8760. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8761. }
  8762. else
  8763. {
  8764. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8765. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8766. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8767. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8768. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8769. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8770. }
  8771. string breakfastPriceStr = string.Empty,
  8772. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8773. governmentRentStr = string.Empty,
  8774. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8775. cityTaxStrStr = string.Empty,
  8776. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8777. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8778. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8779. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8780. pcfds.Add(new HotelReservations_PCFD_View()
  8781. {
  8782. City = item.City,
  8783. HotelName = item.HotelName,
  8784. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8785. // SingleRoomCount = item.SingleRoomCount,
  8786. SingleRoomPrice = singleRoomFeeStr,
  8787. // DoubleRoomCount = item.DoubleRoomCount,
  8788. DoubleRoomPrice = doubleRoomFeeStr,
  8789. //SuiteRoomCount = item.SuiteRoomCount,
  8790. SuiteRoomPrice = suiteRoomFeeStr,
  8791. OtherRoomPrice = otherRoomFeeStr,
  8792. //OtherRoomCount = item.OtherRoomCount,
  8793. BreakfastPrice = breakfastPriceStr,
  8794. GovernmentRent = governmentRentStr,
  8795. CityTax = cityTaxStrStr,
  8796. RoomExplanation = item.RoomExplanation,
  8797. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8798. PayTime = roomInfo.ConsumptionDate,
  8799. BankNo = roomInfo.BankNo,
  8800. PayMoney = payMoneyStr,
  8801. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8802. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8803. CardPrice = cardPriceStr,
  8804. Remark = ccpInfo.Remark
  8805. });
  8806. }
  8807. #endregion
  8808. //载入模板
  8809. WorkbookDesigner designer = new WorkbookDesigner();
  8810. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8811. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8812. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8813. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8814. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8815. designer.SetDataSource("Opertor", userInfo.CnName);
  8816. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8817. dt.TableName = "ViewMyHotelReservations";
  8818. designer.SetDataSource(dt);
  8819. designer.Process();
  8820. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8821. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8822. designer.Workbook.Save(serverPath);
  8823. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8824. #region 删除指定行
  8825. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8826. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8827. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8828. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8829. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8830. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8831. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8832. cssIndex = dt.Columns["CityTax"].Ordinal,
  8833. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8834. remarkIndex = dt.Columns["Remark"].Ordinal;
  8835. //删除指定列
  8836. foreach (DataRow item in dt.Rows)
  8837. {
  8838. string singleStr = item["SingleRoomPrice"].ToString();
  8839. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8840. if (containsDigitButNotZero1) singleDel = false;
  8841. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8842. string doubleStr = item["DoubleRoomPrice"].ToString();
  8843. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8844. if (containsDigitButNotZero2) doubleDel = false;
  8845. string suiteStr = item["SuiteRoomPrice"].ToString();
  8846. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8847. if (containsDigitButNotZero3) suiteDel = false;
  8848. string otherStr = item["OtherRoomPrice"].ToString();
  8849. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8850. if (containsDigitButNotZero4) otherDel = false;
  8851. string zcStr = item["BreakfastPrice"].ToString();
  8852. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8853. if (containsDigitButNotZero5) zcDel = false;
  8854. string dsStr = item["GovernmentRent"].ToString();
  8855. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8856. if (containsDigitButNotZero6) dsDel = false;
  8857. string cssStr = item["CityTax"].ToString();
  8858. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8859. if (containsDigitButNotZero7) cssDel = false;
  8860. string cpStr = item["ConsumptionPatterns"].ToString();
  8861. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8862. string remarkStr = item["Remark"].ToString();
  8863. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8864. }
  8865. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8866. DeleteColumn(serverPath, cpIndex, cpDel);
  8867. DeleteColumn(serverPath, dsIndex, dsDel);
  8868. DeleteColumn(serverPath, cssIndex, cssDel);
  8869. DeleteColumn(serverPath, zcIndex, zcDel);
  8870. DeleteColumn(serverPath, otherIndex, otherDel);
  8871. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8872. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8873. DeleteColumn(serverPath, singleIndex, singleDel);
  8874. #endregion
  8875. //只保留第一个表格
  8876. DeleteSheet(serverPath);
  8877. return Ok(JsonView(true, "操作成功", url = rst));
  8878. }
  8879. /// <summary>
  8880. /// 删除指定列
  8881. /// </summary>
  8882. /// <param name="file"></param>
  8883. /// <param name="columnIndex"></param>
  8884. /// <param name="isDel"></param>
  8885. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8886. {
  8887. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8888. //wb.Save(file);
  8889. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8890. if (sheet1 != null)
  8891. {
  8892. if (isDel)
  8893. {
  8894. Cells cells = sheet1.Cells;
  8895. cells.DeleteColumn(columnIndex);
  8896. }
  8897. }
  8898. wb.Save(file);
  8899. }
  8900. /// <summary>
  8901. /// 删除sheet
  8902. /// </summary>
  8903. /// <param name="file"></param>
  8904. /// <param name="sheetName"></param>
  8905. private void DeleteSheet(string file, string sheetName = "")
  8906. {
  8907. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8908. //wb.Save(file);
  8909. List<string> sheets = new List<string>();
  8910. foreach (var item in wb.Worksheets)
  8911. {
  8912. sheets.Add(item.Name);
  8913. }
  8914. if (sheets.Count > 0)
  8915. {
  8916. sheets.RemoveAt(0);//不删除第一个sheet
  8917. foreach (var item in sheets)
  8918. {
  8919. wb.Worksheets.RemoveAt(item);
  8920. }
  8921. }
  8922. wb.Save(file);
  8923. }
  8924. /// <summary>
  8925. /// 酒店预订
  8926. /// 确认单
  8927. /// </summary>
  8928. /// <param name="_dto"></param>
  8929. /// <returns></returns>
  8930. [HttpPost]
  8931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8932. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  8933. {
  8934. try
  8935. {
  8936. #region 参数验证
  8937. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8938. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8939. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8940. #region 团组操作权限验证 76 酒店预定模块
  8941. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8942. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8943. #endregion
  8944. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8945. #region 页面操作权限验证
  8946. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8947. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8948. #endregion
  8949. #endregion
  8950. //团组信息
  8951. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  8952. //酒店数据
  8953. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  8954. if (listhoteldata.Count < 0)
  8955. {
  8956. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  8957. }
  8958. //利datatable存储
  8959. DataTable dt = new DataTable();
  8960. dt.Columns.Add("CheckInDate", typeof(string));
  8961. dt.Columns.Add("City", typeof(string));
  8962. dt.Columns.Add("Hotel", typeof(string));
  8963. dt.Columns.Add("Room", typeof(string));
  8964. for (int i = 0; i < listhoteldata.Count; i++)
  8965. {
  8966. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8967. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8968. while (dayStart < dayEnd)
  8969. {
  8970. string temp = "";
  8971. DataRow row = dt.NewRow();
  8972. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8973. row["City"] = listhoteldata[i].City;
  8974. row["Hotel"] = listhoteldata[i].HotelName;
  8975. if (listhoteldata[i].SingleRoomCount > 0)
  8976. {
  8977. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8978. }
  8979. if (listhoteldata[i].DoubleRoomCount > 0)
  8980. {
  8981. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  8982. }
  8983. if (listhoteldata[i].SuiteRoomCount > 0)
  8984. {
  8985. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8986. }
  8987. if (listhoteldata[i].OtherRoomCount > 0)
  8988. {
  8989. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  8990. }
  8991. row["Room"] = temp;
  8992. dt.Rows.Add(row);
  8993. dayStart = dayStart.AddDays(1);
  8994. }
  8995. }
  8996. Dictionary<string, string> dic = new Dictionary<string, string>();
  8997. dic.Add("Dele", di.TeamName);
  8998. dic.Add("City", di.VisitCountry);
  8999. //模板路径
  9000. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9001. //载入模板
  9002. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9003. DocumentBuilder builder = new DocumentBuilder(doc);
  9004. foreach (var key in dic.Keys)
  9005. {
  9006. builder.MoveToBookmark(key);
  9007. builder.Write(dic[key]);
  9008. }
  9009. //获取word里所有表格
  9010. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9011. //获取所填表格的序数
  9012. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9013. var rowStart = tableOne.Rows[0]; //获取第1行
  9014. //循环赋值
  9015. for (int i = 0; i < dt.Rows.Count; i++)
  9016. {
  9017. builder.MoveToCell(0, i + 1, 0, 0);
  9018. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9019. builder.MoveToCell(0, i + 1, 1, 0);
  9020. builder.Write(dt.Rows[i]["City"].ToString());
  9021. builder.MoveToCell(0, i + 1, 2, 0);
  9022. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9023. builder.MoveToCell(0, i + 1, 3, 0);
  9024. builder.Write(dt.Rows[i]["Room"].ToString());
  9025. }
  9026. //删除多余行
  9027. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9028. {
  9029. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9030. }
  9031. string strFileName = di.TeamName + "酒店确认单.doc";
  9032. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9033. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9034. return Ok(JsonView(true, "成功", url));
  9035. }
  9036. catch (Exception ex)
  9037. {
  9038. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9039. }
  9040. }
  9041. #endregion
  9042. #region 团组状态
  9043. /// <summary>
  9044. /// 团组状态列表 Page
  9045. /// </summary>
  9046. /// <param name="dto">团组列表请求dto</param>
  9047. /// <returns></returns>
  9048. [HttpPost]
  9049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9050. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9051. {
  9052. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9053. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9054. {
  9055. string sqlWhere = string.Empty;
  9056. if (dto.IsSure == 0) //未完成
  9057. {
  9058. sqlWhere += string.Format(@" And IsSure = 0");
  9059. }
  9060. else if (dto.IsSure == 1) //已完成
  9061. {
  9062. sqlWhere += string.Format(@" And IsSure = 1");
  9063. }
  9064. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9065. {
  9066. string tj = dto.SearchCriteria;
  9067. 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}%')",
  9068. tj, tj, tj, tj, tj);
  9069. }
  9070. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9071. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9072. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9073. From (
  9074. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9075. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9076. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9077. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9078. From Grp_DelegationInfo gdi
  9079. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9080. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9081. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9082. Where gdi.IsDel = 0 {0}
  9083. ) temp ", sqlWhere);
  9084. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9085. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9086. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9087. }
  9088. else
  9089. {
  9090. return Ok(JsonView(false, "查询失败"));
  9091. }
  9092. }
  9093. /// <summary>
  9094. /// 团组状态
  9095. /// 设置操作完成
  9096. /// </summary>
  9097. /// <param name="dto">团组列表请求dto</param>
  9098. /// <returns></returns>
  9099. [HttpPost]
  9100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9101. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9102. {
  9103. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9104. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9105. {
  9106. Id = dto.Id,
  9107. IsSure = 1
  9108. };
  9109. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9110. .UpdateColumns(it => new { it.IsSure })
  9111. .WhereColumns(it => new { it.Id })
  9112. .ExecuteCommandAsync();
  9113. if (result > 0)
  9114. {
  9115. return Ok(JsonView(true, "操作完成!"));
  9116. }
  9117. return Ok(JsonView(false, "操作失败!"));
  9118. }
  9119. #endregion
  9120. #region 保险费用录入
  9121. /// <summary>
  9122. /// 根据团组Id查询保险费用列表
  9123. /// </summary>
  9124. /// <param name="dto"></param>
  9125. /// <returns></returns>
  9126. [HttpPost]
  9127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9128. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9129. {
  9130. try
  9131. {
  9132. Result groupData = await _customersRep.CustomersByDiId(dto);
  9133. if (groupData.Code != 0)
  9134. {
  9135. return Ok(JsonView(false, groupData.Msg));
  9136. }
  9137. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9138. }
  9139. catch (Exception ex)
  9140. {
  9141. return Ok(JsonView(false, ex.Message));
  9142. }
  9143. }
  9144. /// <summary>
  9145. /// 根据保险费用Id查询保险费用详细
  9146. /// </summary>
  9147. /// <param name="dto"></param>
  9148. /// <returns></returns>
  9149. [HttpPost]
  9150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9151. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9152. {
  9153. try
  9154. {
  9155. Result groupData = await _customersRep.CustomersById(dto);
  9156. if (groupData.Code != 0)
  9157. {
  9158. return Ok(JsonView(false, groupData.Msg));
  9159. }
  9160. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9161. }
  9162. catch (Exception ex)
  9163. {
  9164. return Ok(JsonView(false, ex.Message));
  9165. }
  9166. }
  9167. /// <summary>
  9168. /// 保险费用录入页面初始化绑定
  9169. /// </summary>
  9170. /// <param name="dto"></param>
  9171. /// <returns></returns>
  9172. [HttpPost]
  9173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9174. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9175. {
  9176. try
  9177. {
  9178. Result groupData = await _customersRep.CustomersInitialize(dto);
  9179. if (groupData.Code != 0)
  9180. {
  9181. return Ok(JsonView(false, groupData.Msg));
  9182. }
  9183. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9184. }
  9185. catch (Exception ex)
  9186. {
  9187. return Ok(JsonView(false, ex.Message));
  9188. }
  9189. }
  9190. /// <summary>
  9191. /// 保险费用操作(Status:1.新增,2.修改)
  9192. /// </summary>
  9193. /// <param name="dto"></param>
  9194. /// <returns></returns>
  9195. [HttpPost]
  9196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9197. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9198. {
  9199. try
  9200. {
  9201. Result groupData = await _customersRep.OpCustomers(dto);
  9202. if (groupData.Code != 0)
  9203. {
  9204. return Ok(JsonView(false, groupData.Msg));
  9205. }
  9206. #region 应用推送
  9207. try
  9208. {
  9209. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9210. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9211. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9212. }
  9213. catch (Exception ex)
  9214. {
  9215. }
  9216. #endregion
  9217. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9218. }
  9219. catch (Exception ex)
  9220. {
  9221. return Ok(JsonView(false, ex.Message));
  9222. }
  9223. }
  9224. /// <summary>
  9225. /// 保险文件上传
  9226. /// </summary>
  9227. /// <param name="file"></param>
  9228. /// <returns></returns>
  9229. [HttpPost]
  9230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9231. public async Task<IActionResult> UploadCus(IFormFile file)
  9232. {
  9233. try
  9234. {
  9235. if (file != null)
  9236. {
  9237. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9238. //文件名称
  9239. string projectFileName = file.FileName;
  9240. //上传的文件的路径
  9241. string filePath = "";
  9242. if (!Directory.Exists(fileDir))
  9243. {
  9244. Directory.CreateDirectory(fileDir);
  9245. }
  9246. //上传的文件的路径
  9247. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9248. using (FileStream fs = System.IO.File.Create(filePath))
  9249. {
  9250. file.CopyTo(fs);
  9251. fs.Flush();
  9252. }
  9253. return Ok(JsonView(true, "上传成功!", projectFileName));
  9254. }
  9255. else
  9256. {
  9257. return Ok(JsonView(false, "上传失败!"));
  9258. }
  9259. }
  9260. catch (Exception ex)
  9261. {
  9262. return Ok(JsonView(false, "程序错误!"));
  9263. throw;
  9264. }
  9265. }
  9266. /// <summary>
  9267. /// 保险删除指定文件
  9268. /// </summary>
  9269. /// <param name="dto"></param>
  9270. /// <returns></returns>
  9271. [HttpPost]
  9272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9273. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9274. {
  9275. try
  9276. {
  9277. string filePath = "";
  9278. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9279. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9280. //int id = 0;
  9281. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9282. // 删除该文件
  9283. try
  9284. {
  9285. System.IO.File.Delete(filePath);
  9286. 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()
  9287. {
  9288. Attachment = "",
  9289. }).ExecuteCommandAsync();
  9290. if (result != 0)
  9291. {
  9292. return Ok(JsonView(true, "成功!"));
  9293. }
  9294. else
  9295. {
  9296. return Ok(JsonView(false, "失败!"));
  9297. }
  9298. }
  9299. catch (Exception)
  9300. {
  9301. 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()
  9302. {
  9303. Attachment = "",
  9304. }).ExecuteCommandAsync();
  9305. if (result != 0)
  9306. {
  9307. return Ok(JsonView(true, "成功!"));
  9308. }
  9309. else
  9310. {
  9311. return Ok(JsonView(false, "失败!"));
  9312. }
  9313. }
  9314. }
  9315. catch (Exception ex)
  9316. {
  9317. return Ok(JsonView(false, "程序错误!"));
  9318. throw;
  9319. }
  9320. }
  9321. /// <summary>
  9322. /// 保险费用操作(删除)
  9323. /// </summary>
  9324. /// <param name="dto"></param>
  9325. /// <returns></returns>
  9326. [HttpPost]
  9327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9328. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9329. {
  9330. try
  9331. {
  9332. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9333. if (!res)
  9334. {
  9335. return Ok(JsonView(false, "删除失败"));
  9336. }
  9337. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9338. {
  9339. IsDel = 1,
  9340. DeleteUserId = dto.DeleteUserId,
  9341. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9342. }).ExecuteCommandAsync();
  9343. return Ok(JsonView(true, "删除成功!"));
  9344. }
  9345. catch (Exception ex)
  9346. {
  9347. return Ok(JsonView(false, "程序错误!"));
  9348. throw;
  9349. }
  9350. }
  9351. #endregion
  9352. #region 接团客户名单 PageId 104
  9353. /// <summary>
  9354. /// 接团客户名单
  9355. /// 迁移数据(慎用!)
  9356. /// </summary>
  9357. /// <param name="dto"></param>
  9358. /// <returns></returns>
  9359. [HttpPost]
  9360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9361. public async Task<IActionResult> PostTourClientListChange()
  9362. {
  9363. try
  9364. {
  9365. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9366. //var groupClinetData1
  9367. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9368. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9369. int updateCount = 0;
  9370. if (oldOAClientList.Count > 0)
  9371. {
  9372. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9373. _sqlSugar.BeginTran();
  9374. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9375. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9376. foreach (var item in oldOAClientList)
  9377. {
  9378. int comId = 0;
  9379. string format = "yyyy-MM-dd HH:mm:ss";
  9380. string data11 = "1990-01-01 00:00";
  9381. var data1 = IsValidDate(item.OPdate, format);
  9382. if (data1) data11 = item.OPdate;
  9383. //客户公司验证
  9384. if (!string.IsNullOrEmpty(item.Company))
  9385. {
  9386. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9387. if (clientComInfo == null) // add
  9388. {
  9389. var addInfo = new Crm_CustomerCompany()
  9390. {
  9391. CompanyAbbreviation = "",
  9392. CompanyFullName = item.Company,
  9393. Address = "",
  9394. PostCodes = "",
  9395. LastedOpUserId = item.OPer,
  9396. LastedOpDt = Convert.ToDateTime(data11),
  9397. CreateUserId = item.OPer,
  9398. CreateTime = Convert.ToDateTime(data11),
  9399. IsDel = 0
  9400. };
  9401. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9402. if (comId1 > 0) comId = comId1;
  9403. }
  9404. else comId = clientComInfo.Id;
  9405. }
  9406. //客户人员验证
  9407. int clientId = 0;
  9408. string name = item.LastName + item.Name;
  9409. if (!string.IsNullOrEmpty(name))
  9410. {
  9411. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9412. if (clientInfo == null)
  9413. {
  9414. DateTime? dateTime = null;
  9415. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9416. if (isDt) dateTime = birthDayDt;
  9417. var addInfo1 = new Crm_DeleClient()
  9418. {
  9419. CrmCompanyId = comId,
  9420. DiId = -1,
  9421. LastName = item.LastName,
  9422. FirstName = item.Name,
  9423. OldName = "",
  9424. Pinyin = item.Pinyin,
  9425. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9426. Marriage = 0,
  9427. Phone = item.Phone,
  9428. Job = item.Job,
  9429. BirthDay = dateTime
  9430. };
  9431. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9432. if (clientId1 > 0) clientId = clientId1;
  9433. }
  9434. else clientId = clientInfo.Id;
  9435. }
  9436. if (clientId < 1)
  9437. {
  9438. continue;
  9439. }
  9440. int airType = 0;
  9441. if (item.AirType == "超经舱") airType = 459;
  9442. else if (item.AirType == "公务舱") airType = 458;
  9443. else if (item.AirType == "经济舱") airType = 460;
  9444. else if (item.AirType == "其他") airType = 565;
  9445. else if (item.AirType == "头等舱") airType = 457;
  9446. var _TourClientListEntity = new Grp_TourClientList()
  9447. {
  9448. DiId = item.Diid,
  9449. ClientId = clientId,
  9450. CreateUserId = item.OPer,
  9451. CreateTime = Convert.ToDateTime(data11),
  9452. Remark = item.Remark,
  9453. IsDel = item.Isdel,
  9454. ShippingSpaceTypeId = airType,
  9455. ShippingSpaceSpecialNeeds = item.AirRemark,
  9456. HotelSpecialNeeds = item.RoomType
  9457. };
  9458. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9459. if (_TourClientList > 0)
  9460. {
  9461. updateCount++;
  9462. }
  9463. }
  9464. _sqlSugar.CommitTran();
  9465. }
  9466. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9467. }
  9468. catch (Exception ex)
  9469. {
  9470. _sqlSugar.RollbackTran();
  9471. return Ok(JsonView(false, ex.Message));
  9472. }
  9473. return Ok(JsonView(true));
  9474. }
  9475. private bool IsValidDate(string dateString, string format)
  9476. {
  9477. DateTime dateValue;
  9478. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9479. return valid;
  9480. }
  9481. /// <summary>
  9482. /// 接团客户名单
  9483. /// 根据团组Id查询List
  9484. /// </summary>
  9485. /// <param name="dto"></param>
  9486. /// <returns></returns>
  9487. [HttpPost]
  9488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9489. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9490. {
  9491. #region 参数验证
  9492. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9493. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9494. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9495. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9496. #region 页面操作权限验证
  9497. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9498. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9499. #endregion
  9500. #endregion
  9501. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9502. if (viewData.Code != 0)
  9503. {
  9504. return Ok(JsonView(false, viewData.Msg));
  9505. }
  9506. return Ok(JsonView(viewData.Data));
  9507. }
  9508. /// <summary>
  9509. /// 接团客户名单
  9510. /// 基础数据 Init
  9511. /// </summary>
  9512. /// <param name="_dto"></param>
  9513. /// <returns></returns>
  9514. [HttpPost]
  9515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9516. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9517. {
  9518. #region 参数验证
  9519. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9520. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9521. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9522. #region 页面操作权限验证
  9523. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9524. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9525. #endregion
  9526. #endregion
  9527. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9528. if (viewData.Code != 0)
  9529. {
  9530. return Ok(JsonView(false, viewData.Msg));
  9531. }
  9532. return Ok(JsonView(viewData.Data));
  9533. }
  9534. /// <summary>
  9535. /// 接团客户名单
  9536. /// 根据 Id查询 Details
  9537. /// </summary>
  9538. /// <param name="_dto"></param>
  9539. /// <returns></returns>
  9540. [HttpPost]
  9541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9542. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9543. {
  9544. #region 参数验证
  9545. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9546. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9547. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9548. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9549. #region 页面操作权限验证
  9550. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9551. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9552. #endregion
  9553. #endregion
  9554. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9555. if (viewData.Code != 0)
  9556. {
  9557. return Ok(JsonView(false, viewData.Msg));
  9558. }
  9559. return Ok(JsonView(viewData.Data));
  9560. }
  9561. /// <summary>
  9562. /// 接团客户名单
  9563. /// Add Or Edit
  9564. /// </summary>
  9565. /// <param name="_dto"></param>
  9566. /// <returns></returns>
  9567. [HttpPost]
  9568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9569. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9570. {
  9571. #region 参数验证
  9572. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9573. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9574. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9575. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9576. #region 页面操作权限验证
  9577. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9578. if (_dto.Id == 0) //添加
  9579. {
  9580. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9581. }
  9582. else if (_dto.Id >= 0) //修改
  9583. {
  9584. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9585. }
  9586. #endregion
  9587. #endregion
  9588. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9589. if (viewData.Code != 0)
  9590. {
  9591. return Ok(JsonView(false, viewData.Msg));
  9592. }
  9593. return Ok(JsonView(true));
  9594. }
  9595. /// <summary>
  9596. /// 接团客户名单
  9597. /// AddMultiple(添加多个)
  9598. /// </summary>
  9599. /// <param name="_dto"></param>
  9600. /// <returns></returns>
  9601. [HttpPost]
  9602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9603. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9604. {
  9605. #region 参数验证
  9606. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9607. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9608. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9609. #region 页面操作权限验证
  9610. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9611. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9612. #endregion
  9613. #endregion
  9614. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9615. if (viewData.Code != 0)
  9616. {
  9617. return Ok(JsonView(false, viewData.Msg));
  9618. }
  9619. return Ok(JsonView(true));
  9620. }
  9621. /// <summary>
  9622. /// 接团客户名单
  9623. /// Del
  9624. /// </summary>
  9625. /// <param name="_dto"></param>
  9626. /// <returns></returns>
  9627. [HttpPost]
  9628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9629. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9630. {
  9631. #region 参数验证
  9632. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9633. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9634. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9635. #region 页面操作权限验证
  9636. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9637. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9638. #endregion
  9639. #endregion
  9640. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9641. if (viewData.Code != 0)
  9642. {
  9643. return Ok(JsonView(false, viewData.Msg));
  9644. }
  9645. return Ok(JsonView(true));
  9646. }
  9647. /// <summary>
  9648. /// 接团客户名单
  9649. /// 文件下载 客户名单
  9650. /// </summary>
  9651. /// <param name="_dto"></param>
  9652. /// <returns></returns>
  9653. [HttpPost]
  9654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9655. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9656. {
  9657. #region 参数验证
  9658. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9659. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9660. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9661. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9662. #region 页面操作权限验证
  9663. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9664. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9665. #endregion
  9666. #endregion
  9667. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9668. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9669. From Grp_TourClientList tcl
  9670. Left Join
  9671. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9672. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9673. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9674. From Crm_DeleClient dc
  9675. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9676. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9677. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9678. Where dc.IsDel = 0) temp
  9679. On temp.DcId =tcl.ClientId
  9680. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9681. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9682. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9683. //载入模板
  9684. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9685. if (_dto.Language == 1)
  9686. {
  9687. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9688. }
  9689. //载入模板
  9690. var doc = new Document(tempPath);
  9691. DocumentBuilder builder = new DocumentBuilder(doc);
  9692. //获取word里所有表格
  9693. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9694. //获取所填表格的序数
  9695. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9696. var rowStart = tableOne.Rows[0]; //获取第1行
  9697. if (_dto.Language == 0)
  9698. {
  9699. //循环赋值
  9700. for (int i = 0; i < DcList.Count; i++)
  9701. {
  9702. builder.MoveToCell(0, i + 1, 0, 0);
  9703. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9704. builder.MoveToCell(0, i + 1, 1, 0);
  9705. int sex = DcList[i].Sex;
  9706. string sexStr = string.Empty;
  9707. if (sex == 0) sexStr = "男";
  9708. else if (sex == 1) sexStr = "女";
  9709. else sexStr = "未设置";
  9710. builder.Write(sexStr);
  9711. builder.MoveToCell(0, i + 1, 2, 0);
  9712. string birthDay = DcList[i].BirthDay;
  9713. string birthDayStr = string.Empty;
  9714. if (!string.IsNullOrEmpty(birthDay))
  9715. {
  9716. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9717. }
  9718. builder.Write(birthDayStr);
  9719. builder.MoveToCell(0, i + 1, 3, 0);
  9720. string company = "";
  9721. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9722. {
  9723. company = DcList[i].CompanyFullName.ToString();
  9724. }
  9725. builder.Write(company);
  9726. builder.MoveToCell(0, i + 1, 4, 0);
  9727. builder.Write(DcList[i].Job);
  9728. }
  9729. }
  9730. else if (_dto.Language == 1)
  9731. {
  9732. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9733. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9734. //循环赋值
  9735. for (int i = 0; i < DcList.Count; i++)
  9736. {
  9737. string PYName = "";
  9738. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9739. {
  9740. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9741. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9742. PYName = PY_First + " " + PY_Last;
  9743. }
  9744. else
  9745. {
  9746. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9747. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9748. PYName = PY_First + " " + PY_Last;
  9749. }
  9750. builder.MoveToCell(0, i + 1, 0, 0);
  9751. builder.Write(PYName);
  9752. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9753. builder.MoveToCell(0, i + 1, 1, 0);
  9754. builder.Write(sex);
  9755. DateTime birthDt;
  9756. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9757. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9758. builder.MoveToCell(0, i + 1, 2, 0);
  9759. builder.Write(birthday);
  9760. string company = "";
  9761. try
  9762. {
  9763. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9764. {
  9765. //查询对照表
  9766. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9767. if (tempCec != null)
  9768. {
  9769. company = tempCec.enName;
  9770. }
  9771. //翻译
  9772. else
  9773. {
  9774. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9775. }
  9776. }
  9777. }
  9778. catch (Exception)
  9779. {
  9780. }
  9781. builder.MoveToCell(0, i + 1, 3, 0);
  9782. builder.Write(company);
  9783. string job = "";
  9784. try
  9785. {
  9786. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9787. {
  9788. //查询对照表
  9789. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9790. if (tempPec != null)
  9791. {
  9792. job = tempPec.enName;
  9793. }
  9794. //翻译
  9795. else
  9796. {
  9797. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9798. }
  9799. }
  9800. }
  9801. catch (Exception ex)
  9802. {
  9803. }
  9804. builder.MoveToCell(0, i + 1, 4, 0);
  9805. builder.Write(job);
  9806. }
  9807. }
  9808. //删除多余行
  9809. while (tableOne.Rows.Count > DcList.Count + 1)
  9810. {
  9811. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9812. }
  9813. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9814. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9815. doc.Save(fileDir);
  9816. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9817. return Ok(JsonView(true, "操作成功!", Url));
  9818. }
  9819. #endregion
  9820. #region 团组倒推表
  9821. /// <summary>
  9822. /// 倒推表基础数据
  9823. /// Init
  9824. /// </summary>
  9825. /// <param name="dto"></param>
  9826. /// <returns></returns>
  9827. [HttpPost]
  9828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9829. public async Task<IActionResult> PostInvertedListInit()
  9830. {
  9831. var viewData = await _invertedListRep._Init();
  9832. if (viewData.Code != 0)
  9833. {
  9834. return Ok(JsonView(false, viewData.Msg));
  9835. }
  9836. return Ok(JsonView(viewData.Data));
  9837. }
  9838. /// <summary>
  9839. /// 倒推表
  9840. /// Info
  9841. /// </summary>
  9842. /// <param name="dto"></param>
  9843. /// <returns></returns>
  9844. [HttpPost]
  9845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9846. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9847. {
  9848. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9849. if (viewData.Code != 0)
  9850. {
  9851. return Ok(JsonView(false, viewData.Msg));
  9852. }
  9853. return Ok(JsonView(viewData.Data));
  9854. }
  9855. /// <summary>
  9856. /// 倒推表
  9857. /// Create
  9858. /// </summary>
  9859. /// <param name="dto"></param>
  9860. /// <returns></returns>
  9861. [HttpPost]
  9862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9863. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9864. {
  9865. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9866. if (viewData.Code != 0)
  9867. {
  9868. return Ok(JsonView(false, viewData.Msg));
  9869. }
  9870. return Ok(JsonView(viewData.Data));
  9871. }
  9872. /// <summary>
  9873. /// 倒推表
  9874. /// Update
  9875. /// </summary>
  9876. /// <param name="dto"></param>
  9877. /// <returns></returns>
  9878. [HttpPost]
  9879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9880. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9881. {
  9882. var viewData = await _invertedListRep._Update(dto);
  9883. if (viewData.Code != 0)
  9884. {
  9885. return Ok(JsonView(false, viewData.Msg));
  9886. }
  9887. return Ok(JsonView(viewData.Data));
  9888. }
  9889. /// <summary>
  9890. /// 倒推表
  9891. /// File Download
  9892. /// </summary>
  9893. /// <param name="dto"></param>
  9894. /// <returns></returns>
  9895. [HttpPost]
  9896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9897. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9898. {
  9899. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9900. if (info2.Code != 0)
  9901. {
  9902. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9903. }
  9904. var info1 = info2.Data as InvertedListInfoView;
  9905. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9906. string teamName = "";
  9907. if (info != null) teamName = info.TeamName;
  9908. //载入模板
  9909. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  9910. DocumentBuilder builder = new DocumentBuilder(doc);
  9911. //利用键值对存放数据
  9912. Dictionary<string, string> dic = new Dictionary<string, string>();
  9913. dic.Add("TeamName", teamName);
  9914. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  9915. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  9916. dic.Add("BPRemark", info1.ApprovalDataRemark);
  9917. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  9918. dic.Add("SQRemark", info1.ApprovalRemark);
  9919. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  9920. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  9921. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  9922. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  9923. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  9924. dic.Add("QZRemark", info1.VisaInformationRemark);
  9925. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  9926. dic.Add("SQQZRemark", info1.SendVisaRemark);
  9927. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  9928. dic.Add("CQRemark", info1.IssueVisaRemark);
  9929. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  9930. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  9931. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  9932. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  9933. #region 填充word模板书签内容
  9934. foreach (var key in dic.Keys)
  9935. {
  9936. builder.MoveToBookmark(key);
  9937. builder.Write(dic[key]);
  9938. }
  9939. #endregion
  9940. var fileDir = AppSettingsHelper.Get("WordBasePath");
  9941. string fileName = $"{teamName}团出行准备流程表.doc";
  9942. string filePath = fileDir + $@"InvertedList/{fileName}";
  9943. doc.Save(filePath);
  9944. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  9945. return Ok(JsonView(true, "操作成功!", Url));
  9946. }
  9947. #endregion
  9948. #region 三公签证费用(签证费、代办费)
  9949. /// <summary>
  9950. /// 三公签证费用(签证费、代办费)
  9951. /// List
  9952. /// </summary>
  9953. /// <returns></returns>
  9954. [HttpPost]
  9955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9956. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  9957. {
  9958. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  9959. if (_view.Code != 0)
  9960. {
  9961. return Ok(JsonView(false, _view.Msg));
  9962. }
  9963. return Ok(JsonView(true, "操作成功!", _view.Data));
  9964. }
  9965. /// <summary>
  9966. /// 三公签证费用(签证费、代办费)
  9967. /// Add Or Update
  9968. /// </summary>
  9969. /// <returns></returns>
  9970. [HttpPost]
  9971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9972. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  9973. {
  9974. var _view = await _visaFeeInfoRep._Update(_dto);
  9975. if (_view.Code != 0)
  9976. {
  9977. return Ok(JsonView(false, _view.Msg));
  9978. }
  9979. return Ok(JsonView(true, _view.Msg));
  9980. }
  9981. #endregion
  9982. #region 酒店询价
  9983. /// <summary>
  9984. /// 酒店询价
  9985. /// Init
  9986. /// </summary>
  9987. /// <param name="dto"></param>
  9988. /// <returns></returns>
  9989. [HttpPost]
  9990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9991. public async Task<IActionResult> PostHotelInquiryInit()
  9992. {
  9993. var res = await _hotelInquiryRep._Init();
  9994. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9995. return Ok(JsonView(true, res.Msg, res.Data));
  9996. }
  9997. /// <summary>
  9998. /// 酒店询价
  9999. /// page Item
  10000. /// </summary>
  10001. /// <param name="_dto"></param>
  10002. /// <returns></returns>
  10003. [HttpPost]
  10004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10005. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10006. {
  10007. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10008. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10009. var view = res.Data as PageDataViewBase;
  10010. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10011. }
  10012. /// <summary>
  10013. /// 酒店询价
  10014. /// info
  10015. /// </summary>
  10016. /// <param name="_dto"></param>
  10017. /// <returns></returns>
  10018. [HttpPost]
  10019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10020. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10021. {
  10022. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10023. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10024. return Ok(JsonView(true, res.Msg, res.Data));
  10025. }
  10026. /// <summary>
  10027. /// 酒店询价
  10028. /// Add Or Edit
  10029. /// </summary>
  10030. /// <param name="_dto"></param>
  10031. /// <returns></returns>
  10032. [HttpPost]
  10033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10034. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10035. {
  10036. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10037. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10038. return Ok(JsonView(true, res.Msg, res.Data));
  10039. }
  10040. /// <summary>
  10041. /// 酒店询价
  10042. /// Del
  10043. /// </summary>
  10044. /// <param name="_dto"></param>
  10045. /// <returns></returns>
  10046. [HttpPost]
  10047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10048. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10049. {
  10050. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10051. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10052. return Ok(JsonView(true, res.Msg, res.Data));
  10053. }
  10054. #endregion
  10055. #region 下载匹配op行程单
  10056. /// <summary>
  10057. /// 匹配op行程单
  10058. /// Init
  10059. /// </summary>
  10060. /// <param name="dto">团组列表请求dto</param>
  10061. /// <returns></returns>
  10062. [HttpPost]
  10063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10064. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10065. {
  10066. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10067. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10068. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10069. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10070. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10071. .Where(it => it.IsDel == 0)
  10072. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10073. .OrderByDescending(it => it.CreateUserId)
  10074. .ToList();
  10075. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10076. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10077. var diids = groupInfos.Select(it => it.Id).ToList();
  10078. List<string> countrys = new List<string>();
  10079. foreach (var item in country)
  10080. {
  10081. var data = _groupRepository.FormartTeamName(item);
  10082. var dataArray = _groupRepository.GroupSplitCountry(data);
  10083. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10084. }
  10085. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10086. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10087. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10088. foreach (var item in areaItem)
  10089. {
  10090. string areaStr = item.Value;
  10091. if (!string.IsNullOrEmpty(areaStr))
  10092. {
  10093. string[] str1 = areaStr.Split("-");
  10094. if (str1.Length > 0)
  10095. {
  10096. areaArray.AddRange(str1);
  10097. }
  10098. }
  10099. }
  10100. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10101. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10102. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10103. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10104. .ToList();
  10105. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10106. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10107. .Where(it => countriesIds.Contains(it.Id))
  10108. .Select(it => new { it.Id, Name = it.Name_CN })
  10109. .ToList();
  10110. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10111. .Select(it => it.TeamName).ToList();
  10112. stopwatch.Stop();
  10113. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10114. }
  10115. ///// <summary>
  10116. ///// 匹配op行程单
  10117. ///// Init 查询区域数据
  10118. ///// </summary>
  10119. ///// <param name="dto">团组列表请求dto</param>
  10120. ///// <returns></returns>
  10121. //[HttpPost]
  10122. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10123. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10124. //{
  10125. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10126. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10127. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10128. // if (string.IsNullOrEmpty(countriesDataStr))
  10129. // {
  10130. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10131. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10132. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10133. // }
  10134. // else
  10135. // {
  10136. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10137. // }
  10138. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10139. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10140. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10141. // List<dynamic> childList = new List<dynamic>();
  10142. // int parentId = dto.CountriesId;
  10143. // if (provinceData.Count > 1)
  10144. // {
  10145. // foreach (var item1 in provinceData)
  10146. // {
  10147. // List<dynamic> childList1 = new List<dynamic>();
  10148. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10149. // foreach (var item2 in citiesData1)
  10150. // {
  10151. // List<dynamic> childList2 = new List<dynamic>();
  10152. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10153. // foreach (var item3 in countiesData1)
  10154. // {
  10155. // childList2.Add(new
  10156. // {
  10157. // id = item3.Id,
  10158. // parentId = item2.Id,
  10159. // level = "district",
  10160. // name = item3.Name_CN,
  10161. // });
  10162. // }
  10163. // childList1.Add(new
  10164. // {
  10165. // id = item2.Id,
  10166. // parentId = item1.Id,
  10167. // level = "city",
  10168. // name = item2.Name_CN,
  10169. // childList = childList2
  10170. // });
  10171. // }
  10172. // childList.Add(new
  10173. // {
  10174. // id = item1.Id,
  10175. // parentId = parentId,
  10176. // level = "province",
  10177. // name = item1.Name_CN,
  10178. // childList = childList1
  10179. // });
  10180. // }
  10181. // //城市
  10182. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10183. // foreach (var item2 in citiesData2)
  10184. // {
  10185. // List<dynamic> childList22 = new List<dynamic>();
  10186. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10187. // foreach (var item3 in countiesData1)
  10188. // {
  10189. // childList22.Add(new
  10190. // {
  10191. // id = item3.Id,
  10192. // parentId = item2.Id,
  10193. // level = "district",
  10194. // name = item3.Name_CN,
  10195. // });
  10196. // }
  10197. // childList.Add(new
  10198. // {
  10199. // id = item2.Id,
  10200. // parentId = parentId,
  10201. // level = "city",
  10202. // name = item2.Name_CN,
  10203. // childList = childList22
  10204. // });
  10205. // }
  10206. // }
  10207. // else
  10208. // {
  10209. // foreach (var item2 in citiesData)
  10210. // {
  10211. // string cname = item2.Name_CN;
  10212. // List<dynamic> childList1 = new List<dynamic>();
  10213. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10214. // foreach (var item3 in countiesData1)
  10215. // {
  10216. // childList1.Add(new
  10217. // {
  10218. // Id = item3.Id,
  10219. // parentId = item2.Id,
  10220. // level = "district",
  10221. // name = item3.Name_CN
  10222. // });
  10223. // }
  10224. // childList.Add(new
  10225. // {
  10226. // id = item2.Id,
  10227. // parentId = parentId,
  10228. // level = "city",
  10229. // name = item2.Name_CN,
  10230. // childList = childList1
  10231. // });
  10232. // }
  10233. // }
  10234. // stopwatch.Stop();
  10235. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10236. //}
  10237. /// <summary>
  10238. /// 匹配op行程单
  10239. /// 接团信息列表 Page
  10240. /// </summary>
  10241. /// <param name="dto">团组列表请求dto</param>
  10242. /// <returns></returns>
  10243. [HttpPost]
  10244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10245. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10246. {
  10247. var swatch = new Stopwatch();
  10248. swatch.Start();
  10249. #region 参数验证
  10250. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10251. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10252. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10253. #region 页面操作权限验证
  10254. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10255. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10256. #endregion
  10257. #endregion
  10258. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10259. {
  10260. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10261. string sqlWhere = "";
  10262. if (!string.IsNullOrEmpty(dto.Country))
  10263. {
  10264. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10265. }
  10266. if (!string.IsNullOrEmpty(dto.Area))
  10267. {
  10268. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10269. }
  10270. if (!string.IsNullOrEmpty(dto.TeamName))
  10271. {
  10272. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10273. }
  10274. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10275. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10276. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10277. swatch.Stop();
  10278. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10279. }
  10280. else
  10281. {
  10282. return Ok(JsonView(false, "查询失败"));
  10283. }
  10284. }
  10285. /// <summary>
  10286. /// 匹配op行程单
  10287. /// 行程单下载
  10288. /// </summary>
  10289. /// <param name="dto">团组列表请求dto</param>
  10290. /// <returns></returns>
  10291. [HttpPost]
  10292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10293. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10294. {
  10295. #region 参数验证
  10296. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10297. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10298. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10299. #region 页面操作权限验证
  10300. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10301. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10302. #endregion
  10303. #endregion
  10304. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10305. {
  10306. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10307. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10308. }
  10309. else
  10310. {
  10311. return Ok(JsonView(false, "下载失败!"));
  10312. }
  10313. }
  10314. #endregion
  10315. #region 国家信息 数据 注释
  10316. //[HttpPost]
  10317. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10318. //{
  10319. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10320. // foreach (var item in dto)
  10321. // {
  10322. // infos.Add(new Grp_GroupsTaskAssignment()
  10323. // {
  10324. // DIId = item,
  10325. // CTId = 82,
  10326. // UId = 248,
  10327. // IsEnable = 1,
  10328. // CreateUserId = 233,
  10329. // CreateTime = DateTime.Now,
  10330. // IsDel = 0
  10331. // });
  10332. // infos.Add(new Grp_GroupsTaskAssignment()
  10333. // {
  10334. // DIId = item,
  10335. // CTId = 82,
  10336. // UId = 286,
  10337. // IsEnable = 1,
  10338. // CreateUserId = 233,
  10339. // CreateTime = DateTime.Now,
  10340. // IsDel = 0
  10341. // });
  10342. // }
  10343. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10344. // return Ok("操作成功");
  10345. //}
  10346. //public class paramJsonDto
  10347. //{
  10348. // public List<CountriesInfo> str { get; set; }
  10349. //}
  10350. //[HttpPost]
  10351. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10352. //{
  10353. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10354. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10355. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10356. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10357. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10358. // _sqlSugar.BeginTran();
  10359. // int countitiesIndex = 0;
  10360. // foreach (var item in dto.str)
  10361. // {
  10362. // dynamic data = item.c;
  10363. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10364. // if (data != null)
  10365. // {
  10366. // countitiesIndex++;
  10367. // foreach (var item1 in data)
  10368. // {
  10369. // string cnname = item1.cn;
  10370. // string enname = item1.en;
  10371. // Sys_Cities provinceInfo = new Sys_Cities()
  10372. // {
  10373. // CountriesId = countriesId,
  10374. // Name_CN = cnname,
  10375. // Name_EN = enname,
  10376. // ParentId = 0,
  10377. // IsCapital = 1,
  10378. // CreateUserId = 208,
  10379. // CreateTime = DateTime.Now,
  10380. // IsDel = 0
  10381. // };
  10382. // if (item1.lv == "province") //省份
  10383. // {
  10384. // provinceInfo.Level = 1;
  10385. // int provinceId = 0;
  10386. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10387. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10388. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10389. // var data1 = item1.c;
  10390. // foreach (var item2 in data1)
  10391. // {
  10392. // if (item2.lv == "city")
  10393. // {
  10394. // string citycnname = item2.cn;
  10395. // string cityenname = item2.en;
  10396. // Sys_Cities cityInfo = new Sys_Cities()
  10397. // {
  10398. // CountriesId = countriesId,
  10399. // ParentId = provinceId,
  10400. // Level = 2,
  10401. // Name_CN = citycnname,
  10402. // Name_EN = cityenname,
  10403. // IsCapital = 1,
  10404. // CreateUserId = 208,
  10405. // CreateTime = DateTime.Now,
  10406. // IsDel = 0
  10407. // };
  10408. // if (item2.c != null)
  10409. // {
  10410. // int cityId = 0;
  10411. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10412. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10413. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10414. // foreach (var item3 in item2.c)
  10415. // {
  10416. // if (item3.lv == "district")
  10417. // {
  10418. // var districtInfo = new Sys_Cities()
  10419. // {
  10420. // CountriesId = countriesId,
  10421. // Name_CN = item3.cn,
  10422. // Name_EN = item3.en,
  10423. // Level = 3,
  10424. // ParentId = cityId,
  10425. // IsCapital = 1,
  10426. // CreateUserId = 208,
  10427. // CreateTime = DateTime.Now,
  10428. // IsDel = 0
  10429. // };
  10430. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10431. // //{
  10432. // districts.Add(districtInfo);
  10433. // //}
  10434. // }
  10435. // }
  10436. // }
  10437. // else
  10438. // {
  10439. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10440. // //{
  10441. // cities.Add(cityInfo);
  10442. // //}
  10443. // }
  10444. // }
  10445. // }
  10446. // }
  10447. // else if (item1.lv == "city")//城市
  10448. // {
  10449. // provinceInfo.Level = 2;
  10450. // if (item1.c != null)
  10451. // {
  10452. // int cityId = 0;
  10453. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10454. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10455. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10456. // foreach (var item3 in item1.c)
  10457. // {
  10458. // if (item3.lv == "district")
  10459. // {
  10460. // var districtInfo = new Sys_Cities()
  10461. // {
  10462. // CountriesId = countriesId,
  10463. // Name_CN = item3.cn,
  10464. // Name_EN = item3.en,
  10465. // Level = 3,
  10466. // ParentId = cityId,
  10467. // IsCapital = 1,
  10468. // CreateUserId = 208,
  10469. // CreateTime = DateTime.Now,
  10470. // IsDel = 0
  10471. // };
  10472. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10473. // //{
  10474. // districts.Add(districtInfo);
  10475. // //}
  10476. // }
  10477. // }
  10478. // }
  10479. // else
  10480. // {
  10481. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10482. // //{
  10483. // cities.Add(provinceInfo);
  10484. // //}
  10485. // }
  10486. // }
  10487. // }
  10488. // }
  10489. // }
  10490. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10491. // cities = cities.Distinct().ToList();
  10492. // districts = districts.Distinct().ToList();
  10493. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10494. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10495. // cities.AddRange(districts);
  10496. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10497. // //_sqlSugar.RollbackTran();
  10498. // _sqlSugar.CommitTran();
  10499. // return Ok(JsonView(false, "操作成功!"));
  10500. //}
  10501. //[HttpPost]
  10502. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10503. //{
  10504. // List<CountitiesInfo> infos = dto.MyProperty;
  10505. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10506. // _sqlSugar.BeginTran();
  10507. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10508. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10509. // foreach (var item in infos)
  10510. // {
  10511. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10512. // if (countryInfo != null)
  10513. // {
  10514. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10515. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10516. // if (cityInfo1 != null)
  10517. // {
  10518. // cityInfo1.IsCapital = 0;
  10519. // cityInfos.Add(cityInfo1);
  10520. // }
  10521. // }
  10522. // }
  10523. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10524. // .UpdateColumns(it => it.IsCapital)
  10525. // .WhereColumns(it => it.Id)
  10526. // .ExecuteCommand();
  10527. // //_sqlSugar.RollbackTran();
  10528. // _sqlSugar.CommitTran();
  10529. // return Ok(JsonView(false, "操作成功!"));
  10530. //}
  10531. //public class CounrtiesDto
  10532. //{
  10533. // public List<CountitiesInfo> MyProperty { get; set; }
  10534. //}
  10535. //public class CountitiesInfo
  10536. //{
  10537. // /// <summary>
  10538. // /// 圣约翰
  10539. // /// </summary>
  10540. // public string capital_name_chinese { get; set; }
  10541. // /// <summary>
  10542. // ///
  10543. // /// </summary>
  10544. // public string capital_name { get; set; }
  10545. // /// <summary>
  10546. // ///
  10547. // /// </summary>
  10548. // public string country_type { get; set; }
  10549. // /// <summary>
  10550. // /// 安提瓜和巴布达
  10551. // /// </summary>
  10552. // public string country_name_chinese { get; set; }
  10553. // /// <summary>
  10554. // /// 安提瓜和巴布达
  10555. // /// </summary>
  10556. // public string country_name_chinese_short { get; set; }
  10557. // /// <summary>
  10558. // /// 安提瓜和巴布达
  10559. // /// </summary>
  10560. // public string country_name_chinese_UN { get; set; }
  10561. // /// <summary>
  10562. // ///
  10563. // /// </summary>
  10564. // public string country_name_english_abbreviation { get; set; }
  10565. // /// <summary>
  10566. // ///
  10567. // /// </summary>
  10568. // public string country_name_english_formal { get; set; }
  10569. // /// <summary>
  10570. // ///
  10571. // /// </summary>
  10572. // public string country_name_english_UN { get; set; }
  10573. // /// <summary>
  10574. // ///
  10575. // /// </summary>
  10576. // public string continent_name { get; set; }
  10577. // /// <summary>
  10578. // ///
  10579. // /// </summary>
  10580. // public string subregion_name { get; set; }
  10581. // /// <summary>
  10582. // ///
  10583. // /// </summary>
  10584. // public string country_code2 { get; set; }
  10585. // /// <summary>
  10586. // ///
  10587. // /// </summary>
  10588. // public string country_code3 { get; set; }
  10589. // /// <summary>
  10590. // ///
  10591. // /// </summary>
  10592. // public string phone_code { get; set; }
  10593. //}
  10594. //public class CountriesInfo : BasicInfo
  10595. //{
  10596. // public List<CitiesInfo> c { get; set; }
  10597. //}
  10598. //public class CitiesInfo : BasicInfo
  10599. //{
  10600. // public List<AreaInfo> c { get; set; }
  10601. //}
  10602. //public class AreaInfo : BasicInfo
  10603. //{
  10604. // public List<AreaInfo> c { get; set; }
  10605. //}
  10606. //public class BasicInfo
  10607. //{
  10608. // public string code { get; set; }
  10609. // public string cn { get; set; }
  10610. // public string lv { get; set; }
  10611. // public string en { get; set; }
  10612. //}
  10613. #endregion
  10614. #region 查看邀请方
  10615. /// <summary>
  10616. /// 查看邀请方
  10617. /// 邀请方信息 Init
  10618. /// </summary>
  10619. /// <param name="dto"></param>
  10620. /// <returns></returns>
  10621. [HttpPost]
  10622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10623. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10624. {
  10625. string sqlWhere = string.Empty;
  10626. if (!string.IsNullOrEmpty(dto.Search))
  10627. {
  10628. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10629. }
  10630. string sql = string.Format($@"Select
  10631. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10632. Id,
  10633. UnitName
  10634. From Res_InvitationOfficialActivityData
  10635. Where IsDel = 0
  10636. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10637. RefAsync<int> total = 0;
  10638. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10639. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10640. }
  10641. /// <summary>
  10642. /// 查看邀请方
  10643. /// 国家信息 Init
  10644. /// </summary>
  10645. /// <param name="dto"></param>
  10646. /// <returns></returns>
  10647. [HttpPost]
  10648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10649. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10650. {
  10651. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10652. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10653. var diids = groupInfos.Select(it => it.Id).ToList();
  10654. List<string> countrys = new List<string>();
  10655. foreach (var item in country)
  10656. {
  10657. var data = _groupRepository.FormartTeamName(item);
  10658. var dataArray = _groupRepository.GroupSplitCountry(data);
  10659. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10660. }
  10661. countrys = countrys.Distinct().ToList();
  10662. for (int i = 0; i < countrys.Count; i++)
  10663. {
  10664. string item = countrys[i];
  10665. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10666. {
  10667. countrys.Remove(item);
  10668. i--;
  10669. }
  10670. }
  10671. RefAsync<int> total = 0;
  10672. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10673. .Where(it => countrys.Contains(it.Name_CN))
  10674. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10675. .Select(it => new { id = it.Id, name = it.Name_CN })
  10676. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10677. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10678. }
  10679. /// <summary>
  10680. /// 查看邀请方
  10681. /// 城市信息 Init
  10682. /// </summary>
  10683. /// <param name="dto"></param>
  10684. /// <returns></returns>
  10685. [HttpPost]
  10686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10687. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10688. {
  10689. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10690. RefAsync<int> total = 0;
  10691. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10692. .Where(it => it.CountriesId == dto.CountiesId)
  10693. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10694. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10695. .Select(it => new { id = it.Id, name = it.Name_CN })
  10696. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10697. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10698. }
  10699. /// <summary>
  10700. /// 查看邀请方
  10701. /// 团组名称 Init
  10702. /// </summary>
  10703. /// <param name="dto"></param>
  10704. /// <returns></returns>
  10705. [HttpPost]
  10706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10707. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10708. {
  10709. var watch = new Stopwatch();
  10710. watch.Start();
  10711. RefAsync<int> total = 0;
  10712. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10713. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  10714. .Where((oa, di) => oa.IsDel == 0)
  10715. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10716. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10717. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10718. .Distinct()
  10719. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10720. watch.Stop();
  10721. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10722. }
  10723. /// <summary>
  10724. /// 查看邀请方
  10725. /// 团组 & 邀请方信息
  10726. /// </summary>
  10727. /// <param name="dto"></param>
  10728. /// <returns></returns>
  10729. [HttpPost]
  10730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10731. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10732. {
  10733. var watch = new Stopwatch();
  10734. watch.Start();
  10735. RefAsync<int> total = 0;
  10736. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10737. .AS("Grp_DelegationInfo")
  10738. .Includes(x => x.InvitingInfos)
  10739. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10740. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10741. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10742. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10743. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10744. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10745. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10746. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10747. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10748. infos.ForEach(x =>
  10749. {
  10750. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10751. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10752. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10753. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10754. });
  10755. watch.Stop();
  10756. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10757. }
  10758. #endregion
  10759. #region 报批行程
  10760. /// <summary>
  10761. /// 报批行程初始化
  10762. /// </summary>
  10763. /// <param name="dto"></param>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10767. {
  10768. const int chiNumber = 5;
  10769. var jw = JsonView(false);
  10770. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10771. var group = groupList.First();
  10772. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10773. group = groupList.First(x => x.Id == diid);
  10774. if (group == null)
  10775. {
  10776. jw.Msg = "暂无团组!";
  10777. return Ok(jw);
  10778. }
  10779. var data = new
  10780. {
  10781. groupList = groupList.Select(x => new
  10782. {
  10783. x.TeamName,
  10784. x.Id
  10785. }),
  10786. content = new ArrayList(),
  10787. groupInfo = new
  10788. {
  10789. group.VisitDays,
  10790. group.TourCode,
  10791. group.VisitPNumber,
  10792. group.TeamName,
  10793. group.Id,
  10794. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10795. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10796. },
  10797. };
  10798. var resultArr = new ArrayList();
  10799. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10800. if (content.Count == 0)
  10801. {
  10802. var stay = "-";
  10803. var cityPath = "-";
  10804. //添加城市路径以及住宿地
  10805. //黑屏代码数据
  10806. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10807. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10808. {
  10809. jw = JsonView(true, "黑屏代码有误!", data);
  10810. return Ok(jw);
  10811. }
  10812. foreach (DataRow row in dtBlack.Rows)
  10813. {
  10814. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10815. {
  10816. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10817. return Ok(jw);
  10818. }
  10819. }
  10820. //黑屏代码获取时间区间
  10821. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10822. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10823. _sqlSugar.BeginTran();
  10824. for (int i = 0; i < timeArr.Count; i++)
  10825. {
  10826. stay = "-";
  10827. cityPath = "-";
  10828. DateTime NewData = DateTime.Parse(timeArr[i]);
  10829. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10830. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10831. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10832. if (tbSelect.Length > 0)
  10833. {
  10834. List<string> threeCodeStr = new List<string>();
  10835. foreach (var item in tbSelect)
  10836. {
  10837. var threeCode = item["Three"].ToString() ?? "";
  10838. if (threeCode.Length == 6)
  10839. {
  10840. var start = threeCode.Substring(0, 3);
  10841. var end = threeCode.Substring(3, 3);
  10842. if (threeCodeStr.Count == 0)
  10843. {
  10844. threeCodeStr.Add(start);
  10845. threeCodeStr.Add(end);
  10846. }
  10847. else
  10848. {
  10849. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10850. {
  10851. threeCodeStr.Add(end);
  10852. }
  10853. else
  10854. {
  10855. threeCodeStr.Add(start);
  10856. threeCodeStr.Add(end);
  10857. }
  10858. }
  10859. }
  10860. }
  10861. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10862. var last = threeCodeStr.Last();
  10863. foreach (var item in threeCodeStr)
  10864. {
  10865. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  10866. if (item.Equals(last))
  10867. {
  10868. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10869. }
  10870. }
  10871. cityPath = cityPath.Trim('-');
  10872. }
  10873. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10874. appro.Diid = diid ?? -1;
  10875. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10876. appro.Id = thisId;
  10877. appro.CreateUserId = dto.UserId;
  10878. appro.CreateTime = DateTime.Now;
  10879. content.Add(appro);
  10880. }
  10881. _sqlSugar.CommitTran();
  10882. }
  10883. foreach (var x in content)
  10884. {
  10885. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10886. if (chiList.Count < chiNumber)
  10887. {
  10888. for (int i = chiList.Count; i < chiNumber; i++)
  10889. {
  10890. chiList.Add(new Grp_ApprovalTravelDetails());
  10891. }
  10892. }
  10893. resultArr.Add(new
  10894. {
  10895. x.Id,
  10896. x.Date,
  10897. x.Diid,
  10898. chiList = chiList.Select(x1 => new
  10899. {
  10900. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  10901. x1.Details,
  10902. x1.ParentId,
  10903. x1.Id
  10904. })
  10905. });
  10906. }
  10907. data = data with
  10908. {
  10909. content = resultArr,
  10910. };
  10911. jw = JsonView(true, "获取成功!", data);
  10912. return Ok(jw);
  10913. }
  10914. /// <summary>
  10915. /// 报批行程删除
  10916. /// </summary>
  10917. /// <param name="dto"></param>
  10918. /// <returns></returns>
  10919. [HttpPost]
  10920. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  10921. {
  10922. var jw = JsonView(false);
  10923. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10924. if (group == null)
  10925. {
  10926. jw.Msg = "团组参数有误!";
  10927. return Ok(jw);
  10928. }
  10929. try
  10930. {
  10931. _sqlSugar.BeginTran();
  10932. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  10933. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  10934. {
  10935. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10936. DeleteUserId = dto.uesrId,
  10937. IsDel = 1
  10938. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  10939. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  10940. {
  10941. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10942. DeleteUserId = dto.uesrId,
  10943. IsDel = 1
  10944. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  10945. _sqlSugar.CommitTran();
  10946. jw = JsonView(true, "删除成功");
  10947. }
  10948. catch (Exception ex)
  10949. {
  10950. jw = JsonView(false, ex.Message);
  10951. }
  10952. return Ok(jw);
  10953. }
  10954. /// <summary>
  10955. /// 报批行程保存
  10956. /// </summary>
  10957. /// <param name="dto"></param>
  10958. /// <returns></returns>
  10959. [HttpPost]
  10960. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  10961. {
  10962. var jw = JsonView(false);
  10963. var Find = dto.Arr.Find(x => x.id == 0);
  10964. if (Find != null)
  10965. {
  10966. jw.Msg = "生成的ID为0!";
  10967. return Ok(jw);
  10968. }
  10969. foreach (var item in dto.Arr)
  10970. {
  10971. foreach (var chi in item.chiList)
  10972. {
  10973. if (chi.parentId == 0)
  10974. {
  10975. chi.parentId = item.id;
  10976. }
  10977. }
  10978. }
  10979. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  10980. _sqlSugar.BeginTran();
  10981. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  10982. {
  10983. var parentIds = dto.Arr.Select(x => x.id).ToList();
  10984. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  10985. {
  10986. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10987. DeleteUserId = dto.UserId,
  10988. IsDel = 1
  10989. }).ExecuteCommand();
  10990. }
  10991. try
  10992. {
  10993. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  10994. {
  10995. CreateTime = DateTime.Now,
  10996. CreateUserId = dto.UserId,
  10997. Details = x.details,
  10998. ParentId = x.parentId,
  10999. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11000. Remark = "",
  11001. IsDel = 0
  11002. }).ToList()).ExecuteCommand();
  11003. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11004. {
  11005. Id = x.id,
  11006. Details = x.details,
  11007. ParentId = x.parentId,
  11008. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11009. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11010. {
  11011. Details = x.Details,
  11012. ParentId = x.ParentId,
  11013. Time = x.Time
  11014. }).ExecuteCommand();
  11015. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11016. {
  11017. Id = x.id,
  11018. Date = x.date,
  11019. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11020. {
  11021. Date = x.Date
  11022. }).ExecuteCommand();
  11023. _sqlSugar.CommitTran();
  11024. jw = JsonView(true, "保存成功!");
  11025. }
  11026. catch (Exception ex)
  11027. {
  11028. _sqlSugar.RollbackTran();
  11029. jw = JsonView(false, "保存失败!" + ex.Message);
  11030. }
  11031. return Ok(jw);
  11032. }
  11033. /// <summary>
  11034. /// 报批行程生成
  11035. /// </summary>
  11036. /// <param name="dto"></param>
  11037. /// <returns></returns>
  11038. [HttpPost]
  11039. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11040. {
  11041. var jw = JsonView(false);
  11042. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11043. if (group == null)
  11044. {
  11045. jw.Msg = "暂无该团组!";
  11046. return Ok(jw);
  11047. }
  11048. //黑屏代码数据
  11049. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11050. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11051. {
  11052. jw.Msg = "黑屏代码有误!";
  11053. return Ok(jw);
  11054. }
  11055. foreach (DataRow row in dtBlack.Rows)
  11056. {
  11057. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11058. {
  11059. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11060. return Ok(jw);
  11061. }
  11062. }
  11063. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11064. var resultArr = new ArrayList();
  11065. if (officialActivitiesArr.Count == 0)
  11066. {
  11067. jw.Msg = "暂无公务出访信息!";
  11068. return Ok(jw);
  11069. }
  11070. try
  11071. {
  11072. _sqlSugar.BeginTran();
  11073. DeleteApprovalJourney(new
  11074. Domain.Dtos.Groups.DeleteApprovalJourney
  11075. {
  11076. Diid = dto.Diid,
  11077. uesrId = dto.Userid
  11078. });
  11079. var stay = "-";
  11080. var cityPath = "-";
  11081. //添加城市路径以及住宿地
  11082. //黑屏代码获取时间区间
  11083. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11084. var empty = "【未收入该三字码!请机票同事录入】";
  11085. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11086. for (int i = 0; i < timeArr.Count; i++)
  11087. {
  11088. stay = "-";
  11089. cityPath = "-";
  11090. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11091. DateTime NewData = DateTime.Parse(timeArr[i]);
  11092. 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();
  11093. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11094. if (tbSelect.Length > 0)
  11095. {
  11096. List<string> threeCodeStr = new List<string>();
  11097. bool isTrade = false;
  11098. string trip = string.Empty;
  11099. var rowLast = tbSelect.Last();
  11100. var rowFirst = tbSelect.First();
  11101. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11102. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11103. var takeOffTime = DateTime.Parse(timeArr[i]);
  11104. var fallToTime = DateTime.Parse(timeArr[i]);
  11105. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11106. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11107. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11108. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11109. foreach (var item in tbSelect)
  11110. {
  11111. var start = string.Empty;
  11112. var end = string.Empty;
  11113. var threeCode = item["Three"].ToString() ?? "";
  11114. if (threeCode.Length == 6)
  11115. {
  11116. start = threeCode.Substring(0, 3);
  11117. end = threeCode.Substring(3, 3);
  11118. if (threeCodeStr.Count == 0)
  11119. {
  11120. threeCodeStr.Add(start);
  11121. threeCodeStr.Add(end);
  11122. }
  11123. else
  11124. {
  11125. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11126. {
  11127. threeCodeStr.Add(end);
  11128. }
  11129. else
  11130. {
  11131. threeCodeStr.Add(start);
  11132. threeCodeStr.Add(end);
  11133. }
  11134. }
  11135. }
  11136. //处理机票信息
  11137. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11138. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11139. if (start_Object == null)
  11140. {
  11141. start_Object = new Res_ThreeCode()
  11142. {
  11143. AirPort = empty,
  11144. AirPort_En = empty,
  11145. City = empty,
  11146. Country = empty,
  11147. Four = empty,
  11148. Three = empty,
  11149. };
  11150. }
  11151. if (end_Object == null)
  11152. {
  11153. end_Object = new Res_ThreeCode()
  11154. {
  11155. AirPort = empty,
  11156. AirPort_En = empty,
  11157. City = empty,
  11158. Country = empty,
  11159. Four = empty,
  11160. Three = empty,
  11161. };
  11162. }
  11163. //机型判断
  11164. string airModel = item["AirModel"].ToString();
  11165. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11166. string flightTime = item["FlightTime"].ToString();
  11167. if (flightTime!.Contains(":"))
  11168. {
  11169. flightTime = flightTime.Replace(":", "小时");
  11170. flightTime += "分钟";
  11171. }
  11172. if (flightTime.Contains("H"))
  11173. {
  11174. flightTime = flightTime.Replace("H", "小时");
  11175. }
  11176. if (flightTime.Contains("M"))
  11177. {
  11178. flightTime = flightTime.Replace("M", "分钟");
  11179. }
  11180. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11181. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11182. {
  11183. flightTime = flightDataTime.Hour > 0
  11184. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11185. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11186. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11187. }
  11188. //航班号
  11189. string flightcode = item["Fliagtcode"].ToString();
  11190. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11191. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11192. if (aircompany == null)
  11193. {
  11194. aircompany = new Res_AirCompany
  11195. {
  11196. CnName = hsEmpty,
  11197. EnName = hsEmpty,
  11198. ShortCode = hsEmpty,
  11199. };
  11200. }
  11201. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11202. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11203. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11204. if (isTrade)
  11205. {
  11206. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11207. }
  11208. else
  11209. {
  11210. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11211. }
  11212. }
  11213. chiarr.Add(new Grp_ApprovalTravelDetails
  11214. {
  11215. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11216. CreateTime = DateTime.Now,
  11217. CreateUserId = dto.Userid,
  11218. ParentId = 0,
  11219. Details = trip
  11220. });
  11221. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11222. var last = threeCodeStr.Last();
  11223. foreach (var item in threeCodeStr)
  11224. {
  11225. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11226. if (item.Equals(last))
  11227. {
  11228. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11229. }
  11230. }
  11231. cityPath = cityPath.Trim('-');
  11232. }
  11233. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11234. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11235. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11236. appro.Diid = dto.Diid;
  11237. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11238. appro.Id = thisId;
  11239. appro.CreateUserId = dto.Userid;
  11240. appro.CreateTime = DateTime.Now;
  11241. foreach (var item in gwinfo)
  11242. {
  11243. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11244. chi.Details = "拜访" + item.Client;
  11245. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11246. {
  11247. chi.Details += "," + item.ReqSample;
  11248. }
  11249. chi.ParentId = thisId;
  11250. chi.Time = item.Time;
  11251. chiarr.Add(chi);
  11252. }
  11253. if (chiarr.Count < 5)
  11254. {
  11255. for (int j = chiarr.Count; j < 5; j++)
  11256. {
  11257. chiarr.Add(new
  11258. Grp_ApprovalTravelDetails());
  11259. }
  11260. }
  11261. resultArr.Add(new
  11262. {
  11263. appro.Id,
  11264. appro.Date,
  11265. appro.Diid,
  11266. chiList = chiarr.Select(x1 => new
  11267. {
  11268. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11269. x1.Details,
  11270. x1.ParentId,
  11271. x1.Id
  11272. })
  11273. });
  11274. }
  11275. _sqlSugar.CommitTran();
  11276. jw = JsonView(true, "生成成功!", resultArr);
  11277. }
  11278. catch (Exception ex)
  11279. {
  11280. jw.Code = 400;
  11281. jw.Msg = "生成失败!" + ex.Message;
  11282. }
  11283. return Ok(jw);
  11284. }
  11285. /// <summary>
  11286. /// 报批行程word导出
  11287. /// </summary>
  11288. /// <param name="dto"></param>
  11289. /// <returns></returns>
  11290. [HttpPost]
  11291. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11292. {
  11293. var jw = JsonView(false);
  11294. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11295. if (group == null)
  11296. {
  11297. jw.Msg = "暂无该团组!";
  11298. return Ok(jw);
  11299. }
  11300. //模板路径
  11301. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  11302. //载入模板
  11303. Document doc = new Document(tempPath);
  11304. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11305. //获取所填表格的序数
  11306. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11307. Aspose.Words.Tables.Row titleRowClone = null;
  11308. Aspose.Words.Tables.Row CenterRowClone = null;
  11309. int index = 0;
  11310. int indexChi = 0;
  11311. int SetIndex = 0;
  11312. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11313. //获取数据,放到datatable
  11314. foreach (var item in ApprovalTravelArr)
  11315. {
  11316. if (index > 0)
  11317. {
  11318. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11319. tableOne.AppendChild(titleRowClone);
  11320. }
  11321. var textTime = item.Date;
  11322. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11323. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11324. SetIndex++;
  11325. if (ChiRep.Count > 0)
  11326. {
  11327. foreach (var itemChi in ChiRep)
  11328. {
  11329. var txtTime = itemChi.Time;
  11330. var txtDetail = itemChi.Details;
  11331. if (indexChi > 0)
  11332. {
  11333. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11334. tableOne.AppendChild(CenterRowClone);
  11335. }
  11336. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11337. {
  11338. SetCells(tableOne, doc, SetIndex, 0, "");
  11339. SetCells(tableOne, doc, SetIndex, 1, "");
  11340. indexChi++;
  11341. SetIndex++;
  11342. break;
  11343. }
  11344. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11345. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11346. indexChi++;
  11347. SetIndex++;
  11348. }
  11349. }
  11350. else
  11351. {
  11352. if (indexChi > 0)
  11353. {
  11354. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11355. tableOne.AppendChild(CenterRowClone);
  11356. }
  11357. SetCells(tableOne, doc, SetIndex, 0, "");
  11358. SetCells(tableOne, doc, SetIndex, 1, "");
  11359. indexChi++;
  11360. SetIndex++;
  11361. }
  11362. index++;
  11363. }
  11364. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11365. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11366. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11367. jw.Code = 200;
  11368. jw.Msg = "";
  11369. return Ok(jw);
  11370. }
  11371. private string intToString(int numberVal)
  11372. {
  11373. string numberval = numberVal.ToString();
  11374. Dictionary<char, string> Number = new Dictionary<char, string>();
  11375. Number.Add('1', "一");
  11376. Number.Add('2', "二");
  11377. Number.Add('3', "三");
  11378. Number.Add('4', "四");
  11379. Number.Add('5', "五");
  11380. Number.Add('6', "六");
  11381. Number.Add('7', "七");
  11382. Number.Add('8', "八");
  11383. Number.Add('9', "九");
  11384. string stringNumberVal = string.Empty;
  11385. for (int i = 0; i < numberval.Length; i++)
  11386. {
  11387. if (i == 0)
  11388. {
  11389. stringNumberVal += Number[numberval[i]];
  11390. }
  11391. else if (i >= 1)
  11392. {
  11393. if (numberval[i] == '0')
  11394. {
  11395. stringNumberVal = "十";
  11396. }
  11397. else
  11398. {
  11399. stringNumberVal += "十" + Number[numberval[i]];
  11400. }
  11401. }
  11402. }
  11403. return stringNumberVal;
  11404. }
  11405. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11406. {
  11407. //获取table中的某个单元格,从0开始
  11408. Cell lshCell = table.Rows[rows].Cells[cells];
  11409. //将单元格中段落移除
  11410. foreach (Node item in lshCell.Paragraphs)
  11411. {
  11412. lshCell.Paragraphs.Remove(item);
  11413. }
  11414. if (val.Contains("\r\n"))
  11415. {
  11416. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  11417. foreach (var item in spArr)
  11418. {
  11419. //新建一个段落
  11420. Paragraph p = new Paragraph(doc);
  11421. var r = new Run(doc, item);
  11422. //把设置的值赋给之前新建的段落
  11423. p.AppendChild(r);
  11424. //将此段落加到单元格内
  11425. lshCell.AppendChild(p);
  11426. }
  11427. }
  11428. else
  11429. {
  11430. //新建一个段落
  11431. Paragraph p = new Paragraph(doc);
  11432. var r = new Run(doc, val);
  11433. //把设置的值赋给之前新建的段落
  11434. p.AppendChild(r);
  11435. //将此段落加到单元格内
  11436. lshCell.AppendChild(p);
  11437. }
  11438. }
  11439. [HttpPost]
  11440. public async Task<IActionResult> ServerHttp(string paramStr)
  11441. {
  11442. paramStr = paramStr.TrimEnd('\'');
  11443. paramStr = paramStr.TrimStart('\'');
  11444. JsonView jw = JsonView(false);
  11445. JObject param = JObject.Parse(paramStr);
  11446. if (!param.ContainsKey("url"))
  11447. {
  11448. jw.Msg = "url null";
  11449. return Ok(jw);
  11450. }
  11451. string url = param["url"]!.ToString();
  11452. var methon = "get";
  11453. Dictionary<string, string> bodyValues = null;
  11454. Dictionary<string, string> headValues = null;
  11455. if (param.ContainsKey("methon"))
  11456. {
  11457. methon = param["methon"]!.ToString();
  11458. }
  11459. if (param.ContainsKey("header"))
  11460. {
  11461. var header = param["header"]!.ToString();
  11462. JObject headerJobject = JObject.Parse(header);
  11463. headValues = new Dictionary<string, string>();
  11464. foreach (JProperty item in headerJobject.Properties())
  11465. {
  11466. var value = item.Value.ToString();
  11467. var head = item.Path;
  11468. headValues.Add(head, value);
  11469. }
  11470. }
  11471. if (param.ContainsKey("body"))
  11472. {
  11473. var body = param["body"]!.ToString();
  11474. bodyValues = new Dictionary<string, string>();
  11475. JObject bodyJobject = JObject.Parse(body);
  11476. foreach (JProperty item in bodyJobject.Properties())
  11477. {
  11478. var value = item.Value.ToString();
  11479. var head = item.Path;
  11480. bodyValues.Add(head, value);
  11481. }
  11482. }
  11483. HttpClient client = new HttpClient();
  11484. string responseString = string.Empty;
  11485. if (param.ContainsKey("isJson"))
  11486. {
  11487. }
  11488. if (headValues != null)
  11489. {
  11490. foreach (var item in headValues.Keys)
  11491. {
  11492. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11493. }
  11494. }
  11495. try
  11496. {
  11497. if (methon == "get")
  11498. {
  11499. responseString = await client.GetStringAsync(url);
  11500. }
  11501. else if (methon == "post")
  11502. {
  11503. if (bodyValues == null)
  11504. {
  11505. jw.Msg = "methon post body null";
  11506. return Ok(jw);
  11507. }
  11508. // 数据转化为 key=val 格式
  11509. var content = new FormUrlEncodedContent(bodyValues);
  11510. var response = await client.PostAsync(url, content);
  11511. // 获取数据
  11512. responseString = await response.Content.ReadAsStringAsync();
  11513. }
  11514. else
  11515. {
  11516. jw.Msg = "methon error";
  11517. }
  11518. jw = JsonView(true, "success", responseString);
  11519. }
  11520. catch (Exception ex)
  11521. {
  11522. jw.Msg = "error " + ex.Message;
  11523. jw.Data = ex.StackTrace;
  11524. }
  11525. finally
  11526. {
  11527. client.Dispose();
  11528. }
  11529. return Ok(jw);
  11530. }
  11531. #endregion
  11532. // /// <summary>
  11533. // ///
  11534. // /// </summary>
  11535. // /// <param name="_dto"></param>
  11536. // /// <returns></returns>
  11537. // [HttpPost]
  11538. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11539. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11540. // {
  11541. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11542. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11543. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11544. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11545. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11546. // dic_psg.Add("客人", 974);
  11547. // dic_psg.Add("司机", 975);
  11548. // dic_psg.Add("导游", 976);
  11549. // dic_psg.Add("公司内部人员", 977);
  11550. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11551. // foreach (var item in list_visa)
  11552. // {
  11553. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11554. // temp.Id = item.Id;
  11555. // temp.DIId = item.DIId;
  11556. // temp.VisaClient = item.VisaClient;
  11557. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11558. // temp.VisaCurrency = item.VisaCurrency;
  11559. // temp.IsThird = item.IsThird;
  11560. // if (dic_psg.ContainsKey(item.PassengerType))
  11561. // {
  11562. // temp.PassengerType = dic_psg[item.PassengerType];
  11563. // }
  11564. // else {
  11565. // temp.PassengerType = -1;
  11566. // }
  11567. // temp.VisaNumber = item.VisaNumber;
  11568. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11569. // temp.CreateUserId = item.Operators;
  11570. // DateTime dt_ct;
  11571. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11572. // if (b_ct)
  11573. // {
  11574. // temp.CreateTime = dt_ct;
  11575. // }
  11576. // else
  11577. // {
  11578. // temp.CreateTime = DateTime.Now;
  11579. // }
  11580. // temp.DeleteTime = "";
  11581. // temp.DeleteUserId = 0;
  11582. // temp.Remark = item.Remark;
  11583. // if (string.IsNullOrEmpty(temp.Remark)) {
  11584. // temp.Remark = "";
  11585. // }
  11586. // temp.IsDel = item.IsDel;
  11587. // temp.VisaDescription = item.VisaAttachment;
  11588. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11589. //([Id]
  11590. // ,[DIId]
  11591. // ,[VisaClient]
  11592. // ,[VisaPrice]
  11593. // ,[VisaCurrency]
  11594. // ,[IsThird]
  11595. // ,[PassengerType]
  11596. // ,[VisaNumber]
  11597. // ,[VisaFreeNumber]
  11598. // ,[CreateUserId]
  11599. // ,[CreateTime]
  11600. // ,[DeleteTime]
  11601. // ,[DeleteUserId]
  11602. // ,[Remark]
  11603. // ,[IsDel]
  11604. // ,[visaDescription])
  11605. // VALUES
  11606. // ({0},{1},'{2}',{3},{4}
  11607. //,{5},{6},{7},{8},{9}
  11608. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11609. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11610. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11611. //);
  11612. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11613. // }
  11614. // return Ok(JsonView(true, "操作成功!"));
  11615. // }
  11616. /// <summary>
  11617. /// 123132123
  11618. /// </summary>
  11619. /// <param name="_dto"></param>
  11620. /// <returns></returns>
  11621. [HttpPost]
  11622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11623. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11624. {
  11625. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11626. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11627. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11628. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11629. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11630. dicDetail.Add(789, 1034);
  11631. dicDetail.Add(790, 1035);
  11632. dicDetail.Add(791, 1036);
  11633. dicDetail.Add(792, 1037);
  11634. dicDetail.Add(793, 1038);
  11635. dicDetail.Add(794, 1039);
  11636. dicDetail.Add(795, 1040);
  11637. dicDetail.Add(796, 1041);
  11638. dicDetail.Add(797, 1042);
  11639. dicDetail.Add(798, 1043);
  11640. dicDetail.Add(801, 1044);
  11641. dicDetail.Add(802, 1045);
  11642. dicDetail.Add(803, 1046);
  11643. Dictionary<int, int> dic = new Dictionary<int, int>();
  11644. dic.Add(806, 1027);
  11645. dic.Add(807, 1028);
  11646. dic.Add(808, 1029);
  11647. dic.Add(809, 1030);
  11648. dic.Add(810, 1031);
  11649. dic.Add(811, 1032);
  11650. dic.Add(812, 1033);
  11651. foreach (var item in list_visa)
  11652. {
  11653. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11654. temp.Coefficient = item.coefficient;
  11655. DateTime dtCrt;
  11656. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11657. if (b1)
  11658. {
  11659. temp.CreateTime = dtCrt;
  11660. }
  11661. else
  11662. {
  11663. temp.CreateTime = DateTime.Now;
  11664. }
  11665. temp.CreateUserId = item.Operators;
  11666. temp.DeleteTime = "";
  11667. temp.DeleteUserId = 0;
  11668. temp.DiId = int.Parse(item.DIID);
  11669. temp.FilePath = item.FilePath;
  11670. temp.IsDel = item.IsDel;
  11671. temp.Price = item.Price;
  11672. temp.PriceCount = 1;
  11673. temp.PriceCurrency = item.Currency;
  11674. int detailId = 0;
  11675. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11676. {
  11677. detailId = dicDetail[item.PriceTypeDetail];
  11678. }
  11679. temp.PriceDetailType = detailId;
  11680. temp.PriceDt = DateTime.Now;
  11681. temp.PriceName = item.PriceName;
  11682. temp.PriceSum = item.Price;
  11683. int tid = 0;
  11684. if (dic.ContainsKey(item.PriceType))
  11685. {
  11686. tid = dic[item.PriceType];
  11687. }
  11688. temp.PriceType = tid;
  11689. temp.Remark = item.Remark;
  11690. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11691. }
  11692. return Ok(JsonView(true, "操作成功!"));
  11693. }
  11694. }
  11695. }